@reyaxyz/common 0.189.0 → 0.189.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +1 -1
  2. package/dist/transactions/abis/CustomMulticall3.json +490 -0
  3. package/dist/transactions/buildMulticallTx.js +5 -5
  4. package/dist/transactions/buildMulticallTx.js.map +1 -1
  5. package/dist/transactions/contractAddresses.js +2 -2
  6. package/dist/transactions/contractAddresses.js.map +1 -1
  7. package/dist/transactions/executeTransaction.js +23 -11
  8. package/dist/transactions/executeTransaction.js.map +1 -1
  9. package/dist/transactions/index.js +2 -2
  10. package/dist/transactions/index.js.map +1 -1
  11. package/dist/types/transactions/buildMulticallTx.d.ts +1 -1
  12. package/dist/types/transactions/buildMulticallTx.d.ts.map +1 -1
  13. package/dist/types/transactions/executeTransaction.d.ts +5 -0
  14. package/dist/types/transactions/executeTransaction.d.ts.map +1 -1
  15. package/dist/types/transactions/index.d.ts +1 -1
  16. package/dist/types/transactions/index.d.ts.map +1 -1
  17. package/dist/types/types.d.ts +1 -0
  18. package/dist/types/types.d.ts.map +1 -1
  19. package/dist/types/utils/index.d.ts +1 -0
  20. package/dist/types/utils/index.d.ts.map +1 -1
  21. package/dist/types/utils/stringify.d.ts +2 -0
  22. package/dist/types/utils/stringify.d.ts.map +1 -0
  23. package/dist/types.js.map +1 -1
  24. package/dist/utils/index.js +1 -0
  25. package/dist/utils/index.js.map +1 -1
  26. package/dist/utils/stringify.js +13 -0
  27. package/dist/utils/stringify.js.map +1 -0
  28. package/package.json +2 -2
  29. package/src/transactions/abis/CustomMulticall3.json +490 -0
  30. package/src/transactions/buildMulticallTx.ts +4 -4
  31. package/src/transactions/contractAddresses.ts +2 -2
  32. package/src/transactions/executeTransaction.ts +23 -0
  33. package/src/transactions/index.ts +1 -1
  34. package/src/types.ts +1 -0
  35. package/src/utils/index.ts +1 -0
  36. package/src/utils/stringify.ts +8 -0
  37. package/dist/transactions/abis/MulticallV2.json +0 -376
  38. package/src/transactions/abis/MulticallV2.json +0 -376
@@ -0,0 +1,490 @@
1
+ {
2
+ "abi": [
3
+ {
4
+ "type": "function",
5
+ "name": "aggregate",
6
+ "inputs": [
7
+ {
8
+ "name": "calls",
9
+ "type": "tuple[]",
10
+ "internalType": "struct CustomMulticall3.Call[]",
11
+ "components": [
12
+ {
13
+ "name": "target",
14
+ "type": "address",
15
+ "internalType": "address"
16
+ },
17
+ {
18
+ "name": "callData",
19
+ "type": "bytes",
20
+ "internalType": "bytes"
21
+ }
22
+ ]
23
+ }
24
+ ],
25
+ "outputs": [
26
+ {
27
+ "name": "blockNumber",
28
+ "type": "uint256",
29
+ "internalType": "uint256"
30
+ },
31
+ {
32
+ "name": "returnData",
33
+ "type": "bytes[]",
34
+ "internalType": "bytes[]"
35
+ }
36
+ ],
37
+ "stateMutability": "payable"
38
+ },
39
+ {
40
+ "type": "function",
41
+ "name": "aggregate3",
42
+ "inputs": [
43
+ {
44
+ "name": "calls",
45
+ "type": "tuple[]",
46
+ "internalType": "struct CustomMulticall3.Call3[]",
47
+ "components": [
48
+ {
49
+ "name": "target",
50
+ "type": "address",
51
+ "internalType": "address"
52
+ },
53
+ {
54
+ "name": "allowFailure",
55
+ "type": "bool",
56
+ "internalType": "bool"
57
+ },
58
+ {
59
+ "name": "callData",
60
+ "type": "bytes",
61
+ "internalType": "bytes"
62
+ }
63
+ ]
64
+ }
65
+ ],
66
+ "outputs": [
67
+ {
68
+ "name": "returnData",
69
+ "type": "tuple[]",
70
+ "internalType": "struct CustomMulticall3.Result[]",
71
+ "components": [
72
+ {
73
+ "name": "success",
74
+ "type": "bool",
75
+ "internalType": "bool"
76
+ },
77
+ {
78
+ "name": "returnData",
79
+ "type": "bytes",
80
+ "internalType": "bytes"
81
+ }
82
+ ]
83
+ }
84
+ ],
85
+ "stateMutability": "payable"
86
+ },
87
+ {
88
+ "type": "function",
89
+ "name": "aggregate3Value",
90
+ "inputs": [
91
+ {
92
+ "name": "calls",
93
+ "type": "tuple[]",
94
+ "internalType": "struct CustomMulticall3.Call3Value[]",
95
+ "components": [
96
+ {
97
+ "name": "target",
98
+ "type": "address",
99
+ "internalType": "address"
100
+ },
101
+ {
102
+ "name": "allowFailure",
103
+ "type": "bool",
104
+ "internalType": "bool"
105
+ },
106
+ {
107
+ "name": "value",
108
+ "type": "uint256",
109
+ "internalType": "uint256"
110
+ },
111
+ {
112
+ "name": "callData",
113
+ "type": "bytes",
114
+ "internalType": "bytes"
115
+ }
116
+ ]
117
+ }
118
+ ],
119
+ "outputs": [
120
+ {
121
+ "name": "returnData",
122
+ "type": "tuple[]",
123
+ "internalType": "struct CustomMulticall3.Result[]",
124
+ "components": [
125
+ {
126
+ "name": "success",
127
+ "type": "bool",
128
+ "internalType": "bool"
129
+ },
130
+ {
131
+ "name": "returnData",
132
+ "type": "bytes",
133
+ "internalType": "bytes"
134
+ }
135
+ ]
136
+ }
137
+ ],
138
+ "stateMutability": "payable"
139
+ },
140
+ {
141
+ "type": "function",
142
+ "name": "blockAndAggregate",
143
+ "inputs": [
144
+ {
145
+ "name": "calls",
146
+ "type": "tuple[]",
147
+ "internalType": "struct CustomMulticall3.Call[]",
148
+ "components": [
149
+ {
150
+ "name": "target",
151
+ "type": "address",
152
+ "internalType": "address"
153
+ },
154
+ {
155
+ "name": "callData",
156
+ "type": "bytes",
157
+ "internalType": "bytes"
158
+ }
159
+ ]
160
+ }
161
+ ],
162
+ "outputs": [
163
+ {
164
+ "name": "blockNumber",
165
+ "type": "uint256",
166
+ "internalType": "uint256"
167
+ },
168
+ {
169
+ "name": "blockHash",
170
+ "type": "bytes32",
171
+ "internalType": "bytes32"
172
+ },
173
+ {
174
+ "name": "returnData",
175
+ "type": "tuple[]",
176
+ "internalType": "struct CustomMulticall3.Result[]",
177
+ "components": [
178
+ {
179
+ "name": "success",
180
+ "type": "bool",
181
+ "internalType": "bool"
182
+ },
183
+ {
184
+ "name": "returnData",
185
+ "type": "bytes",
186
+ "internalType": "bytes"
187
+ }
188
+ ]
189
+ }
190
+ ],
191
+ "stateMutability": "payable"
192
+ },
193
+ {
194
+ "type": "function",
195
+ "name": "getBasefee",
196
+ "inputs": [],
197
+ "outputs": [
198
+ {
199
+ "name": "basefee",
200
+ "type": "uint256",
201
+ "internalType": "uint256"
202
+ }
203
+ ],
204
+ "stateMutability": "view"
205
+ },
206
+ {
207
+ "type": "function",
208
+ "name": "getBlockHash",
209
+ "inputs": [
210
+ {
211
+ "name": "blockNumber",
212
+ "type": "uint256",
213
+ "internalType": "uint256"
214
+ }
215
+ ],
216
+ "outputs": [
217
+ {
218
+ "name": "blockHash",
219
+ "type": "bytes32",
220
+ "internalType": "bytes32"
221
+ }
222
+ ],
223
+ "stateMutability": "view"
224
+ },
225
+ {
226
+ "type": "function",
227
+ "name": "getBlockNumber",
228
+ "inputs": [],
229
+ "outputs": [
230
+ {
231
+ "name": "blockNumber",
232
+ "type": "uint256",
233
+ "internalType": "uint256"
234
+ }
235
+ ],
236
+ "stateMutability": "view"
237
+ },
238
+ {
239
+ "type": "function",
240
+ "name": "getChainId",
241
+ "inputs": [],
242
+ "outputs": [
243
+ {
244
+ "name": "chainid",
245
+ "type": "uint256",
246
+ "internalType": "uint256"
247
+ }
248
+ ],
249
+ "stateMutability": "view"
250
+ },
251
+ {
252
+ "type": "function",
253
+ "name": "getCurrentBlockCoinbase",
254
+ "inputs": [],
255
+ "outputs": [
256
+ {
257
+ "name": "coinbase",
258
+ "type": "address",
259
+ "internalType": "address"
260
+ }
261
+ ],
262
+ "stateMutability": "view"
263
+ },
264
+ {
265
+ "type": "function",
266
+ "name": "getCurrentBlockDifficulty",
267
+ "inputs": [],
268
+ "outputs": [
269
+ {
270
+ "name": "difficulty",
271
+ "type": "uint256",
272
+ "internalType": "uint256"
273
+ }
274
+ ],
275
+ "stateMutability": "view"
276
+ },
277
+ {
278
+ "type": "function",
279
+ "name": "getCurrentBlockGasLimit",
280
+ "inputs": [],
281
+ "outputs": [
282
+ {
283
+ "name": "gaslimit",
284
+ "type": "uint256",
285
+ "internalType": "uint256"
286
+ }
287
+ ],
288
+ "stateMutability": "view"
289
+ },
290
+ {
291
+ "type": "function",
292
+ "name": "getCurrentBlockTimestamp",
293
+ "inputs": [],
294
+ "outputs": [
295
+ {
296
+ "name": "timestamp",
297
+ "type": "uint256",
298
+ "internalType": "uint256"
299
+ }
300
+ ],
301
+ "stateMutability": "view"
302
+ },
303
+ {
304
+ "type": "function",
305
+ "name": "getEthBalance",
306
+ "inputs": [
307
+ {
308
+ "name": "addr",
309
+ "type": "address",
310
+ "internalType": "address"
311
+ }
312
+ ],
313
+ "outputs": [
314
+ {
315
+ "name": "balance",
316
+ "type": "uint256",
317
+ "internalType": "uint256"
318
+ }
319
+ ],
320
+ "stateMutability": "view"
321
+ },
322
+ {
323
+ "type": "function",
324
+ "name": "getLastBlockHash",
325
+ "inputs": [],
326
+ "outputs": [
327
+ {
328
+ "name": "blockHash",
329
+ "type": "bytes32",
330
+ "internalType": "bytes32"
331
+ }
332
+ ],
333
+ "stateMutability": "view"
334
+ },
335
+ {
336
+ "type": "function",
337
+ "name": "tryAggregate",
338
+ "inputs": [
339
+ {
340
+ "name": "requireSuccess",
341
+ "type": "bool",
342
+ "internalType": "bool"
343
+ },
344
+ {
345
+ "name": "calls",
346
+ "type": "tuple[]",
347
+ "internalType": "struct CustomMulticall3.Call[]",
348
+ "components": [
349
+ {
350
+ "name": "target",
351
+ "type": "address",
352
+ "internalType": "address"
353
+ },
354
+ {
355
+ "name": "callData",
356
+ "type": "bytes",
357
+ "internalType": "bytes"
358
+ }
359
+ ]
360
+ }
361
+ ],
362
+ "outputs": [
363
+ {
364
+ "name": "returnData",
365
+ "type": "tuple[]",
366
+ "internalType": "struct CustomMulticall3.Result[]",
367
+ "components": [
368
+ {
369
+ "name": "success",
370
+ "type": "bool",
371
+ "internalType": "bool"
372
+ },
373
+ {
374
+ "name": "returnData",
375
+ "type": "bytes",
376
+ "internalType": "bytes"
377
+ }
378
+ ]
379
+ }
380
+ ],
381
+ "stateMutability": "payable"
382
+ },
383
+ {
384
+ "type": "function",
385
+ "name": "tryAggregatePreservingError",
386
+ "inputs": [
387
+ {
388
+ "name": "requireSuccess",
389
+ "type": "bool",
390
+ "internalType": "bool"
391
+ },
392
+ {
393
+ "name": "calls",
394
+ "type": "tuple[]",
395
+ "internalType": "struct CustomMulticall3.Call[]",
396
+ "components": [
397
+ {
398
+ "name": "target",
399
+ "type": "address",
400
+ "internalType": "address"
401
+ },
402
+ {
403
+ "name": "callData",
404
+ "type": "bytes",
405
+ "internalType": "bytes"
406
+ }
407
+ ]
408
+ }
409
+ ],
410
+ "outputs": [
411
+ {
412
+ "name": "returnData",
413
+ "type": "tuple[]",
414
+ "internalType": "struct CustomMulticall3.Result[]",
415
+ "components": [
416
+ {
417
+ "name": "success",
418
+ "type": "bool",
419
+ "internalType": "bool"
420
+ },
421
+ {
422
+ "name": "returnData",
423
+ "type": "bytes",
424
+ "internalType": "bytes"
425
+ }
426
+ ]
427
+ }
428
+ ],
429
+ "stateMutability": "payable"
430
+ },
431
+ {
432
+ "type": "function",
433
+ "name": "tryBlockAndAggregate",
434
+ "inputs": [
435
+ {
436
+ "name": "requireSuccess",
437
+ "type": "bool",
438
+ "internalType": "bool"
439
+ },
440
+ {
441
+ "name": "calls",
442
+ "type": "tuple[]",
443
+ "internalType": "struct CustomMulticall3.Call[]",
444
+ "components": [
445
+ {
446
+ "name": "target",
447
+ "type": "address",
448
+ "internalType": "address"
449
+ },
450
+ {
451
+ "name": "callData",
452
+ "type": "bytes",
453
+ "internalType": "bytes"
454
+ }
455
+ ]
456
+ }
457
+ ],
458
+ "outputs": [
459
+ {
460
+ "name": "blockNumber",
461
+ "type": "uint256",
462
+ "internalType": "uint256"
463
+ },
464
+ {
465
+ "name": "blockHash",
466
+ "type": "bytes32",
467
+ "internalType": "bytes32"
468
+ },
469
+ {
470
+ "name": "returnData",
471
+ "type": "tuple[]",
472
+ "internalType": "struct CustomMulticall3.Result[]",
473
+ "components": [
474
+ {
475
+ "name": "success",
476
+ "type": "bool",
477
+ "internalType": "bool"
478
+ },
479
+ {
480
+ "name": "returnData",
481
+ "type": "bytes",
482
+ "internalType": "bytes"
483
+ }
484
+ ]
485
+ }
486
+ ],
487
+ "stateMutability": "payable"
488
+ }
489
+ ]
490
+ }
@@ -1,22 +1,22 @@
1
1
  import { ethers } from 'ethers';
