Commit 22c3885f authored by Maurelian's avatar Maurelian

feat(ctb): Optionally print cast commands during migration

parent 711ebbe8
---
'@eth-optimism/contracts-bedrock': patch
---
Optionally print cast commands during migration
...@@ -7,3 +7,7 @@ PRIVATE_KEY_DEPLOYER= ...@@ -7,3 +7,7 @@ PRIVATE_KEY_DEPLOYER=
# Optional Tenderly details for a simulation link during deployment # Optional Tenderly details for a simulation link during deployment
TENDERLY_PROJECT= TENDERLY_PROJECT=
TENDERLY_USERNAME= TENDERLY_USERNAME=
# Optional boolean to define if cast commands should be printed.
# Useful during migration testing
CAST_COMMANDS=1
...@@ -14,6 +14,7 @@ import { ...@@ -14,6 +14,7 @@ import {
doStep, doStep,
jsonifyTransaction, jsonifyTransaction,
getTenderlySimulationLink, getTenderlySimulationLink,
getCastCommand,
} from '../src/deploy-utils' } from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
...@@ -98,6 +99,7 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -98,6 +99,7 @@ const deployFn: DeployFunction = async (hre) => {
console.log(`MSD address: ${SystemDictator.address}`) console.log(`MSD address: ${SystemDictator.address}`)
console.log(`JSON:`) console.log(`JSON:`)
console.log(jsonifyTransaction(tx)) console.log(jsonifyTransaction(tx))
console.log(getCastCommand(tx))
console.log(await getTenderlySimulationLink(SystemDictator.provider, tx)) console.log(await getTenderlySimulationLink(SystemDictator.provider, tx))
} }
...@@ -135,6 +137,7 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -135,6 +137,7 @@ const deployFn: DeployFunction = async (hre) => {
console.log(`MSD address: ${SystemDictator.address}`) console.log(`MSD address: ${SystemDictator.address}`)
console.log(`JSON:`) console.log(`JSON:`)
console.log(jsonifyTransaction(tx)) console.log(jsonifyTransaction(tx))
console.log(getCastCommand(tx))
console.log(await getTenderlySimulationLink(SystemDictator.provider, tx)) console.log(await getTenderlySimulationLink(SystemDictator.provider, tx))
} }
...@@ -172,6 +175,7 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -172,6 +175,7 @@ const deployFn: DeployFunction = async (hre) => {
console.log(`MSD address: ${SystemDictator.address}`) console.log(`MSD address: ${SystemDictator.address}`)
console.log(`JSON:`) console.log(`JSON:`)
console.log(jsonifyTransaction(tx)) console.log(jsonifyTransaction(tx))
console.log(getCastCommand(tx))
console.log(await getTenderlySimulationLink(SystemDictator.provider, tx)) console.log(await getTenderlySimulationLink(SystemDictator.provider, tx))
} }
......
...@@ -14,6 +14,7 @@ import { ...@@ -14,6 +14,7 @@ import {
isStep, isStep,
doStep, doStep,
getTenderlySimulationLink, getTenderlySimulationLink,
getCastCommand,
} from '../src/deploy-utils' } from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
...@@ -194,6 +195,7 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -194,6 +195,7 @@ const deployFn: DeployFunction = async (hre) => {
console.log(`MSD address: ${SystemDictator.address}`) console.log(`MSD address: ${SystemDictator.address}`)
console.log(`JSON:`) console.log(`JSON:`)
console.log(jsonifyTransaction(tx)) console.log(jsonifyTransaction(tx))
console.log(getCastCommand(tx))
console.log(await getTenderlySimulationLink(SystemDictator.provider, tx)) console.log(await getTenderlySimulationLink(SystemDictator.provider, tx))
} }
...@@ -305,6 +307,7 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -305,6 +307,7 @@ const deployFn: DeployFunction = async (hre) => {
console.log(`OptimismPortal address: ${OptimismPortal.address}`) console.log(`OptimismPortal address: ${OptimismPortal.address}`)
console.log(`JSON:`) console.log(`JSON:`)
console.log(jsonifyTransaction(tx)) console.log(jsonifyTransaction(tx))
console.log(getCastCommand(tx))
console.log(await getTenderlySimulationLink(SystemDictator.provider, tx)) console.log(await getTenderlySimulationLink(SystemDictator.provider, tx))
} }
...@@ -334,6 +337,7 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -334,6 +337,7 @@ const deployFn: DeployFunction = async (hre) => {
console.log(`MSD address: ${SystemDictator.address}`) console.log(`MSD address: ${SystemDictator.address}`)
console.log(`JSON:`) console.log(`JSON:`)
console.log(jsonifyTransaction(tx)) console.log(jsonifyTransaction(tx))
console.log(getCastCommand(tx))
console.log(await getTenderlySimulationLink(SystemDictator.provider, tx)) console.log(await getTenderlySimulationLink(SystemDictator.provider, tx))
} }
......
...@@ -395,3 +395,15 @@ export const getTenderlySimulationLink = async ( ...@@ -395,3 +395,15 @@ export const getTenderlySimulationLink = async (
}).toString()}` }).toString()}`
} }
} }
/**
* Returns a cast commmand for submitting a given transaction.
*
* @param tx Ethers transaction object.
* @returns the cast command
*/
export const getCastCommand = (tx: ethers.PopulatedTransaction): string => {
if (process.env.CAST_COMMANDS) {
return `cast send ${tx.to} ${tx.data} --from ${tx.from} --value ${tx.value}`
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment