@instadapp/interop-x 0.0.0-dev.2c0a756 → 0.0.0-dev.30b0db0

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 (48) hide show
  1. package/dist/package.json +2 -2
  2. package/dist/src/abi/interopBridgeToken.json +9 -21
  3. package/dist/src/abi/interopXGateway.json +11 -11
  4. package/dist/src/api/index.js +1 -1
  5. package/dist/src/config/index.js +1 -10
  6. package/dist/src/constants/addresses.js +1 -1
  7. package/dist/src/constants/itokens.js +1 -1
  8. package/dist/src/index.js +5 -28
  9. package/dist/src/net/peer/index.js +1 -2
  10. package/dist/src/net/pool/index.js +2 -3
  11. package/dist/src/net/protocol/dial/{TransactionStatusDialProtocol.js → SignatureDialProtocol.1.js} +0 -0
  12. package/dist/src/net/protocol/index.js +6 -6
  13. package/dist/src/tasks/AutoUpdateTask.js +11 -33
  14. package/dist/src/tasks/BaseTask.js +0 -4
  15. package/dist/src/tasks/InteropBridge/{SyncBurnEvents.js → SyncWithdrawEvents.js} +8 -10
  16. package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +1 -14
  17. package/dist/src/tasks/InteropXGateway/SyncDepositEvents.js +2 -2
  18. package/dist/src/tasks/index.js +5 -17
  19. package/dist/src/typechain/factories/InteropBridgeToken__factory.js +11 -23
  20. package/dist/src/typechain/factories/InteropXGateway__factory.js +14 -14
  21. package/dist/src/utils/index.js +7 -7
  22. package/package.json +2 -2
  23. package/src/abi/interopBridgeToken.json +9 -21
  24. package/src/abi/interopXGateway.json +11 -11
  25. package/src/api/index.ts +1 -1
  26. package/src/config/index.ts +1 -9
  27. package/src/constants/addresses.ts +1 -1
  28. package/src/constants/itokens.ts +1 -1
  29. package/src/index.ts +9 -41
  30. package/src/net/peer/index.ts +1 -2
  31. package/src/net/pool/index.ts +2 -3
  32. package/src/net/protocol/dial/{TransactionStatusDialProtocol.ts → SignatureDialProtocol.1.ts} +0 -0
  33. package/src/net/protocol/index.ts +5 -5
  34. package/src/tasks/AutoUpdateTask.ts +14 -36
  35. package/src/tasks/BaseTask.ts +0 -5
  36. package/src/tasks/InteropBridge/{SyncBurnEvents.ts → SyncWithdrawEvents.ts} +8 -10
  37. package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +4 -18
  38. package/src/tasks/InteropXGateway/SyncDepositEvents.ts +2 -2
  39. package/src/tasks/index.ts +4 -24
  40. package/src/typechain/InteropBridgeToken.ts +17 -23
  41. package/src/typechain/InteropXGateway.ts +13 -13
  42. package/src/typechain/factories/InteropBridgeToken__factory.ts +11 -23
  43. package/src/typechain/factories/InteropXGateway__factory.ts +14 -14
  44. package/src/utils/index.ts +7 -7
  45. package/dist/src/tasks/InteropBridge/SyncMintEvents.js +0 -66
  46. package/dist/src/tasks/InteropXGateway/SyncWithdrawtEvents.js +0 -71
  47. package/src/tasks/InteropBridge/SyncMintEvents.ts +0 -98
  48. package/src/tasks/InteropXGateway/SyncWithdrawtEvents.ts +0 -103
@@ -46,11 +46,6 @@ export class BaseTask extends EventEmitter implements IBaseTask {
46
46
  }
47
47
 
