@instadapp/interop-x 0.0.0-dev.3e0fb42 → 0.0.0-dev.6d71015

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 (89) hide show
  1. package/.env.example +2 -1
  2. package/dist/package.json +72 -0
  3. package/dist/src/abi/erc20.json +350 -0
  4. package/dist/src/abi/gnosisSafe.json +747 -0
  5. package/dist/src/abi/index.js +15 -0
  6. package/dist/src/abi/interopBridgeToken.json +286 -0
  7. package/dist/src/abi/interopXGateway.json +184 -0
  8. package/dist/src/api/index.js +33 -0
  9. package/dist/{config → src/config}/index.js +5 -1
  10. package/dist/src/constants/addresses.js +20 -0
  11. package/dist/{constants → src/constants}/index.js +2 -0
  12. package/dist/src/constants/itokens.js +13 -0
  13. package/dist/src/constants/tokens.js +107 -0
  14. package/dist/{db → src/db}/index.js +0 -0
  15. package/dist/{db → src/db}/models/index.js +1 -1
  16. package/dist/src/db/models/transaction.js +54 -0
  17. package/dist/{db → src/db}/sequelize.js +2 -1
  18. package/dist/src/index.js +68 -0
  19. package/dist/{logger → src/logger}/index.js +0 -0
  20. package/dist/{net → src/net}/index.js +0 -0
  21. package/dist/{net → src/net}/peer/index.js +13 -5
  22. package/dist/{net → src/net}/pool/index.js +18 -11
  23. package/dist/{net → src/net}/protocol/dial/BaseDialProtocol.js +1 -1
  24. package/dist/{net → src/net}/protocol/dial/SignatureDialProtocol.js +22 -14
  25. package/dist/{net → src/net}/protocol/index.js +3 -3
  26. package/dist/{tasks → src/tasks}/BaseTask.js +3 -3
  27. package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +147 -0
  28. package/dist/src/tasks/InteropXGateway/SyncDepositEvents.js +75 -0
  29. package/dist/src/tasks/index.js +31 -0
  30. package/dist/src/typechain/Erc20.js +2 -0
  31. package/dist/src/typechain/GnosisSafe.js +2 -0
  32. package/dist/src/typechain/InteropBridgeToken.js +2 -0
  33. package/dist/src/typechain/InteropXGateway.js +2 -0
  34. package/dist/src/typechain/common.js +2 -0
  35. package/dist/src/typechain/factories/Erc20__factory.js +367 -0
  36. package/dist/src/typechain/factories/GnosisSafe__factory.js +1174 -0
  37. package/dist/src/typechain/factories/InteropBridgeToken__factory.js +459 -0
  38. package/dist/src/typechain/factories/InteropXGateway__factory.js +265 -0
  39. package/dist/src/typechain/factories/index.js +14 -0
  40. package/dist/src/typechain/index.js +35 -0
  41. package/dist/{types.js → src/types.js} +0 -0
  42. package/dist/src/utils/index.js +178 -0
  43. package/package.json +19 -6
  44. package/patches/@ethersproject+properties+5.6.0.patch +13 -0
  45. package/src/abi/erc20.json +350 -0
  46. package/src/abi/gnosisSafe.json +747 -0
  47. package/src/abi/index.ts +11 -0
  48. package/src/abi/interopBridgeToken.json +286 -0
  49. package/src/abi/interopXGateway.json +184 -0
  50. package/src/api/index.ts +33 -0
  51. package/src/config/index.ts +7 -1
  52. package/src/constants/addresses.ts +10 -3
  53. package/src/constants/index.ts +2 -0
  54. package/src/constants/itokens.ts +10 -0
  55. package/src/constants/tokens.ts +104 -0
  56. package/src/db/index.ts +1 -1
  57. package/src/db/models/index.ts +1 -1
  58. package/src/db/models/transaction.ts +96 -0
  59. package/src/db/sequelize.ts +2 -1
  60. package/src/index.ts +46 -5
  61. package/src/net/peer/index.ts +15 -8
  62. package/src/net/pool/index.ts +22 -12
  63. package/src/net/protocol/dial/BaseDialProtocol.ts +1 -1
  64. package/src/net/protocol/dial/SignatureDialProtocol.ts +26 -17
  65. package/src/net/protocol/index.ts +4 -4
  66. package/src/tasks/BaseTask.ts +3 -4
  67. package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +241 -0
  68. package/src/tasks/InteropXGateway/SyncDepositEvents.ts +126 -0
  69. package/src/tasks/index.ts +9 -1
  70. package/src/typechain/Erc20.ts +491 -0
  71. package/src/typechain/GnosisSafe.ts +1728 -0
  72. package/src/typechain/InteropBridgeToken.ts +686 -0
  73. package/src/typechain/InteropXGateway.ts +407 -0
  74. package/src/typechain/common.ts +44 -0
  75. package/src/typechain/factories/Erc20__factory.ts +368 -0
  76. package/src/typechain/factories/GnosisSafe__factory.ts +1178 -0
  77. package/src/typechain/factories/InteropBridgeToken__factory.ts +466 -0
  78. package/src/typechain/factories/InteropXGateway__factory.ts +272 -0
  79. package/src/typechain/factories/index.ts +7 -0
  80. package/src/typechain/index.ts +12 -0
  81. package/src/types.ts +2 -2
  82. package/src/utils/index.ts +124 -2
  83. package/tsconfig.json +3 -0
  84. package/dist/constants/addresses.js +0 -13
  85. package/dist/db/models/execution.js +0 -38
  86. package/dist/index.js +0 -34
  87. package/dist/tasks/index.js +0 -19
  88. package/dist/utils/index.js +0 -89
  89. package/src/db/models/execution.ts +0 -57
