import fs from "fs"; import {keccak256} from "ethers"; const vaultCode = JSON.parse(fs.readFileSync('../contract/out/Vault.sol/Vault.json').toString()) export const VAULT_INIT_CODE_HASH = keccak256(vaultCode.bytecode.object) console.log('VAULT_INIT_CODE_HASH', VAULT_INIT_CODE_HASH) export const chainInfo = {} const _chains = [ {id:42161, name:'Arbitrum'}, {id:31337, name:'Mockchain'}, {id:1337, name:'Dexorder Alpha'}, ] for (const chain of _chains) { const path = `../contract/broadcast/Deploy.sol/${chain.id}/run-latest.json`; let deployment try { deployment = JSON.parse(fs.readFileSync(path, 'utf8')) //null synchronous is ok we only do this once on init } catch { console.log(`warning: could not read deployment files for ${chain.id}`) continue } let maybeFactory = null for (const tx of deployment.transactions) { if (tx.contractName === 'Factory') chain.factory = tx.contractAddress else if (tx.contractName === 'QueryHelper') 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 Factory deployment found for chainId ${chain.id} ${path}`) } if (chain.helper === undefined) throw Error(`No QueryHelper deployment found for chainId ${chain.id} ${path}`) console.log('Factory', chain.factory) console.log('QueryHelper', chain.helper) chainInfo[chain.id] = chain }