Skip to content

Commit 5ef67d5

Browse files
SyedAsadKazmiaelmanaadev-dist
authored
Hardhat -> Foundry, update contracts, contracts-ccip & OZ packages (#3046)
* Hardhat -> Foundry, update contracts,ccip & oz pkg * fixes * fixes * update * Revise CCT tutorials * added smartdata tag to base sepolia (#3090) (#3093) Co-authored-by: devin distefano <[email protected]> --------- Co-authored-by: aelmanaa <[email protected]> Co-authored-by: devin distefano <[email protected]> Co-authored-by: Amine E. <[email protected]>
1 parent 6d34007 commit 5ef67d5

File tree

151 files changed

+15506
-15092
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+15506
-15092
lines changed

.github/workflows/test.yml

Lines changed: 30 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ concurrency:
66
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
77
cancel-in-progress: true
88

9+
env:
10+
FOUNDRY_PROFILE: ci
11+
912
# Set default permissions as restrictive as possible
1013
permissions:
1114
actions: write # Required for upload-artifact
@@ -27,14 +30,12 @@ jobs:
2730
cache: 'npm'
2831
cache-dependency-path: '**/package-lock.json'
2932

30-
# Only cache node_modules, let setup-node handle npm cache
3133
- name: Cache node_modules
3234
uses: actions/cache@v4
3335
id: cache-node-modules
3436
continue-on-error: true
3537
with:
36-
path: |
37-
node_modules
38+
path: node_modules
3839
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
3940

4041
- name: Install Dependencies
@@ -50,24 +51,29 @@ jobs:
5051
steps:
5152
- name: Checkout Repo
5253
uses: actions/checkout@v5
53-
54+
5455
- name: Setup Node.js
5556
uses: actions/setup-node@v6
5657
with:
5758
node-version: '20'
5859
cache: 'npm'
5960
cache-dependency-path: '**/package-lock.json'
6061

61-
# Restore node_modules from setup job
62+
- name: Install Foundry
63+
uses: foundry-rs/foundry-toolchain@50d5a8956f2e319df19e6b57539d7e2acb9f8c1e # v1.5
64+
with:
65+
version: stable
66+
cache: false
67+
68+
- name: Show Forge version
69+
run: forge --version
70+
6271
- name: Restore node_modules
63-
uses: actions/cache@v4
72+
uses: actions/cache/restore@v4
6473
continue-on-error: true
6574
with:
66-
path: |
67-
node_modules
75+
path: node_modules
6876
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
69-
restore-keys: |
70-
${{ runner.os }}-node-modules-
7177

7278
- name: Ensure Dependencies
7379
run: |
@@ -76,31 +82,15 @@ jobs:
7682
npm ci --prefer-offline --no-audit
7783
fi
7884
79-
# Cache Solidity compilation artifacts
80-
- name: Restore compilation caches
81-
id: cache-solidity
82-
uses: actions/cache@v4
83-
continue-on-error: true
84-
with:
85-
path: |
86-
.test/artifacts
87-
.test/cache
88-
~/.cache/hardhat
89-
typechain-types
90-
key: ${{ runner.os }}-solidity-${{ hashFiles('public/samples/**/*.sol', 'hardhat.config.cts') }}
91-
restore-keys: |
92-
${{ runner.os }}-solidity-
85+
- name: Check Solidity Formatting
86+
run: npm run sol:fmt:check
9387

9488
- name: Check Solidity Compilation
95-
run: |
96-
echo "Running Solidity compilation with cache..."
97-
npm run sol:compile
98-
99-
- name: Check Solidity Solhint
100-
run: |
101-
echo "Running Solhint..."
102-
npm run lint-solc
89+
run: forge build --sizes
10390

91+
- name: Check Solidity Linting
92+
run: npm run lint-solc
93+
10494
# Job 2: Check ESLint
10595
eslint:
10696
needs: setup
@@ -116,16 +106,12 @@ jobs:
116106
cache: 'npm'
117107
cache-dependency-path: '**/package-lock.json'
118108

119-
# Restore node_modules from setup job
120109
- name: Restore node_modules
121-
uses: actions/cache@v4
110+
uses: actions/cache/restore@v4
122111
continue-on-error: true
123112
with:
124-
path: |
125-
node_modules
113+
path: node_modules
126114
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
127-
restore-keys: |
128-
${{ runner.os }}-node-modules-
129115

130116
- name: Ensure Dependencies
131117
run: |
@@ -159,16 +145,12 @@ jobs:
159145
cache: 'npm'
160146
cache-dependency-path: '**/package-lock.json'
161147

162-
# Restore node_modules from setup job
163148
- name: Restore node_modules
164-
uses: actions/cache@v4
149+
uses: actions/cache/restore@v4
165150
continue-on-error: true
166151
with:
167-
path: |
168-
node_modules
152+
path: node_modules
169153
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
170-
restore-keys: |
171-
${{ runner.os }}-node-modules-
172154

173155
- name: Ensure Dependencies
174156
run: |
@@ -195,16 +177,12 @@ jobs:
195177
cache: 'npm'
196178
cache-dependency-path: '**/package-lock.json'
197179

198-
# Restore node_modules from setup job
199180
- name: Restore node_modules
200-
uses: actions/cache@v4
181+
uses: actions/cache/restore@v4
201182
continue-on-error: true
202183
with:
203-
path: |
204-
node_modules
184+
path: node_modules
205185
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
206-
restore-keys: |
207-
${{ runner.os }}-node-modules-
208186

209187
- name: Ensure Dependencies
210188
run: |
@@ -243,16 +221,12 @@ jobs:
243221
cache: 'npm'
244222
cache-dependency-path: '**/package-lock.json'
245223

246-
# Restore node_modules from setup job
247224
- name: Restore node_modules
248-
uses: actions/cache@v4
225+
uses: actions/cache/restore@v4
249226
continue-on-error: true
250227
with:
251-
path: |
252-
node_modules
228+
path: node_modules
253229
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
254-
restore-keys: |
255-
${{ runner.os }}-node-modules-
256230

257231
- name: Ensure Dependencies
258232
run: |

.prettierrc

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,6 @@
1212
"parser": "astro"
1313
}
1414
},
15-
{
16-
"files": "*.sol",
17-
"options": {
18-
"printWidth": 80,
19-
"tabWidth": 4,
20-
"useTabs": false,
21-
"singleQuote": false,
22-
"bracketSpacing": false
23-
}
24-
},
2515
{
2616
"files": "public/samples/ChainlinkFunctions/*.js",
2717
"options": {

.solhint.json

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,39 @@
11
{
22
"extends": "solhint:recommended",
3-
"plugins": ["prettier", "chainlink-solidity"],
3+
"plugins": ["chainlink-solidity"],
44
"rules": {
5-
"prettier/prettier": "error",
6-
"compiler-version": ["error", ">=0.4.24"],
5+
"compiler-version": ["off", "^0.8.0"],
76
"const-name-snakecase": "off",
8-
"constructor-syntax": "error",
97
"var-name-mixedcase": "off",
108
"func-named-parameters": "off",
119
"immutable-vars-naming": "off",
1210
"no-inline-assembly": "off",
11+
"contract-name-capwords": "off",
12+
"use-natspec": "off",
13+
"gas-indexed-events": "off",
14+
"function-max-lines": "off",
15+
"gas-strict-inequalities": "off",
16+
"gas-increment-by-one": "off",
17+
"gas-calldata-parameters": "off",
18+
"gas-small-strings": "off",
19+
"not-rely-on-time": "off",
20+
"no-empty-blocks": "off",
1321
"no-unused-import": "error",
14-
"func-visibility": ["error", { "ignoreConstructors": true }],
22+
"import-path-check": "off",
23+
"func-visibility": [
24+
"error",
25+
{
26+
"ignoreConstructors": true
27+
}
28+
],
1529
"quotes": ["error", "double"],
16-
"reason-string": ["warn", { "maxLength": 64 }],
1730
"chainlink-solidity/prefix-internal-functions-with-underscore": "warn",
1831
"chainlink-solidity/prefix-private-functions-with-underscore": "warn",
1932
"chainlink-solidity/prefix-storage-variables-with-s-underscore": "warn",
20-
"chainlink-solidity/prefix-immutable-variables-with-i": "warn"
33+
"chainlink-solidity/prefix-immutable-variables-with-i": "warn",
34+
"chainlink-solidity/all-caps-constant-storage-variables": "warn",
35+
"chainlink-solidity/no-hardhat-imports": "warn",
36+
"chainlink-solidity/inherited-constructor-args-not-in-contract-definition": "warn",
37+
"chainlink-solidity/explicit-returns": "warn"
2138
}
2239
}

.vscode/extensions.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
"recommendations": [
33
"dbaeumer.vscode-eslint",
44
"esbenp.prettier-vscode",
5-
"NomicFoundation.hardhat-solidity",
5+
"JuanBlanco.solidity",
66
"astro-build.astro-vscode",
77
"unifiedjs.vscode-mdx",
88
"streetsidesoftware.code-spell-checker"
99
],
10-
"unwantedRecommendations": []
10+
"unwantedRecommendations": ["NomicFoundation.hardhat-solidity"]
1111
}

.vscode/settings.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
"*.mdx": "mdx"
44
},
55
"editor.formatOnSave": true,
6-
"solidity.formatter": "prettier", // This is the default so it might be missing.
76
"prettier.documentSelectors": ["**/*.astro"],
7+
// Solidity settings for Foundry
8+
"solidity.formatter": "forge",
9+
"solidity.packageDefaultDependenciesContractsDirectory": "public/samples",
10+
"solidity.packageDefaultDependenciesDirectory": "node_modules",
811
"[solidity]": {
9-
"editor.defaultFormatter": "NomicFoundation.hardhat-solidity"
12+
"editor.defaultFormatter": "JuanBlanco.solidity"
1013
},
1114
"[astro]": {
1215
"editor.defaultFormatter": "esbenp.prettier-vscode"
@@ -17,7 +20,11 @@
1720
"[mdx]": {
1821
"editor.wordWrap": "on"
1922
},
20-
"cSpell.enableFiletypes": ["astro", "mdx", "solidity"],
23+
"cSpell.enabledFileTypes": {
24+
"astro": true,
25+
"mdx": true,
26+
"solidity": true
27+
},
2128
"cSpell.words": [
2229
"AGOR",
2330
"Alfajores",

foundry.toml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This configuration file sets up the paths and compilers so we can test our solidity samples
2+
[profile.default]
3+
# Let Forge download/choose solc per file's pragma automatically
4+
auto_detect_solc = true
5+
evm_version = 'paris'
6+
7+
src = "public/samples"
8+
out = ".test/artifacts"
9+
cache_path = ".test/cache"
10+
libs = ["lib", "node_modules"]
11+
12+
# Optimization settings
13+
optimizer = true
14+
optimizer_runs = 1_000_000
15+
16+
# Test environment defaults
17+
bytecode_hash = "none"
18+
ffi = false
19+
gas_price = 1
20+
block_timestamp = 1234567890
21+
block_number = 12345
22+
23+
[profile.ci]
24+
verbosity = 2
25+
26+
[fmt]
27+
tab_width = 2
28+
multiline_func_header = "params_first"
29+
sort_imports = true
30+
single_line_statement_blocks = "preserve"
31+
number_underscore = "thousands"
32+
wrap_comments = true
33+
34+
[lint]
35+
lint_on_build = false
36+
37+
# See more config options https://github.com/foundry-rs/foundry/tree/master/config

hardhat.config.cts

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

knip.json

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"astro.config.ts",
77
"src/content.config.ts",
88
"src/integrations/**/*.ts",
9-
"hardhat.config.cts",
109
"codegen.ts",
1110
"jest.config.cjs",
1211
"src/**/__tests__/**/*.test.ts",
@@ -16,15 +15,8 @@
1615
"entry": ["src/**/__tests__/**/*.test.ts", "src/**/*.test.ts"]
1716
},
1817
"project": ["src/**/*.{ts,tsx,astro}", "!src/**/*.d.ts"],
19-
"ignore": [
20-
"src/types/**/*.d.ts",
21-
"public/**/*",
22-
"src/__mocks__/**/*",
23-
"templates/**/*",
24-
"typechain-types/**/*",
25-
"dist/**/*"
26-
],
27-
"ignoreDependencies": ["@types/*", "prettier*", "@astrojs/*", "hardhat*", "solhint*", "jest*", "@project-serum/*"],
18+
"ignore": ["src/types/**/*.d.ts", "public/**/*", "src/__mocks__/**/*", "templates/**/*", "dist/**/*"],
19+
"ignoreDependencies": ["@types/*", "prettier*", "@astrojs/*", "solhint*", "jest*", "@project-serum/*"],
2820
"ignoreExportsUsedInFile": {
2921
"interface": true,
3022
"type": true,

0 commit comments

Comments
 (0)