2022-02-14 09:35:55 +01:00
|
|
|
/* eslint-disable no-unused-vars */
|
2022-06-24 09:06:44 +02:00
|
|
|
const fs = require('fs')
|
|
|
|
let addresses = require('@oceanprotocol/contracts/addresses/address.json')
|
2022-02-14 09:35:55 +01:00
|
|
|
|
|
|
|
async function replaceContractAddresses() {
|
|
|
|
// load addresses file first
|
2022-02-17 11:59:55 +01:00
|
|
|
if (!process.argv[2]) {
|
|
|
|
console.error('Missing network..')
|
|
|
|
return
|
|
|
|
}
|
2022-02-14 09:35:55 +01:00
|
|
|
if (process.env.ADDRESS_FILE) {
|
|
|
|
console.log('Using custom ADDRESS_FILE instead of ocean-contracts npm dep')
|
|
|
|
addresses = JSON.parse(fs.readFileSync(process.env.ADDRESS_FILE, 'utf8'))
|
|
|
|
}
|
2022-02-17 11:59:55 +01:00
|
|
|
|
2022-02-14 09:35:55 +01:00
|
|
|
for (const network in addresses) {
|
2022-02-17 11:59:55 +01:00
|
|
|
if (process.argv[2] != network) {
|
2022-02-14 09:35:55 +01:00
|
|
|
console.log('Skipping ' + network)
|
|
|
|
continue
|
|
|
|
}
|
2022-02-17 11:59:55 +01:00
|
|
|
console.log('Creating subgraph.yaml for ' + network)
|
|
|
|
let subgraph = fs.readFileSync('./subgraph.template.yaml', 'utf8')
|
2022-02-14 09:35:55 +01:00
|
|
|
|
|
|
|
subgraph = subgraph.replace(/__NETWORK__/g, network)
|
|
|
|
subgraph = subgraph.replace(
|
|
|
|
/__STARTBLOCK__/g,
|
|
|
|
addresses[network].startBlock
|
|
|
|
)
|
|
|
|
subgraph = subgraph.replace(
|
|
|
|
/__ERC721FACTORYADDRESS__/g,
|
|
|
|
"'" + addresses[network].ERC721Factory + "'"
|
|
|
|
)
|
|
|
|
subgraph = subgraph.replace(
|
|
|
|
/__FACTORYROUTERADDRESS__/g,
|
|
|
|
"'" + addresses[network].Router + "'"
|
|
|
|
)
|
2022-02-17 11:59:55 +01:00
|
|
|
fs.writeFileSync('subgraph.yaml', subgraph, 'utf8')
|
2022-02-14 09:35:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
replaceContractAddresses()
|