import fs from "fs"; import util from "util"; import {keccak256} from "ethers"; export const readFile = (fileName) => util.promisify(fs.readFile)(fileName, 'utf8'); const vaultCode = JSON.parse(fs.readFileSync('./contract/out/Vault.sol/Vault.json').toString()) export const VAULT_INIT_CODE_HASH = keccak256(vaultCode.bytecode.object) export const chainInfo = {} const _chains = [ {id:42161, name:'Arbitrum'}, {id:1338, name:'Mock'}, ] function _setChainInfo(c, k, v) { c.update(v) chainInfo[c][k] = v } for (const chain of _chains) { const path = `contract/broadcast/Deploy.sol/${chain.id}/run-${process.env['DEXORDER_DEPLOYMENT_' + chain.id]}.json`; let deployment try { deployment = JSON.parse(fs.readFileSync(path, 'utf8')) //null synchronous is ok we only do this once on init } catch { continue } 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 === 'MockEnv') { // todo set up mock coins, etc } } if (chain.factory === undefined) 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}`) chainInfo[chain.id] = chain }