@instadapp/interop-x 0.0.0-dev.a775e30 → 0.0.0-dev.a861339

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 (70) hide show
  1. package/dist/package.json +2 -2
  2. package/dist/src/abi/index.js +2 -4
  3. package/dist/src/abi/interopXContract.json +391 -0
  4. package/dist/src/alias.js +10 -0
  5. package/dist/src/api/index.js +3 -0
  6. package/dist/src/constants/addresses.js +3 -3
  7. package/dist/src/constants/index.js +0 -1
  8. package/dist/src/db/models/transaction.js +27 -9
  9. package/dist/src/gnosis/actions/index.js +9 -0
  10. package/dist/src/gnosis/actions/withdraw/index.js +41 -0
  11. package/dist/src/gnosis/index.js +20 -0
  12. package/dist/src/index.js +7 -18
  13. package/dist/src/net/protocol/dial/SignatureDialProtocol.js +9 -10
  14. package/dist/src/net/protocol/dial/{SignatureDialProtocol.1.js → TransactionStatusDialProtocol.js} +2 -0
  15. package/dist/src/net/protocol/index.js +17 -7
  16. package/dist/src/tasks/{InteropXGateway/ProcessDepositEvents.js → InteropXContract/ProcessBridgeRequestEvents.js} +49 -51
  17. package/dist/src/tasks/InteropXContract/SyncBridgeRequestEvents.js +78 -0
  18. package/dist/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.js +80 -0
  19. package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +2 -0
  20. package/dist/src/tasks/index.js +13 -19
  21. package/dist/src/typechain/{InteropBridgeToken.js → InteropXContract.js} +0 -0
  22. package/dist/src/typechain/factories/InteropXContract__factory.js +526 -0
  23. package/dist/src/typechain/factories/index.js +3 -5
  24. package/dist/src/typechain/index.js +3 -5
  25. package/dist/src/utils/index.js +14 -84
  26. package/package.json +2 -2
  27. package/src/abi/index.ts +2 -4
  28. package/src/abi/interopXContract.json +391 -0
  29. package/src/alias.ts +6 -0
  30. package/src/api/index.ts +3 -0
  31. package/src/constants/addresses.ts +3 -3
  32. package/src/constants/index.ts +0 -1
  33. package/src/db/models/transaction.ts +66 -21
  34. package/src/gnosis/actions/index.ts +5 -0
  35. package/src/gnosis/actions/withdraw/index.ts +56 -0
  36. package/src/gnosis/index.ts +19 -0
  37. package/src/index.ts +6 -17
  38. package/src/net/protocol/dial/SignatureDialProtocol.ts +11 -13
  39. package/src/net/protocol/dial/{SignatureDialProtocol.1.ts → TransactionStatusDialProtocol.ts} +3 -1
  40. package/src/net/protocol/index.ts +17 -7
  41. package/src/tasks/{InteropBridge/ProcessWithdrawEvents.ts → InteropXContract/ProcessBridgeRequestEvents.ts} +75 -95
  42. package/src/tasks/InteropXContract/SyncBridgeRequestEvents.ts +116 -0
  43. package/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.ts +112 -0
  44. package/src/tasks/Transactions/SyncTransactionStatusTask.ts +2 -0
  45. package/src/tasks/index.ts +17 -20
  46. package/src/typechain/InteropXContract.ts +524 -0
  47. package/src/typechain/factories/InteropXContract__factory.ts +533 -0
  48. package/src/typechain/factories/index.ts +1 -2
  49. package/src/typechain/index.ts +2 -4
  50. package/src/utils/index.ts +46 -125
  51. package/tsconfig.json +7 -2
  52. package/dist/src/abi/interopBridgeToken.json +0 -286
  53. package/dist/src/abi/interopXGateway.json +0 -184
  54. package/dist/src/constants/itokens.js +0 -13
  55. package/dist/src/tasks/InteropBridge/ProcessWithdrawEvents.js +0 -146
  56. package/dist/src/tasks/InteropBridge/SyncWithdrawEvents.js +0 -69
  57. package/dist/src/tasks/InteropXGateway/SyncDepositEvents.js +0 -74
  58. package/dist/src/typechain/InteropXGateway.js +0 -2
  59. package/dist/src/typechain/factories/InteropBridgeToken__factory.js +0 -459
  60. package/dist/src/typechain/factories/InteropXGateway__factory.js +0 -265
  61. package/src/abi/interopBridgeToken.json +0 -286
  62. package/src/abi/interopXGateway.json +0 -184
  63. package/src/constants/itokens.ts +0 -10
  64. package/src/tasks/InteropBridge/SyncWithdrawEvents.ts +0 -119
  65. package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +0 -243
  66. package/src/tasks/InteropXGateway/SyncDepositEvents.ts +0 -124
  67. package/src/typechain/InteropBridgeToken.ts +0 -686
  68. package/src/typechain/InteropXGateway.ts +0 -407
  69. package/src/typechain/factories/InteropBridgeToken__factory.ts +0 -466
  70. 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.InteropXGateway__factory = exports.InteropBridgeToken__factory = exports.GnosisSafe__factory = exports.Erc20__factory = void 0;
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 InteropBridgeToken__factory_1 = require("./InteropBridgeToken__factory");
12
- Object.defineProperty(exports, "InteropBridgeToken__factory", { enumerable: true, get: function () { return InteropBridgeToken__factory_1.InteropBridgeToken__factory; } });
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.InteropXGateway__factory = exports.InteropBridgeToken__factory = exports.GnosisSafe__factory = exports.Erc20__factory = exports.factories = void 0;
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 InteropBridgeToken__factory_1 = require("./factories/InteropBridgeToken__factory");
33
- Object.defineProperty(exports, "InteropBridgeToken__factory", { enumerable: true, get: function () { return InteropBridgeToken__factory_1.InteropBridgeToken__factory; } });
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; } });
@@ -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.getContract = exports.buildWithdrawDataForTransaction = exports.buildDepositDataForTransaction = exports.buildDataForTransaction = exports.generateInteropTransactionHash = exports.asyncCallWithTimeout = exports.buildSignatureBytes = exports.getRpcProviderUrl = exports.signGnosisSafeTx = exports.short = exports.shortenHash = exports.http = void 0;
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,9 +11,6 @@ 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 });
19
16
  function shortenHash(hash, length = 4) {
@@ -104,92 +101,15 @@ const asyncCallWithTimeout = async (asyncPromise, timeout) => {
104
101
  };
105
102
  exports.asyncCallWithTimeout = asyncCallWithTimeout;
106
103
  const generateInteropTransactionHash = (data) => {
107
- return ethers_1.ethers.utils.solidityKeccak256(['string', 'string', 'string', 'string'], [
104
+ return ethers_1.ethers.utils.solidityKeccak256(['string', 'string', 'string', 'string', 'string'], [
108
105
  String(data.action),
109
- String(data.submitTransactionHash),
106
+ String(data.bridger),
107
+ String(data.requestTransactionHash),
110
108
  String(data.sourceChainId),
111
109
  String(data.targetChainId),
112
110
  ]);
113
111
  };
114
112
  exports.generateInteropTransactionHash = generateInteropTransactionHash;
115
- const buildDataForTransaction = async (transaction, type) => {
116
- type = type || transaction.sourceStatus === 'pending' ? 'source' : 'target';
117
- switch (transaction.action) {
118
- case "deposit":
119
- return await (0, exports.buildDepositDataForTransaction)(transaction, type);
120
- case "withdraw":
121
- return await (0, exports.buildWithdrawDataForTransaction)(transaction, type);
122
- default:
123
- throw new Error(`Unknown action: ${transaction.action}`);
124
- }
125
- };
126
- exports.buildDataForTransaction = buildDataForTransaction;
127
- const buildDepositDataForTransaction = async (transaction, type) => {
128
- const transactions = [];
129
- if (transaction.action !== 'deposit') {
130
- throw new Error(`Invalid action: ${transaction.action}`);
131
- }
132
- if (transaction.action === 'deposit' && transaction.sourceStatus === 'pending') {
133
- throw Error('Cannot build data for pending deposit transaction');
134
- }
135
- if (!transaction.submitEvent) {
136
- throw Error('Cannot build data for transaction without submitEvent');
137
- }
138
- const token = constants_1.tokens[transaction.sourceChainId].find(token => token.address.toLowerCase() === transaction.submitEvent.token.toLowerCase());
139
- if (!token) {
140
- throw Error('Cannot build data for transaction without token');
141
- }
142
- const itoken = constants_1.itokens[transaction.targetChainId].find(itoken => itoken.symbol.toLowerCase() === token.symbol.toLowerCase());
143
- if (!itoken) {
144
- throw Error('Cannot build data for transaction without itoken');
145
- }
146
- const targetChainProvider = new ethers_1.ethers.providers.JsonRpcProvider((0, exports.getRpcProviderUrl)(transaction.targetChainId));
147
- const targetWallet = new ethers_1.ethers.Wallet(config_1.default.privateKey, targetChainProvider);
148
- const interopBridgeContract = getContract(itoken.address, abi_1.default.interopBridgeToken, targetWallet);
149
- 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.submitTransactionHash);
150
- transactions.push({
151
- to: itoken.address,
152
- data: data,
153
- value: '0',
154
- operation: ethers_multisend_1.OperationType.Call,
155
- });
156
- return (0, ethers_multisend_1.encodeMulti)(transactions).data;
157
- };
158
- exports.buildDepositDataForTransaction = buildDepositDataForTransaction;
159
- const buildWithdrawDataForTransaction = async (transaction, type) => {
160
- const transactions = [];
161
- if (transaction.action !== 'withdraw') {
162
- throw new Error(`Invalid action: ${transaction.action}`);
163
- }
164
- if (transaction.action === 'withdraw' && transaction.sourceStatus === 'pending') {
165
- throw Error('Cannot build data for pending withdraw transaction');
166
- }
167
- if (!transaction.submitEvent) {
168
- throw Error('Cannot build data for transaction without submitEvent');
169
- }
170
- const { to, amount, chainId, itoken: itokenAddress } = transaction.submitEvent;
171
- const itoken = constants_1.itokens[transaction.sourceChainId].find(token => token.address.toLowerCase() === itokenAddress.toLowerCase());
172
- if (!itoken) {
173
- throw Error('Cannot build data for transaction without itoken');
174
- }
175
- const token = constants_1.tokens[chainId].find(t => t.symbol.toLowerCase() === itoken.symbol.toLowerCase());
176
- if (!token) {
177
- throw Error('Cannot build data for transaction without token');
178
- }
179
- const targetChainProvider = new ethers_1.ethers.providers.JsonRpcProvider((0, exports.getRpcProviderUrl)(transaction.targetChainId));
180
- const targetWallet = new ethers_1.ethers.Wallet(config_1.default.privateKey, targetChainProvider);
181
- const gatewayAddress = constants_1.addresses[chainId].interopXGateway;
182
- const interopBridgeContract = getContract(gatewayAddress, abi_1.default.interopXGateway, targetWallet);
183
- const { data } = await interopBridgeContract.populateTransaction.systemWithdraw(ethers_1.ethers.BigNumber.from(amount.toString()), to, token.address, ethers_1.ethers.BigNumber.from(transaction.sourceChainId.toString()), transaction.submitTransactionHash);
184
- transactions.push({
185
- to: gatewayAddress,
186
- data: data,
187
- value: '0',
188
- operation: ethers_multisend_1.OperationType.Call,
189
- });
190
- return (0, ethers_multisend_1.encodeMulti)(transactions).data;
191
- };
192
- exports.buildWithdrawDataForTransaction = buildWithdrawDataForTransaction;
193
113
  function getContract(address, contractInterface, signerOrProvider) {
194
114
  if (!ethers_1.ethers.utils.getAddress(address) || address === ethers_1.ethers.constants.AddressZero) {
195
115
  throw Error(`Invalid 'address' parameter '${address}'.`);
@@ -236,3 +156,13 @@ function getContract(address, contractInterface, signerOrProvider) {
236
156
  });
237
157
  }
238
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;