2
2
  import { abi as CoreAbi } from './abis/CoreProxy.json';
3
- import { abi as MulticallAbi } from './abis/MulticallV2.json';
3
+ import { abi as MulticallAbi } from './abis/CustomMulticall3.json';
4
4
 
5
5
  export type Call = {
6
6
  target: string;
7
7
  callData: string;
8
8
  };
9
9
 
10
- export const encodeCoreMulticall = (calls: Call[]): string => {
10
+ export const encodeCoreMulticall = (calldatas: string[]): string => {
11
11
  const functionSignature = 'tryAggregate';
12
- const parameters: [boolean, string[]] = [false, calls.map((c) => c.callData)];
12
+ const parameters: [boolean, string[]] = [false, calldatas];
13
13
  const INTERFACE = new ethers.Interface(CoreAbi);
14
14
  const calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);
15
15
  return calldata;
16
16
  };
17
17
 
18
18
  const encodeMulticall = (requireSuccess: boolean, calls: Call[]): string => {
19
- const functionSignature = 'tryAggregate';
19
+ const functionSignature = 'tryAggregatePreservingError';
20
20
  const parameters: [boolean, Call[]] = [requireSuccess, calls];
21
21
  const INTERFACE = new ethers.Interface(MulticallAbi);
22
22
  const calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);
