Skip to content

Commit

Permalink
Add contract verification
Browse files Browse the repository at this point in the history
  • Loading branch information
mdehoog committed Oct 8, 2024
1 parent e4cb64a commit 01a4391
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
guard-%:
@ if [ "${${*}}" = "" ]; then echo "Environment variable $* not set" && exit 1; fi

.PHONY: bindings
bindings:
go install github.com/ethereum/go-ethereum/cmd/[email protected]
forge clean && forge build --extra-output-files abi
mkdir -p bindings
abigen --abi out/OutputOracle.sol/OutputOracle.abi.json --pkg bindings --type OutputOracle --out bindings/output_oracle.go
abigen --abi out/Portal.sol/Portal.abi.json --pkg bindings --type Portal --out bindings/portal.go
abigen --abi out/DeployChain.sol/DeployChain.abi.json --pkg bindings --type DeployChain --out bindings/deploy_chain.go

.PHONY: deploy
deploy: guard-IMPL_SALT guard-DEPLOY_CONFIG_PATH guard-DEPLOY_PRIVATE_KEY guard-RPC_URL
@forge script DeploySystem --sig deploy --rpc-url $(RPC_URL) \
--private-key $(DEPLOY_PRIVATE_KEY) --broadcast

.PHONY: testnet guard-L1_URL guard-DEPLOY_PRIVATE_KEY
testnet:
DEPLOY_CHAIN_ADDRESS=${DEPLOY_CHAIN_ADDRESS:-$(jq -r ".DeployChain" deployments/84532-deploy.json)} \
go run ./testnet

.PHONY: verify
verify:
deploy=broadcast/DeploySystem.s.sol/84532/deploy-latest.json; \
addresses=$$(jq -r '.transactions[] | select(.transactionType=="CREATE" or .transactionType=="CREATE2") | .contractAddress' $$deploy); \
for address in $$addresses; do \
name=$$(jq -r --arg address "$$address" '.transactions[] | select((.transactionType=="CREATE" or .transactionType=="CREATE2") and .contractAddress==$$address) | .contractName' $$deploy); \
arguments=$$(jq -r --arg address "$$address" '.transactions[] | select((.transactionType=="CREATE" or .transactionType=="CREATE2") and .contractAddress==$$address) | .arguments // [] | join(" ")' $$deploy); \
constructor=$$(jq '.[] | select(.type=="constructor")' out/$$name.sol/$$name.abi.json | jq -r '.inputs | map(.type) | join(",")'); \
echo "Verifying $$name @ $$address using constructor($$constructor) $$arguments"; \
constructor_args=$$(cast abi-encode "constructor($$constructor)" $$arguments); \
forge verify-contract --watch --verifier-url https://api-sepolia.basescan.org/api --constructor-args $$constructor_args $$address $$name ; \
done

2 changes: 2 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
[profile.default]
src = "src"
out = "out"
broadcast = "broadcast"
libs = ["lib"]
optimizer = true
optimizer_runs = 999999

extra_output_files = ['abi']
bytecode_hash = 'none'
ast = true
gas_limit = 9223372036854775807
Expand Down

0 comments on commit 01a4391

Please sign in to comment.