Skip to content

Commit

Permalink
foundry: avoid extra compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
portdeveloper authored Dec 24, 2024
1 parent 8790db7 commit 8c4e925
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 44 deletions.
5 changes: 5 additions & 0 deletions .changeset/cool-vans-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-eth": patch
---

foundry: avoid extra compilation (https://github.com/scaffold-eth/scaffold-eth-2/pull/1020)
30 changes: 3 additions & 27 deletions templates/solidity-frameworks/foundry/packages/foundry/Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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 \
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -99,6 +78,3 @@ lint:
# Verify contracts
verify:
forge script script/VerifyAll.s.sol --ffi --rpc-url $(RPC_URL)

build-and-verify: build verify

31 changes: 15 additions & 16 deletions templates/solidity-frameworks/foundry/packages/foundry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -28,6 +27,6 @@
"toml": "~3.0.0"
},
"devDependencies": {
"shx": "~0.3.4"
"shx": "^0.3.4"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
],
Expand Down

0 comments on commit 8c4e925

Please sign in to comment.