chainInfo fix
This commit is contained in:
74
chain.js
74
chain.js
@@ -15,39 +15,47 @@ const _chains = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
for (const chain of _chains) {
|
for (const chain of _chains) {
|
||||||
const path = `../contract/broadcast/Deploy.sol/${chain.id}/run-latest.json`;
|
fs.readdir('../contract/broadcast', (err, files) => {
|
||||||
let deployment
|
if (err) throw err;
|
||||||
try {
|
for (const deploymentClassDir of files) {
|
||||||
deployment = JSON.parse(fs.readFileSync(path, 'utf8')) //null synchronous is ok we only do this once on init
|
if (deploymentClassDir.startsWith('Deploy') && deploymentClassDir.endsWith('.sol')) {
|
||||||
}
|
const path = `${deploymentClassDir}/${chain.id}/run-latest.json`;
|
||||||
catch {
|
let deployment
|
||||||
console.log(`warning: could not read deployment files for ${chain.id}`)
|
try {
|
||||||
continue
|
deployment = JSON.parse(fs.readFileSync(path, 'utf8')) //null synchronous is ok we only do this once on init
|
||||||
}
|
}
|
||||||
let maybeFactory = null
|
catch {
|
||||||
for (const tx of deployment.transactions) {
|
console.log(`warning: could not read deployment files for ${chain.id}`)
|
||||||
if (tx.contractName === 'VaultFactory')
|
continue
|
||||||
chain.factory = tx.contractAddress
|
}
|
||||||
else if (tx.contractName === 'QueryHelper')
|
let maybeFactory = null
|
||||||
chain.helper = tx.contractAddress
|
for (const tx of deployment.transactions) {
|
||||||
else if (tx.contractName === null) {
|
if (tx.contractName === 'VaultFactory')
|
||||||
if( maybeFactory !== null ) {
|
chain.factory = tx.contractAddress
|
||||||
console.warn('Multiple broadcast deployments found with a null contractAddress')
|
else if (tx.contractName === 'QueryHelper')
|
||||||
maybeFactory = -1 // prevent ever using the null labeled contracts
|
chain.helper = tx.contractAddress
|
||||||
|
else if (tx.contractName === null) {
|
||||||
|
if( maybeFactory !== null ) {
|
||||||
|
console.warn('Multiple broadcast deployments found with a null contractAddress')
|
||||||
|
maybeFactory = -1 // prevent ever using the null labeled contracts
|
||||||
|
}
|
||||||
|
else if (maybeFactory !== -1)
|
||||||
|
maybeFactory = tx.contractAddress
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (chain.factory === undefined) {
|
||||||
|
if ( maybeFactory !== null && maybeFactory !== -1)
|
||||||
|
chain.factory = maybeFactory
|
||||||
|
else
|
||||||
|
throw Error(`No VaultFactory deployment found for chainId ${chain.id} ${path}`)
|
||||||
|
}
|
||||||
|
if (chain.helper === undefined)
|
||||||
|
throw Error(`No QueryHelper deployment found for chainId ${chain.id} ${path}`)
|
||||||
|
console.log('VaultFactory', chain.factory)
|
||||||
|
console.log('QueryHelper', chain.helper)
|
||||||
|
chainInfo[chain.id] = chain
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (maybeFactory !== -1)
|
|
||||||
maybeFactory = tx.contractAddress
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
if (chain.factory === undefined) {
|
|
||||||
if ( maybeFactory !== null && maybeFactory !== -1)
|
|
||||||
chain.factory = maybeFactory
|
|
||||||
else
|
|
||||||
throw Error(`No VaultFactory deployment found for chainId ${chain.id} ${path}`)
|
|
||||||
}
|
|
||||||
if (chain.helper === undefined)
|
|
||||||
throw Error(`No QueryHelper deployment found for chainId ${chain.id} ${path}`)
|
|
||||||
console.log('VaultFactory', chain.factory)
|
|
||||||
console.log('QueryHelper', chain.helper)
|
|
||||||
chainInfo[chain.id] = chain
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user