Skip to content

Commit 4c2e2d8

Browse files
authored
feat: hybrid-foundry-hardhat (#20)
1 parent 35cf799 commit 4c2e2d8

26 files changed

+11661
-190
lines changed

.env.example

Lines changed: 0 additions & 5 deletions
This file was deleted.

.gitignore

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
1+
node_modules
2+
.env
3+
4+
# Hardhat files
5+
/cache
6+
/artifacts
7+
8+
# TypeChain files
9+
/typechain
10+
/typechain-types
11+
12+
# solidity-coverage files
13+
/coverage
14+
/coverage.json
15+
16+
# Hardhat Ignition default folder for deployments against a local node
17+
ignition/deployments/chain-31337
18+
119
# Compiler files
2-
cache/
20+
cache_forge/
321
out/
422

523
# Ignores development broadcast logs
@@ -14,11 +32,7 @@ docs/
1432
.env
1533

1634
# Subgraphs
17-
deployment.txt
18-
deployment-anvil.txt
19-
subgraph/subgraph.config.json
20-
subgraph/node_modules
21-
subgraph/generated
22-
subgraph/build
35+
generated
36+
build
2337

2438
.pnpm

.solhint.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "solhint:recommended"
3+
}

.vscode/extensions.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"nomicfoundation.hardhat-solidity",
44
"genieai.chatgpt-vscode",
55
"esbenp.prettier-vscode",
6-
"dracula-theme.theme-dracula",
76
"cnshenj.vscode-task-manager",
87
"catppuccin.catppuccin-vsc-icons",
98
"catppuccin.catppuccin-vsc"

.vscode/tasks.json

Lines changed: 34 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,101 +2,84 @@
22
"version": "2.0.0",
33
"tasks": [
44
{
5-
"label": "build",
5+
"label": "Foundry - Build",
66
"type": "shell",
7-
"command": "make build",
7+
"command": "btp-scs foundry build",
88
"group": {
99
"kind": "build",
1010
"isDefault": true
1111
},
1212
"problemMatcher": []
1313
},
1414
{
15-
"label": "test",
15+
"label": "Hardhat - Build",
1616
"type": "shell",
17-
"command": "make test",
18-
"group": "test",
17+
"command": "btp-scs hardhat build",
18+
"group": {
19+
"kind": "build",
20+
"isDefault": false
21+
},
1922
"problemMatcher": []
2023
},
2124
{
22-
"label": "format",
25+
"label": "Foundry - Test",
2326
"type": "shell",
24-
"command": "make format",
27+
"command": "btp-scs foundry test",
28+
"group": "test",
2529
"problemMatcher": []
2630
},
2731
{
28-
"label": "snapshot",
32+
"label": "Hardhat - Test",
2933
"type": "shell",
30-
"command": "make snapshot",
34+
"command": "btp-scs hardhat test",
35+
"group": "test",
3136
"problemMatcher": []
3237
},
3338
{
34-
"label": "anvil",
39+
"label": "Foundry - Format",
3540
"type": "shell",
36-
"command": "make anvil",
41+
"command": "btp-scs foundry format",
3742
"problemMatcher": []
3843
},
3944
{
40-
"label": "deploy-anvil",
45+
"label": "Foundry - Start network",
4146
"type": "shell",
42-
"command": "make deploy-anvil",
43-
"problemMatcher": []
47+
"command": "btp-scs foundry network",
48+
"problemMatcher": [],
49+
"isBackground": true
4450
},
4551
{
46-
"label": "deploy-btp",
52+
"label": "Hardhat - Start network",
4753
"type": "shell",
48-
"command": "EXTRA_ARGS=\"${input:extra-deployment-verify} ${input:extra-deployment-other}\" make deploy-btp",
49-
"problemMatcher": []
54+
"command": "btp-scs hardhat network",
55+
"problemMatcher": [],
56+
"isBackground": true,
5057
},
5158
{
52-
"label": "script-anvil",
59+
"label": "Hardhat - Deploy to local network",
5360
"type": "shell",
54-
"command": "EXTRA_ARGS=\"${input:extra-script-broadcast} ${input:extra-script-other}\" make script-anvil",
61+
"command": "btp-scs hardhat deploy local -m ${input:deployment-module}",
5562
"problemMatcher": []
5663
},
5764
{
58-
"label": "script",
65+
"label": "Hardhat - Deploy to platform network",
5966
"type": "shell",
60-
"command": "EXTRA_ARGS=\"${input:extra-script-broadcast} ${input:extra-script-other}\" make script",
67+
"command": "btp-scs hardhat deploy remote -m ${input:deployment-module}",
6168
"problemMatcher": []
6269
},
6370
{
64-
"label": "help",
71+
"label": "The Graph - Deploy or update the subgraph",
6572
"type": "shell",
66-
"command": "make help",
73+
"command": "btp-scs subgraph deploy",
6774
"problemMatcher": []
6875
}
6976
],
7077
"inputs": [
7178
{
72-
"id": "extra-deployment-verify",
73-
"description": "Extra deployment options?",
74-
"default": "",
75-
"type": "pickString",
76-
"options": [
77-
"",
78-
"--verify --verifier sourcify",
79-
"--verify --verifier etherscan --etherscan-api-key ${ETHERSCAN_API_KEY}"
80-
]
81-
},
82-
{
83-
"id": "extra-deployment-other",
84-
"description": "Other extra deployment options?",
85-
"default": "",
86-
"type": "promptString"
87-
},
88-
{
89-
"id": "extra-script-broadcast",
90-
"description": "Broadcast?",
91-
"default": "",
92-
"type": "pickString",
93-
"options": ["", "--broadcast"]
94-
},
95-
{
96-
"id": "extra-script-other",
97-
"description": "Other extra script options?",
98-
"default": "",
99-
"type": "promptString"
79+
"id": "deployment-module",
80+
"description": "Hardhat Ignition Module",
81+
"type": "promptString",
82+
"default": "ignition/modules/Counter.ts"
10083
}
10184
]
10285
}