@@ -23,7 +23,7 @@ const addresses: Record<ReyaChainId, Record<ContractType, Address>> = {
23
23
  '0x9ec177fed042ef2307928be2f5cdbf663b20244b',
24
24
  [ContractType.ORACLE_ADAPTERS_PROXY]:
25
25
  '0xc501a2356703cd351703d68963c6f4136120f7cf',
26
- [ContractType.MULTICALL]: '0xd9f0f399f5264faac91476dbd950574726d18633',
26
+ [ContractType.MULTICALL]: '0x5abde4f0af8eaf3c9967f7fa126e59a103357b5c',
27
27
  },
28
28
  [ReyaChainId.reyaNetwork]: {
29
29
  [ContractType.CORE_PROXY]: '0xa763b6a5e09378434406c003dae6487fbbdc1a80',
@@ -37,7 +37,7 @@ const addresses: Record<ReyaChainId, Record<ContractType, Address>> = {
37
37
  '0x27e5cb712334e101b3c232eb0be198baaa595f5f',
38
38
  [ContractType.ORACLE_ADAPTERS_PROXY]:
39
39
  '0x32edabc058c1207fe0ec5f8557643c28e4ff379e',
40
- [ContractType.MULTICALL]: '0x82a55eb2346277d85d5d0a60101ebd0f02680b0d',
40
+ [ContractType.MULTICALL]: '0xed28d27dfca47ad2513c9f2e2d3c098c2ea5a47f',
41
41
  },
42
42
  };
