@instadapp/interop-x 0.0.0-dev.cbee93c → 0.0.0-dev.d4e8223
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 -1
- package/dist/src/abi/interopBridgeToken.json +21 -9
- package/dist/src/abi/interopXGateway.json +11 -11
- package/dist/src/api/index.js +3 -0
- package/dist/src/config/index.js +10 -1
- package/dist/src/constants/addresses.js +1 -1
- package/dist/src/constants/itokens.js +1 -1
- package/dist/src/index.js +28 -5
- package/dist/src/net/protocol/dial/{SignatureDialProtocol.1.js → TransactionStatusDialProtocol.js} +0 -0
- package/dist/src/net/protocol/index.js +6 -6
- package/dist/src/tasks/AutoUpdateTask.js +6 -2
- package/dist/src/tasks/BaseTask.js +4 -0
- package/dist/src/tasks/InteropBridge/{SyncWithdrawEvents.js → SyncBurnEvents.js} +10 -8
- package/dist/src/tasks/InteropBridge/SyncMintEvents.js +67 -0
- package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +14 -1
- package/dist/src/tasks/InteropXGateway/SyncDepositEvents.js +2 -2
- package/dist/src/tasks/InteropXGateway/SyncWithdrawtEvents.js +72 -0
- package/dist/src/tasks/index.js +16 -5
- package/dist/src/typechain/factories/InteropBridgeToken__factory.js +23 -11
- package/dist/src/typechain/factories/InteropXGateway__factory.js +14 -14
- package/dist/src/utils/index.js +6 -6
- package/package.json +2 -1
- package/src/abi/interopBridgeToken.json +21 -9
- package/src/abi/interopXGateway.json +11 -11
- package/src/api/index.ts +3 -0
- package/src/config/index.ts +9 -1
- package/src/constants/addresses.ts +1 -1
- package/src/constants/itokens.ts +1 -1
- package/src/index.ts +41 -9
- package/src/net/protocol/dial/{SignatureDialProtocol.1.ts → TransactionStatusDialProtocol.ts} +0 -0
- package/src/net/protocol/index.ts +5 -5
- package/src/tasks/AutoUpdateTask.ts +12 -9
- package/src/tasks/BaseTask.ts +5 -0
- package/src/tasks/InteropBridge/{SyncWithdrawEvents.ts → SyncBurnEvents.ts} +10 -8
- package/src/tasks/InteropBridge/SyncMintEvents.ts +99 -0
- package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +18 -4
- package/src/tasks/InteropXGateway/SyncDepositEvents.ts +2 -2
- package/src/tasks/InteropXGateway/SyncWithdrawtEvents.ts +105 -0
- package/src/tasks/index.ts +24 -5
- package/src/typechain/InteropBridgeToken.ts +23 -17
- package/src/typechain/InteropXGateway.ts +13 -13
- package/src/typechain/factories/InteropBridgeToken__factory.ts +23 -11
- package/src/typechain/factories/InteropXGateway__factory.ts +14 -14
- package/src/utils/index.ts +6 -6
@@ -0,0 +1,99 @@
|
|
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 - 500,
|
32
|
+
currentBlock,
|
33
|
+
);
|
34
|
+
|
35
|
+
for (const event of events) {
|
36
|
+
|
37
|
+
try {
|
38
|
+
if (!event.args) {
|
39
|
+
continue;
|
40
|
+
}
|
41
|
+
|
42
|
+
const { sourceChainId, targetChainId, amount, to, submitTransactionHash } = event.args;
|
43
|
+
|
44
|
+
const uniqueIdentifier = {
|
45
|
+
action: 'deposit',
|
46
|
+
submitTransactionHash: submitTransactionHash,
|
47
|
+
sourceChainId: sourceChainId,
|
48
|
+
targetChainId: targetChainId,
|
49
|
+
|
50
|
+
targetEvent: null
|
51
|
+
}
|
52
|
+
|
53
|
+
const transaction = await Transaction.findOne({ where: uniqueIdentifier });
|
54
|
+
|
55
|
+
if(! transaction){
|
56
|
+
return;
|
57
|
+
}
|
58
|
+
|
59
|
+
const tx = await event.getTransaction()
|
60
|
+
|
61
|
+
transaction.targetStatus = 'success'
|
62
|
+
transaction.targetErrors = []
|
63
|
+
transaction.targetTransactionHash = tx.hash
|
64
|
+
transaction.targetEvent = {
|
65
|
+
sourceChainId,
|
66
|
+
targetChainId,
|
67
|
+
amount: amount.toString(),
|
68
|
+
to,
|
69
|
+
submitTransactionHash
|
70
|
+
}
|
71
|
+
transaction.status = 'success'
|
72
|
+
|
73
|
+
await transaction.save()
|
74
|
+
|
75
|
+
this.logger.info(
|
76
|
+
`Mint confirmation received: ${transaction.transactionHash} `
|
77
|
+
);
|
78
|
+
} catch (error) {
|
79
|
+
this.logger.error(error);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
async start(): Promise<void> {
|
85
|
+
this.provider = new ethers.providers.JsonRpcProvider(
|
86
|
+
getRpcProviderUrl(this.chainId)
|
87
|
+
);
|
88
|
+
|
89
|
+
this.contract = getContract<InteropBridgeToken>(
|
90
|
+
this.itokenAddress,
|
91
|
+
abi.interopBridgeToken,
|
92
|
+
new ethers.Wallet(config.privateKey!, this.provider)
|
93
|
+
);
|
94
|
+
|
95
|
+
await super.start()
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
export default SyncMintEvents;
|
@@ -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,9 +121,23 @@ 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
|
+
|
124
138
|
let gnosisTx = await generateGnosisTransaction({
|
125
139
|
baseGas: "0",
|
126
|
-
data
|
140
|
+
data,
|
127
141
|
gasPrice: "0",
|
128
142
|
gasToken: "0x0000000000000000000000000000000000000000",
|
129
143
|
nonce: '0',
|
@@ -142,7 +156,7 @@ class ProcessDepositEvents extends BaseTask {
|
|
142
156
|
console.log(`Collecting signatures for execution ${transaction.transactionHash}`)
|
143
157
|
|
144
158
|
console.log(ownerPeerIds);
|
145
|
-
|
159
|
+
|
146
160
|
const signatures = await protocol.requestSignatures({
|
147
161
|
type: 'source',
|
148
162
|
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,
|
49
|
+
targetChainId: targetChainId,
|
50
50
|
}
|
51
51
|
|
52
52
|
if (await Transaction.findOne({ where: uniqueIdentifier })) {
|
@@ -0,0 +1,105 @@
|
|
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 { addresses } from "@/constants";
|
8
|
+
import { ChainId } from "@/types";
|
9
|
+
import config from "@/config";
|
10
|
+
import { InteropXGateway } from "@/typechain";
|
11
|
+
|
12
|
+
class SyncWithdrawEvents extends BaseTask {
|
13
|
+
contractAddress: string;
|
14
|
+
provider: ethers.providers.JsonRpcProvider;
|
15
|
+
contract: InteropXGateway;
|
16
|
+
chainId: ChainId;
|
17
|
+
|
18
|
+
constructor({ chainId }: { chainId: ChainId }) {
|
19
|
+
super({
|
20
|
+
logger: new Logger("InteropXGateway::SyncWithdrawEvents"),
|
21
|
+
})
|
22
|
+
this.chainId = chainId;
|
23
|
+
}
|
24
|
+
|
25
|
+
async pollHandler() {
|
26
|
+
const currentBlock = await this.provider.getBlockNumber();
|
27
|
+
|
28
|
+
const events = await this.contract.queryFilter(
|
29
|
+
this.contract.filters.LogGatewayWithdraw(),
|
30
|
+
currentBlock - 500,
|
31
|
+
currentBlock,
|
32
|
+
);
|
33
|
+
|
34
|
+
let processedEvents = 0;
|
35
|
+
|
36
|
+
for (const event of events) {
|
37
|
+
|
38
|
+
try {
|
39
|
+
if (!event.args) {
|
40
|
+
continue;
|
41
|
+
}
|
42
|
+
|
43
|
+
const { user, token, amount, sourceChainId, targetChainId, transactionHash } = event.args;
|
44
|
+
|
45
|
+
const uniqueIdentifier = {
|
46
|
+
action: 'withdraw',
|
47
|
+
submitTransactionHash: transactionHash,
|
48
|
+
sourceChainId: sourceChainId,
|
49
|
+
targetChainId: targetChainId,
|
50
|
+
|
51
|
+
targetEvent: null
|
52
|
+
}
|
53
|
+
const transaction = await Transaction.findOne({ where: uniqueIdentifier });
|
54
|
+
|
55
|
+
if (!transaction) {
|
56
|
+
return;
|
57
|
+
}
|
58
|
+
|
59
|
+
const tx = await event.getTransaction()
|
60
|
+
|
61
|
+
transaction.targetStatus = 'success'
|
62
|
+
transaction.targetErrors = []
|
63
|
+
transaction.targetTransactionHash = tx.hash
|
64
|
+
transaction.targetEvent = {
|
65
|
+
user,
|
66
|
+
token,
|
67
|
+
amount: amount.toString(),
|
68
|
+
sourceChainId,
|
69
|
+
targetChainId,
|
70
|
+
transactionHash,
|
71
|
+
}
|
72
|
+
transaction.status = 'success'
|
73
|
+
|
74
|
+
await transaction.save()
|
75
|
+
|
76
|
+
this.logger.info(
|
77
|
+
`Witdraw confirmation received: ${transaction.transactionHash} `
|
78
|
+
);
|
79
|
+
} catch (error) {
|
80
|
+
this.logger.error(error);
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
if (processedEvents > 0)
|
85
|
+
this.logger.info(`${processedEvents} events processed`);
|
86
|
+
}
|
87
|
+
|
88
|
+
async start(): Promise<void> {
|
89
|
+
this.contractAddress = addresses[this.chainId].interopXGateway;
|
90
|
+
|
91
|
+
this.provider = new ethers.providers.JsonRpcProvider(
|
92
|
+
getRpcProviderUrl(this.chainId)
|
93
|
+
);
|
94
|
+
|
95
|
+
this.contract = getContract<InteropXGateway>(
|
96
|
+
this.contractAddress,
|
97
|
+
abi.interopXGateway,
|
98
|
+
new ethers.Wallet(config.privateKey!, this.provider)
|
99
|
+
);
|
100
|
+
|
101
|
+
await super.start()
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
export default SyncWithdrawEvents;
|
package/src/tasks/index.ts
CHANGED
@@ -1,18 +1,24 @@
|
|
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";
|
4
5
|
|
5
|
-
import InteropBridgeSyncWithdrawEvents from "./InteropBridge/SyncWithdrawEvents";
|
6
6
|
import InteropBridgeProcessWithdrawEvents from "./InteropBridge/ProcessWithdrawEvents";
|
7
|
-
import
|
7
|
+
import InteropBridgeSyncBurnEvents from "./InteropBridge/SyncBurnEvents";
|
8
|
+
import InteropBridgeSyncMintEvents from "./InteropBridge/SyncMintEvents";
|
9
|
+
|
8
10
|
import SyncTransactionStatusTask from "./Transactions/SyncTransactionStatusTask";
|
9
11
|
|
12
|
+
import AutoUpdateTask from "./AutoUpdateTask";
|
13
|
+
|
10
14
|
export class Tasks {
|
11
15
|
|
12
16
|
tasks: BaseTask[] = [
|
13
17
|
new SyncTransactionStatusTask(),
|
14
18
|
new AutoUpdateTask(),
|
15
19
|
|
20
|
+
// InteropXGateway
|
21
|
+
|
16
22
|
new InteropXGatewaySyncDepositEvents({
|
17
23
|
chainId: 43114
|
18
24
|
}),
|
@@ -21,13 +27,26 @@ export class Tasks {
|
|
21
27
|
chainId: 43114
|
22
28
|
}),
|
23
29
|
|
24
|
-
|
25
|
-
|
26
|
-
|
30
|
+
|
31
|
+
new InteropXGatewaySyncWithdrawEvents({
|
32
|
+
chainId: 43114
|
27
33
|
}),
|
28
34
|
|
35
|
+
|
36
|
+
// InteropBridge
|
37
|
+
|
29
38
|
new InteropBridgeProcessWithdrawEvents({
|
30
39
|
chainId: 137,
|
40
|
+
}),
|
41
|
+
|
42
|
+
new InteropBridgeSyncMintEvents({
|
43
|
+
chainId: 137,
|
44
|
+
itokenAddress: '0x62c0045f3277e7067cacad3c8038eeabb1bd92d1',
|
45
|
+
}),
|
46
|
+
|
47
|
+
new InteropBridgeSyncBurnEvents({
|
48
|
+
chainId: 137,
|
49
|
+
itokenAddress: '0x62c0045f3277e7067cacad3c8038eeabb1bd92d1',
|
31
50
|
})
|
32
51
|
];
|
33
52
|
|
@@ -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,uint32)": 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,uint32,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,uint32,uint32)": EventFragment;
|
157
|
+
"Mint(address,uint256,uint32,uint32,bytes32)": EventFragment;
|
158
158
|
"OwnershipTransferred(address,address)": EventFragment;
|
159
159
|
"Transfer(address,address,uint256)": EventFragment;
|
160
160
|
};
|
@@ -181,10 +181,11 @@ export type ApprovalEventFilter = TypedEventFilter<ApprovalEvent>;
|
|
181
181
|
export interface BurnEventObject {
|
182
182
|
to: string;
|
183
183
|
amount: BigNumber;
|
184
|
-
|
184
|
+
sourceChainId: number;
|
185
|
+
targetChainId: number;
|
185
186
|
}
|
186
187
|
export type BurnEvent = TypedEvent<
|
187
|
-
[string, BigNumber,
|
188
|
+
[string, BigNumber, number, number],
|
188
189
|
BurnEventObject
|
189
190
|
>;
|
190
191
|
|
@@ -193,11 +194,12 @@ export type BurnEventFilter = TypedEventFilter<BurnEvent>;
|
|
193
194
|
export interface MintEventObject {
|
194
195
|
to: string;
|
195
196
|
amount: BigNumber;
|
196
|
-
|
197
|
-
|
197
|
+
sourceChainId: number;
|
198
|
+
targetChainId: number;
|
199
|
+
submitTransactionHash: string;
|
198
200
|
}
|
199
201
|
export type MintEvent = TypedEvent<
|
200
|
-
[string, BigNumber,
|
202
|
+
[string, BigNumber, number, number, string],
|
201
203
|
MintEventObject
|
202
204
|
>;
|
203
205
|
|
@@ -486,28 +488,32 @@ export interface InteropBridgeToken extends BaseContract {
|
|
486
488
|
value?: null
|
487
489
|
): ApprovalEventFilter;
|
488
490
|
|
489
|
-
"Burn(address,uint256,
|
491
|
+
"Burn(address,uint256,uint32,uint32)"(
|
490
492
|
to?: string | null,
|
491
493
|
amount?: null,
|
492
|
-
|
494
|
+
sourceChainId?: null,
|
495
|
+
targetChainId?: BigNumberish | null
|
493
496
|
): BurnEventFilter;
|
494
497
|
Burn(
|
495
498
|
to?: string | null,
|
496
499
|
amount?: null,
|
497
|
-
|
500
|
+
sourceChainId?: null,
|
501
|
+
targetChainId?: BigNumberish | null
|
498
502
|
): BurnEventFilter;
|
499
503
|
|
500
|
-
"Mint(address,uint256,
|
504
|
+
"Mint(address,uint256,uint32,uint32,bytes32)"(
|
501
505
|
to?: string | null,
|
502
506
|
amount?: null,
|
503
|
-
|
504
|
-
|
507
|
+
sourceChainId?: BigNumberish | null,
|
508
|
+
targetChainId?: null,
|
509
|
+
submitTransactionHash?: BytesLike | null
|
505
510
|
): MintEventFilter;
|
506
511
|
Mint(
|
507
512
|
to?: string | null,
|
508
513
|
amount?: null,
|
509
|
-
|
510
|
-
|
514
|
+
sourceChainId?: BigNumberish | null,
|
515
|
+
targetChainId?: null,
|
516
|
+
submitTransactionHash?: BytesLike | null
|
511
517
|
): MintEventFilter;
|
512
518
|
|
513
519
|
"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,uint32)": FunctionFragment;
|
33
|
+
"depositFor(address,address,uint256,uint32)": FunctionFragment;
|
34
34
|
"owner()": FunctionFragment;
|
35
35
|
"renounceOwnership()": FunctionFragment;
|
36
|
-
"systemWithdraw(uint256,address,address,
|
36
|
+
"systemWithdraw(uint256,address,address,uint32,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,uint32,uint32)": EventFragment;
|
93
|
+
"LogGatewayWithdraw(address,address,uint256,uint32,uint32,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: number;
|
108
|
+
targetChainId: number;
|
109
109
|
}
|
110
110
|
export type LogGatewayDepositEvent = TypedEvent<
|
111
|
-
[string, string, BigNumber, BigNumber,
|
111
|
+
[string, string, BigNumber, BigNumber, number, number],
|
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: number;
|
123
|
+
targetChainId: number;
|
124
124
|
transactionHash: string;
|
125
125
|
}
|
126
126
|
export type LogGatewayWithdrawEvent = TypedEvent<
|
127
|
-
[string, string, BigNumber,
|
127
|
+
[string, string, BigNumber, number, number, 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,uint32,uint32)"(
|
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,uint32,uint32,bytes32)"(
|
304
304
|
user?: null,
|
305
305
|
token?: string | null,
|
306
306
|
amount?: null,
|
@@ -61,11 +61,17 @@ 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
|
+
},
|
64
70
|
{
|
65
71
|
indexed: true,
|
66
|
-
internalType: "
|
67
|
-
name: "
|
68
|
-
type: "
|
72
|
+
internalType: "uint32",
|
73
|
+
name: "targetChainId",
|
74
|
+
type: "uint32",
|
69
75
|
},
|
70
76
|
],
|
71
77
|
name: "Burn",
|
@@ -88,14 +94,20 @@ const _abi = [
|
|
88
94
|
},
|
89
95
|
{
|
90
96
|
indexed: true,
|
91
|
-
internalType: "
|
92
|
-
name: "
|
93
|
-
type: "
|
97
|
+
internalType: "uint32",
|
98
|
+
name: "sourceChainId",
|
99
|
+
type: "uint32",
|
100
|
+
},
|
101
|
+
{
|
102
|
+
indexed: false,
|
103
|
+
internalType: "uint32",
|
104
|
+
name: "targetChainId",
|
105
|
+
type: "uint32",
|
94
106
|
},
|
95
107
|
{
|
96
108
|
indexed: true,
|
97
109
|
internalType: "bytes32",
|
98
|
-
name: "
|
110
|
+
name: "submitTransactionHash",
|
99
111
|
type: "bytes32",
|
100
112
|
},
|
101
113
|
],
|
@@ -226,9 +238,9 @@ const _abi = [
|
|
226
238
|
type: "uint256",
|
227
239
|
},
|
228
240
|
{
|
229
|
-
internalType: "
|
241
|
+
internalType: "uint32",
|
230
242
|
name: "chainId",
|
231
|
-
type: "
|
243
|
+
type: "uint32",
|
232
244
|
},
|
233
245
|
],
|
234
246
|
name: "burn",
|
@@ -310,9 +322,9 @@ const _abi = [
|
|
310
322
|
type: "uint256",
|
311
323
|
},
|
312
324
|
{
|
313
|
-
internalType: "
|
325
|
+
internalType: "uint32",
|
314
326
|
name: "chainId",
|
315
|
-
type: "
|
327
|
+
type: "uint32",
|
316
328
|
},
|
317
329
|
{
|
318
330
|
internalType: "bytes32",
|
@@ -50,15 +50,15 @@ const _abi = [
|
|
50
50
|
},
|
51
51
|
{
|
52
52
|
indexed: false,
|
53
|
-
internalType: "
|
53
|
+
internalType: "uint32",
|
54
54
|
name: "sourceChainId",
|
55
|
-
type: "
|
55
|
+
type: "uint32",
|
56
56
|
},
|
57
57
|
{
|
58
58
|
indexed: true,
|
59
|
-
internalType: "
|
59
|
+
internalType: "uint32",
|
60
60
|
name: "targetChainId",
|
61
|
-
type: "
|
61
|
+
type: "uint32",
|
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: "uint32",
|
91
91
|
name: "sourceChainId",
|
92
|
-
type: "
|
92
|
+
type: "uint32",
|
93
93
|
},
|
94
94
|
{
|
95
95
|
indexed: false,
|
96
|
-
internalType: "
|
96
|
+
internalType: "uint32",
|
97
97
|
name: "targetChainId",
|
98
|
-
type: "
|
98
|
+
type: "uint32",
|
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: "uint32",
|
156
156
|
name: "chainId_",
|
157
|
-
type: "
|
157
|
+
type: "uint32",
|
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: "uint32",
|
184
184
|
name: "chainId_",
|
185
|
-
type: "
|
185
|
+
type: "uint32",
|
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: "uint32",
|
232
232
|
name: "chainId_",
|
233
|
-
type: "
|
233
|
+
type: "uint32",
|
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, sourceChainId, targetChainId, itoken: itokenAddress } = transaction.submitEvent;
|
226
226
|
|
227
|
-
const itoken = itokens[
|
227
|
+
const itoken = itokens[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[targetChainId].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(
|
239
|
+
const targetChainProvider = new ethers.providers.JsonRpcProvider(getRpcProviderUrl(targetChainId as ChainId));
|
240
240
|
const targetWallet = new ethers.Wallet(config.privateKey, targetChainProvider);
|
241
|
-
const gatewayAddress = addresses[
|
241
|
+
const gatewayAddress = addresses[targetChainId].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(
|
248
|
+
ethers.BigNumber.from(sourceChainId.toString()),
|
249
249
|
transaction.submitTransactionHash,
|
250
250
|
);
|
251
251
|
|