Dockerfile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,23 @@ FROM node:20.13.1-bookworm as build
22

33
ENV FOUNDRY_DIR /usr/local
44
RUN curl -L https://foundry.paradigm.xyz | bash && \
5-
/usr/local/bin/foundryup --version nightly-f625d0fa7c51e65b4bf1e8f7931cd1c6e2e285e9
5+
/usr/local/bin/foundryup
66

77
WORKDIR /
88

9-
RUN git config --global user.email "[email protected]" && \
10-
git config --global user.name "SettleMint" && \
11-
forge init usecase --template settlemint/solidity-empty && \
12-
cd usecase && \
13-
forge build
9+
COPY . /usecase
10+
11+
WORKDIR /usecase
1412

1513
USER root
1614

15+
RUN forge build
16+
17+
RUN npm install
18+
RUN npx hardhat compile
19+
1720
FROM cgr.dev/chainguard/busybox:latest
1821

1922
COPY --from=build /usecase /usecase
2023
COPY --from=build /root/.svm /usecase-svm
24+
COPY --from=build /root/.cache /usecase-cache

Makefile

Lines changed: 0 additions & 82 deletions
This file was deleted.

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ If you want to use it separately, bootstrap a new project using
1212
forge init my-erc20-token --template settlemint/solidity-token-erc20
1313
```
1414

15-
## DX: Foundry
15+
## DX: Foundry & Hardhat hybrid
1616

1717
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
1818

@@ -23,6 +23,14 @@ Foundry consists of:
2323
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
2424
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.
2525

26+
**Hardhat is a Flexible, Extensible, Fast Ethereum development environment for professionals in typescript**
27+
28+
Hardhat consists of:
29+
30+
- **Hardhat Runner**: Hardhat Runner is the main component you interact with when using Hardhat. It's a flexible and extensible task runner that helps you manage and automate the recurring tasks inherent to developing smart contracts and dApps.
31+
- **Hardhat Ignition**: Declarative deployment system that enables you to deploy your smart contracts without navigating the mechanics of the deployment process.
32+
- **Hardhat Network**: Declarative deployment system that enables you to deploy your smart contracts without navigating the mechanics of the deployment process.
33+
2634
## Documentation
2735

2836
- https://console.settlemint.com/documentation/docs/using-platform/integrated-development-environment/

src/Counter.sol renamed to contracts/Counter.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
pragma solidity 0.8.26;
33

44
contract Counter {
5+
event CounterIncremented(uint256 indexed newValue);
6+
57
uint256 public number;
68

79
function setNumber(uint256 newNumber) public {
@@ -10,5 +12,6 @@ contract Counter {
1012

1113
function increment() public {
1214
number++;
15+
emit CounterIncremented(number);
1316
}
1417
}

foundry.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
wrap_comments = true
1414

1515
[rpc_endpoints]
16-
anvil = "http://localhost:8545"
17-
btp = "${BTP_RPC_URL}"
16+
anvil = "http://localhost:8545"
17+
btp = "${BTP_RPC_URL}"
1818

1919
[profile.default]
20-
src = "src"
21-
test = "test"
22-
out = "out"
23-
libs = ["lib"]
20+
src = 'contracts'
21+
out = 'out'
22+
libs = ['node_modules', 'lib']
23+
test = 'test'
24+
cache_path = 'cache_forge'
2425
solc = "0.8.26"
2526
optimizer = true
2627
optimizer_runs = 10_000

0 commit comments

Comments
 (0)