Skip to content

Commit 33c94ce

Browse files
committed
Fix spec consistency and add pipeline tests
- Regenerate spec JSONs from Lean: contractName is now "ERC20" (from compiler), not "USDC" (deployment-specific) - Fix circuit registry keys to match: "ERC20:transfer" not "USDC:transfer" - Add ENS read caching (1min TTL) to avoid redundant RPC calls - Use EnsSpecEntry type in loader instead of inline duplicate - Remove dead code: parseStmt, parseCondition, parseExpr "call" case - Add 19 tests covering: - Spec loading from compiler JSON with deploy overrides - Deployment decimals override (6 for USDC vs 18 for WETH) - Calldata encoding/decoding roundtrip - Intent evaluation: normal amount vs MAX_UINT256 template selection - Template collection in AST order - UniswapV2 spec loading - ENS entry with/without deploy overrides
1 parent 2ae8852 commit 33c94ce

8 files changed

Lines changed: 6421 additions & 2744 deletions

File tree

package-lock.json

Lines changed: 6077 additions & 2671 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919
},
2020
"devDependencies": {
2121
"@tailwindcss/postcss": "^4",
22+
"@types/jest": "^30.0.0",
2223
"@types/node": "^20",
2324
"@types/react": "^19",
2425
"@types/react-dom": "^19",
2526
"eslint": "^9",
2627
"eslint-config-next": "16.2.1",
28+
"jest": "^30.3.0",
2729
"tailwindcss": "^4",
30+
"ts-jest": "^29.4.9",
2831
"typescript": "^5"
2932
}
3033
}

public/specs/ERC20.intent.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"contractName": "USDC",
2+
"contractName": "ERC20",
33
"fns": [
44
{
55
"name": "isMaxUint",
@@ -53,7 +53,7 @@
5353
{
5454
"kind": "emit",
5555
"template": {
56-
"text": "Send all USDC to {to}",
56+
"text": "Send all tokens to {to}",
5757
"holes": [
5858
{
5959
"name": "to",
@@ -69,13 +69,13 @@
6969
{
7070
"kind": "emit",
7171
"template": {
72-
"text": "Send {amount} USDC to {to}",
72+
"text": "Send {amount} tokens to {to}",
7373
"holes": [
7474
{
7575
"name": "amount",
7676
"format": {
7777
"kind": "tokenAmount",
78-
"decimals": 6
78+
"decimals": 18
7979
}
8080
},
8181
{
@@ -122,7 +122,7 @@
122122
{
123123
"kind": "emit",
124124
"template": {
125-
"text": "Approve {spender} to spend unlimited USDC",
125+
"text": "Approve {spender} to spend unlimited tokens",
126126
"holes": [
127127
{
128128
"name": "spender",
@@ -138,7 +138,7 @@
138138
{
139139
"kind": "emit",
140140
"template": {
141-
"text": "Approve {spender} to spend {amount} USDC",
141+
"text": "Approve {spender} to spend {amount} tokens",
142142
"holes": [
143143
{
144144
"name": "spender",
@@ -150,7 +150,7 @@
150150
"name": "amount",
151151
"format": {
152152
"kind": "tokenAmount",
153-
"decimals": 6
153+
"decimals": 18
154154
}
155155
}
156156
]
@@ -165,7 +165,7 @@
165165
"name": "transferFrom",
166166
"params": [
167167
{
168-
"name": "from",
168+
"name": "fromAddr",
169169
"type": "address"
170170
},
171171
{
@@ -195,10 +195,10 @@
195195
{
196196
"kind": "emit",
197197
"template": {
198-
"text": "Transfer all USDC from {from} to {to}",
198+
"text": "Transfer all tokens from {fromAddr} to {to}",
199199
"holes": [
200200
{
201-
"name": "from",
201+
"name": "fromAddr",
202202
"format": {
203203
"kind": "address"
204204
}
@@ -217,17 +217,17 @@
217217
{
218218
"kind": "emit",
219219
"template": {
220-
"text": "Transfer {amount} USDC from {from} to {to}",
220+
"text": "Transfer {amount} tokens from {fromAddr} to {to}",
221221
"holes": [
222222
{
223223
"name": "amount",
224224
"format": {
225225
"kind": "tokenAmount",
226-
"decimals": 6
226+
"decimals": 18
227227
}
228228
},
229229
{
230-
"name": "from",
230+
"name": "fromAddr",
231231
"format": {
232232
"kind": "address"
233233
}
@@ -283,10 +283,10 @@
283283
"selector": "0x23b872dd",
284284
"abiSignature": "transferFrom(address,address,uint256)",
285285
"paramMapping": [
286-
"from",
286+
"fromAddr",
287287
"to",
288288
"amount"
289289
]
290290
}
291291
]
292-
}
292+
}

public/specs/UniswapV2.intent.json

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"contractName": "UniswapV2Router",
33
"fns": [
44
{
5-
"name": "swapExactETHForTokens",
5+
"name": "swapExactTokensForTokens",
66
"params": [
77
{
8-
"name": "amountOutMin",
8+
"name": "amountIn",
99
"type": "uint256"
1010
},
1111
{
12-
"name": "path",
13-
"type": "address[]"
12+
"name": "amountOutMin",
13+
"type": "uint256"
1414
},
1515
{
1616
"name": "to",
@@ -22,18 +22,20 @@
2222
{
2323
"kind": "emit",
2424
"template": {
25-
"text": "Swap ETH for at least {amountOutMin} {tokenOut}, send to {to}",
25+
"text": "Swap {amountIn} for at least {amountOutMin}, send to {to}",
2626
"holes": [
2727
{
28-
"name": "amountOutMin",
28+
"name": "amountIn",
2929
"format": {
30-
"kind": "raw"
30+
"kind": "tokenAmount",
31+
"decimals": 18
3132
}
3233
},
3334
{
34-
"name": "tokenOut",
35+
"name": "amountOutMin",
3536
"format": {
36-
"kind": "address"
37+
"kind": "tokenAmount",
38+
"decimals": 6
3739
}
3840
},
3941
{
@@ -52,16 +54,17 @@
5254
"constants": [],
5355
"bindings": [
5456
{
55-
"functionName": "swapExactETHForTokens",
56-
"intentFnName": "swapExactETHForTokens",
57-
"selector": "0x7ff36ab5",
58-
"abiSignature": "swapExactETHForTokens(uint256,address[],address,uint256)",
57+
"functionName": "swapExactTokensForTokens",
58+
"intentFnName": "swapExactTokensForTokens",
59+
"selector": "0x38ed1739",
60+
"abiSignature": "swapExactTokensForTokens(uint256,uint256,address[],address,uint256)",
5961
"paramMapping": [
62+
"amountIn",
6063
"amountOutMin",
6164
"path",
6265
"to",
6366
"deadline"
6467
]
6568
}
6669
]
67-
}
70+
}

0 commit comments

Comments
 (0)