From 948f9ff7a8c7dd64ec8177cb7be8ef671d5f15b9 Mon Sep 17 00:00:00 2001 From: Tim Olson <> Date: Thu, 2 Nov 2023 17:23:48 -0400 Subject: [PATCH] mockenv deployment rework; price and setprice scripts --- chain.js | 61 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/chain.js b/chain.js index d8317a9..564acc3 100644 --- a/chain.js +++ b/chain.js @@ -34,38 +34,45 @@ for (const chain of _chains) { chain.factory = tx.contractAddress else if (tx.contractName === 'QueryHelper') chain.helper = tx.contractAddress - else if (tx.contractName === 'MockEnv') { - // set up mock coins, etc - if( - false && - chain.id === 31337 ) { - console.log('Detected MockEnv at', tx.contractAddress) - const mock = new ethers.Contract(tx.contractAddress, await getAbi('MockEnv'), getProvider(chain.id)) - const coinAddr = await mock.COIN() - const usdAddr = await mock.USD() - chain.tokens = [ - { - name: 'Mockcoin', - symbol: 'MOCK', - decimals: 18, - icon: null, - address: coinAddr, - }, - { - name: 'Universally Stable Denomination', - symbol: 'USD', - decimals: 6, - icon: null, - address: usdAddr, - }, - ] - } - } } 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}`) console.log('Factory', chain.factory) + + if(chain.id === 31337 ) { + const mockpath = `../contract/broadcast/DeployMock.sol/${chain.id}/run-${process.env['DEXORDER_DEPLOYMENT_' + chain.id]}.json` + try { + deployment = JSON.parse(fs.readFileSync(mockpath, 'utf8')) //null synchronous is ok we only do this once on init + for (const tx of deployment.transactions) { + if (tx.contractName === 'MockEnv') { + // set up mock coins, etc + const mock = new ethers.Contract(tx.contractAddress, await getAbi('MockEnv'), getProvider(chain.id)) + const coinAddr = await mock.COIN() + const usdAddr = await mock.USD() + chain.mockenv = tx.contractAddress + chain.tokens = [ + { + name: 'Mockcoin', + symbol: 'MOCK', + decimals: 18, + image: null, + address: coinAddr, + }, + { + name: 'Universally Stable Denomination', + symbol: 'USD', + decimals: 6, + image: null, + address: usdAddr, + }, + ] + console.log('Detected MockEnv at', tx.contractAddress) + } + } + } catch { + } + } chainInfo[chain.id] = chain }