diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eb62b8e..b0b8c24 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/Makefile b/Makefile index 6152388..2f7ce69 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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/abigen@v1.14.11 - forge build + cd contracts && forge build mkdir -p bindings @$(call abigen,"OutputOracle","output_oracle","0.8.15") @$(call abigen,"Portal","portal","0.8.15") @@ -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")