@instadapp/interop-x 0.0.0-dev.2c0a756 → 0.0.0-dev.3d62ebf
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.
- package/dist/package.json +2 -2
- package/dist/src/abi/interopBridgeToken.json +9 -21
- package/dist/src/abi/interopXGateway.json +11 -11
- package/dist/src/config/index.js +1 -10
- package/dist/src/constants/addresses.js +1 -1
- package/dist/src/constants/itokens.js +1 -1
- package/dist/src/index.js +5 -28
- package/dist/src/net/protocol/dial/{TransactionStatusDialProtocol.js → SignatureDialProtocol.1.js} +0 -0
- package/dist/src/net/protocol/index.js +6 -6
- package/dist/src/tasks/AutoUpdateTask.js +6 -11
- package/dist/src/tasks/BaseTask.js +0 -4
- package/dist/src/tasks/InteropBridge/{SyncBurnEvents.js → SyncWithdrawEvents.js} +8 -10
- package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +1 -14
- package/dist/src/tasks/InteropXGateway/SyncDepositEvents.js +2 -2
- package/dist/src/tasks/index.js +5 -17
- package/dist/src/typechain/factories/InteropBridgeToken__factory.js +11 -23
- package/dist/src/typechain/factories/InteropXGateway__factory.js +14 -14
- package/dist/src/utils/index.js +6 -6
- package/package.json +2 -2
- package/src/abi/interopBridgeToken.json +9 -21
- package/src/abi/interopXGateway.json +11 -11
- package/src/config/index.ts +1 -9
- package/src/constants/addresses.ts +1 -1
- package/src/constants/itokens.ts +1 -1
- package/src/index.ts +9 -41
- package/src/net/protocol/dial/{TransactionStatusDialProtocol.ts → SignatureDialProtocol.1.ts} +0 -0
- package/src/net/protocol/index.ts +5 -5
- package/src/tasks/AutoUpdateTask.ts +12 -15
- package/src/tasks/BaseTask.ts +0 -5
- package/src/tasks/InteropBridge/{SyncBurnEvents.ts → SyncWithdrawEvents.ts} +8 -10
- package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +4 -18
- package/src/tasks/InteropXGateway/SyncDepositEvents.ts +2 -2
- package/src/tasks/index.ts +4 -24
- package/src/typechain/InteropBridgeToken.ts +17 -23
- package/src/typechain/InteropXGateway.ts +13 -13
- package/src/typechain/factories/InteropBridgeToken__factory.ts +11 -23
- package/src/typechain/factories/InteropXGateway__factory.ts +14 -14
- package/src/utils/index.ts +6 -6
- package/dist/src/tasks/InteropBridge/SyncMintEvents.js +0 -66
- package/dist/src/tasks/InteropXGateway/SyncWithdrawtEvents.js +0 -71
- package/src/tasks/InteropBridge/SyncMintEvents.ts +0 -98
- package/src/tasks/InteropXGateway/SyncWithdrawtEvents.ts +0 -103
@@ -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,
|
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,
|
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,
|
157
|
-
"Mint(address,uint256,
|
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
|
-
|
185
|
-
targetChainId: number;
|
184
|
+
chainId: BigNumber;
|
186
185
|
}
|
187
186
|
export type BurnEvent = TypedEvent<
|
188
|
-
[string, BigNumber,
|
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
|
-
|
198
|
-
|
199
|
-
submitTransactionHash: string;
|
196
|
+
chainId: BigNumber;
|
197
|
+
transactionHash: string;
|
200
198
|
}
|
201
199
|
export type MintEvent = TypedEvent<
|
202
|
-
[string, BigNumber,
|
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,
|
489
|
+
"Burn(address,uint256,uint256)"(
|
492
490
|
to?: string | null,
|
493
491
|
amount?: null,
|
494
|
-
|
495
|
-
targetChainId?: BigNumberish | null
|
492
|
+
chainId?: BigNumberish | null
|
496
493
|
): BurnEventFilter;
|
497
494
|
Burn(
|
498
495
|
to?: string | null,
|
499
496
|
amount?: null,
|
500
|
-
|
501
|
-
targetChainId?: BigNumberish | null
|
497
|
+
chainId?: BigNumberish | null
|
502
498
|
): BurnEventFilter;
|
503
499
|
|
504
|
-
"Mint(address,uint256,
|
500
|
+
"Mint(address,uint256,uint256,bytes32)"(
|
505
501
|
to?: string | null,
|
506
502
|
amount?: null,
|
507
|
-
|
508
|
-
|
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
|
-
|
515
|
-
|
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,
|
33
|
-
"depositFor(address,address,uint256,
|
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,
|
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,
|
93
|
-
"LogGatewayWithdraw(address,address,uint256,
|
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:
|
108
|
-
targetChainId:
|
107
|
+
sourceChainId: BigNumber;
|
108
|
+
targetChainId: BigNumber;
|
109
109
|
}
|
110
110
|
export type LogGatewayDepositEvent = TypedEvent<
|
111
|
-
[string, string, BigNumber, BigNumber,
|
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:
|
123
|
-
targetChainId:
|
122
|
+
sourceChainId: BigNumber;
|
123
|
+
targetChainId: BigNumber;
|
124
124
|
transactionHash: string;
|
125
125
|
}
|
126
126
|
export type LogGatewayWithdrawEvent = TypedEvent<
|
127
|
-
[string, string, BigNumber,
|
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,
|
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,
|
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: "
|
73
|
-
name: "
|
74
|
-
type: "
|
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: "
|
98
|
-
name: "
|
99
|
-
type: "
|
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: "
|
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: "
|
229
|
+
internalType: "uint256",
|
242
230
|
name: "chainId",
|
243
|
-
type: "
|
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: "
|
313
|
+
internalType: "uint256",
|
326
314
|
name: "chainId",
|
327
|
-
type: "
|
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: "
|
53
|
+
internalType: "uint256",
|
54
54
|
name: "sourceChainId",
|
55
|
-
type: "
|
55
|
+
type: "uint256",
|
56
56
|
},
|
57
57
|
{
|
58
58
|
indexed: true,
|
59
|
-
internalType: "
|
59
|
+
internalType: "uint256",
|
60
60
|
name: "targetChainId",
|
61
|
-
type: "
|
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: "
|
90
|
+
internalType: "uint256",
|
91
91
|
name: "sourceChainId",
|
92
|
-
type: "
|
92
|
+
type: "uint256",
|
93
93
|
},
|
94
94
|
{
|
95
95
|
indexed: false,
|
96
|
-
internalType: "
|
96
|
+
internalType: "uint256",
|
97
97
|
name: "targetChainId",
|
98
|
-
type: "
|
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: "
|
155
|
+
internalType: "uint256",
|
156
156
|
name: "chainId_",
|
157
|
-
type: "
|
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: "
|
183
|
+
internalType: "uint256",
|
184
184
|
name: "chainId_",
|
185
|
-
type: "
|
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: "
|
231
|
+
internalType: "uint256",
|
232
232
|
name: "chainId_",
|
233
|
-
type: "
|
233
|
+
type: "uint256",
|
234
234
|
},
|
235
235
|
{
|
236
236
|
internalType: "bytes32",
|
package/src/utils/index.ts
CHANGED
@@ -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,
|
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[
|
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[
|
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;
|
@@ -1,71 +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 SyncWithdrawEvents extends BaseTask_1.BaseTask {
|
15
|
-
constructor({ chainId }) {
|
16
|
-
super({
|
17
|
-
logger: new logger_1.default("InteropXGateway::SyncWithdrawEvents"),
|
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.LogGatewayWithdraw(), currentBlock - 300, currentBlock);
|
24
|
-
let processedEvents = 0;
|
25
|
-
for (const event of events) {
|
26
|
-
try {
|
27
|
-
if (!event.args) {
|
28
|
-
continue;
|
29
|
-
}
|
30
|
-
const { user, token, amount, sourceChainId, targetChainId, transactionHash } = event.args;
|
31
|
-
const uniqueIdentifier = {
|
32
|
-
action: 'withdraw',
|
33
|
-
submitTransactionHash: transactionHash,
|
34
|
-
sourceChainId: sourceChainId,
|
35
|
-
targetChainId: targetChainId,
|
36
|
-
};
|
37
|
-
const transaction = await db_1.Transaction.findOne({ where: uniqueIdentifier });
|
38
|
-
if (!transaction) {
|
39
|
-
return;
|
40
|
-
}
|
41
|
-
const tx = await event.getTransaction();
|
42
|
-
transaction.targetStatus = 'success';
|
43
|
-
transaction.targetErrors = [];
|
44
|
-
transaction.targetTransactionHash = tx.hash;
|
45
|
-
transaction.targetEvent = {
|
46
|
-
user,
|
47
|
-
token,
|
48
|
-
amount: amount.toString(),
|
49
|
-
sourceChainId,
|
50
|
-
targetChainId,
|
51
|
-
transactionHash,
|
52
|
-
};
|
53
|
-
transaction.status = 'success';
|
54
|
-
await transaction.save();
|
55
|
-
this.logger.info(`Witdraw confirmation received: ${transaction.transactionHash} `);
|
56
|
-
}
|
57
|
-
catch (error) {
|
58
|
-
this.logger.error(error);
|
59
|
-
}
|
60
|
-
}
|
61
|
-
if (processedEvents > 0)
|
62
|
-
this.logger.info(`${processedEvents} events processed`);
|
63
|
-
}
|
64
|
-
async start() {
|
65
|
-
this.contractAddress = constants_1.addresses[this.chainId].interopXGateway;
|
66
|
-
this.provider = new ethers_1.ethers.providers.JsonRpcProvider((0, utils_1.getRpcProviderUrl)(this.chainId));
|
67
|
-
this.contract = (0, utils_1.getContract)(this.contractAddress, abi_1.default.interopXGateway, new ethers_1.ethers.Wallet(config_1.default.privateKey, this.provider));
|
68
|
-
await super.start();
|
69
|
-
}
|
70
|
-
}
|
71
|
-
exports.default = SyncWithdrawEvents;
|
@@ -1,98 +0,0 @@
|
|
1
|
-
import { BaseTask } from "../BaseTask";
|
2
|
-
import Logger from '@/logger';
|
3
|
-
import { ethers } from "ethers";
|
4
|
-
import abi from "@/abi";
|
5
|
-
import { Transaction } from "@/db";
|
6
|
-
import { getContract, getRpcProviderUrl } from "@/utils";
|
7
|
-
import { ChainId } from "@/types";
|
8
|
-
import config from "@/config";
|
9
|
-
import { InteropBridgeToken } from "@/typechain";
|
10
|
-
|
11
|
-
class SyncMintEvents extends BaseTask {
|
12
|
-
contractAddress: string;
|
13
|
-
provider: ethers.providers.JsonRpcProvider;
|
14
|
-
contract: InteropBridgeToken;
|
15
|
-
chainId: ChainId;
|
16
|
-
itokenAddress: string;
|
17
|
-
|
18
|
-
constructor({ chainId, itokenAddress }: { chainId: ChainId, itokenAddress: string }) {
|
19
|
-
super({
|
20
|
-
logger: new Logger("InteropBridgeToken::SyncMintEvents"),
|
21
|
-
})
|
22
|
-
this.chainId = chainId;
|
23
|
-
this.itokenAddress = itokenAddress;
|
24
|
-
}
|
25
|
-
|
26
|
-
async pollHandler() {
|
27
|
-
const currentBlock = await this.provider.getBlockNumber();
|
28
|
-
|
29
|
-
const events = await this.contract.queryFilter(
|
30
|
-
this.contract.filters.Mint(),
|
31
|
-
currentBlock - 300,
|
32
|
-
currentBlock,
|
33
|
-
);
|
34
|
-
|
35
|
-
|
36
|
-
for (const event of events) {
|
37
|
-
|
38
|
-
try {
|
39
|
-
if (!event.args) {
|
40
|
-
continue;
|
41
|
-
}
|
42
|
-
|
43
|
-
const { sourceChainId, targetChainId, amount, to, submitTransactionHash } = event.args;
|
44
|
-
|
45
|
-
const uniqueIdentifier = {
|
46
|
-
action: 'deposit',
|
47
|
-
submitTransactionHash: submitTransactionHash,
|
48
|
-
sourceChainId: sourceChainId,
|
49
|
-
targetChainId: targetChainId,
|
50
|
-
}
|
51
|
-
|
52
|
-
const transaction = await Transaction.findOne({ where: uniqueIdentifier });
|
53
|
-
|
54
|
-
if(! transaction){
|
55
|
-
return;
|
56
|
-
}
|
57
|
-
|
58
|
-
const tx = await event.getTransaction()
|
59
|
-
|
60
|
-
transaction.targetStatus = 'success'
|
61
|
-
transaction.targetErrors = []
|
62
|
-
transaction.targetTransactionHash = tx.hash
|
63
|
-
transaction.targetEvent = {
|
64
|
-
sourceChainId,
|
65
|
-
targetChainId,
|
66
|
-
amount: amount.toString(),
|
67
|
-
to,
|
68
|
-
submitTransactionHash
|
69
|
-
}
|
70
|
-
transaction.status = 'success'
|
71
|
-
|
72
|
-
await transaction.save()
|
73
|
-
|
74
|
-
this.logger.info(
|
75
|
-
`Mint confirmation received: ${transaction.transactionHash} `
|
76
|
-
);
|
77
|
-
} catch (error) {
|
78
|
-
this.logger.error(error);
|
79
|
-
}
|
80
|
-
}
|
81
|
-
}
|
82
|
-
|
83
|
-
async start(): Promise<void> {
|
84
|
-
this.provider = new ethers.providers.JsonRpcProvider(
|
85
|
-
getRpcProviderUrl(this.chainId)
|
86
|
-
);
|
87
|
-
|
88
|
-
this.contract = getContract<InteropBridgeToken>(
|
89
|
-
this.itokenAddress,
|
90
|
-
abi.interopBridgeToken,
|
91
|
-
new ethers.Wallet(config.privateKey!, this.provider)
|
92
|
-
);
|
93
|
-
|
94
|
-
await super.start()
|
95
|
-
}
|
96
|
-
}
|
97
|
-
|
98
|
-
export default SyncMintEvents;
|