reworked to optionally use Hardhat in mock; chain id 31337; refactored TransactionJob management; execute() mostly commented out for minimalism

This commit is contained in:
Tim Olson
2023-10-26 16:56:08 -04:00
parent bd127b00ce
commit e05f0cc8dc
8 changed files with 80 additions and 53 deletions

46
misc.js
View File

@@ -1,48 +1,4 @@
import fs from "fs";
import util from "util";
import {keccak256} from "ethers";
import fs from "fs";
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)
console.log('VAULT_INIT_CODE_HASH', VAULT_INIT_CODE_HASH)
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 {
console.log(`warning: could not read deployment files for ${chain.id}`)
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}`)
console.log('Factory', chain.factory)
chainInfo[chain.id] = chain
}