mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
99090ee058
* adding network 8896 (barge) * Update ocean.ts * development network with env variable * temp patch for provider url check * removed logs * fix typing error * set local provider url to asset metadata * clean development config * wip make use of barge addresses * update env vars from script * more fixes * cleanup * update readme * more readme updates * cleanup fixes * more fixes * script readme updates * update readme * update readme * bump oceanjs * fix tests after oceanjs upgrade * adding custom provider for mac barge * fix test app.config path * remove log * added NEXT_PUBLIC_PROVIDER_URL to load dev env * added env variable for mac on load dev env * fre fixes * review suggestions * Update README.md Co-authored-by: Jamie Hewitt <jamie@oceanprotocol.com> * add private key example * bump oceanlib * fix build * fix provider uri for mac * add custom rpc env var example * fix build * update barge env vars script * remove brage from supported and default chainIds by default * remove log --------- Co-authored-by: Bogdan Fazakas <bogdan.fazakas@gmail.com> Co-authored-by: Jamie Hewitt <jamie@oceanprotocol.com>
77 lines
1.9 KiB
JavaScript
77 lines
1.9 KiB
JavaScript
const fs = require('fs')
|
|
const os = require('os')
|
|
|
|
function getLocalAddresses() {
|
|
const data = JSON.parse(
|
|
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
fs.readFileSync(
|
|
`${os.homedir}/.ocean/ocean-contracts/artifacts/address.json`,
|
|
'utf8'
|
|
)
|
|
)
|
|
return data.development
|
|
}
|
|
|
|
function updateEnvVariable(key, value) {
|
|
fs.readFile('.env', 'utf8', (err, data) => {
|
|
if (err) {
|
|
console.error(err)
|
|
return
|
|
}
|
|
|
|
const lines = data.split('\n')
|
|
|
|
let keyExists = false
|
|
for (let i = 0; i < lines.length; i++) {
|
|
const line = lines[i]
|
|
if (line.startsWith(key + '=')) {
|
|
lines[i] = `${key}=${value}`
|
|
keyExists = true
|
|
break
|
|
}
|
|
}
|
|
|
|
if (!keyExists) {
|
|
lines.push(`${key}=${value}`)
|
|
}
|
|
|
|
const updatedContent = lines.join('\n')
|
|
fs.writeFile('.env', updatedContent, 'utf8', (err) => {
|
|
if (err) {
|
|
console.error(err)
|
|
return
|
|
}
|
|
console.log(
|
|
`Successfully ${
|
|
keyExists ? 'updated' : 'added'
|
|
} the ${key} environment variable.`
|
|
)
|
|
})
|
|
})
|
|
}
|
|
|
|
const addresses = getLocalAddresses()
|
|
updateEnvVariable('NEXT_PUBLIC_NFT_FACTORY_ADDRESS', addresses.ERC721Factory)
|
|
updateEnvVariable(
|
|
'NEXT_PUBLIC_OPF_COMMUNITY_FEE_COLECTOR',
|
|
addresses.OPFCommunityFeeCollector
|
|
)
|
|
updateEnvVariable(
|
|
'NEXT_PUBLIC_FIXED_RATE_EXCHANGE_ADDRESS',
|
|
addresses.FixedPrice
|
|
)
|
|
updateEnvVariable('NEXT_PUBLIC_DISPENSER_ADDRESS', addresses.Dispenser)
|
|
updateEnvVariable('NEXT_PUBLIC_OCEAN_TOKEN_ADDRESS', addresses.Ocean)
|
|
updateEnvVariable('NEXT_PUBLIC_MARKET_DEVELOPMENT', true)
|
|
updateEnvVariable(
|
|
'#NEXT_PUBLIC_PROVIDER_URL',
|
|
'"http://127.0.0.1:8030" # only for mac'
|
|
)
|
|
updateEnvVariable(
|
|
`#NEXT_PUBLIC_SUBGRAPH_URI',"http://127.0.0.1:9000" # only for mac`
|
|
)
|
|
updateEnvVariable(
|
|
'#NEXT_PUBLIC_METADATACACHE_URI',
|
|
'"http://127.0.0.1:5000" # only for mac'
|
|
)
|