Skip to content

Commit 6bfef95

Browse files
committed
feat(devnet): Add commands for setting up localnet ENV file for Optimism devnet
1 parent 6695578 commit 6bfef95

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

.devcontainer/justfile

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,22 @@ l3_chain_id := "5100"
1717
op_devnet_private_key := "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
1818

1919
# Define layer-2 devnet RPC URL launched by the Optimism devnet
20-
op_devnet_l2_rpc_url := "127.0.0.1:9545"
20+
op_devnet_l2_rpc_url := "http://127.0.0.1:9545"
21+
22+
# Define layer-2 rollup chain ID in decimal
23+
op_devnet_l2_chain_id := "901"
24+
25+
# Define root directory of the git repository
26+
repository_root := justfile_directory() + "/.."
2127

2228
# Define root directory of the metabased contracts project
23-
contracts_root := justfile_directory() + "/../metabased-contracts"
29+
contracts_root := repository_root + "/metabased-contracts"
30+
31+
# Define file for localnet environment variables
32+
localenv_file := repository_root + "/localnet.env"
33+
34+
# Define deploy file created on latest run of the deploy script for metabased sequencer chain contract
35+
contract_deploy_file := contracts_root + "/broadcast/DeployContractsForSequencerChain_.s.sol/" + op_devnet_l2_chain_id + "/run-latest.json"
2436

2537
# Add Foundry's bin directory to the PATH for all recipes
2638
export PATH := foundry_path
@@ -40,12 +52,26 @@ op-clean:
4052

4153
op-reclone: op-down op-clean op-clone
4254

43-
# Deploy MetabasedSequencerChain smart contract to devnet
55+
# Deploy MetabasedSequencerChain smart contract to Optimism devnet
4456
op-deploy-chain:
4557
cat {{ contracts_root }}/script/DeployContractsForSequencerChain.s.sol | sed 's/l3ChainId = 0;[^\n]*/l3ChainId = {{ l3_chain_id }};/' > {{ contracts_root }}/script/DeployContractsForSequencerChain_.s.sol
46-
forge script --root {{ contracts_root }} {{ contracts_root }}/script/DeployContractsForSequencerChain_.s.sol:DeployMetabasedSequencerChainPlusSetupWithAlwaysAllowModule --rpc-url {{ op_devnet_l2_rpc_url }} --private-key {{ op_devnet_private_key }} --broadcast -vv
58+
[ -f {{ contract_deploy_file }} ] || forge script --root {{ contracts_root }} {{ contracts_root }}/script/DeployContractsForSequencerChain_.s.sol:DeployMetabasedSequencerChainPlusSetupWithAlwaysAllowModule --rpc-url {{ op_devnet_l2_rpc_url }} --private-key {{ op_devnet_private_key }} --broadcast -vv
4759
rm {{ contracts_root }}/script/DeployContractsForSequencerChain_.s.sol
4860

61+
# Removes files generated by deploying metabased sequencer chain contract to Optimism devnet
62+
op-clean-chain:
63+
rm -rf {{ contract_deploy_file }}
64+
65+
# Puts contract address to localnet ENV file
66+
op-update-chain-address: op-deploy-chain op-create-localenv
67+
cat {{ localenv_file }} | grep -v METABASED_CHAIN_CONTRACT_ADDRESS= > {{ localenv_file }}.tmp
68+
echo METABASED_CHAIN_CONTRACT_ADDRESS=0x$(cat {{ contract_deploy_file }} | grep MetabasedSequencerChain -A1 | grep contractAddress | sed 's/[^x]*0x//' | cut -c 1-40 | uniq) >> {{ localenv_file }}.tmp
69+
mv {{ localenv_file }}.tmp {{ localenv_file }}
70+
71+
# Creates localnet ENV file with values fit for Optimism devnet
72+
op-create-localenv:
73+
[ -f {{ localenv_file }} ] || echo -e "METABASED_CHAIN_RPC_ADDRESS={{ op_devnet_l2_rpc_url }}\nMETABASED_PRIVATE_KEY={{ op_devnet_private_key }}" > {{ localenv_file }}
74+
4975
go-install:
5076
go install /workspaces/metabased-rollup/op-translator
5177
# go install /workspaces/metabased-rollup/metabased-publisher/cmd

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
# Local environment
1818
.env
19+
localnet.env
1920

2021
# Build files
2122
bin/

0 commit comments

Comments
 (0)