Skip to content

Commit

Permalink
add --dry-run flag to main.go
Browse files Browse the repository at this point in the history
  • Loading branch information
sisyphusSmiling committed May 21, 2024
1 parent fca86fc commit ca64c11
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (
* - The bridge account has enough FLOW to cover the storage required for the deployed contracts
*/

// Overflow prefixes signer names with the current network - e.g. "emulator-flow-evm-bridge"
// Overflow prefixes signer names with the current network - e.g. "crescendo-flow-evm-bridge"
// Ensure accounts in flow.json are named accordingly
var networks = []string{"emulator", "previewnet", "crescendo", "testnet", "mainnet"}
var networks = []string{"previewnet", "crescendo", "testnet", "mainnet"}

// Pulled from flow.json deployments. Specified here as some contracts have init arg values that
// are emitted in transaction events and cannot be hardcoded in the deployment config section
Expand Down Expand Up @@ -69,6 +69,20 @@ func main() {
WithGlobalPrintOptions(WithTransactionUrl()),
)

// Check if the script is a dry run
if checkDryRun() {
log.Printf("Dry run detected...running setup script in dry run mode")
// Run the dry run transaction
serviceDryRunResult := o.Tx("bridge/admin/dry_run", WithSigner("service-account"))
checkNoErr(serviceDryRunResult.Err)
log.Printf("Service Account dry run run successful...")
bridgeDryRunResult := o.Tx("bridge/admin/dry_run", WithSigner("flow-evm-bridge"))
checkNoErr(bridgeDryRunResult.Err)
log.Printf("Bridge Account dry run run successful...")
log.Printf("Dry run complete...exiting script")
return
}

// Create a COA in the bridge account if one does not already exist
bridgeCOAHex, err := o.Script("evm/get_evm_address_string", WithArg("flowAddress", o.Address("flow-evm-bridge"))).GetAsInterface()
checkNoErr(err)
Expand Down Expand Up @@ -327,6 +341,13 @@ func main() {
log.Printf("SETUP COMPLETE! Bridge is now unpaused and ready for use.")
}

func checkDryRun() bool {
if len(os.Args) < 3 {
return false
}
return os.Args[2] == "--dry-run"
}

// Parses the network argument from the command line
// e.g. go run main.go $NETWORK
func getSpecifiedNetwork() string {
Expand Down

0 comments on commit ca64c11

Please sign in to comment.