43
43
  export const getAddress = (
@@ -36,11 +36,34 @@ export async function estimateGas(
36
36
  > {
37
37
  const accountAddress = await signer.getAddress();
38
38
 
39
+ return estimateGasGivenAddress(
40
+ accountAddress,
41
+ data,
42
+ value,
43
+ chainId,
44
+ targetContract,
45
+ );
46
+ }
47
+
48
+ export async function estimateGasGivenAddress(
49
+ accountAddress: string,
50
+ data: string,
51
+ value: string,
52
+ chainId: number,
53
+ targetContract: ContractType | string,
54
+ ): Promise<
55
+ Transaction & {
56
+ gasLimit: bigint;
57
+ maxPriorityFeePerGas?: bigint;
58
+ maxFeePerGas?: bigint;
59
+ }
60
+ > {
39
61
  const contractAddress = Object.values(ContractType).includes(
40
62
  targetContract as ContractType,
41
63
  )
42
64
  ? getAddress(chainId, targetContract as ContractType)
43
65
  : targetContract;
66
+
44
67
  const tx = {
45
68
  from: accountAddress, // @todo Update with relayer address
46
69
  to: contractAddress,
@@ -1,6 +1,6 @@
1
1
  export * from './action';
2
2
  export { abi as CoreAbi } from './abis/CoreProxy.json';
3
- export { abi as MulticallAbi } from './abis/MulticallV2.json';
3
+ export { abi as MulticallAbi } from './abis/CustomMulticall3.json';
4
4
  export { abi as OracleAdaptersAbi } from './abis/OracleAdaptersProxy.json';
5
5
  export { abi as PeripheryAbi } from './abis/Periphery.json';
6
6
  export { abi as Socket_VaultWithPayloadAbi } from './abis/socket/VaultWithPayload.json';
package/src/types.ts CHANGED
@@ -877,6 +877,7 @@ export type TransactionExecutionMetadata = {
877
877
 
878
878
  export type TransactionExecutionOutput = {
879
879
  txHash: string;
880
+ errorMessage?: string;
880
881
  accountId?: string | null;
881
882
  coreSigNonce?: string | null;
882
883
  poolSigNonce?: string | null;
@@ -6,3 +6,4 @@ export * from './timestamp';
6
6
  export * from './token';
7
7
  export * from './task-wrapper';
8
8
  export * from './whitelisted-wallets';
9
+ export * from './stringify';
@@ -0,0 +1,8 @@
1
+ export const stringifyObject = (obj: unknown): string => {
2
+ let stringifiedObject = 'Could not stringify object';
3
+ try {
4
+ stringifiedObject = JSON.stringify(obj, undefined, 2);
5
+ } catch {}
6
+
7
+ return stringifiedObject;
8
+ };