@@ -0,0 +1,75 @@
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(`Execution 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;
@@ -0,0 +1,31 @@
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
+ exports.Tasks = void 0;
7
+ const ProcessDepositEvents_1 = __importDefault(require("./InteropXGateway/ProcessDepositEvents"));
8
+ const SyncDepositEvents_1 = __importDefault(require("./InteropXGateway/SyncDepositEvents"));
9
+ class Tasks {
10
+ constructor() {
11
+ this.tasks = [
12
+ new SyncDepositEvents_1.default({
13
+ chainId: 43114
14
+ }),
15
+ new ProcessDepositEvents_1.default({
16
+ chainId: 43114
17
+ })
18
+ ];
19
+ }
20
+ async start() {
21
+ for (const task of this.tasks) {
22
+ try {
23
+ task.start();
24
+ }
25
+ catch (error) {
26
+ console.error(`Error starting task: ${task.constructor.name}`);
27
+ }
28
+ }
29
+ }
30
+ }
31
+ exports.Tasks = Tasks;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,367 @@
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.Erc20__factory = void 0;
7
+ const ethers_1 = require("ethers");
8
+ const _abi = [
9
+ {
10
+ inputs: [
11
+ {
12
+ internalType: "uint256",
13
+ name: "_totalSupply",
14
+ type: "uint256",
15
+ },
16
+ ],
17
+ payable: false,
18
+ stateMutability: "nonpayable",
19
+ type: "constructor",
20
+ },
21
+ {
22
+ anonymous: false,
23
+ inputs: [
24
+ {
25
+ indexed: true,
26
+ internalType: "address",
27
+ name: "owner",
28
+ type: "address",
29
+ },
30
+ {
31
+ indexed: true,
32
+ internalType: "address",
33
+ name: "spender",
34
+ type: "address",
35
+ },
36
+ {
37
+ indexed: false,
38
+ internalType: "uint256",
39
+ name: "value",
40
+ type: "uint256",
41
+ },
42
+ ],
43
+ name: "Approval",
44
+ type: "event",
45
+ },
46
+ {
47
+ anonymous: false,
48
+ inputs: [
49
+ {
50
+ indexed: true,
51
+ internalType: "address",
52
+ name: "from",
53
+ type: "address",
54
+ },
55
+ {
56
+ indexed: true,
57
+ internalType: "address",
58
+ name: "to",
59
+ type: "address",
60
+ },
61
+ {
62
+ indexed: false,
63
+ internalType: "uint256",
64
+ name: "value",
65
+ type: "uint256",
66
+ },
67
+ ],
68
+ name: "Transfer",
69
+ type: "event",
70
+ },
71
+ {
72
+ constant: true,
73
+ inputs: [],
74
+ name: "DOMAIN_SEPARATOR",
75
+ outputs: [
76
+ {
77
+ internalType: "bytes32",
78
+ name: "",
79
+ type: "bytes32",
80
+ },
81
+ ],
82
+ payable: false,
83
+ stateMutability: "view",
84
+ type: "function",
85
+ },
86
+ {
87
+ constant: true,
88
+ inputs: [],
89
+ name: "PERMIT_TYPEHASH",
90
+ outputs: [
91
+ {
92
+ internalType: "bytes32",
93
+ name: "",
94
+ type: "bytes32",
95
+ },
96
+ ],
97
+ payable: false,
98
+ stateMutability: "view",
99
+ type: "function",
100
+ },
101
+ {
102
+ constant: true,
103
+ inputs: [
104
+ {
105
+ internalType: "address",
106
+ name: "",
107
+ type: "address",
108
+ },
109
+ {
110
+ internalType: "address",
111
+ name: "",
112
+ type: "address",
113
+ },
114
+ ],
115
+ name: "allowance",
116
+ outputs: [
117
+ {
118
+ internalType: "uint256",
119
+ name: "",
120
+ type: "uint256",
121
+ },
122
+ ],
123
+ payable: false,
124
+ stateMutability: "view",
125
+ type: "function",
126
+ },
127
+ {
128
+ constant: false,
129
+ inputs: [
130
+ {
131
+ internalType: "address",
132
+ name: "spender",
133
+ type: "address",
134
+ },
135
+ {
136
+ internalType: "uint256",
137
+ name: "value",
138
+ type: "uint256",
139
+ },
140
+ ],
141
+ name: "approve",
142
+ outputs: [
143
+ {
144
+ internalType: "bool",
145
+ name: "",
146
+ type: "bool",
147
+ },
148
+ ],
149
+ payable: false,
150
+ stateMutability: "nonpayable",
151
+ type: "function",
152
+ },
153
+ {
154
+ constant: true,
155
+ inputs: [
156
+ {
157
+ internalType: "address",
158
+ name: "",
159
+ type: "address",
160
+ },
161
+ ],
162
+ name: "balanceOf",
163
+ outputs: [
164
+ {
165
+ internalType: "uint256",
166
+ name: "",
167
+ type: "uint256",
168
+ },
169
+ ],
170
+ payable: false,
171
+ stateMutability: "view",
172
+ type: "function",
173
+ },
174
+ {
175
+ constant: true,
176
+ inputs: [],
177
+ name: "decimals",
178
+ outputs: [
179
+ {
180
+ internalType: "uint8",
181
+ name: "",
182
+ type: "uint8",
183
+ },
184
+ ],
185
+ payable: false,
186
+ stateMutability: "view",
187
+ type: "function",
188
+ },
189
+ {
190
+ constant: true,
191
+ inputs: [],
192
+ name: "name",
193
+ outputs: [
194
+ {
195
+ internalType: "string",
196
+ name: "",
197
+ type: "string",
198
+ },
199
+ ],
200
+ payable: false,
201
+ stateMutability: "view",
202
+ type: "function",
203
+ },
204
+ {
205
+ constant: true,
206
+ inputs: [
207
+ {
208
+ internalType: "address",
209
+ name: "",
210
+ type: "address",
211
+ },
212
+ ],
213
+ name: "nonces",
214
+ outputs: [
215
+ {
216
+ internalType: "uint256",
217
+ name: "",
218
+ type: "uint256",
219
+ },
220
+ ],
221
+ payable: false,
222
+ stateMutability: "view",
223
+ type: "function",
224
+ },
225
+ {
226
+ constant: false,
227
+ inputs: [
228
+ {
229
+ internalType: "address",
230
+ name: "owner",
231
+ type: "address",
232
+ },
233
+ {
234
+ internalType: "address",
235
+ name: "spender",
236
+ type: "address",
237
+ },
238
+ {
239
+ internalType: "uint256",
240
+ name: "value",
241
+ type: "uint256",
242
+ },
243
+ {
244
+ internalType: "uint256",
245
+ name: "deadline",
246
+ type: "uint256",
247
+ },
248
+ {
249
+ internalType: "uint8",
250
+ name: "v",
251
+ type: "uint8",
252
+ },
253
+ {
254
+ internalType: "bytes32",
255
+ name: "r",
256
+ type: "bytes32",
257
+ },
258
+ {
259
+ internalType: "bytes32",
260
+ name: "s",
261
+ type: "bytes32",
262
+ },
263
+ ],
264
+ name: "permit",
265
+ outputs: [],
266
+ payable: false,
267
+ stateMutability: "nonpayable",
268
+ type: "function",
269
+ },
270
+ {
271
+ constant: true,
272
+ inputs: [],
273
+ name: "symbol",
274
+ outputs: [
275
+ {
276
+ internalType: "string",
277
+ name: "",
278
+ type: "string",
279
+ },
280
+ ],
281
+ payable: false,
282
+ stateMutability: "view",
283
+ type: "function",
284
+ },
285
+ {
286
+ constant: true,
287
+ inputs: [],
288
+ name: "totalSupply",
289
+ outputs: [
290
+ {
291
+ internalType: "uint256",
292
+ name: "",
293
+ type: "uint256",
294
+ },
295
+ ],
296
+ payable: false,
297
+ stateMutability: "view",
298
+ type: "function",
299
+ },
300
+ {
301
+ constant: false,
302
+ inputs: [
303
+ {
304
+ internalType: "address",
305
+ name: "to",
306
+ type: "address",
307
+ },
308
+ {
309
+ internalType: "uint256",
310
+ name: "value",
311
+ type: "uint256",
312
+ },
313
+ ],
314
+ name: "transfer",
315
+ outputs: [
316
+ {
317
+ internalType: "bool",
318
+ name: "",
319
+ type: "bool",
320
+ },
321
+ ],
322
+ payable: false,
323
+ stateMutability: "nonpayable",
324
+ type: "function",
325
+ },
326
+ {
327
+ constant: false,
328
+ inputs: [
329
+ {
330
+ internalType: "address",
331
+ name: "from",
332
+ type: "address",
333
+ },
334
+ {
335
+ internalType: "address",
336
+ name: "to",
337
+ type: "address",
338
+ },
339
+ {
340
+ internalType: "uint256",
341
+ name: "value",
342
+ type: "uint256",
343
+ },
344
+ ],
345
+ name: "transferFrom",
346
+ outputs: [
347
+ {
348
+ internalType: "bool",
349
+ name: "",
350
+ type: "bool",
351
+ },
352
+ ],
353
+ payable: false,
354
+ stateMutability: "nonpayable",
355
+ type: "function",
356
+ },
357
+ ];
358
+ class Erc20__factory {
359
+ static createInterface() {
360
+ return new ethers_1.utils.Interface(_abi);
361
+ }
362
+ static connect(address, signerOrProvider) {
363
+ return new ethers_1.Contract(address, _abi, signerOrProvider);
364
+ }
365
+ }
366
+ exports.Erc20__factory = Erc20__factory;
367
+ Erc20__factory.abi = _abi;