@instadapp/interop-x 0.0.0-dev.9b1fcb8 → 0.0.0-dev.9b26e43

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 (78) hide show
  1. package/dist/package.json +7 -6
  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 +6 -3
  6. package/dist/src/config/index.js +11 -1
  7. package/dist/src/constants/addresses.js +3 -3
  8. package/dist/src/constants/index.js +0 -1
  9. package/dist/src/db/models/transaction.js +27 -9
  10. package/dist/src/gnosis/actions/index.js +9 -0
  11. package/dist/src/gnosis/actions/withdraw/index.js +41 -0
  12. package/dist/src/gnosis/index.js +20 -0
  13. package/dist/src/index.js +75 -24
  14. package/dist/src/net/peer/index.js +2 -1
  15. package/dist/src/net/pool/index.js +18 -2
  16. package/dist/src/net/protocol/dial/SignatureDialProtocol.js +9 -10
  17. package/dist/src/net/protocol/dial/TransactionStatusDialProtocol.js +30 -0
  18. package/dist/src/net/protocol/index.js +51 -1
  19. package/dist/src/tasks/AutoUpdateTask.js +70 -0
  20. package/dist/src/tasks/BaseTask.js +11 -3
  21. package/dist/src/tasks/{InteropXGateway/ProcessDepositEvents.js → InteropXContract/ProcessBridgeRequestEvents.js} +50 -50
  22. package/dist/src/tasks/InteropXContract/SyncBridgeRequestEvents.js +78 -0
  23. package/dist/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.js +80 -0
  24. package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +55 -0
  25. package/dist/src/tasks/index.js +15 -13
  26. package/dist/src/typechain/{InteropBridgeToken.js → InteropXContract.js} +0 -0
  27. package/dist/src/typechain/factories/InteropXContract__factory.js +526 -0
  28. package/dist/src/typechain/factories/index.js +3 -5
  29. package/dist/src/typechain/index.js +3 -5
  30. package/dist/src/utils/index.js +32 -42
  31. package/package.json +7 -6
  32. package/src/abi/index.ts +2 -4
  33. package/src/abi/interopXContract.json +391 -0
  34. package/src/alias.ts +6 -0
  35. package/src/api/index.ts +5 -2
  36. package/src/config/index.ts +11 -1
  37. package/src/constants/addresses.ts +3 -3
  38. package/src/constants/index.ts +0 -1
  39. package/src/db/models/transaction.ts +66 -21
  40. package/src/gnosis/actions/index.ts +5 -0
  41. package/src/gnosis/actions/withdraw/index.ts +56 -0
  42. package/src/gnosis/index.ts +19 -0
  43. package/src/index.ts +96 -26
  44. package/src/net/peer/index.ts +2 -1
  45. package/src/net/pool/index.ts +25 -5
  46. package/src/net/protocol/dial/SignatureDialProtocol.ts +11 -13
  47. package/src/net/protocol/dial/TransactionStatusDialProtocol.ts +33 -0
  48. package/src/net/protocol/index.ts +67 -1
  49. package/src/tasks/AutoUpdateTask.ts +82 -0
  50. package/src/tasks/BaseTask.ts +13 -3
  51. package/src/tasks/{InteropXGateway/ProcessDepositEvents.ts → InteropXContract/ProcessBridgeRequestEvents.ts} +70 -100
  52. package/src/tasks/InteropXContract/SyncBridgeRequestEvents.ts +116 -0
  53. package/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.ts +112 -0
  54. package/src/tasks/Transactions/SyncTransactionStatusTask.ts +67 -0
  55. package/src/tasks/index.ts +24 -16
  56. package/src/typechain/InteropXContract.ts +524 -0
  57. package/src/typechain/factories/InteropXContract__factory.ts +533 -0
  58. package/src/typechain/factories/index.ts +1 -2
  59. package/src/typechain/index.ts +2 -4
  60. package/src/utils/index.ts +67 -65
  61. package/tsconfig.json +7 -2
  62. package/dist/src/abi/interopBridgeToken.json +0 -286
  63. package/dist/src/abi/interopXGateway.json +0 -184
  64. package/dist/src/constants/itokens.js +0 -13
  65. package/dist/src/tasks/InteropBridge/SyncWithdrawEvents.js +0 -68
  66. package/dist/src/tasks/InteropXGateway/SyncDepositEvents.js +0 -75
  67. package/dist/src/typechain/InteropXGateway.js +0 -2
  68. package/dist/src/typechain/factories/InteropBridgeToken__factory.js +0 -459
  69. package/dist/src/typechain/factories/InteropXGateway__factory.js +0 -265
  70. package/src/abi/interopBridgeToken.json +0 -286
  71. package/src/abi/interopXGateway.json +0 -184
  72. package/src/constants/itokens.ts +0 -10
  73. package/src/tasks/InteropBridge/SyncWithdrawEvents.ts +0 -119
  74. package/src/tasks/InteropXGateway/SyncDepositEvents.ts +0 -126
  75. package/src/typechain/InteropBridgeToken.ts +0 -686
  76. package/src/typechain/InteropXGateway.ts +0 -407
  77. package/src/typechain/factories/InteropBridgeToken__factory.ts +0 -466
  78. package/src/typechain/factories/InteropXGateway__factory.ts +0 -272
