@instadapp/interop-x 0.0.0-dev.e53015f → 0.0.0-dev.edef11e
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 +1 -1
- package/dist/src/abi/interopBridgeToken.json +21 -9
- package/dist/src/abi/interopXGateway.json +11 -11
- package/dist/src/constants/addresses.js +1 -1
- package/dist/src/constants/itokens.js +1 -1
- package/dist/src/index.js +17 -5
- package/dist/src/net/protocol/dial/{SignatureDialProtocol.1.js → TransactionStatusDialProtocol.js} +0 -0
- package/dist/src/net/protocol/index.js +2 -2
- package/dist/src/tasks/AutoUpdateTask.js +6 -2
- package/dist/src/tasks/InteropBridge/SyncWithdrawEvents.js +7 -5
- package/dist/src/tasks/InteropXGateway/SyncDepositEvents.js +2 -2
- 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 +1 -1
- package/src/abi/interopBridgeToken.json +21 -9
- package/src/abi/interopXGateway.json +11 -11
- package/src/constants/addresses.ts +1 -1
- package/src/constants/itokens.ts +1 -1
- package/src/index.ts +24 -6
- package/src/net/protocol/dial/{SignatureDialProtocol.1.ts → TransactionStatusDialProtocol.ts} +0 -0
- package/src/net/protocol/index.ts +1 -1
- package/src/tasks/AutoUpdateTask.ts +12 -9
- package/src/tasks/InteropBridge/SyncWithdrawEvents.ts +7 -5
- package/src/tasks/InteropXGateway/SyncDepositEvents.ts +2 -2
- 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
package/dist/package.json
CHANGED
@@ -46,11 +46,17 @@
|
|
46
46
|
"name": "amount",
|
47
47
|
"type": "uint256"
|
48
48
|
},
|
49
|
+
{
|
50
|
+
"indexed": false,
|
51
|
+
"internalType": "uint32",
|
52
|
+
"name": "sourceChainId",
|
53
|
+
"type": "uint32"
|
54
|
+
},
|
49
55
|
{
|
50
56
|
"indexed": true,
|
51
|
-
"internalType": "
|
52
|
-
"name": "
|
53
|
-
"type": "
|
57
|
+
"internalType": "uint32",
|
58
|
+
"name": "targetChainId",
|
59
|
+
"type": "uint32"
|
54
60
|
}
|
55
61
|
],
|
56
62
|
"name": "Burn",
|
@@ -73,14 +79,20 @@
|
|
73
79
|
},
|
74
80
|
{
|
75
81
|
"indexed": true,
|
76
|
-
"internalType": "
|
77
|
-
"name": "
|
78
|
-
"type": "
|
82
|
+
"internalType": "uint32",
|
83
|
+
"name": "sourceChainId",
|
84
|
+
"type": "uint32"
|
85
|
+
},
|
86
|
+
{
|
87
|
+
"indexed": false,
|
88
|
+
"internalType": "uint32",
|
89
|
+
"name": "targetChainId",
|
90
|
+
"type": "uint32"
|
79
91
|
},
|
80
92
|
{
|
81
93
|
"indexed": true,
|
82
94
|
"internalType": "bytes32",
|
83
|
-
"name": "
|
95
|
+
"name": "submitTransactionHash",
|
84
96
|
"type": "bytes32"
|
85
97
|
}
|
86
98
|
],
|
@@ -164,7 +176,7 @@
|
|
164
176
|
"inputs": [
|
165
177
|
{ "internalType": "address", "name": "to", "type": "address" },
|
166
178
|
{ "internalType": "uint256", "name": "amount", "type": "uint256" },
|
167
|
-
{ "internalType": "
|
179
|
+
{ "internalType": "uint32", "name": "chainId", "type": "uint32" }
|
168
180
|
],
|
169
181
|
"name": "burn",
|
170
182
|
"outputs": [],
|
@@ -206,7 +218,7 @@
|
|
206
218
|
"inputs": [
|
207
219
|
{ "internalType": "address", "name": "to", "type": "address" },
|
208
220
|
{ "internalType": "uint256", "name": "amount", "type": "uint256" },
|
209
|
-
{ "internalType": "
|
221
|
+
{ "internalType": "uint32", "name": "chainId", "type": "uint32" },
|
210
222
|
{
|
211
223
|
"internalType": "bytes32",
|
212
224
|
"name": "transactionHash",
|
@@ -35,15 +35,15 @@
|
|
35
35
|
},
|
36
36
|
{
|
37
37
|
"indexed": false,
|
38
|
-
"internalType": "
|
38
|
+
"internalType": "uint32",
|
39
39
|
"name": "sourceChainId",
|
40
|
-
"type": "
|
40
|
+
"type": "uint32"
|
41
41
|
},
|
42
42
|
{
|
43
43
|
"indexed": true,
|
44
|
-
"internalType": "
|
44
|
+
"internalType": "uint32",
|
45
45
|
"name": "targetChainId",
|
46
|
-
"type": "
|
46
|
+
"type": "uint32"
|
47
47
|
}
|
48
48
|
],
|
49
49
|
"name": "LogGatewayDeposit",
|
@@ -72,15 +72,15 @@
|
|
72
72
|
},
|
73
73
|
{
|
74
74
|
"indexed": true,
|
75
|
-
"internalType": "
|
75
|
+
"internalType": "uint32",
|
76
76
|
"name": "sourceChainId",
|
77
|
-
"type": "
|
77
|
+
"type": "uint32"
|
78
78
|
},
|
79
79
|
{
|
80
80
|
"indexed": false,
|
81
|
-
"internalType": "
|
81
|
+
"internalType": "uint32",
|
82
82
|
"name": "targetChainId",
|
83
|
-
"type": "
|
83
|
+
"type": "uint32"
|
84
84
|
},
|
85
85
|
{
|
86
86
|
"indexed": true,
|
@@ -122,7 +122,7 @@
|
|
122
122
|
"inputs": [
|
123
123
|
{ "internalType": "address", "name": "token_", "type": "address" },
|
124
124
|
{ "internalType": "uint256", "name": "amount_", "type": "uint256" },
|
125
|
-
{ "internalType": "
|
125
|
+
{ "internalType": "uint32", "name": "chainId_", "type": "uint32" }
|
126
126
|
],
|
127
127
|
"name": "deposit",
|
128
128
|
"outputs": [],
|
@@ -134,7 +134,7 @@
|
|
134
134
|
{ "internalType": "address", "name": "to_", "type": "address" },
|
135
135
|
{ "internalType": "address", "name": "token_", "type": "address" },
|
136
136
|
{ "internalType": "uint256", "name": "amount_", "type": "uint256" },
|
137
|
-
{ "internalType": "
|
137
|
+
{ "internalType": "uint32", "name": "chainId_", "type": "uint32" }
|
138
138
|
],
|
139
139
|
"name": "depositFor",
|
140
140
|
"outputs": [],
|
@@ -160,7 +160,7 @@
|
|
160
160
|
{ "internalType": "uint256", "name": "amount_", "type": "uint256" },
|
161
161
|
{ "internalType": "address", "name": "user_", "type": "address" },
|
162
162
|
{ "internalType": "address", "name": "token_", "type": "address" },
|
163
|
-
{ "internalType": "
|
163
|
+
{ "internalType": "uint32", "name": "chainId_", "type": "uint32" },
|
164
164
|
{
|
165
165
|
"internalType": "bytes32",
|
166
166
|
"name": "transactionHash_",
|
@@ -15,6 +15,6 @@ exports.addresses = {
|
|
15
15
|
43114: {
|
16
16
|
gnosisSafe: '0x31d7a5194Fe60AC209Cf1Ce2d539C9A60662Ed6b',
|
17
17
|
multisend: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
|
18
|
-
interopXGateway: '
|
18
|
+
interopXGateway: '0xF0317C5Bc206F2291dd2f3eE9C4cDB5Bbb25418d',
|
19
19
|
}
|
20
20
|
};
|
package/dist/src/index.js
CHANGED
@@ -28,12 +28,23 @@ const package_json_1 = __importDefault(require("../package.json"));
|
|
28
28
|
dotenv_1.default.config();
|
29
29
|
const logger_1 = __importDefault(require("@/logger"));
|
30
30
|
const logger = new logger_1.default('Process');
|
31
|
+
const GIT_SHORT_HASH = 'edef11e';
|
31
32
|
const printUsage = () => {
|
33
|
+
console.log();
|
34
|
+
console.log(`Interop X Node (v${package_json_1.default.version} - rev.${GIT_SHORT_HASH})`);
|
35
|
+
console.log();
|
32
36
|
console.log('Usage:');
|
33
|
-
console.log('
|
34
|
-
console.log('
|
35
|
-
console.log(
|
36
|
-
console.log('
|
37
|
+
console.log(' interop-x help Show this message');
|
38
|
+
console.log(' interop-x version Print out the installed version of Interop X');
|
39
|
+
console.log();
|
40
|
+
console.log(' interop-x down Put the node into maintenance mode');
|
41
|
+
console.log(' interop-x up Take the node out of maintenance mode');
|
42
|
+
console.log();
|
43
|
+
console.log(' PRIVATE_KEY=abcd1234 interop-x Start the node with the given private key');
|
44
|
+
console.log(' PRIVATE_KEY=abcd1234 STAGING=true interop-x Start the node in staging mode');
|
45
|
+
console.log(' PRIVATE_KEY=abcd1234 AUTO_UPDATE=true interop-x Start the node in auto update mode');
|
46
|
+
console.log(' PRIVATE_KEY=abcd1234 API_HOST=0.0.0.0 API_PORT=8080 interop-x Start the node with custom API host and port');
|
47
|
+
console.log();
|
37
48
|
};
|
38
49
|
if (process.argv.at(-1) === 'help') {
|
39
50
|
printUsage();
|
@@ -42,13 +53,14 @@ if (process.argv.at(-1) === 'help') {
|
|
42
53
|
const basePath = (0, expand_home_dir_1.default)(`~/.interop-x`);
|
43
54
|
if (process.argv.at(-1) === 'down') {
|
44
55
|
fs_extra_1.default.outputFileSync(basePath + '/maintenance', Date.now().toString());
|
56
|
+
console.log(chalk_1.default.red('Maintenance mode enabled'));
|
45
57
|
process.exit(0);
|
46
58
|
}
|
47
59
|
if (process.argv.at(-1) === 'up') {
|
48
60
|
fs_extra_1.default.removeSync(basePath + '/maintenance');
|
61
|
+
console.log(chalk_1.default.green('Maintenance mode disabled'));
|
49
62
|
process.exit(0);
|
50
63
|
}
|
51
|
-
const GIT_SHORT_HASH = 'e53015f';
|
52
64
|
if (process.argv.at(-1) === 'version') {
|
53
65
|
console.log(`Interop X Node (v${package_json_1.default.version} - rev.${GIT_SHORT_HASH})`);
|
54
66
|
process.exit(0);
|
package/dist/src/net/protocol/dial/{SignatureDialProtocol.1.js → TransactionStatusDialProtocol.js}
RENAMED
File without changes
|
@@ -10,7 +10,7 @@ const SignatureDialProtocol_1 = require("./dial/SignatureDialProtocol");
|
|
10
10
|
const __1 = require("..");
|
11
11
|
const config_1 = __importDefault(require("@/config"));
|
12
12
|
const types_1 = require("@/types");
|
13
|
-
const
|
13
|
+
const TransactionStatusDialProtocol_1 = require("./dial/TransactionStatusDialProtocol");
|
14
14
|
class Protocol extends stream_1.EventEmitter {
|
15
15
|
constructor() {
|
16
16
|
super(...arguments);
|
@@ -65,7 +65,7 @@ class Protocol extends stream_1.EventEmitter {
|
|
65
65
|
});
|
66
66
|
});
|
67
67
|
this.signature = new SignatureDialProtocol_1.SignatureDialProtocol(this.libp2p);
|
68
|
-
this.transactionStatus = new
|
68
|
+
this.transactionStatus = new TransactionStatusDialProtocol_1.TransactionStatusDialProtocol(this.libp2p);
|
69
69
|
}
|
70
70
|
init() {
|
71
71
|
this.libp2p.pubsub.subscribe(this.topic);
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const BaseTask_1 = require("./BaseTask");
|
7
7
|
const logger_1 = __importDefault(require("@/logger"));
|
8
8
|
const await_spawn_1 = __importDefault(require("await-spawn"));
|
9
|
+
const child_process_1 = require("child_process");
|
9
10
|
const config_1 = __importDefault(require("@/config"));
|
10
11
|
const waait_1 = __importDefault(require("waait"));
|
11
12
|
const package_json_1 = __importDefault(require("../../package.json"));
|
@@ -56,10 +57,13 @@ class AutoUpdateTask extends BaseTask_1.BaseTask {
|
|
56
57
|
}
|
57
58
|
this.logger.warn(`Installed version ${version}`);
|
58
59
|
this.logger.warn(`Restarting...`);
|
59
|
-
|
60
|
+
// TODO: its restarting in the bg, but it should be in the fg
|
61
|
+
const subprocess = (0, child_process_1.spawn)(process.argv[0], process.argv.slice(1), {
|
60
62
|
cwd: process.cwd(),
|
61
|
-
stdio: "inherit"
|
63
|
+
stdio: "inherit",
|
64
|
+
// shell: process.env.SHELL,
|
62
65
|
});
|
66
|
+
subprocess.unref();
|
63
67
|
process.exit();
|
64
68
|
}
|
65
69
|
}
|
@@ -27,12 +27,12 @@ class SyncWithdrawEvents extends BaseTask_1.BaseTask {
|
|
27
27
|
if (!event.args) {
|
28
28
|
continue;
|
29
29
|
}
|
30
|
-
const { to, amount,
|
30
|
+
const { to, amount, sourceChainId, targetChainId } = event.args;
|
31
31
|
const uniqueIdentifier = {
|
32
32
|
action: 'withdraw',
|
33
33
|
submitTransactionHash: event.transactionHash,
|
34
|
-
sourceChainId:
|
35
|
-
targetChainId:
|
34
|
+
sourceChainId: sourceChainId,
|
35
|
+
targetChainId: targetChainId,
|
36
36
|
};
|
37
37
|
if (await db_1.Transaction.findOne({ where: uniqueIdentifier })) {
|
38
38
|
continue;
|
@@ -44,12 +44,14 @@ class SyncWithdrawEvents extends BaseTask_1.BaseTask {
|
|
44
44
|
to,
|
45
45
|
amount: amount.toString(),
|
46
46
|
itoken: this.itokenAddress,
|
47
|
-
|
47
|
+
sourceChainId: sourceChainId,
|
48
|
+
targetChainId: targetChainId,
|
48
49
|
}, sourceEvent: {
|
49
50
|
to,
|
50
51
|
amount: amount.toString(),
|
51
52
|
itoken: this.itokenAddress,
|
52
|
-
|
53
|
+
sourceChainId: sourceChainId,
|
54
|
+
targetChainId: targetChainId,
|
53
55
|
}, status: "pending" }));
|
54
56
|
this.logger.info(`Withdraw queued: ${event.transactionHash} ${event.blockNumber}`);
|
55
57
|
}
|
@@ -31,8 +31,8 @@ class SyncDepositEvents extends BaseTask_1.BaseTask {
|
|
31
31
|
const uniqueIdentifier = {
|
32
32
|
action: 'deposit',
|
33
33
|
submitTransactionHash: event.transactionHash,
|
34
|
-
sourceChainId: sourceChainId
|
35
|
-
targetChainId: targetChainId
|
34
|
+
sourceChainId: sourceChainId,
|
35
|
+
targetChainId: targetChainId,
|
36
36
|
};
|
37
37
|
if (await db_1.Transaction.findOne({ where: uniqueIdentifier })) {
|
38
38
|
continue;
|
@@ -57,11 +57,17 @@ const _abi = [
|
|
57
57
|
name: "amount",
|
58
58
|
type: "uint256",
|
59
59
|
},
|
60
|
+
{
|
61
|
+
indexed: false,
|
62
|
+
internalType: "uint32",
|
63
|
+
name: "sourceChainId",
|
64
|
+
type: "uint32",
|
65
|
+
},
|
60
66
|
{
|
61
67
|
indexed: true,
|
62
|
-
internalType: "
|
63
|
-
name: "
|
64
|
-
type: "
|
68
|
+
internalType: "uint32",
|
69
|
+
name: "targetChainId",
|
70
|
+
type: "uint32",
|
65
71
|
},
|
66
72
|
],
|
67
73
|
name: "Burn",
|
@@ -84,14 +90,20 @@ const _abi = [
|
|
84
90
|
},
|
85
91
|
{
|
86
92
|
indexed: true,
|
87
|
-
internalType: "
|
88
|
-
name: "
|
89
|
-
type: "
|
93
|
+
internalType: "uint32",
|
94
|
+
name: "sourceChainId",
|
95
|
+
type: "uint32",
|
96
|
+
},
|
97
|
+
{
|
98
|
+
indexed: false,
|
99
|
+
internalType: "uint32",
|
100
|
+
name: "targetChainId",
|
101
|
+
type: "uint32",
|
90
102
|
},
|
91
103
|
{
|
92
104
|
indexed: true,
|
93
105
|
internalType: "bytes32",
|
94
|
-
name: "
|
106
|
+
name: "submitTransactionHash",
|
95
107
|
type: "bytes32",
|
96
108
|
},
|
97
109
|
],
|
@@ -222,9 +234,9 @@ const _abi = [
|
|
222
234
|
type: "uint256",
|
223
235
|
},
|
224
236
|
{
|
225
|
-
internalType: "
|
237
|
+
internalType: "uint32",
|
226
238
|
name: "chainId",
|
227
|
-
type: "
|
239
|
+
type: "uint32",
|
228
240
|
},
|
229
241
|
],
|
230
242
|
name: "burn",
|
@@ -306,9 +318,9 @@ const _abi = [
|
|
306
318
|
type: "uint256",
|
307
319
|
},
|
308
320
|
{
|
309
|
-
internalType: "
|
321
|
+
internalType: "uint32",
|
310
322
|
name: "chainId",
|
311
|
-
type: "
|
323
|
+
type: "uint32",
|
312
324
|
},
|
313
325
|
{
|
314
326
|
internalType: "bytes32",
|
@@ -46,15 +46,15 @@ const _abi = [
|
|
46
46
|
},
|
47
47
|
{
|
48
48
|
indexed: false,
|
49
|
-
internalType: "
|
49
|
+
internalType: "uint32",
|
50
50
|
name: "sourceChainId",
|
51
|
-
type: "
|
51
|
+
type: "uint32",
|
52
52
|
},
|
53
53
|
{
|
54
54
|
indexed: true,
|
55
|
-
internalType: "
|
55
|
+
internalType: "uint32",
|
56
56
|
name: "targetChainId",
|
57
|
-
type: "
|
57
|
+
type: "uint32",
|
58
58
|
},
|
59
59
|
],
|
60
60
|
name: "LogGatewayDeposit",
|
@@ -83,15 +83,15 @@ const _abi = [
|
|
83
83
|
},
|
84
84
|
{
|
85
85
|
indexed: true,
|
86
|
-
internalType: "
|
86
|
+
internalType: "uint32",
|
87
87
|
name: "sourceChainId",
|
88
|
-
type: "
|
88
|
+
type: "uint32",
|
89
89
|
},
|
90
90
|
{
|
91
91
|
indexed: false,
|
92
|
-
internalType: "
|
92
|
+
internalType: "uint32",
|
93
93
|
name: "targetChainId",
|
94
|
-
type: "
|
94
|
+
type: "uint32",
|
95
95
|
},
|
96
96
|
{
|
97
97
|
indexed: true,
|
@@ -148,9 +148,9 @@ const _abi = [
|
|
148
148
|
type: "uint256",
|
149
149
|
},
|
150
150
|
{
|
151
|
-
internalType: "
|
151
|
+
internalType: "uint32",
|
152
152
|
name: "chainId_",
|
153
|
-
type: "
|
153
|
+
type: "uint32",
|
154
154
|
},
|
155
155
|
],
|
156
156
|
name: "deposit",
|
@@ -176,9 +176,9 @@ const _abi = [
|
|
176
176
|
type: "uint256",
|
177
177
|
},
|
178
178
|
{
|
179
|
-
internalType: "
|
179
|
+
internalType: "uint32",
|
180
180
|
name: "chainId_",
|
181
|
-
type: "
|
181
|
+
type: "uint32",
|
182
182
|
},
|
183
183
|
],
|
184
184
|
name: "depositFor",
|
@@ -224,9 +224,9 @@ const _abi = [
|
|
224
224
|
type: "address",
|
225
225
|
},
|
226
226
|
{
|
227
|
-
internalType: "
|
227
|
+
internalType: "uint32",
|
228
228
|
name: "chainId_",
|
229
|
-
type: "
|
229
|
+
type: "uint32",
|
230
230
|
},
|
231
231
|
{
|
232
232
|
internalType: "bytes32",
|
package/dist/src/utils/index.js
CHANGED
@@ -167,20 +167,20 @@ const buildWithdrawDataForTransaction = async (transaction, type) => {
|
|
167
167
|
if (!transaction.submitEvent) {
|
168
168
|
throw Error('Cannot build data for transaction without submitEvent');
|
169
169
|
}
|
170
|
-
const { to, amount,
|
171
|
-
const itoken = constants_1.itokens[
|
170
|
+
const { to, amount, sourceChainId, targetChainId, itoken: itokenAddress } = transaction.submitEvent;
|
171
|
+
const itoken = constants_1.itokens[sourceChainId].find(token => token.address.toLowerCase() === itokenAddress.toLowerCase());
|
172
172
|
if (!itoken) {
|
173
173
|
throw Error('Cannot build data for transaction without itoken');
|
174
174
|
}
|
175
|
-
const token = constants_1.tokens[
|
175
|
+
const token = constants_1.tokens[targetChainId].find(t => t.symbol.toLowerCase() === itoken.symbol.toLowerCase());
|
176
176
|
if (!token) {
|
177
177
|
throw Error('Cannot build data for transaction without token');
|
178
178
|
}
|
179
|
-
const targetChainProvider = new ethers_1.ethers.providers.JsonRpcProvider((0, exports.getRpcProviderUrl)(
|
179
|
+
const targetChainProvider = new ethers_1.ethers.providers.JsonRpcProvider((0, exports.getRpcProviderUrl)(targetChainId));
|
180
180
|
const targetWallet = new ethers_1.ethers.Wallet(config_1.default.privateKey, targetChainProvider);
|
181
|
-
const gatewayAddress = constants_1.addresses[
|
181
|
+
const gatewayAddress = constants_1.addresses[targetChainId].interopXGateway;
|
182
182
|
const interopBridgeContract = getContract(gatewayAddress, abi_1.default.interopXGateway, targetWallet);
|
183
|
-
const { data } = await interopBridgeContract.populateTransaction.systemWithdraw(ethers_1.ethers.BigNumber.from(amount.toString()), to, token.address, ethers_1.ethers.BigNumber.from(
|
183
|
+
const { data } = await interopBridgeContract.populateTransaction.systemWithdraw(ethers_1.ethers.BigNumber.from(amount.toString()), to, token.address, ethers_1.ethers.BigNumber.from(sourceChainId.toString()), transaction.submitTransactionHash);
|
184
184
|
transactions.push({
|
185
185
|
to: gatewayAddress,
|
186
186
|
data: data,
|
package/package.json
CHANGED
@@ -46,11 +46,17 @@
|
|
46
46
|
"name": "amount",
|
47
47
|
"type": "uint256"
|
48
48
|
},
|
49
|
+
{
|
50
|
+
"indexed": false,
|
51
|
+
"internalType": "uint32",
|
52
|
+
"name": "sourceChainId",
|
53
|
+
"type": "uint32"
|
54
|
+
},
|
49
55
|
{
|
50
56
|
"indexed": true,
|
51
|
-
"internalType": "
|
52
|
-
"name": "
|
53
|
-
"type": "
|
57
|
+
"internalType": "uint32",
|
58
|
+
"name": "targetChainId",
|
59
|
+
"type": "uint32"
|
54
60
|
}
|
55
61
|
],
|
56
62
|
"name": "Burn",
|
@@ -73,14 +79,20 @@
|
|
73
79
|
},
|
74
80
|
{
|
75
81
|
"indexed": true,
|
76
|
-
"internalType": "
|
77
|
-
"name": "
|
78
|
-
"type": "
|
82
|
+
"internalType": "uint32",
|
83
|
+
"name": "sourceChainId",
|
84
|
+
"type": "uint32"
|
85
|
+
},
|
86
|
+
{
|
87
|
+
"indexed": false,
|
88
|
+
"internalType": "uint32",
|
89
|
+
"name": "targetChainId",
|
90
|
+
"type": "uint32"
|
79
91
|
},
|
80
92
|
{
|
81
93
|
"indexed": true,
|
82
94
|
"internalType": "bytes32",
|
83
|
-
"name": "
|
95
|
+
"name": "submitTransactionHash",
|
84
96
|
"type": "bytes32"
|
85
97
|
}
|
86
98
|
],
|
@@ -164,7 +176,7 @@
|
|
164
176
|
"inputs": [
|
165
177
|
{ "internalType": "address", "name": "to", "type": "address" },
|
166
178
|
{ "internalType": "uint256", "name": "amount", "type": "uint256" },
|
167
|
-
{ "internalType": "
|
179
|
+
{ "internalType": "uint32", "name": "chainId", "type": "uint32" }
|
168
180
|
],
|
169
181
|
"name": "burn",
|
170
182
|
"outputs": [],
|
@@ -206,7 +218,7 @@
|
|
206
218
|
"inputs": [
|
207
219
|
{ "internalType": "address", "name": "to", "type": "address" },
|
208
220
|
{ "internalType": "uint256", "name": "amount", "type": "uint256" },
|
209
|
-
{ "internalType": "
|
221
|
+
{ "internalType": "uint32", "name": "chainId", "type": "uint32" },
|
210
222
|
{
|
211
223
|
"internalType": "bytes32",
|
212
224
|
"name": "transactionHash",
|
@@ -35,15 +35,15 @@
|
|
35
35
|
},
|
36
36
|
{
|
37
37
|
"indexed": false,
|
38
|
-
"internalType": "
|
38
|
+
"internalType": "uint32",
|
39
39
|
"name": "sourceChainId",
|
40
|
-
"type": "
|
40
|
+
"type": "uint32"
|
41
41
|
},
|
42
42
|
{
|
43
43
|
"indexed": true,
|
44
|
-
"internalType": "
|
44
|
+
"internalType": "uint32",
|
45
45
|
"name": "targetChainId",
|
46
|
-
"type": "
|
46
|
+
"type": "uint32"
|
47
47
|
}
|
48
48
|
],
|
49
49
|
"name": "LogGatewayDeposit",
|
@@ -72,15 +72,15 @@
|
|
72
72
|
},
|
73
73
|
{
|
74
74
|
"indexed": true,
|
75
|
-
"internalType": "
|
75
|
+
"internalType": "uint32",
|
76
76
|
"name": "sourceChainId",
|
77
|
-
"type": "
|
77
|
+
"type": "uint32"
|
78
78
|
},
|
79
79
|
{
|
80
80
|
"indexed": false,
|
81
|
-
"internalType": "
|
81
|
+
"internalType": "uint32",
|
82
82
|
"name": "targetChainId",
|
83
|
-
"type": "
|
83
|
+
"type": "uint32"
|
84
84
|
},
|
85
85
|
{
|
86
86
|
"indexed": true,
|
@@ -122,7 +122,7 @@
|
|
122
122
|
"inputs": [
|
123
123
|
{ "internalType": "address", "name": "token_", "type": "address" },
|
124
124
|
{ "internalType": "uint256", "name": "amount_", "type": "uint256" },
|
125
|
-
{ "internalType": "
|
125
|
+
{ "internalType": "uint32", "name": "chainId_", "type": "uint32" }
|
126
126
|
],
|
127
127
|
"name": "deposit",
|
128
128
|
"outputs": [],
|
@@ -134,7 +134,7 @@
|
|
134
134
|
{ "internalType": "address", "name": "to_", "type": "address" },
|
135
135
|
{ "internalType": "address", "name": "token_", "type": "address" },
|
136
136
|
{ "internalType": "uint256", "name": "amount_", "type": "uint256" },
|
137
|
-
{ "internalType": "
|
137
|
+
{ "internalType": "uint32", "name": "chainId_", "type": "uint32" }
|
138
138
|
],
|
139
139
|
"name": "depositFor",
|
140
140
|
"outputs": [],
|
@@ -160,7 +160,7 @@
|
|
160
160
|
{ "internalType": "uint256", "name": "amount_", "type": "uint256" },
|
161
161
|
{ "internalType": "address", "name": "user_", "type": "address" },
|
162
162
|
{ "internalType": "address", "name": "token_", "type": "address" },
|
163
|
-
{ "internalType": "
|
163
|
+
{ "internalType": "uint32", "name": "chainId_", "type": "uint32" },
|
164
164
|
{
|
165
165
|
"internalType": "bytes32",
|
166
166
|
"name": "transactionHash_",
|
@@ -12,6 +12,6 @@ export const addresses = {
|
|
12
12
|
43114: {
|
13
13
|
gnosisSafe: '0x31d7a5194Fe60AC209Cf1Ce2d539C9A60662Ed6b',
|
14
14
|
multisend: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
|
15
|
-
interopXGateway: '
|
15
|
+
interopXGateway: '0xF0317C5Bc206F2291dd2f3eE9C4cDB5Bbb25418d',
|
16
16
|
}
|
17
17
|
}
|
package/src/constants/itokens.ts
CHANGED
package/src/index.ts
CHANGED
@@ -26,12 +26,30 @@ dotenv.config();
|
|
26
26
|
import Logger from "@/logger";
|
27
27
|
const logger = new Logger('Process')
|
28
28
|
|
29
|
+
const GIT_SHORT_HASH = '@GIT_SHORT_HASH@';
|
30
|
+
|
29
31
|
const printUsage = () => {
|
32
|
+
console.log()
|
33
|
+
console.log(`Interop X Node (v${packageJson.version} - rev.${GIT_SHORT_HASH})`)
|
34
|
+
console.log()
|
35
|
+
|
30
36
|
console.log('Usage:')
|
31
|
-
console.log('
|
32
|
-
console.log('
|
33
|
-
|
34
|
-
console.log(
|
37
|
+
console.log(' interop-x help Show this message')
|
38
|
+
console.log(' interop-x version Print out the installed version of Interop X')
|
39
|
+
|
40
|
+
console.log()
|
41
|
+
|
42
|
+
console.log(' interop-x down Put the node into maintenance mode')
|
43
|
+
console.log(' interop-x up Take the node out of maintenance mode')
|
44
|
+
|
45
|
+
console.log()
|
46
|
+
|
47
|
+
console.log(' PRIVATE_KEY=abcd1234 interop-x Start the node with the given private key')
|
48
|
+
console.log(' PRIVATE_KEY=abcd1234 STAGING=true interop-x Start the node in staging mode')
|
49
|
+
console.log(' PRIVATE_KEY=abcd1234 AUTO_UPDATE=true interop-x Start the node in auto update mode')
|
50
|
+
console.log(' PRIVATE_KEY=abcd1234 API_HOST=0.0.0.0 API_PORT=8080 interop-x Start the node with custom API host and port')
|
51
|
+
console.log()
|
52
|
+
|
35
53
|
}
|
36
54
|
|
37
55
|
if (process.argv.at(-1) === 'help') {
|
@@ -43,17 +61,17 @@ const basePath = expandHomeDir(`~/.interop-x`);
|
|
43
61
|
|
44
62
|
if (process.argv.at(-1) === 'down') {
|
45
63
|
fs.outputFileSync(basePath + '/maintenance', Date.now().toString())
|
64
|
+
console.log(chalk.red('Maintenance mode enabled'))
|
46
65
|
process.exit(0)
|
47
66
|
}
|
48
67
|
|
49
68
|
if (process.argv.at(-1) === 'up') {
|
50
69
|
fs.removeSync(basePath + '/maintenance')
|
70
|
+
console.log(chalk.green('Maintenance mode disabled'))
|
51
71
|
process.exit(0)
|
52
72
|
}
|
53
73
|
|
54
74
|
|
55
|
-
const GIT_SHORT_HASH = '@GIT_SHORT_HASH@';
|
56
|
-
|
57
75
|
if (process.argv.at(-1) === 'version') {
|
58
76
|
console.log(`Interop X Node (v${packageJson.version} - rev.${GIT_SHORT_HASH})`)
|
59
77
|
process.exit(0)
|
package/src/net/protocol/dial/{SignatureDialProtocol.1.ts → TransactionStatusDialProtocol.ts}
RENAMED
File without changes
|
@@ -6,7 +6,7 @@ import { IPeerInfo, peerPool } from "..";
|
|
6
6
|
import config from "@/config";
|
7
7
|
import { Event } from "@/types";
|
8
8
|
import { Transaction } from "@/db";
|
9
|
-
import { TransactionStatusDialProtocol } from "./dial/
|
9
|
+
import { TransactionStatusDialProtocol } from "./dial/TransactionStatusDialProtocol";
|
10
10
|
|
11
11
|
export interface ProtocolOptions {
|
12
12
|
/* Handshake timeout in ms (default: 8000) */
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { BaseTask } from "./BaseTask";
|
2
2
|
import Logger from '@/logger';
|
3
|
-
import
|
4
|
-
import spawn from '
|
3
|
+
import spawnAsync from 'await-spawn';
|
4
|
+
import { spawn } from 'child_process'
|
5
5
|
import config from "@/config";
|
6
6
|
import wait from "waait";
|
7
7
|
import packageJson from "../../package.json";
|
@@ -24,22 +24,20 @@ class AutoUpdateTask extends BaseTask {
|
|
24
24
|
|
25
25
|
async getInstalledVersion() {
|
26
26
|
try {
|
27
|
-
const stdout = await
|
27
|
+
const stdout = await spawnAsync('npm', ['-g', 'ls', '--depth=0', '--json'])
|
28
28
|
return JSON.parse(stdout.toString()).dependencies[packageJson.name].version
|
29
29
|
} catch (error) {
|
30
30
|
this.logger.error(error)
|
31
|
-
|
32
31
|
return currentVersion
|
33
32
|
}
|
34
33
|
}
|
35
34
|
|
36
35
|
async getLatestVersion() {
|
37
36
|
try {
|
38
|
-
const stdout = await
|
37
|
+
const stdout = await spawnAsync('npm', ['view', `${packageJson.name}@${tag}`, 'version'])
|
39
38
|
return stdout.toString().trim()
|
40
39
|
} catch (error) {
|
41
40
|
this.logger.error(error)
|
42
|
-
|
43
41
|
return currentVersion
|
44
42
|
}
|
45
43
|
}
|
@@ -55,7 +53,7 @@ class AutoUpdateTask extends BaseTask {
|
|
55
53
|
|
56
54
|
this.logger.info('Updating...')
|
57
55
|
|
58
|
-
await
|
56
|
+
await spawnAsync('npm', ['-g', 'install', `@instadapp/interop-x@${tag}`, '-f']);
|
59
57
|
|
60
58
|
await wait(5000)
|
61
59
|
|
@@ -67,11 +65,16 @@ class AutoUpdateTask extends BaseTask {
|
|
67
65
|
this.logger.warn(`Installed version ${version}`)
|
68
66
|
this.logger.warn(`Restarting...`)
|
69
67
|
|
70
|
-
|
68
|
+
|
69
|
+
// TODO: its restarting in the bg, but it should be in the fg
|
70
|
+
const subprocess = spawn(process.argv[0], process.argv.slice(1), {
|
71
71
|
cwd: process.cwd(),
|
72
|
-
stdio: "inherit"
|
72
|
+
stdio: "inherit",
|
73
|
+
// shell: process.env.SHELL,
|
73
74
|
});
|
74
75
|
|
76
|
+
subprocess.unref();
|
77
|
+
|
75
78
|
process.exit()
|
76
79
|
}
|
77
80
|
}
|
@@ -41,13 +41,13 @@ class SyncWithdrawEvents extends BaseTask {
|
|
41
41
|
continue;
|
42
42
|
}
|
43
43
|
|
44
|
-
const { to, amount,
|
44
|
+
const { to, amount, sourceChainId, targetChainId } = event.args;
|
45
45
|
|
46
46
|
const uniqueIdentifier = {
|
47
47
|
action: 'withdraw',
|
48
48
|
submitTransactionHash: event.transactionHash,
|
49
|
-
sourceChainId:
|
50
|
-
targetChainId:
|
49
|
+
sourceChainId: sourceChainId,
|
50
|
+
targetChainId: targetChainId,
|
51
51
|
}
|
52
52
|
|
53
53
|
if (await Transaction.findOne({ where: uniqueIdentifier })) {
|
@@ -77,14 +77,16 @@ class SyncWithdrawEvents extends BaseTask {
|
|
77
77
|
to,
|
78
78
|
amount: amount.toString(),
|
79
79
|
itoken: this.itokenAddress,
|
80
|
-
|
80
|
+
sourceChainId: sourceChainId,
|
81
|
+
targetChainId: targetChainId,
|
81
82
|
},
|
82
83
|
|
83
84
|
sourceEvent: {
|
84
85
|
to,
|
85
86
|
amount: amount.toString(),
|
86
87
|
itoken: this.itokenAddress,
|
87
|
-
|
88
|
+
sourceChainId: sourceChainId,
|
89
|
+
targetChainId: targetChainId,
|
88
90
|
},
|
89
91
|
status: "pending",
|
90
92
|
})
|
@@ -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 })) {
|
@@ -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
|
|