48
48
  prePollHandler(): boolean {
49
- if(config.isMaintenanceMode()){
50
- this.logger.warn('Maintenance mode is enabled. Skipping task.')
51
- return false
52
- }
53
-
54
49
  if (this.exceptLeadNode) {
55
50
  return !config.isLeadNode();
56
51
  }
@@ -8,7 +8,7 @@ import { ChainId } from "@/types";
8
8
  import config from "@/config";
9
9
  import { InteropBridgeToken } from "@/typechain";
10
10
 
11
- class SyncBurnEvents extends BaseTask {
11
+ class SyncWithdrawEvents extends BaseTask {
12
12
  contractAddress: string;
13
13
  provider: ethers.providers.JsonRpcProvider;
14
14
  contract: InteropBridgeToken;
@@ -17,7 +17,7 @@ class SyncBurnEvents extends BaseTask {
17
17
 
18
18
  constructor({ chainId, itokenAddress }: { chainId: ChainId, itokenAddress: string }) {
19
19
  super({
20
- logger: new Logger("InteropBridgeToken::SyncBurnEvents"),
20
+ logger: new Logger("InteropBridgeToken::SyncWithdrawEvents"),
21
21
  })
22
22
  this.chainId = chainId;
23
23
  this.itokenAddress = itokenAddress;
@@ -41,13 +41,13 @@ class SyncBurnEvents extends BaseTask {
41
41
  continue;
42
42
  }
43
43
 
44
- const { to, amount, sourceChainId, targetChainId } = event.args;
44
+ const { to, amount, chainId } = event.args;
45
45
 
46
46
  const uniqueIdentifier = {
47
47
  action: 'withdraw',
48
48
  submitTransactionHash: event.transactionHash,
49
- sourceChainId: sourceChainId,
50
- targetChainId: targetChainId,
49
+ sourceChainId:this.chainId,
50
+ targetChainId: chainId.toNumber(),
51
51
  }
52
52
 
53
53
  if (await Transaction.findOne({ where: uniqueIdentifier })) {
@@ -77,16 +77,14 @@ class SyncBurnEvents extends BaseTask {
77
77
  to,
78
78
  amount: amount.toString(),
79
79
  itoken: this.itokenAddress,
80
- sourceChainId: sourceChainId,
81
- targetChainId: targetChainId,
80
+ chainId: chainId.toString()
82
81
  },
83
82
 
84
83
  sourceEvent: {
85
84
  to,
86
85
  amount: amount.toString(),
87
86
  itoken: this.itokenAddress,
88
- sourceChainId: sourceChainId,
89
- targetChainId: targetChainId,
87
+ chainId: chainId.toString(),
90
88
  },
91
89
  status: "pending",
92
90
  })
@@ -118,4 +116,4 @@ class SyncBurnEvents extends BaseTask {
118
116
  }
119
117
  }
120
118
 
121
- export default SyncBurnEvents;
119
+ export default SyncWithdrawEvents;
@@ -15,7 +15,7 @@ import { LogDescription } from "ethers/lib/utils";
15
15
 
16
16
  const generateGnosisTransaction = async (transactionData: any, safeContract: GnosisSafe) => {
17
17
  console.log(transactionData);
18
-
18
+
19
19
  let isExecuted = await safeContract.dataHashes(
20
20
  await safeContract.getTransactionHash(
21
21
  transactionData.to,
@@ -97,7 +97,7 @@ class ProcessDepositEvents extends BaseTask {
97
97
  }
98
98
 
99
99
  console.log(`Processing transaction ${transaction.transactionHash}`);
100
-
100
+
101
101
  transaction.targetStatus = 'pending';
102
102
  await transaction.save();
103
103
 
@@ -121,23 +121,9 @@ class ProcessDepositEvents extends BaseTask {
121
121
  const ownersThreshold = await safeContract.getThreshold();
122
122
  await wait(10000);
123
123
 
124
- let data;
125
-
126
- try {
127
- data = await buildDataForTransaction(transaction);
128
- } catch (error) {
129
- console.log(error);
130
- transaction.targetStatus = 'failed';
131
- transaction.targetErrors = [error.message];
132
- transaction.status = 'failed'
133
- await transaction.save();
134
- protocol.sendTransaction(transaction)
135
- return;
136
- }
137
-
138
124
  let gnosisTx = await generateGnosisTransaction({
139
125
  baseGas: "0",
140
- data,
126
+ data: await buildDataForTransaction(transaction),
141
127
  gasPrice: "0",
142
128
  gasToken: "0x0000000000000000000000000000000000000000",
143
129
  nonce: '0',
@@ -156,7 +142,7 @@ class ProcessDepositEvents extends BaseTask {
156
142
  console.log(`Collecting signatures for execution ${transaction.transactionHash}`)
157
143
 
158
144
  console.log(ownerPeerIds);
159
-
145
+
160
146
  const signatures = await protocol.requestSignatures({
161
147
  type: 'source',
162
148
  transactionHash: transaction.transactionHash,
@@ -45,8 +45,8 @@ class SyncDepositEvents extends BaseTask {
45
45
  const uniqueIdentifier = {
46
46
  action: 'deposit',
47
47
  submitTransactionHash: event.transactionHash,
48
- sourceChainId: sourceChainId,
49
- targetChainId: targetChainId,
48
+ sourceChainId: sourceChainId.toNumber(),
49
+ targetChainId: targetChainId.toNumber(),
50
50
  }
51
51
 
52
52
  if (await Transaction.findOne({ where: uniqueIdentifier })) {
@@ -1,15 +1,11 @@
1
1
  import { BaseTask } from "./BaseTask";
2
2
  import InteropXGatewayProcessDepositEvents from "./InteropXGateway/ProcessDepositEvents";
3
3
  import InteropXGatewaySyncDepositEvents from "./InteropXGateway/SyncDepositEvents";
4
- import InteropXGatewaySyncWithdrawEvents from "./InteropXGateway/SyncWithdrawtEvents";
5
-
6
- import InteropBridgeSyncWithdrawEvents from "./InteropBridge/SyncBurnEvents";
7
- import InteropBridgeSyncBurnEvents from "./InteropBridge/SyncBurnEvents";
8
- import InteropBridgeSyncMintEvents from "./InteropBridge/SyncMintEvents";
9
-
10
- import SyncTransactionStatusTask from "./Transactions/SyncTransactionStatusTask";
11
4
 
5
+ import InteropBridgeSyncWithdrawEvents from "./InteropBridge/SyncWithdrawEvents";
6
+ import InteropBridgeProcessWithdrawEvents from "./InteropBridge/ProcessWithdrawEvents";
12
7
  import AutoUpdateTask from "./AutoUpdateTask";
8
+ import SyncTransactionStatusTask from "./Transactions/SyncTransactionStatusTask";
13
9
 
14
10
  export class Tasks {
15
11
 
@@ -17,8 +13,6 @@ export class Tasks {
17
13
  new SyncTransactionStatusTask(),
18
14
  new AutoUpdateTask(),
19
15
 
20
- // InteropXGateway
21
-
22
16
  new InteropXGatewaySyncDepositEvents({
23
17
  chainId: 43114
24
18
  }),
@@ -27,27 +21,13 @@ export class Tasks {
27
21
  chainId: 43114
28
22
  }),
29
23
 
30
-
31
- new InteropXGatewaySyncWithdrawEvents({
32
- chainId: 43114
33
- }),
34
-
35
-
36
- // InteropBridge
37
-
38
24
  new InteropBridgeSyncWithdrawEvents({
39
25
  chainId: 137,
40
26
  itokenAddress: '0xEab02fe1F016eE3e4106c1C6aad35FeEe657268E',
41
27
  }),
42
28
 
43
- new InteropBridgeSyncMintEvents({
44
- chainId: 137,
45
- itokenAddress: '0xEab02fe1F016eE3e4106c1C6aad35FeEe657268E',
46
- }),
47
-
48
- new InteropBridgeSyncBurnEvents({
29
+ new InteropBridgeProcessWithdrawEvents({
49
30
  chainId: 137,
50
- itokenAddress: '0xEab02fe1F016eE3e4106c1C6aad35FeEe657268E',
51
31
  })
52
32
  ];
53
33
 
@@ -31,11 +31,11 @@ export interface InteropBridgeTokenInterface extends utils.Interface {
31
31
  "allowance(address,address)": FunctionFragment;
32
32
  "approve(address,uint256)": FunctionFragment;
33
33
  "balanceOf(address)": FunctionFragment;
34
- "burn(address,uint256,uint32)": FunctionFragment;
34
+ "burn(address,uint256,uint256)": FunctionFragment;
35
35
  "decimals()": FunctionFragment;
36
36
  "decreaseAllowance(address,uint256)": FunctionFragment;
37
37
  "increaseAllowance(address,uint256)": FunctionFragment;
38
- "mint(address,uint256,uint32,bytes32)": FunctionFragment;
38
+ "mint(address,uint256,uint256,bytes32)": FunctionFragment;
39
39
  "name()": FunctionFragment;
40
40
  "owner()": FunctionFragment;
41
41
  "renounceOwnership()": FunctionFragment;
@@ -153,8 +153,8 @@ export interface InteropBridgeTokenInterface extends utils.Interface {
153
153
 
154
154
  events: {
155
155
  "Approval(address,address,uint256)": EventFragment;
156
- "Burn(address,uint256,uint32,uint32)": EventFragment;
157
- "Mint(address,uint256,uint32,uint32,bytes32)": EventFragment;
156
+ "Burn(address,uint256,uint256)": EventFragment;
157
+ "Mint(address,uint256,uint256,bytes32)": EventFragment;
158
158
  "OwnershipTransferred(address,address)": EventFragment;
159
159
  "Transfer(address,address,uint256)": EventFragment;
160
160
  };
@@ -181,11 +181,10 @@ export type ApprovalEventFilter = TypedEventFilter<ApprovalEvent>;
181
181
  export interface BurnEventObject {
182
182
  to: string;
183
183
  amount: BigNumber;
184
- sourceChainId: number;
185
- targetChainId: number;
184
+ chainId: BigNumber;
186
185
  }
187
186
  export type BurnEvent = TypedEvent<
188
- [string, BigNumber, number, number],
187
+ [string, BigNumber, BigNumber],
189
188
  BurnEventObject
190
189
  >;
191
190
 
@@ -194,12 +193,11 @@ export type BurnEventFilter = TypedEventFilter<BurnEvent>;
194
193
  export interface MintEventObject {
195
194
  to: string;
196
195
  amount: BigNumber;
197
- sourceChainId: number;
198
- targetChainId: number;
199
- submitTransactionHash: string;
196
+ chainId: BigNumber;
197
+ transactionHash: string;
200
198
  }
201
199
  export type MintEvent = TypedEvent<
202
- [string, BigNumber, number, number, string],
200
+ [string, BigNumber, BigNumber, string],
203
201
  MintEventObject
204
202
  >;
205
203
 
@@ -488,32 +486,28 @@ export interface InteropBridgeToken extends BaseContract {
488
486
  value?: null
489
487
  ): ApprovalEventFilter;
490
488
 
491
- "Burn(address,uint256,uint32,uint32)"(
489
+ "Burn(address,uint256,uint256)"(
492
490
  to?: string | null,
493
491
  amount?: null,
494
- sourceChainId?: null,
495
- targetChainId?: BigNumberish | null
492
+ chainId?: BigNumberish | null
496
493
  ): BurnEventFilter;
497
494
  Burn(
498
495
  to?: string | null,
499
496
  amount?: null,
500
- sourceChainId?: null,
501
- targetChainId?: BigNumberish | null
497
+ chainId?: BigNumberish | null
502
498
  ): BurnEventFilter;
503
499
 
504
- "Mint(address,uint256,uint32,uint32,bytes32)"(
500
+ "Mint(address,uint256,uint256,bytes32)"(
505
501
  to?: string | null,
506
502
  amount?: null,
507
- sourceChainId?: BigNumberish | null,
508
- targetChainId?: null,
509
- submitTransactionHash?: BytesLike | null
503
+ chainId?: BigNumberish | null,
504
+ transactionHash?: BytesLike | null
510
505
  ): MintEventFilter;
511
506
  Mint(
512
507
  to?: string | null,
513
508
  amount?: null,
514
- sourceChainId?: BigNumberish | null,
515
- targetChainId?: null,
516
- submitTransactionHash?: BytesLike | null
509
+ chainId?: BigNumberish | null,
510
+ transactionHash?: BytesLike | null
517
511
  ): MintEventFilter;
518
512
 
519
513
  "OwnershipTransferred(address,address)"(
@@ -29,11 +29,11 @@ import type {
29
29
  export interface InteropXGatewayInterface extends utils.Interface {
30
30
  functions: {
31
31
  "_vnonce()": FunctionFragment;
32
- "deposit(address,uint256,uint32)": FunctionFragment;
33
- "depositFor(address,address,uint256,uint32)": FunctionFragment;
32
+ "deposit(address,uint256,uint256)": FunctionFragment;
33
+ "depositFor(address,address,uint256,uint256)": FunctionFragment;
34
34
  "owner()": FunctionFragment;
35
35
  "renounceOwnership()": FunctionFragment;
36
- "systemWithdraw(uint256,address,address,uint32,bytes32)": FunctionFragment;
36
+ "systemWithdraw(uint256,address,address,uint256,bytes32)": FunctionFragment;
37
37
  "transferOwnership(address)": FunctionFragment;
38
38
  };
39
39
 
@@ -89,8 +89,8 @@ export interface InteropXGatewayInterface extends utils.Interface {
89
89
  ): Result;
90
90
 
91
91
  events: {
92
- "LogGatewayDeposit(address,address,uint256,uint256,uint32,uint32)": EventFragment;
93
- "LogGatewayWithdraw(address,address,uint256,uint32,uint32,bytes32)": EventFragment;
92
+ "LogGatewayDeposit(address,address,uint256,uint256,uint256,uint256)": EventFragment;
93
+ "LogGatewayWithdraw(address,address,uint256,uint256,uint256,bytes32)": EventFragment;
94
94
  "OwnershipTransferred(address,address)": EventFragment;
95
95
  };
96
96
 
@@ -104,11 +104,11 @@ export interface LogGatewayDepositEventObject {
104
104
  token: string;
105
105
  amount: BigNumber;
106
106
  vnonce: BigNumber;
107
- sourceChainId: number;
108
- targetChainId: number;
107
+ sourceChainId: BigNumber;
108
+ targetChainId: BigNumber;
109
109
  }
110
110
  export type LogGatewayDepositEvent = TypedEvent<
111
- [string, string, BigNumber, BigNumber, number, number],
111
+ [string, string, BigNumber, BigNumber, BigNumber, BigNumber],
112
112
  LogGatewayDepositEventObject
113
113
  >;
114
114
 
@@ -119,12 +119,12 @@ export interface LogGatewayWithdrawEventObject {
119
119
  user: string;
120
120
  token: string;
121
121
  amount: BigNumber;
122
- sourceChainId: number;
123
- targetChainId: number;
122
+ sourceChainId: BigNumber;
123
+ targetChainId: BigNumber;
124
124
  transactionHash: string;
125
125
  }
126
126
  export type LogGatewayWithdrawEvent = TypedEvent<
127
- [string, string, BigNumber, number, number, string],
127
+ [string, string, BigNumber, BigNumber, BigNumber, string],
128
128
  LogGatewayWithdrawEventObject
129
129
  >;
130
130
 
@@ -283,7 +283,7 @@ export interface InteropXGateway extends BaseContract {
283
283
  };
284
284
 
285
285
  filters: {
286
- "LogGatewayDeposit(address,address,uint256,uint256,uint32,uint32)"(
286
+ "LogGatewayDeposit(address,address,uint256,uint256,uint256,uint256)"(
287
287
  user?: null,
288
288
  token?: string | null,
289
289
  amount?: null,
@@ -300,7 +300,7 @@ export interface InteropXGateway extends BaseContract {
300
300
  targetChainId?: BigNumberish | null
301
301
  ): LogGatewayDepositEventFilter;
302
302
 
303
- "LogGatewayWithdraw(address,address,uint256,uint32,uint32,bytes32)"(
303
+ "LogGatewayWithdraw(address,address,uint256,uint256,uint256,bytes32)"(
304
304
  user?: null,
305
305
  token?: string | null,
306
306
  amount?: null,
@@ -61,17 +61,11 @@ const _abi = [
61
61
  name: "amount",
62
62
  type: "uint256",
63
63
  },
64
- {
65
- indexed: false,
66
- internalType: "uint32",
67
- name: "sourceChainId",
68
- type: "uint32",
69
- },
70
64
  {
71
65
  indexed: true,
72
- internalType: "uint32",
73
- name: "targetChainId",
74
- type: "uint32",
66
+ internalType: "uint256",
67
+ name: "chainId",
68
+ type: "uint256",
75
69
  },
76
70
  ],
77
71
  name: "Burn",
@@ -94,20 +88,14 @@ const _abi = [
94
88
  },
95
89
  {
96
90
  indexed: true,
97
- internalType: "uint32",
98
- name: "sourceChainId",
99
- type: "uint32",
100
- },
101
- {
102
- indexed: false,
103
- internalType: "uint32",
104
- name: "targetChainId",
105
- type: "uint32",
91
+ internalType: "uint256",
92
+ name: "chainId",
93
+ type: "uint256",
106
94
  },
107
95
  {
108
96
  indexed: true,
109
97
  internalType: "bytes32",
110
- name: "submitTransactionHash",
98
+ name: "transactionHash",
111
99
  type: "bytes32",
112
100
  },
113
101
  ],
@@ -238,9 +226,9 @@ const _abi = [
238
226
  type: "uint256",
239
227
  },
240
228
  {
241
- internalType: "uint32",
229
+ internalType: "uint256",
242
230
  name: "chainId",
243
- type: "uint32",
231
+ type: "uint256",
244
232
  },
245
233
  ],
246
234
  name: "burn",
@@ -322,9 +310,9 @@ const _abi = [
322
310
  type: "uint256",
323
311
  },
324
312
  {
325
- internalType: "uint32",
313
+ internalType: "uint256",
326
314
  name: "chainId",
327
- type: "uint32",
315
+ type: "uint256",
328
316
  },
329
317
  {
330
318
  internalType: "bytes32",
@@ -50,15 +50,15 @@ const _abi = [
50
50
  },
51
51
  {
52
52
  indexed: false,
53
- internalType: "uint32",
53
+ internalType: "uint256",
54
54
  name: "sourceChainId",
55
- type: "uint32",
55
+ type: "uint256",
56
56
  },
57
57
  {
58
58
  indexed: true,
59
- internalType: "uint32",
59
+ internalType: "uint256",
60
60
  name: "targetChainId",
61
- type: "uint32",
61
+ type: "uint256",
62
62
  },
63
63
  ],
64
64
  name: "LogGatewayDeposit",
@@ -87,15 +87,15 @@ const _abi = [
87
87
  },
88
88
  {
89
89
  indexed: true,
90
- internalType: "uint32",
90
+ internalType: "uint256",
91
91
  name: "sourceChainId",
92
- type: "uint32",
92
+ type: "uint256",
93
93
  },
94
94
  {
95
95
  indexed: false,
96
- internalType: "uint32",
96
+ internalType: "uint256",
97
97
  name: "targetChainId",
98
- type: "uint32",
98
+ type: "uint256",
99
99
  },
100
100
  {
101
101
  indexed: true,
@@ -152,9 +152,9 @@ const _abi = [
152
152
  type: "uint256",
153
153
  },
154
154
  {
155
- internalType: "uint32",
155
+ internalType: "uint256",
156
156
  name: "chainId_",
157
- type: "uint32",
157
+ type: "uint256",
158
158
  },
159
159
  ],
160
160
  name: "deposit",
@@ -180,9 +180,9 @@ const _abi = [
180
180
  type: "uint256",
181
181
  },
182
182
  {
183
- internalType: "uint32",
183
+ internalType: "uint256",
184
184
  name: "chainId_",
185
- type: "uint32",
185
+ type: "uint256",
186
186
  },
187
187
  ],
188
188
  name: "depositFor",
@@ -228,9 +228,9 @@ const _abi = [
228
228
  type: "address",
229
229
  },
230
230
  {
231
- internalType: "uint32",
231
+ internalType: "uint256",
232
232
  name: "chainId_",
233
- type: "uint32",
233
+ type: "uint256",
234
234
  },
235
235
  {
236
236
  internalType: "bytes32",
@@ -24,7 +24,7 @@ export function shortenHash(hash: string, length: number = 4) {
24
24
 
25
25
  const beginningChars = hash.startsWith("0x") ? length + 2 : length;
26
26
 
27
- const shortened = hash.substr(0, beginningChars) + "…" + hash.substr(-length);
27
+ const shortened = hash.substring(0, beginningChars) + "…" + hash.substring(-length);
28
28
 
29
29
  return shortened;
30
30
  }
@@ -222,30 +222,30 @@ export const buildWithdrawDataForTransaction = async (transaction: Transaction,
222
222
  throw Error('Cannot build data for transaction without submitEvent');
223
223
  }
224
224
 
225
- const { to, amount, sourceChainId, targetChainId, itoken: itokenAddress } = transaction.submitEvent;
225
+ const { to, amount, chainId, itoken: itokenAddress } = transaction.submitEvent;
226
226
 
227
- const itoken = itokens[sourceChainId].find(token => token.address.toLowerCase() === itokenAddress.toLowerCase());
227
+ const itoken = itokens[transaction.sourceChainId].find(token => token.address.toLowerCase() === itokenAddress.toLowerCase());
228
228
 
229
229
  if (!itoken) {
230
230
  throw Error('Cannot build data for transaction without itoken');
231
231
  }
232
232
 
233
- const token = tokens[targetChainId].find(t => t.symbol.toLowerCase() === itoken.symbol.toLowerCase());
233
+ const token = tokens[chainId].find(t => t.symbol.toLowerCase() === itoken.symbol.toLowerCase());
234
234
 
235
235
  if (!token) {
236
236
  throw Error('Cannot build data for transaction without token');
237
237
  }
238
238
 
239
- const targetChainProvider = new ethers.providers.JsonRpcProvider(getRpcProviderUrl(targetChainId as ChainId));
239
+ const targetChainProvider = new ethers.providers.JsonRpcProvider(getRpcProviderUrl(transaction.targetChainId as ChainId));
240
240
  const targetWallet = new ethers.Wallet(config.privateKey, targetChainProvider);
241
- const gatewayAddress = addresses[targetChainId].interopXGateway;
241
+ const gatewayAddress = addresses[chainId].interopXGateway;
242
242
  const interopBridgeContract = getContract<InteropXGateway>(gatewayAddress, abi.interopXGateway, targetWallet);
243
243
 
244
244
  const { data } = await interopBridgeContract.populateTransaction.systemWithdraw(
245
245
  ethers.BigNumber.from(amount.toString()),
246
246
  to,
247
247
  token.address,
248
- ethers.BigNumber.from(sourceChainId.toString()),
248
+ ethers.BigNumber.from(transaction.sourceChainId.toString()),
249
249
  transaction.submitTransactionHash,
250
250
  );
251
251
 
@@ -1,66 +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 SyncMintEvents extends BaseTask_1.BaseTask {
14
- constructor({ chainId, itokenAddress }) {
15
- super({
16
- logger: new logger_1.default("InteropBridgeToken::SyncMintEvents"),
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.Mint(), currentBlock - 300, currentBlock);
24
- for (const event of events) {
25
- try {
26
- if (!event.args) {
27
- continue;
28
- }
29
- const { sourceChainId, targetChainId, amount, to, submitTransactionHash } = event.args;
30
- const uniqueIdentifier = {
31
- action: 'deposit',
32
- submitTransactionHash: submitTransactionHash,
33
- sourceChainId: sourceChainId,
34
- targetChainId: targetChainId,
35
- };
36
- const transaction = await db_1.Transaction.findOne({ where: uniqueIdentifier });
37
- if (!transaction) {
38
- return;
39
- }
40
- const tx = await event.getTransaction();
41
- transaction.targetStatus = 'success';
42
- transaction.targetErrors = [];
43
- transaction.targetTransactionHash = tx.hash;
44
- transaction.targetEvent = {
45
- sourceChainId,
46
- targetChainId,
47
- amount: amount.toString(),
48
- to,
49
- submitTransactionHash
50
- };
51
- transaction.status = 'success';
52
- await transaction.save();
53
- this.logger.info(`Mint confirmation received: ${transaction.transactionHash} `);
54
- }
55
- catch (error) {
56
- this.logger.error(error);
57
- }
58
- }
59
- }
60
- async start() {
61
- this.provider = new ethers_1.ethers.providers.JsonRpcProvider((0, utils_1.getRpcProviderUrl)(this.chainId));
62
- this.contract = (0, utils_1.getContract)(this.itokenAddress, abi_1.default.interopBridgeToken, new ethers_1.ethers.Wallet(config_1.default.privateKey, this.provider));
63
- await super.start();
64
- }
65
- }
66
- exports.default = SyncMintEvents;