@@ -1,68 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const BaseTask_1 = require("../BaseTask");
7
- const logger_1 = __importDefault(require("@/logger"));
8
- const ethers_1 = require("ethers");
9
- const abi_1 = __importDefault(require("@/abi"));
10
- const db_1 = require("@/db");
11
- const utils_1 = require("@/utils");
12
- const config_1 = __importDefault(require("@/config"));
13
- class SyncWithdrawEvents extends BaseTask_1.BaseTask {
14
- constructor({ chainId, itokenAddress }) {
15
- super({
16
- logger: new logger_1.default("InteropBridgeToken::SyncWithdrawEvents"),
17
- });
18
- this.chainId = chainId;
19
- this.itokenAddress = itokenAddress;
20
- }
21
- async pollHandler() {
22
- const currentBlock = await this.provider.getBlockNumber();
23
- const events = await this.contract.queryFilter(this.contract.filters.Burn(), currentBlock - 2000, currentBlock);
24
- let processedEvents = 0;
25
- for (const event of events) {
26
- try {
27
- if (!event.args) {
28
- continue;
29
- }
30
- const { to, amount, chainId } = event.args;
31
- const uniqueIdentifier = {
32
- action: 'withdraw',
33
- submitTransactionHash: event.transactionHash,
34
- sourceChainId: this.chainId,
35
- targetChainId: chainId.toNumber(),
36
- };
37
- if (await db_1.Transaction.findOne({ where: uniqueIdentifier })) {
38
- continue;
39
- }
40
- const tx = await event.getTransaction();
41
- await db_1.Transaction.create(Object.assign(Object.assign({}, uniqueIdentifier), { transactionHash: (0, utils_1.generateInteropTransactionHash)(uniqueIdentifier), from: tx.from, to, submitTransactionHash: event.transactionHash, submitBlockNumber: event.blockNumber,
42
- // submit & source are the same
43
- sourceTransactionHash: event.transactionHash, sourceBlockNumber: event.blockNumber, sourceStatus: "success", targetStatus: "uninitialised", submitEvent: {
44
- to,
45
- amount: amount.toString(),
46
- chainId: chainId.toString()
47
- }, sourceEvent: {
48
- to,
49
- amount: amount.toString(),
50
- chainId: chainId.toString(),
51
- }, status: "pending" }));
52
- this.logger.info(`Withdraw queued: ${event.transactionHash} ${event.blockNumber}`);
53
- }
54
- catch (error) {
55
- this.logger.error(error);
56
- }
57
- }
58
- if (processedEvents > 0)
59
- this.logger.info(`${processedEvents} events processed`);
60
- }
61
- async start() {
62
- this.logger.info(`Starting execution watcher on interop chain`);
63
- this.provider = new ethers_1.ethers.providers.JsonRpcProvider((0, utils_1.getRpcProviderUrl)(this.chainId));
64
- this.contract = (0, utils_1.getContract)(this.itokenAddress, abi_1.default.interopBridgeToken, new ethers_1.ethers.Wallet(config_1.default.privateKey, this.provider));
65
- await super.start();
66
- }
67
- }
68
- exports.default = SyncWithdrawEvents;
@@ -1,75 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const BaseTask_1 = require("../BaseTask");
7
- const logger_1 = __importDefault(require("@/logger"));
8
- const ethers_1 = require("ethers");
9
- const abi_1 = __importDefault(require("@/abi"));
10
- const db_1 = require("@/db");
11
- const utils_1 = require("@/utils");
12
- const constants_1 = require("@/constants");
13
- const config_1 = __importDefault(require("@/config"));
14
- class SyncDepositEvents extends BaseTask_1.BaseTask {
15
- constructor({ chainId }) {
16
- super({
17
- logger: new logger_1.default("InteropXGateway::SyncDepositEvents"),
18
- });
19
- this.chainId = chainId;
20
- }
21
- async pollHandler() {
22
- const currentBlock = await this.provider.getBlockNumber();
23
- const events = await this.contract.queryFilter(this.contract.filters.LogGatewayDeposit(), currentBlock - 2000, currentBlock);
24
- let processedEvents = 0;
25
- for (const event of events) {
26
- try {
27
- if (!event.args) {
28
- continue;
29
- }
30
- const { sourceChainId, targetChainId, user, vnonce, amount, token } = event.args;
31
- const uniqueIdentifier = {
32
- action: 'deposit',
33
- submitTransactionHash: event.transactionHash,
34
- sourceChainId: sourceChainId.toNumber(),
35
- targetChainId: targetChainId.toNumber(),
36
- };
37
- if (await db_1.Transaction.findOne({ where: uniqueIdentifier })) {
38
- continue;
39
- }
40
- const tx = await event.getTransaction();
41
- await db_1.Transaction.create(Object.assign(Object.assign({}, uniqueIdentifier), { transactionHash: (0, utils_1.generateInteropTransactionHash)(uniqueIdentifier), from: tx.from, to: user, submitTransactionHash: event.transactionHash, submitBlockNumber: event.blockNumber,
42
- // submit & source are the same
43
- sourceTransactionHash: event.transactionHash, sourceBlockNumber: event.blockNumber, sourceStatus: "success", targetStatus: "uninitialised", submitEvent: {
44
- user,
45
- sourceChainId: sourceChainId.toString(),
46
- targetChainId: targetChainId.toString(),
47
- token: token,
48
- amount: amount.toString(),
49
- vnonce: vnonce.toString(),
50
- }, sourceEvent: {
51
- user,
52
- sourceChainId: sourceChainId.toString(),
53
- targetChainId: targetChainId.toString(),
54
- token: token,
55
- amount: amount.toString(),
56
- vnonce: vnonce.toString(),
57
- }, status: "pending" }));
58
- this.logger.info(`Deposit queued: ${event.transactionHash} ${event.blockNumber}`);
59
- }
60
- catch (error) {
61
- this.logger.error(error);
62
- }
63
- }
64
- if (processedEvents > 0)
65
- this.logger.info(`${processedEvents} events processed`);
66
- }
67
- async start() {
68
- this.logger.info(`Starting execution watcher on interop chain`);
69
- this.contractAddress = constants_1.addresses[this.chainId].interopXGateway;
70
- this.provider = new ethers_1.ethers.providers.JsonRpcProvider((0, utils_1.getRpcProviderUrl)(this.chainId));
71
- this.contract = (0, utils_1.getContract)(this.contractAddress, abi_1.default.interopXGateway, new ethers_1.ethers.Wallet(config_1.default.privateKey, this.provider));
72
- await super.start();
73
- }
74
- }
75
- exports.default = SyncDepositEvents;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,459 +0,0 @@
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.InteropBridgeToken__factory = void 0;
7
- const ethers_1 = require("ethers");
8
- const _abi = [
9
- {
10
- inputs: [
11
- {
12
- internalType: "address",
13
- name: "__owner",
14
- type: "address",
15
- },
16
- ],
17
- stateMutability: "nonpayable",
18
- type: "constructor",
19
- },
20
- {
21
- anonymous: false,
22
- inputs: [
23
- {
24
- indexed: true,
25
- internalType: "address",
26
- name: "owner",
27
- type: "address",
28
- },
29
- {
30
- indexed: true,
31
- internalType: "address",
32
- name: "spender",
33
- type: "address",
34
- },
35
- {
36
- indexed: false,
37
- internalType: "uint256",
38
- name: "value",
39
- type: "uint256",
40
- },
41
- ],
42
- name: "Approval",
43
- type: "event",
44
- },
45
- {
46
- anonymous: false,
47
- inputs: [
48
- {
49
- indexed: true,
50
- internalType: "address",
51
- name: "to",
52
- type: "address",
53
- },
54
- {
55
- indexed: false,
56
- internalType: "uint256",
57
- name: "amount",
58
- type: "uint256",
59
- },
60
- {
61
- indexed: true,
62
- internalType: "uint256",
63
- name: "chainId",
64
- type: "uint256",
65
- },
66
- ],
67
- name: "Burn",
68
- type: "event",
69
- },
70
- {
71
- anonymous: false,
72
- inputs: [
73
- {
74
- indexed: true,
75
- internalType: "address",
76
- name: "to",
77
- type: "address",
78
- },
79
- {
80
- indexed: false,
81
- internalType: "uint256",
82
- name: "amount",
83
- type: "uint256",
84
- },
85
- {
86
- indexed: true,
87
- internalType: "uint256",
88
- name: "chainId",
89
- type: "uint256",
90
- },
91
- {
92
- indexed: true,
93
- internalType: "bytes32",
94
- name: "transactionHash",
95
- type: "bytes32",
96
- },
97
- ],
98
- name: "Mint",
99
- type: "event",
100
- },
101
- {
102
- anonymous: false,
103
- inputs: [
104
- {
105
- indexed: true,
106
- internalType: "address",
107
- name: "previousOwner",
108
- type: "address",
109
- },
110
- {
111
- indexed: true,
112
- internalType: "address",
113
- name: "newOwner",
114
- type: "address",
115
- },
116
- ],
117
- name: "OwnershipTransferred",
118
- type: "event",
119
- },
120
- {
121
- anonymous: false,
122
- inputs: [
123
- {
124
- indexed: true,
125
- internalType: "address",
126
- name: "from",
127
- type: "address",
128
- },
129
- {
130
- indexed: true,
131
- internalType: "address",
132
- name: "to",
133
- type: "address",
134
- },
135
- {
136
- indexed: false,
137
- internalType: "uint256",
138
- name: "value",
139
- type: "uint256",
140
- },
141
- ],
142
- name: "Transfer",
143
- type: "event",
144
- },
145
- {
146
- inputs: [
147
- {
148
- internalType: "address",
149
- name: "owner",
150
- type: "address",
151
- },
152
- {
153
- internalType: "address",
154
- name: "spender",
155
- type: "address",
156
- },
157
- ],
158
- name: "allowance",
159
- outputs: [
160
- {
161
- internalType: "uint256",
162
- name: "",
163
- type: "uint256",
164
- },
165
- ],
166
- stateMutability: "view",
167
- type: "function",
168
- },
169
- {
170
- inputs: [
171
- {
172
- internalType: "address",
173
- name: "spender",
174
- type: "address",
175
- },
176
- {
177
- internalType: "uint256",
178
- name: "amount",
179
- type: "uint256",
180
- },
181
- ],
182
- name: "approve",
183
- outputs: [
184
- {
185
- internalType: "bool",
186
- name: "",
187
- type: "bool",
188
- },
189
- ],
190
- stateMutability: "nonpayable",
191
- type: "function",
192
- },
193
- {
194
- inputs: [
195
- {
196
- internalType: "address",
197
- name: "account",
198
- type: "address",
199
- },
200
- ],
201
- name: "balanceOf",
202
- outputs: [
203
- {
204
- internalType: "uint256",
205
- name: "",
206
- type: "uint256",
207
- },
208
- ],
209
- stateMutability: "view",
210
- type: "function",
211
- },
212
- {
213
- inputs: [
214
- {
215
- internalType: "address",
216
- name: "to",
217
- type: "address",
218
- },
219
- {
220
- internalType: "uint256",
221
- name: "amount",
222
- type: "uint256",
223
- },
224
- {
225
- internalType: "uint256",
226
- name: "chainId",
227
- type: "uint256",
228
- },
229
- ],
230
- name: "burn",
231
- outputs: [],
232
- stateMutability: "nonpayable",
233
- type: "function",
234
- },
235
- {
236
- inputs: [],
237
- name: "decimals",
238
- outputs: [
239
- {
240
- internalType: "uint8",
241
- name: "",
242
- type: "uint8",
243
- },
244
- ],
245
- stateMutability: "view",
246
- type: "function",
247
- },
248
- {
249
- inputs: [
250
- {
251
- internalType: "address",
252
- name: "spender",
253
- type: "address",
254
- },
255
- {
256
- internalType: "uint256",
257
- name: "subtractedValue",
258
- type: "uint256",
259
- },
260
- ],
261
- name: "decreaseAllowance",
262
- outputs: [
263
- {
264
- internalType: "bool",
265
- name: "",
266
- type: "bool",
267
- },
268
- ],
269
- stateMutability: "nonpayable",
270
- type: "function",
271
- },
272
- {
273
- inputs: [
274
- {
275
- internalType: "address",
276
- name: "spender",
277
- type: "address",
278
- },
279
- {
280
- internalType: "uint256",
281
- name: "addedValue",
282
- type: "uint256",
283
- },
284
- ],
285
- name: "increaseAllowance",
286
- outputs: [
287
- {
288
- internalType: "bool",
289
- name: "",
290
- type: "bool",
291
- },
292
- ],
293
- stateMutability: "nonpayable",
294
- type: "function",
295
- },
296
- {
297
- inputs: [
298
- {
299
- internalType: "address",
300
- name: "to",
301
- type: "address",
302
- },
303
- {
304
- internalType: "uint256",
305
- name: "amount",
306
- type: "uint256",
307
- },
308
- {
309
- internalType: "uint256",
310
- name: "chainId",
311
- type: "uint256",
312
- },
313
- {
314
- internalType: "bytes32",
315
- name: "transactionHash",
316
- type: "bytes32",
317
- },
318
- ],
319
- name: "mint",
320
- outputs: [],
321
- stateMutability: "nonpayable",
322
- type: "function",
323
- },
324
- {
325
- inputs: [],
326
- name: "name",
327
- outputs: [
328
- {
329
- internalType: "string",
330
- name: "",
331
- type: "string",
332
- },
333
- ],
334
- stateMutability: "view",
335
- type: "function",
336
- },
337
- {
338
- inputs: [],
339
- name: "owner",
340
- outputs: [
341
- {
342
- internalType: "address",
343
- name: "",
344
- type: "address",
345
- },
346
- ],
347
- stateMutability: "view",
348
- type: "function",
349
- },
350
- {
351
- inputs: [],
352
- name: "renounceOwnership",
353
- outputs: [],
354
- stateMutability: "nonpayable",
355
- type: "function",
356
- },
357
- {
358
- inputs: [],
359
- name: "symbol",
360
- outputs: [
361
- {
362
- internalType: "string",
363
- name: "",
364
- type: "string",
365
- },
366
- ],
367
- stateMutability: "view",
368
- type: "function",
369
- },
370
- {
371
- inputs: [],
372
- name: "totalSupply",
373
- outputs: [
374
- {
375
- internalType: "uint256",
376
- name: "",
377
- type: "uint256",
378
- },
379
- ],
380
- stateMutability: "view",
381
- type: "function",
382
- },
383
- {
384
- inputs: [
385
- {
386
- internalType: "address",
387
- name: "to",
388
- type: "address",
389
- },
390
- {
391
- internalType: "uint256",
392
- name: "amount",
393
- type: "uint256",
394
- },
395
- ],
396
- name: "transfer",
397
- outputs: [
398
- {
399
- internalType: "bool",
400
- name: "",
401
- type: "bool",
402
- },
403
- ],
404
- stateMutability: "nonpayable",
405
- type: "function",
406
- },
407
- {
408
- inputs: [
409
- {
410
- internalType: "address",
411
- name: "from",
412
- type: "address",
413
- },
414
- {
415
- internalType: "address",
416
- name: "to",
417
- type: "address",
418
- },
419
- {
420
- internalType: "uint256",
421
- name: "amount",
422
- type: "uint256",
423
- },
424
- ],
425
- name: "transferFrom",
426
- outputs: [
427
- {
428
- internalType: "bool",
429
- name: "",
430
- type: "bool",
431
- },
432
- ],
433
- stateMutability: "nonpayable",
434
- type: "function",
435
- },
436
- {
437
- inputs: [
438
- {
439
- internalType: "address",
440
- name: "newOwner",
441
- type: "address",
442
- },
443
- ],
444
- name: "transferOwnership",
445
- outputs: [],
446
- stateMutability: "nonpayable",
447
- type: "function",
448
- },
449
- ];
450
- class InteropBridgeToken__factory {
451
- static createInterface() {
452
- return new ethers_1.utils.Interface(_abi);
453
- }
454
- static connect(address, signerOrProvider) {
455
- return new ethers_1.Contract(address, _abi, signerOrProvider);
456
- }
457
- }
458
- exports.InteropBridgeToken__factory = InteropBridgeToken__factory;
459
- InteropBridgeToken__factory.abi = _abi;