@instadapp/interop-x 0.0.0-dev.868731f → 0.0.0-dev.8965b57
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/package.json +8 -7
- package/dist/src/abi/index.js +2 -4
- package/dist/src/abi/interopXContract.json +391 -0
- package/dist/src/alias.js +10 -0
- package/dist/src/api/index.js +6 -3
- package/dist/src/config/index.js +11 -1
- package/dist/src/constants/addresses.js +3 -3
- package/dist/src/constants/index.js +0 -1
- package/dist/src/constants/tokens.js +31 -1
- package/dist/src/db/models/transaction.js +26 -10
- package/dist/src/gnosis/actions/index.js +9 -0
- package/dist/src/gnosis/actions/withdraw/index.js +55 -0
- package/dist/src/gnosis/index.js +20 -0
- package/dist/src/index.js +75 -24
- package/dist/src/net/peer/index.js +2 -1
- package/dist/src/net/pool/index.js +25 -9
- package/dist/src/net/protocol/dial/SignatureDialProtocol.js +8 -2
- package/dist/src/net/protocol/dial/TransactionStatusDialProtocol.js +30 -0
- package/dist/src/net/protocol/index.js +51 -1
- package/dist/src/tasks/AutoUpdateTask.js +70 -0
- package/dist/src/tasks/BaseTask.js +11 -3
- package/dist/src/tasks/InteropXContract/ProcessBridgeRequestEvents.js +152 -0
- package/dist/src/tasks/InteropXContract/SyncBridgeRequestEvents.js +77 -0
- package/dist/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.js +89 -0
- package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +55 -0
- package/dist/src/tasks/index.js +15 -8
- package/dist/src/typechain/{InteropBridgeToken.js → InteropXContract.js} +0 -0
- package/dist/src/typechain/factories/InteropXContract__factory.js +526 -0
- package/dist/src/typechain/factories/index.js +3 -5
- package/dist/src/typechain/index.js +3 -5
- package/dist/src/utils/index.js +32 -42
- package/package.json +8 -7
- package/src/abi/index.ts +2 -4
- package/src/abi/interopXContract.json +391 -0
- package/src/alias.ts +6 -0
- package/src/api/index.ts +5 -2
- package/src/config/index.ts +11 -1
- package/src/constants/addresses.ts +3 -3
- package/src/constants/index.ts +0 -1
- package/src/constants/tokens.ts +32 -2
- package/src/db/models/transaction.ts +64 -25
- package/src/gnosis/actions/index.ts +5 -0
- package/src/gnosis/actions/withdraw/index.ts +76 -0
- package/src/gnosis/index.ts +19 -0
- package/src/index.ts +96 -26
- package/src/net/peer/index.ts +2 -1
- package/src/net/pool/index.ts +33 -13
- package/src/net/protocol/dial/SignatureDialProtocol.ts +10 -4
- package/src/net/protocol/dial/TransactionStatusDialProtocol.ts +33 -0
- package/src/net/protocol/index.ts +67 -1
- package/src/tasks/AutoUpdateTask.ts +82 -0
- package/src/tasks/BaseTask.ts +13 -3
- package/src/tasks/InteropXContract/ProcessBridgeRequestEvents.ts +216 -0
- package/src/tasks/InteropXContract/SyncBridgeRequestEvents.ts +114 -0
- package/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.ts +120 -0
- package/src/tasks/Transactions/SyncTransactionStatusTask.ts +67 -0
- package/src/tasks/index.ts +23 -9
- package/src/typechain/InteropXContract.ts +524 -0
- package/src/typechain/factories/InteropXContract__factory.ts +533 -0
- package/src/typechain/factories/index.ts +1 -2
- package/src/typechain/index.ts +2 -4
- package/src/utils/index.ts +67 -65
- package/tsconfig.json +7 -2
- package/dist/src/abi/interopBridgeToken.json +0 -286
- package/dist/src/abi/interopXGateway.json +0 -184
- package/dist/src/constants/itokens.js +0 -13
- package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +0 -152
- package/dist/src/tasks/InteropXGateway/SyncDepositEvents.js +0 -75
- package/dist/src/typechain/InteropXGateway.js +0 -2
- package/dist/src/typechain/factories/InteropBridgeToken__factory.js +0 -459
- package/dist/src/typechain/factories/InteropXGateway__factory.js +0 -265
- package/src/abi/interopBridgeToken.json +0 -286
- package/src/abi/interopXGateway.json +0 -184
- package/src/constants/itokens.ts +0 -10
- package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +0 -247
- package/src/tasks/InteropXGateway/SyncDepositEvents.ts +0 -126
- package/src/typechain/InteropBridgeToken.ts +0 -686
- package/src/typechain/InteropXGateway.ts +0 -407
- package/src/typechain/factories/InteropBridgeToken__factory.ts +0 -466
- package/src/typechain/factories/InteropXGateway__factory.ts +0 -272
@@ -0,0 +1,526 @@
|
|
1
|
+
"use strict";
|
2
|
+
/* Autogenerated file. Do not edit manually. */
|
3
|
+
/* tslint:disable */
|
4
|
+
/* eslint-disable */
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.InteropXContract__factory = void 0;
|
7
|
+
const ethers_1 = require("ethers");
|
8
|
+
const _abi = [
|
9
|
+
{
|
10
|
+
anonymous: false,
|
11
|
+
inputs: [
|
12
|
+
{
|
13
|
+
indexed: true,
|
14
|
+
internalType: "address",
|
15
|
+
name: "bridger",
|
16
|
+
type: "address",
|
17
|
+
},
|
18
|
+
{
|
19
|
+
components: [
|
20
|
+
{
|
21
|
+
components: [
|
22
|
+
{
|
23
|
+
internalType: "address",
|
24
|
+
name: "sourceToken",
|
25
|
+
type: "address",
|
26
|
+
},
|
27
|
+
{
|
28
|
+
internalType: "address",
|
29
|
+
name: "targetToken",
|
30
|
+
type: "address",
|
31
|
+
},
|
32
|
+
{
|
33
|
+
internalType: "uint256",
|
34
|
+
name: "amount",
|
35
|
+
type: "uint256",
|
36
|
+
},
|
37
|
+
],
|
38
|
+
internalType: "struct InteropXContractBeta.TokenInfo[]",
|
39
|
+
name: "supply",
|
40
|
+
type: "tuple[]",
|
41
|
+
},
|
42
|
+
{
|
43
|
+
components: [
|
44
|
+
{
|
45
|
+
internalType: "address",
|
46
|
+
name: "sourceToken",
|
47
|
+
type: "address",
|
48
|
+
},
|
49
|
+
{
|
50
|
+
internalType: "address",
|
51
|
+
name: "targetToken",
|
52
|
+
type: "address",
|
53
|
+
},
|
54
|
+
{
|
55
|
+
internalType: "uint256",
|
56
|
+
name: "amount",
|
57
|
+
type: "uint256",
|
58
|
+
},
|
59
|
+
],
|
60
|
+
internalType: "struct InteropXContractBeta.TokenInfo[]",
|
61
|
+
name: "withdraw",
|
62
|
+
type: "tuple[]",
|
63
|
+
},
|
64
|
+
],
|
65
|
+
indexed: false,
|
66
|
+
internalType: "struct InteropXContractBeta.Position",
|
67
|
+
name: "position",
|
68
|
+
type: "tuple",
|
69
|
+
},
|
70
|
+
{
|
71
|
+
indexed: true,
|
72
|
+
internalType: "uint32",
|
73
|
+
name: "sourceChainId",
|
74
|
+
type: "uint32",
|
75
|
+
},
|
76
|
+
{
|
77
|
+
indexed: false,
|
78
|
+
internalType: "uint32",
|
79
|
+
name: "targetChainId",
|
80
|
+
type: "uint32",
|
81
|
+
},
|
82
|
+
{
|
83
|
+
indexed: true,
|
84
|
+
internalType: "bytes32",
|
85
|
+
name: "requestTransactionHash",
|
86
|
+
type: "bytes32",
|
87
|
+
},
|
88
|
+
{
|
89
|
+
indexed: false,
|
90
|
+
internalType: "bytes",
|
91
|
+
name: "metadata",
|
92
|
+
type: "bytes",
|
93
|
+
},
|
94
|
+
],
|
95
|
+
name: "LogBridgeCommitted",
|
96
|
+
type: "event",
|
97
|
+
},
|
98
|
+
{
|
99
|
+
anonymous: false,
|
100
|
+
inputs: [
|
101
|
+
{
|
102
|
+
indexed: true,
|
103
|
+
internalType: "address",
|
104
|
+
name: "bridger",
|
105
|
+
type: "address",
|
106
|
+
},
|
107
|
+
{
|
108
|
+
components: [
|
109
|
+
{
|
110
|
+
components: [
|
111
|
+
{
|
112
|
+
internalType: "address",
|
113
|
+
name: "sourceToken",
|
114
|
+
type: "address",
|
115
|
+
},
|
116
|
+
{
|
117
|
+
internalType: "address",
|
118
|
+
name: "targetToken",
|
119
|
+
type: "address",
|
120
|
+
},
|
121
|
+
{
|
122
|
+
internalType: "uint256",
|
123
|
+
name: "amount",
|
124
|
+
type: "uint256",
|
125
|
+
},
|
126
|
+
],
|
127
|
+
internalType: "struct InteropXContractBeta.TokenInfo[]",
|
128
|
+
name: "supply",
|
129
|
+
type: "tuple[]",
|
130
|
+
},
|
131
|
+
{
|
132
|
+
components: [
|
133
|
+
{
|
134
|
+
internalType: "address",
|
135
|
+
name: "sourceToken",
|
136
|
+
type: "address",
|
137
|
+
},
|
138
|
+
{
|
139
|
+
internalType: "address",
|
140
|
+
name: "targetToken",
|
141
|
+
type: "address",
|
142
|
+
},
|
143
|
+
{
|
144
|
+
internalType: "uint256",
|
145
|
+
name: "amount",
|
146
|
+
type: "uint256",
|
147
|
+
},
|
148
|
+
],
|
149
|
+
internalType: "struct InteropXContractBeta.TokenInfo[]",
|
150
|
+
name: "withdraw",
|
151
|
+
type: "tuple[]",
|
152
|
+
},
|
153
|
+
],
|
154
|
+
indexed: false,
|
155
|
+
internalType: "struct InteropXContractBeta.Position",
|
156
|
+
name: "position",
|
157
|
+
type: "tuple",
|
158
|
+
},
|
159
|
+
{
|
160
|
+
indexed: false,
|
161
|
+
internalType: "uint256",
|
162
|
+
name: "sourceChainId",
|
163
|
+
type: "uint256",
|
164
|
+
},
|
165
|
+
{
|
166
|
+
indexed: true,
|
167
|
+
internalType: "uint256",
|
168
|
+
name: "targetChainId",
|
169
|
+
type: "uint256",
|
170
|
+
},
|
171
|
+
{
|
172
|
+
indexed: true,
|
173
|
+
internalType: "bytes32",
|
174
|
+
name: "requestTransactionHash",
|
175
|
+
type: "bytes32",
|
176
|
+
},
|
177
|
+
{
|
178
|
+
indexed: false,
|
179
|
+
internalType: "bytes32",
|
180
|
+
name: "targetCommittedTransactionHash",
|
181
|
+
type: "bytes32",
|
182
|
+
},
|
183
|
+
{
|
184
|
+
indexed: false,
|
185
|
+
internalType: "bytes",
|
186
|
+
name: "metadata",
|
187
|
+
type: "bytes",
|
188
|
+
},
|
189
|
+
],
|
190
|
+
name: "LogBridgeCompleted",
|
191
|
+
type: "event",
|
192
|
+
},
|
193
|
+
{
|
194
|
+
anonymous: false,
|
195
|
+
inputs: [
|
196
|
+
{
|
197
|
+
indexed: true,
|
198
|
+
internalType: "address",
|
199
|
+
name: "bridger",
|
200
|
+
type: "address",
|
201
|
+
},
|
202
|
+
{
|
203
|
+
components: [
|
204
|
+
{
|
205
|
+
components: [
|
206
|
+
{
|
207
|
+
internalType: "address",
|
208
|
+
name: "sourceToken",
|
209
|
+
type: "address",
|
210
|
+
},
|
211
|
+
{
|
212
|
+
internalType: "address",
|
213
|
+
name: "targetToken",
|
214
|
+
type: "address",
|
215
|
+
},
|
216
|
+
{
|
217
|
+
internalType: "uint256",
|
218
|
+
name: "amount",
|
219
|
+
type: "uint256",
|
220
|
+
},
|
221
|
+
],
|
222
|
+
internalType: "struct InteropXContractBeta.TokenInfo[]",
|
223
|
+
name: "supply",
|
224
|
+
type: "tuple[]",
|
225
|
+
},
|
226
|
+
{
|
227
|
+
components: [
|
228
|
+
{
|
229
|
+
internalType: "address",
|
230
|
+
name: "sourceToken",
|
231
|
+
type: "address",
|
232
|
+
},
|
233
|
+
{
|
234
|
+
internalType: "address",
|
235
|
+
name: "targetToken",
|
236
|
+
type: "address",
|
237
|
+
},
|
238
|
+
{
|
239
|
+
internalType: "uint256",
|
240
|
+
name: "amount",
|
241
|
+
type: "uint256",
|
242
|
+
},
|
243
|
+
],
|
244
|
+
internalType: "struct InteropXContractBeta.TokenInfo[]",
|
245
|
+
name: "withdraw",
|
246
|
+
type: "tuple[]",
|
247
|
+
},
|
248
|
+
],
|
249
|
+
indexed: false,
|
250
|
+
internalType: "struct InteropXContractBeta.Position",
|
251
|
+
name: "position",
|
252
|
+
type: "tuple",
|
253
|
+
},
|
254
|
+
{
|
255
|
+
indexed: false,
|
256
|
+
internalType: "uint256",
|
257
|
+
name: "sourceChainId",
|
258
|
+
type: "uint256",
|
259
|
+
},
|
260
|
+
{
|
261
|
+
indexed: true,
|
262
|
+
internalType: "uint256",
|
263
|
+
name: "targetChainId",
|
264
|
+
type: "uint256",
|
265
|
+
},
|
266
|
+
{
|
267
|
+
indexed: false,
|
268
|
+
internalType: "bytes",
|
269
|
+
name: "metadata",
|
270
|
+
type: "bytes",
|
271
|
+
},
|
272
|
+
],
|
273
|
+
name: "LogBridgeRequest",
|
274
|
+
type: "event",
|
275
|
+
},
|
276
|
+
{
|
277
|
+
anonymous: false,
|
278
|
+
inputs: [
|
279
|
+
{
|
280
|
+
indexed: true,
|
281
|
+
internalType: "address",
|
282
|
+
name: "bridger",
|
283
|
+
type: "address",
|
284
|
+
},
|
285
|
+
{
|
286
|
+
components: [
|
287
|
+
{
|
288
|
+
components: [
|
289
|
+
{
|
290
|
+
internalType: "address",
|
291
|
+
name: "sourceToken",
|
292
|
+
type: "address",
|
293
|
+
},
|
294
|
+
{
|
295
|
+
internalType: "address",
|
296
|
+
name: "targetToken",
|
297
|
+
type: "address",
|
298
|
+
},
|
299
|
+
{
|
300
|
+
internalType: "uint256",
|
301
|
+
name: "amount",
|
302
|
+
type: "uint256",
|
303
|
+
},
|
304
|
+
],
|
305
|
+
internalType: "struct InteropXContractBeta.TokenInfo[]",
|
306
|
+
name: "supply",
|
307
|
+
type: "tuple[]",
|
308
|
+
},
|
309
|
+
{
|
310
|
+
components: [
|
311
|
+
{
|
312
|
+
internalType: "address",
|
313
|
+
name: "sourceToken",
|
314
|
+
type: "address",
|
315
|
+
},
|
316
|
+
{
|
317
|
+
internalType: "address",
|
318
|
+
name: "targetToken",
|
319
|
+
type: "address",
|
320
|
+
},
|
321
|
+
{
|
322
|
+
internalType: "uint256",
|
323
|
+
name: "amount",
|
324
|
+
type: "uint256",
|
325
|
+
},
|
326
|
+
],
|
327
|
+
internalType: "struct InteropXContractBeta.TokenInfo[]",
|
328
|
+
name: "withdraw",
|
329
|
+
type: "tuple[]",
|
330
|
+
},
|
331
|
+
],
|
332
|
+
indexed: false,
|
333
|
+
internalType: "struct InteropXContractBeta.Position",
|
334
|
+
name: "position",
|
335
|
+
type: "tuple",
|
336
|
+
},
|
337
|
+
{
|
338
|
+
indexed: false,
|
339
|
+
internalType: "uint32",
|
340
|
+
name: "sourceChainId",
|
341
|
+
type: "uint32",
|
342
|
+
},
|
343
|
+
{
|
344
|
+
indexed: true,
|
345
|
+
internalType: "uint32",
|
346
|
+
name: "targetChainId",
|
347
|
+
type: "uint32",
|
348
|
+
},
|
349
|
+
{
|
350
|
+
indexed: true,
|
351
|
+
internalType: "bytes32",
|
352
|
+
name: "requestTransactionHash",
|
353
|
+
type: "bytes32",
|
354
|
+
},
|
355
|
+
{
|
356
|
+
indexed: false,
|
357
|
+
internalType: "bytes",
|
358
|
+
name: "metadata",
|
359
|
+
type: "bytes",
|
360
|
+
},
|
361
|
+
],
|
362
|
+
name: "LogBridgeRequestSent",
|
363
|
+
type: "event",
|
364
|
+
},
|
365
|
+
{
|
366
|
+
inputs: [],
|
367
|
+
name: "_vnonce",
|
368
|
+
outputs: [
|
369
|
+
{
|
370
|
+
internalType: "uint256",
|
371
|
+
name: "",
|
372
|
+
type: "uint256",
|
373
|
+
},
|
374
|
+
],
|
375
|
+
stateMutability: "view",
|
376
|
+
type: "function",
|
377
|
+
},
|
378
|
+
{
|
379
|
+
inputs: [
|
380
|
+
{
|
381
|
+
internalType: "address",
|
382
|
+
name: "to_",
|
383
|
+
type: "address",
|
384
|
+
},
|
385
|
+
{
|
386
|
+
internalType: "address",
|
387
|
+
name: "sourceToken_",
|
388
|
+
type: "address",
|
389
|
+
},
|
390
|
+
{
|
391
|
+
internalType: "address",
|
392
|
+
name: "targetToken_",
|
393
|
+
type: "address",
|
394
|
+
},
|
395
|
+
{
|
396
|
+
internalType: "uint256",
|
397
|
+
name: "amount_",
|
398
|
+
type: "uint256",
|
399
|
+
},
|
400
|
+
{
|
401
|
+
internalType: "uint32",
|
402
|
+
name: "targetChainId_",
|
403
|
+
type: "uint32",
|
404
|
+
},
|
405
|
+
{
|
406
|
+
internalType: "bytes32",
|
407
|
+
name: "transactionHash_",
|
408
|
+
type: "bytes32",
|
409
|
+
},
|
410
|
+
{
|
411
|
+
internalType: "bytes",
|
412
|
+
name: "metadata_",
|
413
|
+
type: "bytes",
|
414
|
+
},
|
415
|
+
],
|
416
|
+
name: "completeBridge",
|
417
|
+
outputs: [],
|
418
|
+
stateMutability: "nonpayable",
|
419
|
+
type: "function",
|
420
|
+
},
|
421
|
+
{
|
422
|
+
inputs: [
|
423
|
+
{
|
424
|
+
internalType: "address",
|
425
|
+
name: "sourceToken_",
|
426
|
+
type: "address",
|
427
|
+
},
|
428
|
+
{
|
429
|
+
internalType: "address",
|
430
|
+
name: "targetToken_",
|
431
|
+
type: "address",
|
432
|
+
},
|
433
|
+
{
|
434
|
+
internalType: "uint256",
|
435
|
+
name: "amount_",
|
436
|
+
type: "uint256",
|
437
|
+
},
|
438
|
+
{
|
439
|
+
internalType: "uint32",
|
440
|
+
name: "targetChainId_",
|
441
|
+
type: "uint32",
|
442
|
+
},
|
443
|
+
{
|
444
|
+
internalType: "bytes",
|
445
|
+
name: "metadata_",
|
446
|
+
type: "bytes",
|
447
|
+
},
|
448
|
+
],
|
449
|
+
name: "requestWithdraw",
|
450
|
+
outputs: [],
|
451
|
+
stateMutability: "nonpayable",
|
452
|
+
type: "function",
|
453
|
+
},
|
454
|
+
{
|
455
|
+
inputs: [
|
456
|
+
{
|
457
|
+
internalType: "address",
|
458
|
+
name: "",
|
459
|
+
type: "address",
|
460
|
+
},
|
461
|
+
],
|
462
|
+
name: "whitelistedMapping",
|
463
|
+
outputs: [
|
464
|
+
{
|
465
|
+
internalType: "uint256",
|
466
|
+
name: "",
|
467
|
+
type: "uint256",
|
468
|
+
},
|
469
|
+
],
|
470
|
+
stateMutability: "view",
|
471
|
+
type: "function",
|
472
|
+
},
|
473
|
+
{
|
474
|
+
inputs: [
|
475
|
+
{
|
476
|
+
internalType: "address",
|
477
|
+
name: "user_",
|
478
|
+
type: "address",
|
479
|
+
},
|
480
|
+
{
|
481
|
+
internalType: "address",
|
482
|
+
name: "sourceToken_",
|
483
|
+
type: "address",
|
484
|
+
},
|
485
|
+
{
|
486
|
+
internalType: "address",
|
487
|
+
name: "targetToken_",
|
488
|
+
type: "address",
|
489
|
+
},
|
490
|
+
{
|
491
|
+
internalType: "uint256",
|
492
|
+
name: "amount_",
|
493
|
+
type: "uint256",
|
494
|
+
},
|
495
|
+
{
|
496
|
+
internalType: "uint32",
|
497
|
+
name: "chainId_",
|
498
|
+
type: "uint32",
|
499
|
+
},
|
500
|
+
{
|
501
|
+
internalType: "bytes32",
|
502
|
+
name: "transactionHash_",
|
503
|
+
type: "bytes32",
|
504
|
+
},
|
505
|
+
{
|
506
|
+
internalType: "bytes",
|
507
|
+
name: "metadata_",
|
508
|
+
type: "bytes",
|
509
|
+
},
|
510
|
+
],
|
511
|
+
name: "withdrawRequested",
|
512
|
+
outputs: [],
|
513
|
+
stateMutability: "nonpayable",
|
514
|
+
type: "function",
|
515
|
+
},
|
516
|
+
];
|
517
|
+
class InteropXContract__factory {
|
518
|
+
static createInterface() {
|
519
|
+
return new ethers_1.utils.Interface(_abi);
|
520
|
+
}
|
521
|
+
static connect(address, signerOrProvider) {
|
522
|
+
return new ethers_1.Contract(address, _abi, signerOrProvider);
|
523
|
+
}
|
524
|
+
}
|
525
|
+
exports.InteropXContract__factory = InteropXContract__factory;
|
526
|
+
InteropXContract__factory.abi = _abi;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.InteropXContract__factory = exports.GnosisSafe__factory = exports.Erc20__factory = void 0;
|
4
4
|
/* Autogenerated file. Do not edit manually. */
|
5
5
|
/* tslint:disable */
|
6
6
|
/* eslint-disable */
|
@@ -8,7 +8,5 @@ var Erc20__factory_1 = require("./Erc20__factory");
|
|
8
8
|
Object.defineProperty(exports, "Erc20__factory", { enumerable: true, get: function () { return Erc20__factory_1.Erc20__factory; } });
|
9
9
|
var GnosisSafe__factory_1 = require("./GnosisSafe__factory");
|
10
10
|
Object.defineProperty(exports, "GnosisSafe__factory", { enumerable: true, get: function () { return GnosisSafe__factory_1.GnosisSafe__factory; } });
|
11
|
-
var
|
12
|
-
Object.defineProperty(exports, "
|
13
|
-
var InteropXGateway__factory_1 = require("./InteropXGateway__factory");
|
14
|
-
Object.defineProperty(exports, "InteropXGateway__factory", { enumerable: true, get: function () { return InteropXGateway__factory_1.InteropXGateway__factory; } });
|
11
|
+
var InteropXContract__factory_1 = require("./InteropXContract__factory");
|
12
|
+
Object.defineProperty(exports, "InteropXContract__factory", { enumerable: true, get: function () { return InteropXContract__factory_1.InteropXContract__factory; } });
|
@@ -23,13 +23,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
23
|
return result;
|
24
24
|
};
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
-
exports.
|
26
|
+
exports.InteropXContract__factory = exports.GnosisSafe__factory = exports.Erc20__factory = exports.factories = void 0;
|
27
27
|
exports.factories = __importStar(require("./factories"));
|
28
28
|
var Erc20__factory_1 = require("./factories/Erc20__factory");
|
29
29
|
Object.defineProperty(exports, "Erc20__factory", { enumerable: true, get: function () { return Erc20__factory_1.Erc20__factory; } });
|
30
30
|
var GnosisSafe__factory_1 = require("./factories/GnosisSafe__factory");
|
31
31
|
Object.defineProperty(exports, "GnosisSafe__factory", { enumerable: true, get: function () { return GnosisSafe__factory_1.GnosisSafe__factory; } });
|
32
|
-
var
|
33
|
-
Object.defineProperty(exports, "
|
34
|
-
var InteropXGateway__factory_1 = require("./factories/InteropXGateway__factory");
|
35
|
-
Object.defineProperty(exports, "InteropXGateway__factory", { enumerable: true, get: function () { return InteropXGateway__factory_1.InteropXGateway__factory; } });
|
32
|
+
var InteropXContract__factory_1 = require("./factories/InteropXContract__factory");
|
33
|
+
Object.defineProperty(exports, "InteropXContract__factory", { enumerable: true, get: function () { return InteropXContract__factory_1.InteropXContract__factory; } });
|
package/dist/src/utils/index.js
CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.
|
6
|
+
exports.generateGnosisTransaction = exports.getContract = exports.generateInteropTransactionHash = exports.asyncCallWithTimeout = exports.buildSignatureBytes = exports.getRpcProviderUrl = exports.signGnosisSafeTx = exports.short = exports.shortenHash = exports.http = void 0;
|
7
7
|
/**
|
8
8
|
* @module util
|
9
9
|
*/
|
@@ -11,11 +11,18 @@ const axios_1 = __importDefault(require("axios"));
|
|
11
11
|
const axios_retry_1 = __importDefault(require("axios-retry"));
|
12
12
|
const constants_1 = require("@/constants");
|
13
13
|
const ethers_1 = require("ethers");
|
14
|
-
const ethers_multisend_1 = require("ethers-multisend");
|
15
|
-
const config_1 = __importDefault(require("@/config"));
|
16
|
-
const abi_1 = __importDefault(require("@/abi"));
|
17
14
|
exports.http = axios_1.default.create();
|
18
15
|
(0, axios_retry_1.default)(exports.http, { retries: 3, retryDelay: axios_retry_1.default.exponentialDelay });
|
16
|
+
function shortenHash(hash, length = 4) {
|
17
|
+
if (!hash)
|
18
|
+
return;
|
19
|
+
if (hash.length < 12)
|
20
|
+
return hash;
|
21
|
+
const beginningChars = hash.startsWith("0x") ? length + 2 : length;
|
22
|
+
const shortened = hash.substr(0, beginningChars) + "…" + hash.substr(-length);
|
23
|
+
return shortened;
|
24
|
+
}
|
25
|
+
exports.shortenHash = shortenHash;
|
19
26
|
function short(buffer) {
|
20
27
|
return buffer.toString('hex').slice(0, 8) + '...';
|
21
28
|
}
|
@@ -59,11 +66,11 @@ exports.signGnosisSafeTx = signGnosisSafeTx;
|
|
59
66
|
const getRpcProviderUrl = (chainId) => {
|
60
67
|
switch (chainId) {
|
61
68
|
case 1:
|
62
|
-
return 'https://rpc.
|
69
|
+
return 'https://rpc.ankr.com/eth';
|
63
70
|
case 137:
|
64
|
-
return 'https://rpc.
|
71
|
+
return 'https://rpc.ankr.com/polygon';
|
65
72
|
case 43114:
|
66
|
-
return 'https://rpc.
|
73
|
+
return 'https://rpc.ankr.com/avalanche';
|
67
74
|
default:
|
68
75
|
throw new Error(`Unknown chainId: ${chainId}`);
|
69
76
|
}
|
@@ -94,52 +101,25 @@ const asyncCallWithTimeout = async (asyncPromise, timeout) => {
|
|
94
101
|
};
|
95
102
|
exports.asyncCallWithTimeout = asyncCallWithTimeout;
|
96
103
|
const generateInteropTransactionHash = (data) => {
|
97
|
-
return ethers_1.ethers.utils.solidityKeccak256(['string', 'string', 'string', 'string'], [
|
104
|
+
return ethers_1.ethers.utils.solidityKeccak256(['string', 'string', 'string', 'string', 'string'], [
|
98
105
|
String(data.action),
|
99
|
-
String(data.
|
106
|
+
String(data.bridger),
|
107
|
+
String(data.requestTransactionHash),
|
100
108
|
String(data.sourceChainId),
|
101
109
|
String(data.targetChainId),
|
102
110
|
]);
|
103
111
|
};
|
104
112
|
exports.generateInteropTransactionHash = generateInteropTransactionHash;
|
105
|
-
const buildDataForTransaction = async (transaction, type) => {
|
106
|
-
type = type || transaction.sourceStatus === 'pending' ? 'source' : 'target';
|
107
|
-
const transactions = [];
|
108
|
-
if (transaction.action != 'deposit') {
|
109
|
-
throw new Error('Invalid action');
|
110
|
-
}
|
111
|
-
if (transaction.action === 'deposit' && transaction.sourceStatus === 'pending') {
|
112
|
-
throw Error('Cannot build data for pending deposit transaction');
|
113
|
-
}
|
114
|
-
if (!transaction.submitEvent) {
|
115
|
-
throw Error('Cannot build data for transaction without submitEvent');
|
116
|
-
}
|
117
|
-
const token = constants_1.tokens[transaction.sourceChainId].find(token => token.address.toLowerCase() === transaction.submitEvent.token.toLowerCase());
|
118
|
-
if (!token) {
|
119
|
-
throw Error('Cannot build data for transaction without token');
|
120
|
-
}
|
121
|
-
const itoken = constants_1.itokens[transaction.targetChainId].find(itoken => itoken.symbol.toLowerCase() === token.symbol.toLowerCase());
|
122
|
-
if (!itoken) {
|
123
|
-
throw Error('Cannot build data for transaction without itoken');
|
124
|
-
}
|
125
|
-
const targetChainProvider = new ethers_1.ethers.providers.JsonRpcProvider((0, exports.getRpcProviderUrl)(transaction.targetChainId));
|
126
|
-
const targetWallet = new ethers_1.ethers.Wallet(config_1.default.privateKey, targetChainProvider);
|
127
|
-
const interopBridgeContract = getContract(itoken.address, abi_1.default.interopBridgeToken, targetWallet);
|
128
|
-
const { data } = await interopBridgeContract.populateTransaction.mint(transaction.submitEvent.user, ethers_1.ethers.BigNumber.from(transaction.submitEvent.amount.toString()), ethers_1.ethers.BigNumber.from(transaction.submitEvent.sourceChainId.toString()), transaction.sourceTransactionHash);
|
129
|
-
transactions.push({
|
130
|
-
to: itoken.address,
|
131
|
-
data: data,
|
132
|
-
value: '0',
|
133
|
-
operation: ethers_multisend_1.OperationType.Call,
|
134
|
-
});
|
135
|
-
return (0, ethers_multisend_1.encodeMulti)(transactions).data;
|
136
|
-
};
|
137
|
-
exports.buildDataForTransaction = buildDataForTransaction;
|
138
113
|
function getContract(address, contractInterface, signerOrProvider) {
|
139
114
|
if (!ethers_1.ethers.utils.getAddress(address) || address === ethers_1.ethers.constants.AddressZero) {
|
140
115
|
throw Error(`Invalid 'address' parameter '${address}'.`);
|
141
116
|
}
|
142
117
|
const contract = new ethers_1.ethers.Contract(address, contractInterface, signerOrProvider);
|
118
|
+
// Make sure the contract properties is writable
|
119
|
+
const desc = Object.getOwnPropertyDescriptor(contract, 'functions');
|
120
|
+
if (!desc || desc.writable !== true) {
|
121
|
+
return contract;
|
122
|
+
}
|
143
123
|
return new Proxy(contract, {
|
144
124
|
get(target, prop, receiver) {
|
145
125
|
const value = Reflect.get(target, prop, receiver);
|
@@ -176,3 +156,13 @@ function getContract(address, contractInterface, signerOrProvider) {
|
|
176
156
|
});
|
177
157
|
}
|
178
158
|
exports.getContract = getContract;
|
159
|
+
const generateGnosisTransaction = async (transactionData, safeContract) => {
|
160
|
+
console.log(transactionData);
|
161
|
+
let isExecuted = await safeContract.dataHashes(await safeContract.getTransactionHash(transactionData.to, transactionData.value, transactionData.data, transactionData.operation, transactionData.safeTxGas, transactionData.baseGas, transactionData.gasPrice, transactionData.gasToken, transactionData.refundReceiver, transactionData.nonce));
|
162
|
+
while (isExecuted == 1) {
|
163
|
+
transactionData.safeTxGas = ethers_1.ethers.BigNumber.from(String(transactionData.safeTxGas)).add(1).toString();
|
164
|
+
isExecuted = await safeContract.dataHashes(await safeContract.getTransactionHash(transactionData.to, transactionData.value, transactionData.data, transactionData.operation, transactionData.safeTxGas, transactionData.baseGas, transactionData.gasPrice, transactionData.gasToken, transactionData.refundReceiver, transactionData.nonce));
|
165
|
+
}
|
166
|
+
return transactionData;
|
167
|
+
};
|
168
|
+
exports.generateGnosisTransaction = generateGnosisTransaction;
|