diff --git a/.changeset/cool-vans-kick.md b/.changeset/cool-vans-kick.md new file mode 100644 index 000000000..f654d903a --- /dev/null +++ b/.changeset/cool-vans-kick.md @@ -0,0 +1,5 @@ +--- +"create-eth": patch +--- + +foundry: avoid extra compilation (https://github.com/scaffold-eth/scaffold-eth-2/pull/1020) diff --git a/templates/solidity-frameworks/foundry/packages/foundry/Makefile b/templates/solidity-frameworks/foundry/packages/foundry/Makefile index c8817e64c..2e0c8f9a6 100644 --- a/templates/solidity-frameworks/foundry/packages/foundry/Makefile +++ b/templates/solidity-frameworks/foundry/packages/foundry/Makefile @@ -1,4 +1,4 @@ -.PHONY: build deploy generate-abis verify-keystore account chain compile deploy-verify flatten fork format lint test verify +.PHONY: build deploy generate-abis verify-keystore account chain compile flatten fork format lint test verify DEPLOY_SCRIPT ?= script/Deploy.s.sol @@ -16,10 +16,6 @@ chain: setup-anvil-wallet fork: setup-anvil-wallet anvil --fork-url ${FORK_URL} --chain-id 31337 -# Build the project -build: - forge build --via-ir --build-info --build-info-path out/build-info/ - # Deploy the contracts deploy: @if [ ! -f "$(DEPLOY_SCRIPT)" ]; then \ @@ -36,8 +32,8 @@ deploy: forge script $(DEPLOY_SCRIPT) --rpc-url $(RPC_URL) --broadcast --legacy --ffi; \ fi -# Build and deploy target -build-and-deploy: build deploy generate-abis +# Deploy and generate ABIs +deploy-and-generate-abis: deploy generate-abis # Generate TypeScript ABIs generate-abis: @@ -67,23 +63,6 @@ account-import: compile: forge compile -# Deploy and verify -deploy-verify: - @if [ ! -f "$(DEPLOY_SCRIPT)" ]; then \ - echo "Error: Deploy script '$(DEPLOY_SCRIPT)' not found"; \ - exit 1; \ - fi - @if [ "$(RPC_URL)" = "localhost" ]; then \ - if [ "$(ETH_KEYSTORE_ACCOUNT)" = "scaffold-eth-default" ]; then \ - forge script $(DEPLOY_SCRIPT) --rpc-url localhost --password localhost --broadcast --legacy --ffi --verify; \ - else \ - forge script $(DEPLOY_SCRIPT) --rpc-url localhost --broadcast --legacy --ffi --verify; \ - fi \ - else \ - forge script $(DEPLOY_SCRIPT) --rpc-url $(RPC_URL) --broadcast --legacy --ffi --verify; \ - fi - node scripts-js/generateTsAbis.js - # Flatten contracts flatten: forge flatten @@ -99,6 +78,3 @@ lint: # Verify contracts verify: forge script script/VerifyAll.s.sol --ffi --rpc-url $(RPC_URL) - -build-and-verify: build verify - diff --git a/templates/solidity-frameworks/foundry/packages/foundry/package.json b/templates/solidity-frameworks/foundry/packages/foundry/package.json index 35389f931..c6876f16e 100644 --- a/templates/solidity-frameworks/foundry/packages/foundry/package.json +++ b/templates/solidity-frameworks/foundry/packages/foundry/package.json @@ -3,21 +3,20 @@ "version": "0.0.1", "type": "module", "scripts": { - "account": "make account", - "account:generate": "make account-generate ACCOUNT_NAME=${1:-scaffold-eth-custom}", - "account:import": "make account-import ACCOUNT_NAME=${1:-scaffold-eth-custom}", - "chain": "make chain", - "compile": "make compile", - "deploy": "node scripts-js/parseArgs.js", - "deploy:verify": "node scripts/parseArgs.js --verify", - "flatten": "make flatten", - "fork": "make fork FORK_URL=${1:-mainnet}", - "format": "make format", - "lint": "make lint", - "postinstall": "shx cp -n .env.example .env", - "test": "forge test", - "verify": "make build-and-verify RPC_URL=${1:-localhost}", - "verify-keystore": "make verify-keystore" + "verify-keystore": "make verify-keystore", + "account": "make account", + "account:generate": "make account-generate ACCOUNT_NAME=${1:-scaffold-eth-custom}", + "account:import": "make account-import ACCOUNT_NAME=${1:-scaffold-eth-custom}", + "chain": "make chain", + "compile": "make compile", + "deploy": "node scripts-js/parseArgs.js", + "flatten": "make flatten", + "fork": "make fork FORK_URL=${1:-mainnet}", + "format": "make format", + "lint": "make lint", + "test": "forge test", + "verify": "make verify RPC_URL=${1:-localhost}", + "postinstall": "shx cp -n .env.example .env" }, "dependencies": { "dotenv": "~16.3.1", @@ -28,6 +27,6 @@ "toml": "~3.0.0" }, "devDependencies": { - "shx": "~0.3.4" + "shx": "^0.3.4" } } diff --git a/templates/solidity-frameworks/foundry/packages/foundry/scripts-js/parseArgs.js b/templates/solidity-frameworks/foundry/packages/foundry/scripts-js/parseArgs.js index a9f2fea78..72bd06068 100644 --- a/templates/solidity-frameworks/foundry/packages/foundry/scripts-js/parseArgs.js +++ b/templates/solidity-frameworks/foundry/packages/foundry/scripts-js/parseArgs.js @@ -102,7 +102,7 @@ process.env.RPC_URL = network; const result = spawnSync( "make", [ - "build-and-deploy", + "deploy-and-generate-abis", `DEPLOY_SCRIPT=${process.env.DEPLOY_SCRIPT}`, `RPC_URL=${process.env.RPC_URL}`, ],