Skip to content

Commit 635b67a

Browse files
committed
Make ABI files readable (cowprotocol#3815)
I'm still playing with the idea of reducing the ABI files to the subset of types, functions, and events that we actually use in the code base. That should cut down the compile time of the `contracts` crate quite a lot. There are quite a few ABI files that expose >30 functions of which we only use 2 or 3. Since we still generate code for these 27 unused functions this is just a lot of time wasted. (e.g. take a look at [BalancerV2ComposableStablePool.json](https://github.com/cowprotocol/services/compare/format-abi-files?expand=1#diff-76cc4a1d98b9b1a835fe83e09a890ca42ebf19a1f94d73ede5701ae055e88a48)) So after this PR is merged it would be a lot easier to verify what things we actually remove from the ABI files to speed up the compile time (if we ever do that). But even if we decide not to trim the files having them formatted into multiple lines still helps with readability and also makes it easier for text editors to handle these files. formatted all files with: ```fish for f in *.json if test -L "$f" echo "Skipping symlink: $f" continue end jq . "$f" > "$f.tmp" && mv "$f.tmp" "$f" end ``` look at the files, I guess. 😅
1 parent 16b0ab9 commit 635b67a

36 files changed

+24179
-36
lines changed

Justfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,15 @@ fmt *extra:
3939
# Start database for E2E tests
4040
start-db:
4141
docker compose up -d
42+
43+
# Properly formats all ABI files that we generate bindings for to make them human readable
44+
format-abi-files:
45+
#!/bin/sh
46+
cd ./crates/contracts/artifacts
47+
for f in *.json; do
48+
if [ -L "$f" ]; then
49+
echo "Skipping symlink: $f"
50+
continue
51+
fi
52+
jq . "$f" > "$f.tmp" && mv "$f.tmp" "$f"
53+
done
Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,31 @@
1-
{"abi":[{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isSolver","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"}],"bytecode":"0x608060405234801561001057600080fd5b50609a8061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c806302cc250d14602d575b600080fd5b603e60383660046052565b50600190565b604051901515815260200160405180910390f35b600060208284031215606357600080fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114608657600080fd5b939250505056fea164736f6c6343000811000a","deployedBytecode":"0x6080604052348015600f57600080fd5b506004361060285760003560e01c806302cc250d14602d575b600080fd5b603e60383660046052565b50600190565b604051901515815260200160405180910390f35b600060208284031215606357600080fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114608657600080fd5b939250505056fea164736f6c6343000811000a","devdoc":{"methods":{}},"userdoc":{"methods":{}}}
1+
{
2+
"abi": [
3+
{
4+
"inputs": [
5+
{
6+
"internalType": "address",
7+
"name": "",
8+
"type": "address"
9+
}
10+
],
11+
"name": "isSolver",
12+
"outputs": [
13+
{
14+
"internalType": "bool",
15+
"name": "",
16+
"type": "bool"
17+
}
18+
],
19+
"stateMutability": "pure",
20+
"type": "function"
21+
}
22+
],
23+
"bytecode": "0x608060405234801561001057600080fd5b50609a8061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c806302cc250d14602d575b600080fd5b603e60383660046052565b50600190565b604051901515815260200160405180910390f35b600060208284031215606357600080fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114608657600080fd5b939250505056fea164736f6c6343000811000a",
24+
"deployedBytecode": "0x6080604052348015600f57600080fd5b506004361060285760003560e01c806302cc250d14602d575b600080fd5b603e60383660046052565b50600190565b604051901515815260200160405180910390f35b600060208284031215606357600080fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114608657600080fd5b939250505056fea164736f6c6343000811000a",
25+
"devdoc": {
26+
"methods": {}
27+
},
28+
"userdoc": {
29+
"methods": {}
30+
}
31+
}
Lines changed: 311 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,311 @@
1-
{"abi":[{"inputs":[{"internalType":"contract IVault","name":"_vault","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"enum IVault.SwapKind","name":"kind","type":"uint8"},{"components":[{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"uint256","name":"assetInIndex","type":"uint256"},{"internalType":"uint256","name":"assetOutIndex","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"userData","type":"bytes"}],"internalType":"struct IVault.BatchSwapStep[]","name":"swaps","type":"tuple[]"},{"internalType":"contract IAsset[]","name":"assets","type":"address[]"},{"components":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"bool","name":"fromInternalBalance","type":"bool"},{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"bool","name":"toInternalBalance","type":"bool"}],"internalType":"struct IVault.FundManagement","name":"funds","type":"tuple"}],"name":"queryBatchSwap","outputs":[{"internalType":"int256[]","name":"assetDeltas","type":"int256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"components":[{"internalType":"contract IAsset[]","name":"assets","type":"address[]"},{"internalType":"uint256[]","name":"minAmountsOut","type":"uint256[]"},{"internalType":"bytes","name":"userData","type":"bytes"},{"internalType":"bool","name":"toInternalBalance","type":"bool"}],"internalType":"struct IVault.ExitPoolRequest","name":"request","type":"tuple"}],"name":"queryExit","outputs":[{"internalType":"uint256","name":"bptIn","type":"uint256"},{"internalType":"uint256[]","name":"amountsOut","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"components":[{"internalType":"contract IAsset[]","name":"assets","type":"address[]"},{"internalType":"uint256[]","name":"maxAmountsIn","type":"uint256[]"},{"internalType":"bytes","name":"userData","type":"bytes"},{"internalType":"bool","name":"fromInternalBalance","type":"bool"}],"internalType":"struct IVault.JoinPoolRequest","name":"request","type":"tuple"}],"name":"queryJoin","outputs":[{"internalType":"uint256","name":"bptOut","type":"uint256"},{"internalType":"uint256[]","name":"amountsIn","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"enum IVault.SwapKind","name":"kind","type":"uint8"},{"internalType":"contract IAsset","name":"assetIn","type":"address"},{"internalType":"contract IAsset","name":"assetOut","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"userData","type":"bytes"}],"internalType":"struct IVault.SingleSwap","name":"singleSwap","type":"tuple"},{"components":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"bool","name":"fromInternalBalance","type":"bool"},{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"bool","name":"toInternalBalance","type":"bool"}],"internalType":"struct IVault.FundManagement","name":"funds","type":"tuple"}],"name":"querySwap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"vault","outputs":[{"internalType":"contract IVault","name":"","type":"address"}],"stateMutability":"view","type":"function"}]}
1+
{
2+
"abi": [
3+
{
4+
"inputs": [
5+
{
6+
"internalType": "contract IVault",
7+
"name": "_vault",
8+
"type": "address"
9+
}
10+
],
11+
"stateMutability": "nonpayable",
12+
"type": "constructor"
13+
},
14+
{
15+
"inputs": [
16+
{
17+
"internalType": "enum IVault.SwapKind",
18+
"name": "kind",
19+
"type": "uint8"
20+
},
21+
{
22+
"components": [
23+
{
24+
"internalType": "bytes32",
25+
"name": "poolId",
26+
"type": "bytes32"
27+
},
28+
{
29+
"internalType": "uint256",
30+
"name": "assetInIndex",
31+
"type": "uint256"
32+
},
33+
{
34+
"internalType": "uint256",
35+
"name": "assetOutIndex",
36+
"type": "uint256"
37+
},
38+
{
39+
"internalType": "uint256",
40+
"name": "amount",
41+
"type": "uint256"
42+
},
43+
{
44+
"internalType": "bytes",
45+
"name": "userData",
46+
"type": "bytes"
47+
}
48+
],
49+
"internalType": "struct IVault.BatchSwapStep[]",
50+
"name": "swaps",
51+
"type": "tuple[]"
52+
},
53+
{
54+
"internalType": "contract IAsset[]",
55+
"name": "assets",
56+
"type": "address[]"
57+
},
58+
{
59+
"components": [
60+
{
61+
"internalType": "address",
62+
"name": "sender",
63+
"type": "address"
64+
},
65+
{
66+
"internalType": "bool",
67+
"name": "fromInternalBalance",
68+
"type": "bool"
69+
},
70+
{
71+
"internalType": "address payable",
72+
"name": "recipient",
73+
"type": "address"
74+
},
75+
{
76+
"internalType": "bool",
77+
"name": "toInternalBalance",
78+
"type": "bool"
79+
}
80+
],
81+
"internalType": "struct IVault.FundManagement",
82+
"name": "funds",
83+
"type": "tuple"
84+
}
85+
],
86+
"name": "queryBatchSwap",
87+
"outputs": [
88+
{
89+
"internalType": "int256[]",
90+
"name": "assetDeltas",
91+
"type": "int256[]"
92+
}
93+
],
94+
"stateMutability": "nonpayable",
95+
"type": "function"
96+
},
97+
{
98+
"inputs": [
99+
{
100+
"internalType": "bytes32",
101+
"name": "poolId",
102+
"type": "bytes32"
103+
},
104+
{
105+
"internalType": "address",
106+
"name": "sender",
107+
"type": "address"
108+
},
109+
{
110+
"internalType": "address",
111+
"name": "recipient",
112+
"type": "address"
113+
},
114+
{
115+
"components": [
116+
{
117+
"internalType": "contract IAsset[]",
118+
"name": "assets",
119+
"type": "address[]"
120+
},
121+
{
122+
"internalType": "uint256[]",
123+
"name": "minAmountsOut",
124+
"type": "uint256[]"
125+
},
126+
{
127+
"internalType": "bytes",
128+
"name": "userData",
129+
"type": "bytes"
130+
},
131+
{
132+
"internalType": "bool",
133+
"name": "toInternalBalance",
134+
"type": "bool"
135+
}
136+
],
137+
"internalType": "struct IVault.ExitPoolRequest",
138+
"name": "request",
139+
"type": "tuple"
140+
}
141+
],
142+
"name": "queryExit",
143+
"outputs": [
144+
{
145+
"internalType": "uint256",
146+
"name": "bptIn",
147+
"type": "uint256"
148+
},
149+
{
150+
"internalType": "uint256[]",
151+
"name": "amountsOut",
152+
"type": "uint256[]"
153+
}
154+
],
155+
"stateMutability": "nonpayable",
156+
"type": "function"
157+
},
158+
{
159+
"inputs": [
160+
{
161+
"internalType": "bytes32",
162+
"name": "poolId",
163+
"type": "bytes32"
164+
},
165+
{
166+
"internalType": "address",
167+
"name": "sender",
168+
"type": "address"
169+
},
170+
{
171+
"internalType": "address",
172+
"name": "recipient",
173+
"type": "address"
174+
},
175+
{
176+
"components": [
177+
{
178+
"internalType": "contract IAsset[]",
179+
"name": "assets",
180+
"type": "address[]"
181+
},
182+
{
183+
"internalType": "uint256[]",
184+
"name": "maxAmountsIn",
185+
"type": "uint256[]"
186+
},
187+
{
188+
"internalType": "bytes",
189+
"name": "userData",
190+
"type": "bytes"
191+
},
192+
{
193+
"internalType": "bool",
194+
"name": "fromInternalBalance",
195+
"type": "bool"
196+
}
197+
],
198+
"internalType": "struct IVault.JoinPoolRequest",
199+
"name": "request",
200+
"type": "tuple"
201+
}
202+
],
203+
"name": "queryJoin",
204+
"outputs": [
205+
{
206+
"internalType": "uint256",
207+
"name": "bptOut",
208+
"type": "uint256"
209+
},
210+
{
211+
"internalType": "uint256[]",
212+
"name": "amountsIn",
213+
"type": "uint256[]"
214+
}
215+
],
216+
"stateMutability": "nonpayable",
217+
"type": "function"
218+
},
219+
{
220+
"inputs": [
221+
{
222+
"components": [
223+
{
224+
"internalType": "bytes32",
225+
"name": "poolId",
226+
"type": "bytes32"
227+
},
228+
{
229+
"internalType": "enum IVault.SwapKind",
230+
"name": "kind",
231+
"type": "uint8"
232+
},
233+
{
234+
"internalType": "contract IAsset",
235+
"name": "assetIn",
236+
"type": "address"
237+
},
238+
{
239+
"internalType": "contract IAsset",
240+
"name": "assetOut",
241+
"type": "address"
242+
},
243+
{
244+
"internalType": "uint256",
245+
"name": "amount",
246+
"type": "uint256"
247+
},
248+
{
249+
"internalType": "bytes",
250+
"name": "userData",
251+
"type": "bytes"
252+
}
253+
],
254+
"internalType": "struct IVault.SingleSwap",
255+
"name": "singleSwap",
256+
"type": "tuple"
257+
},
258+
{
259+
"components": [
260+
{
261+
"internalType": "address",
262+
"name": "sender",
263+
"type": "address"
264+
},
265+
{
266+
"internalType": "bool",
267+
"name": "fromInternalBalance",
268+
"type": "bool"
269+
},
270+
{
271+
"internalType": "address payable",
272+
"name": "recipient",
273+
"type": "address"
274+
},
275+
{
276+
"internalType": "bool",
277+
"name": "toInternalBalance",
278+
"type": "bool"
279+
}
280+
],
281+
"internalType": "struct IVault.FundManagement",
282+
"name": "funds",
283+
"type": "tuple"
284+
}
285+
],
286+
"name": "querySwap",
287+
"outputs": [
288+
{
289+
"internalType": "uint256",
290+
"name": "",
291+
"type": "uint256"
292+
}
293+
],
294+
"stateMutability": "nonpayable",
295+
"type": "function"
296+
},
297+
{
298+
"inputs": [],
299+
"name": "vault",
300+
"outputs": [
301+
{
302+
"internalType": "contract IVault",
303+
"name": "",
304+
"type": "address"
305+
}
306+
],
307+
"stateMutability": "view",
308+
"type": "function"
309+
}
310+
]
311+
}

0 commit comments

Comments
 (0)