mockenv deployment rework; price and setprice scripts

This commit is contained in:
Tim Olson
2023-11-02 17:23:48 -04:00
parent 763f78916c
commit 948f9ff7a8

View File

@@ -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
}