Skip to content

Commit

Permalink
Fix Makefile and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mdehoog committed Dec 12, 2024
1 parent 07f8782 commit a430c5c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,18 @@ jobs:
- name: Run Forge fmt
run: |
cd contracts
forge fmt --check
id: fmt

- name: Run Forge build
run: |
cd contracts
forge build --sizes
id: build

- name: Run Forge tests
run: |
cd contracts
forge test -vvv
id: test
30 changes: 16 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ guard-%:

define abigen
echo "Generating bindings for $(1)"
cp out/$(1).sol/$(1).$(3).json out/$(1).sol/$(1).json 2>/dev/null || true
jq -r '.bytecode.object' out/$(1).sol/$(1).json > out/$(1).sol/$(1).bin
jq -r '.abi' out/$(1).sol/$(1).json > out/$(1).sol/$(1).abi
abigen --abi out/$(1).sol/$(1).abi --bin out/$(1).sol/$(1).bin --pkg bindings --type $(1) --out bindings/$(2).go
cp contracts/out/$(1).sol/$(1).$(3).json contracts/out/$(1).sol/$(1).json 2>/dev/null || true
jq -r '.bytecode.object' contracts/out/$(1).sol/$(1).json > contracts/out/$(1).sol/$(1).bin
jq -r '.abi' contracts/out/$(1).sol/$(1).json > contracts/out/$(1).sol/$(1).abi
abigen --abi contracts/out/$(1).sol/$(1).abi --bin contracts/out/$(1).sol/$(1).bin --pkg bindings --type $(1) --out bindings/$(2).go
endef

define verify
Expand All @@ -17,18 +17,20 @@ define verify
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); \
namewithoutversion=$${name%.*.*.*}; \
constructor=$$(jq '.abi[] | select(.type=="constructor")' out/$$namewithoutversion.sol/$$name.json | jq -r '.inputs | map(.type) | join(",")'); \
constructor=$$(jq '.abi[] | select(.type=="constructor")' contracts/out/$$namewithoutversion.sol/$$name.json | jq -r '.inputs | map(.type) | join(",")'); \
echo; \
echo "Verifying $$namewithoutversion @ $$address using constructor($$constructor) $$arguments"; \
constructor_args=$$(cast abi-encode "constructor($$constructor)" $$arguments); \
forge verify-contract --compiler-version $$version --watch --verifier-url https://api-sepolia.basescan.org/api --constructor-args $$constructor_args $$address $$namewithoutversion ; \
cd contracts; \
forge verify-contract --compiler-version $$version --watch --verifier-url https://api-sepolia.basescan.org/api --constructor-args $$constructor_args $$address $$namewithoutversion; \
cd ..; \
done
endef

.PHONY: bindings
bindings:
go install github.com/ethereum/go-ethereum/cmd/[email protected]
forge build
cd contracts && forge build
mkdir -p bindings
@$(call abigen,"OutputOracle","output_oracle","0.8.15")
@$(call abigen,"Portal","portal","0.8.15")
Expand All @@ -39,26 +41,26 @@ bindings:

.PHONY: deploy-cert-manager
deploy-cert-manager: guard-IMPL_SALT guard-DEPLOY_PRIVATE_KEY guard-RPC_URL
@forge script DeployCertManager --rpc-url $(RPC_URL) \
@cd contracts && forge script DeployCertManager --rpc-url $(RPC_URL) \
--private-key $(DEPLOY_PRIVATE_KEY) --broadcast

.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) \
@cd contracts && forge script DeploySystem --sig deploy --rpc-url $(RPC_URL) \
--private-key $(DEPLOY_PRIVATE_KEY) --broadcast

.PHONY: deploy-deploy-chain
deploy-deploy-chain: guard-IMPL_SALT guard-DEPLOY_PRIVATE_KEY guard-RPC_URL
@forge script DeployDeployChain --rpc-url $(RPC_URL) \
@cd contracts && forge script DeployDeployChain --rpc-url $(RPC_URL) \
--private-key $(DEPLOY_PRIVATE_KEY) --broadcast

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

.PHONY: verify
verify:
@$(call verify,"broadcast/DeployCertManager.s.sol/84532/run-1733890597.json","0.8.24")
@$(call verify,"broadcast/DeploySystem.s.sol/84532/run-1733867021.json","0.8.15")
@$(call verify,"broadcast/DeployDeployChain.s.sol/84532/run-1733884066.json","0.8.15")
@$(call verify,"contracts/broadcast/DeployCertManager.s.sol/84532/run-1733890597.json","0.8.24")
@$(call verify,"contracts/broadcast/DeploySystem.s.sol/84532/run-1733867021.json","0.8.15")
@$(call verify,"contracts/broadcast/DeployDeployChain.s.sol/84532/run-1733884066.json","0.8.15")

0 comments on commit a430c5c

Please sign in to comment.