diff --git a/packages/contracts-bedrock/deploy/020-SystemDictatorSteps-1.ts b/packages/contracts-bedrock/deploy/020-SystemDictatorSteps-1.ts index 114a9901f06..1e8900f7454 100644 --- a/packages/contracts-bedrock/deploy/020-SystemDictatorSteps-1.ts +++ b/packages/contracts-bedrock/deploy/020-SystemDictatorSteps-1.ts @@ -12,9 +12,9 @@ import { getContractsFromArtifacts, getDeploymentAddress, doPhase, - jsonifyTransaction, - getTenderlySimulationLink, - getCastCommand, + printJsonTransaction, + printTenderlySimulationLink, + printCastCommand, } from '../src/deploy-utils' const uint128Max = ethers.BigNumber.from('0xffffffffffffffffffffffffffffffff') @@ -99,10 +99,9 @@ const deployFn: DeployFunction = async (hre) => { console.log(`Please transfer AddressManager owner to MSD`) console.log(`AddressManager address: ${AddressManager.address}`) console.log(`MSD address: ${SystemDictator.address}`) - console.log(`JSON:`) - console.log(jsonifyTransaction(tx)) - console.log(getCastCommand(tx)) - console.log(await getTenderlySimulationLink(SystemDictator.provider, tx)) + printJsonTransaction(tx) + printCastCommand(tx) + await printTenderlySimulationLink(SystemDictator.provider, tx) } // Wait for the ownership transfer to complete. @@ -137,10 +136,9 @@ const deployFn: DeployFunction = async (hre) => { `L1StandardBridgeProxy address: ${L1StandardBridgeProxy.address}` ) console.log(`MSD address: ${SystemDictator.address}`) - console.log(`JSON:`) - console.log(jsonifyTransaction(tx)) - console.log(getCastCommand(tx)) - console.log(await getTenderlySimulationLink(SystemDictator.provider, tx)) + printJsonTransaction(tx) + printCastCommand(tx) + await printTenderlySimulationLink(SystemDictator.provider, tx) } // Wait for the ownership transfer to complete. @@ -175,10 +173,9 @@ const deployFn: DeployFunction = async (hre) => { console.log(`Please transfer L1ERC721Bridge (proxy) owner to MSD`) console.log(`L1ERC721BridgeProxy address: ${L1ERC721BridgeProxy.address}`) console.log(`MSD address: ${SystemDictator.address}`) - console.log(`JSON:`) - console.log(jsonifyTransaction(tx)) - console.log(getCastCommand(tx)) - console.log(await getTenderlySimulationLink(SystemDictator.provider, tx)) + printJsonTransaction(tx) + printCastCommand(tx) + await printTenderlySimulationLink(SystemDictator.provider, tx) } // Wait for the ownership transfer to complete. diff --git a/packages/contracts-bedrock/deploy/021-SystemDictatorSteps-2.ts b/packages/contracts-bedrock/deploy/021-SystemDictatorSteps-2.ts index fa44f1be709..97356572820 100644 --- a/packages/contracts-bedrock/deploy/021-SystemDictatorSteps-2.ts +++ b/packages/contracts-bedrock/deploy/021-SystemDictatorSteps-2.ts @@ -10,11 +10,11 @@ import '@nomiclabs/hardhat-ethers' import { assertContractVariable, getContractsFromArtifacts, - jsonifyTransaction, + printJsonTransaction, isStep, doStep, - getTenderlySimulationLink, - getCastCommand, + printTenderlySimulationLink, + printCastCommand, } from '../src/deploy-utils' const deployFn: DeployFunction = async (hre) => { @@ -206,10 +206,9 @@ const deployFn: DeployFunction = async (hre) => { ) ) console.log(`MSD address: ${SystemDictator.address}`) - console.log(`JSON:`) - console.log(jsonifyTransaction(tx)) - console.log(getCastCommand(tx)) - console.log(await getTenderlySimulationLink(SystemDictator.provider, tx)) + printJsonTransaction(tx) + printCastCommand(tx) + await printTenderlySimulationLink(SystemDictator.provider, tx) } await awaitCondition( @@ -318,10 +317,9 @@ const deployFn: DeployFunction = async (hre) => { const tx = await OptimismPortal.populateTransaction.unpause() console.log(`Please unpause the OptimismPortal...`) console.log(`OptimismPortal address: ${OptimismPortal.address}`) - console.log(`JSON:`) - console.log(jsonifyTransaction(tx)) - console.log(getCastCommand(tx)) - console.log(await getTenderlySimulationLink(SystemDictator.provider, tx)) + printJsonTransaction(tx) + printCastCommand(tx) + await printTenderlySimulationLink(SystemDictator.provider, tx) } await awaitCondition( @@ -348,10 +346,9 @@ const deployFn: DeployFunction = async (hre) => { const tx = await SystemDictator.populateTransaction.finalize() console.log(`Please finalize deployment...`) console.log(`MSD address: ${SystemDictator.address}`) - console.log(`JSON:`) - console.log(jsonifyTransaction(tx)) - console.log(getCastCommand(tx)) - console.log(await getTenderlySimulationLink(SystemDictator.provider, tx)) + printJsonTransaction(tx) + printCastCommand(tx) + await printTenderlySimulationLink(SystemDictator.provider, tx) } await awaitCondition( diff --git a/packages/contracts-bedrock/src/deploy-utils.ts b/packages/contracts-bedrock/src/deploy-utils.ts index 9e72a9b86f1..3c20cb98e54 100644 --- a/packages/contracts-bedrock/src/deploy-utils.ts +++ b/packages/contracts-bedrock/src/deploy-utils.ts @@ -305,17 +305,20 @@ export const getDeploymentAddress = async ( * @param tx Ethers transaction object. * @returns JSON-ified transaction object. */ -export const jsonifyTransaction = (tx: ethers.PopulatedTransaction): string => { - return JSON.stringify( - { - from: tx.from, - to: tx.to, - data: tx.data, - value: tx.value, - chainId: tx.chainId, - }, - null, - 2 +export const printJsonTransaction = (tx: ethers.PopulatedTransaction): void => { + console.log( + 'JSON transaction parameters:\n' + + JSON.stringify( + { + from: tx.from, + to: tx.to, + data: tx.data, + value: tx.value, + chainId: tx.chainId, + }, + null, + 2 + ) ) } @@ -388,11 +391,8 @@ export const doStep = async (opts: { ]() console.log(`Please execute step ${opts.step}...`) console.log(`MSD address: ${opts.SystemDictator.address}`) - console.log(`JSON:`) - console.log(jsonifyTransaction(tx)) - console.log( - await getTenderlySimulationLink(opts.SystemDictator.provider, tx) - ) + printJsonTransaction(tx) + await printTenderlySimulationLink(opts.SystemDictator.provider, tx) } // Wait for the step to complete. @@ -444,11 +444,8 @@ export const doPhase = async (opts: { ]() console.log(`Please execute phase ${opts.phase}...`) console.log(`MSD address: ${opts.SystemDictator.address}`) - console.log(`JSON:`) - console.log(jsonifyTransaction(tx)) - console.log( - await getTenderlySimulationLink(opts.SystemDictator.provider, tx) - ) + printJsonTransaction(tx) + await printTenderlySimulationLink(opts.SystemDictator.provider, tx) } // Wait for the step to complete. @@ -465,36 +462,38 @@ export const doPhase = async (opts: { } /** - * Returns a direct link to a Tenderly simulation. + * Prints a direct link to a Tenderly simulation. * * @param provider Ethers Provider. * @param tx Ethers transaction object. - * @returns the url of the tenderly simulation. */ -export const getTenderlySimulationLink = async ( +export const printTenderlySimulationLink = async ( provider: ethers.providers.Provider, tx: ethers.PopulatedTransaction -): Promise => { +): Promise => { if (process.env.TENDERLY_PROJECT && process.env.TENDERLY_USERNAME) { - return `https://dashboard.tenderly.co/${process.env.TENDERLY_PROJECT}/${ - process.env.TENDERLY_USERNAME - }/simulator/new?${new URLSearchParams({ - network: (await provider.getNetwork()).chainId.toString(), - contractAddress: tx.to, - rawFunctionInput: tx.data, - from: tx.from, - }).toString()}` + console.log( + `https://dashboard.tenderly.co/${process.env.TENDERLY_PROJECT}/${ + process.env.TENDERLY_USERNAME + }/simulator/new?${new URLSearchParams({ + network: (await provider.getNetwork()).chainId.toString(), + contractAddress: tx.to, + rawFunctionInput: tx.data, + from: tx.from, + }).toString()}` + ) } } /** - * Returns a cast commmand for submitting a given transaction. + * Prints a cast commmand for submitting a given transaction. * * @param tx Ethers transaction object. - * @returns the cast command */ -export const getCastCommand = (tx: ethers.PopulatedTransaction): string => { +export const printCastCommand = (tx: ethers.PopulatedTransaction): void => { if (process.env.CAST_COMMANDS) { - return `cast send ${tx.to} ${tx.data} --from ${tx.from} --value ${tx.value}` + console.log( + `cast send ${tx.to} ${tx.data} --from ${tx.from} --value ${tx.value}` + ) } }