diff --git a/chain.js b/chain.js index 3121296..95d612c 100644 --- a/chain.js +++ b/chain.js @@ -29,17 +29,31 @@ for (const chain of _chains) { 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.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) + console.log('QueryHelper', chain.helper) if(chain.id === 31337 ) { const mockpath = `../contract/broadcast/DeployMock.sol/${chain.id}/run-${process.env['DEXORDER_DEPLOYMENT_' + chain.id]}.json` @@ -69,7 +83,7 @@ for (const chain of _chains) { address: usdAddr, }, ] - console.log('Detected MockEnv at', tx.contractAddress) + console.log('Detected MockEnv at', chain.id, tx.contractAddress) } } } catch {