From 03cee85da89c22be8f537012ba9f575de5bc87fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Dan?= Date: Fri, 16 Jun 2023 16:36:19 -0400 Subject: [PATCH] feat: expose contract addresses in deploy script stdout (#88) --- scripts/deploy-topos-msg-protocol.ts | 34 ++++++++-------------------- scripts/deploy.ts | 12 ++++------ 2 files changed, 14 insertions(+), 32 deletions(-) diff --git a/scripts/deploy-topos-msg-protocol.ts b/scripts/deploy-topos-msg-protocol.ts index 6561912..0c41318 100644 --- a/scripts/deploy-topos-msg-protocol.ts +++ b/scripts/deploy-topos-msg-protocol.ts @@ -58,7 +58,6 @@ const main = async function (...args: string[]) { const wallet = new Wallet(toposDeployerPrivateKey, provider) const tokenDeployerAddress = await processContract( - 'TokenDeployer', wallet, tokenDeployerJSON, tokenDeployerSalt!, @@ -67,7 +66,6 @@ const main = async function (...args: string[]) { ) const toposCoreAddress = await processContract( - 'ToposCore', wallet, toposCoreJSON, toposCoreSalt!, @@ -80,7 +78,6 @@ const main = async function (...args: string[]) { [[wallet.address], 1] // TODO: Use a different admin address than ToposDeployer ) const toposCoreProxyAddress = await processContract( - 'ToposCoreProxy', wallet, toposCoreProxyJSON, toposCoreProxySalt!, @@ -88,8 +85,7 @@ const main = async function (...args: string[]) { 4_000_000 ) - await processContract( - 'ERC20Messaging', + const erc20MessagingAddresss = await processContract( wallet, erc20MessagingJSON, erc20MessagingSalt!, @@ -98,6 +94,13 @@ const main = async function (...args: string[]) { ) setSubnetId(toposCoreProxyAddress, wallet, subnetId) + + console.log(` +export TOPOS_CORE_CONTRACT_ADDRESS=${toposCoreAddress} +export TOPOS_CORE_PROXY_CONTRACT_ADDRESS=${toposCoreProxyAddress} +export TOKEN_DEPLOYER_CONTRACT_ADDRESS=${tokenDeployerAddress} +export ERC20_MESSAGING_CONTRACT_ADDRESS=${erc20MessagingAddresss} + `) } const sanitizeHexString = function (hexString: string) { @@ -118,15 +121,12 @@ const verifySalt = function ( } const processContract = async function ( - contractName: string, wallet: Wallet, contractJson: ContractOutputJSON, salt: string, args: Arg[] = [], gasLimit: number | null = null ) { - console.info(`\nVerifying if ${contractName} is already deployed...`) - const predictedContractAddress = await predictContractConstant( wallet, contractJson, @@ -144,14 +144,8 @@ const processContract = async function ( const thereIsCodeAtAddress = codeAtPredictedAddress !== '0x' if (thereIsCodeAtAddress) { - console.info( - `${contractName} is already deployed! (${predictedContractAddress})` - ) - return predictedContractAddress } else { - console.info(`Deploying ${contractName} with constant address...`) - const newContractAddress = await deployContractConstant( wallet, contractJson, @@ -165,10 +159,6 @@ const processContract = async function ( process.exit(1) }) - console.info( - `Successfully deployed ${contractName} at ${newContractAddress}\n` - ) - return newContractAddress } } @@ -178,8 +168,6 @@ const setSubnetId = async function ( wallet: Wallet, subnetId: string ) { - console.info(`\nSetting subnetId on ToposCore via proxy`) - const toposCoreInterface = new Contract( toposCoreProxyAddress, toposCoreInterfaceJSON.abi, @@ -204,10 +192,8 @@ const setSubnetId = async function ( console.error(error) process.exit(1) }) - const networkSubnetId = await toposCoreInterface.networkSubnetId() - console.info( - `Successfully set ${networkSubnetId} subnetId on ToposCore via proxy\n` - ) + + await toposCoreInterface.networkSubnetId() } const args = process.argv.slice(2) diff --git a/scripts/deploy.ts b/scripts/deploy.ts index 2624d1d..2774d86 100644 --- a/scripts/deploy.ts +++ b/scripts/deploy.ts @@ -39,21 +39,17 @@ const main = async function (..._args: Arg[]) { return } - await deployContractConstant( + const address = await deployContractConstant( wallet, contractJson, salt, args, gasLimit ) - .then((contract) => { - console.info( - `Successfully deployed ${ - (contractJsonPath).split('.json')[0] - } at ${contract.address}` - ) - }) + .then(({ address }) => address) .catch(console.error) + + console.log(address) } const args = process.argv.slice(2)