@instadapp/interop-x 0.0.0-dev.f0a6281 → 0.0.0-dev.fabee70
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 +2 -2
- package/dist/src/tasks/AutoUpdateTask.js +7 -20
- package/dist/src/tasks/BaseTask.js +0 -4
- package/dist/src/tasks/InteropBridge/SyncWithdrawEvents.js +5 -7
- package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +1 -13
- package/dist/src/tasks/InteropXGateway/SyncDepositEvents.js +2 -2
- 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 +1 -1
- package/src/tasks/AutoUpdateTask.ts +15 -24
- package/src/tasks/BaseTask.ts +0 -5
- package/src/tasks/InteropBridge/SyncWithdrawEvents.ts +5 -7
- package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +4 -17
- package/src/tasks/InteropXGateway/SyncDepositEvents.ts +2 -2
- 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/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@instadapp/interop-x",
|
3
|
-
"version": "0.0.0-dev.
|
3
|
+
"version": "0.0.0-dev.fabee70",
|
4
4
|
"license": "MIT",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"engines": {
|
@@ -28,6 +28,7 @@
|
|
28
28
|
"await-spawn": "^4.0.2",
|
29
29
|
"axios": "^0.27.1",
|
30
30
|
"axios-retry": "^3.2.4",
|
31
|
+
"bignumber.js": "^9.0.2",
|
31
32
|
"chalk": "4.1.2",
|
32
33
|
"dotenv": "^16.0.0",
|
33
34
|
"ethereumjs-util": "^7.1.4",
|
@@ -35,7 +36,6 @@
|
|
35
36
|
"ethers-multisend": "^2.1.1",
|
36
37
|
"expand-home-dir": "^0.0.3",
|
37
38
|
"fastify": "^3.28.0",
|
38
|
-
"fs-extra": "^10.1.0",
|
39
39
|
"libp2p": "^0.36.2",
|
40
40
|
"libp2p-bootstrap": "^0.14.0",
|
41
41
|
"libp2p-kad-dht": "^0.28.6",
|
@@ -46,17 +46,11 @@
|
|
46
46
|
"name": "amount",
|
47
47
|
"type": "uint256"
|
48
48
|
},
|
49
|
-
{
|
50
|
-
"indexed": false,
|
51
|
-
"internalType": "uint32",
|
52
|
-
"name": "sourceChainId",
|
53
|
-
"type": "uint32"
|
54
|
-
},
|
55
49
|
{
|
56
50
|
"indexed": true,
|
57
|
-
"internalType": "
|
58
|
-
"name": "
|
59
|
-
"type": "
|
51
|
+
"internalType": "uint256",
|
52
|
+
"name": "chainId",
|
53
|
+
"type": "uint256"
|
60
54
|
}
|
61
55
|
],
|
62
56
|
"name": "Burn",
|
@@ -79,20 +73,14 @@
|
|
79
73
|
},
|
80
74
|
{
|
81
75
|
"indexed": true,
|
82
|
-
"internalType": "
|
83
|
-
"name": "
|
84
|
-
"type": "
|
85
|
-
},
|
86
|
-
{
|
87
|
-
"indexed": false,
|
88
|
-
"internalType": "uint32",
|
89
|
-
"name": "targetChainId",
|
90
|
-
"type": "uint32"
|
76
|
+
"internalType": "uint256",
|
77
|
+
"name": "chainId",
|
78
|
+
"type": "uint256"
|
91
79
|
},
|
92
80
|
{
|
93
81
|
"indexed": true,
|
94
82
|
"internalType": "bytes32",
|
95
|
-
"name": "
|
83
|
+
"name": "transactionHash",
|
96
84
|
"type": "bytes32"
|
97
85
|
}
|
98
86
|
],
|
@@ -176,7 +164,7 @@
|
|
176
164
|
"inputs": [
|
177
165
|
{ "internalType": "address", "name": "to", "type": "address" },
|
178
166
|
{ "internalType": "uint256", "name": "amount", "type": "uint256" },
|
179
|
-
{ "internalType": "
|
167
|
+
{ "internalType": "uint256", "name": "chainId", "type": "uint256" }
|
180
168
|
],
|
181
169
|
"name": "burn",
|
182
170
|
"outputs": [],
|
@@ -218,7 +206,7 @@
|
|
218
206
|
"inputs": [
|
219
207
|
{ "internalType": "address", "name": "to", "type": "address" },
|
220
208
|
{ "internalType": "uint256", "name": "amount", "type": "uint256" },
|
221
|
-
{ "internalType": "
|
209
|
+
{ "internalType": "uint256", "name": "chainId", "type": "uint256" },
|
222
210
|
{
|
223
211
|
"internalType": "bytes32",
|
224
212
|
"name": "transactionHash",
|
@@ -35,15 +35,15 @@
|
|
35
35
|
},
|
36
36
|
{
|
37
37
|
"indexed": false,
|
38
|
-
"internalType": "
|
38
|
+
"internalType": "uint256",
|
39
39
|
"name": "sourceChainId",
|
40
|
-
"type": "
|
40
|
+
"type": "uint256"
|
41
41
|
},
|
42
42
|
{
|
43
43
|
"indexed": true,
|
44
|
-
"internalType": "
|
44
|
+
"internalType": "uint256",
|
45
45
|
"name": "targetChainId",
|
46
|
-
"type": "
|
46
|
+
"type": "uint256"
|
47
47
|
}
|
48
48
|
],
|
49
49
|
"name": "LogGatewayDeposit",
|
@@ -72,15 +72,15 @@
|
|
72
72
|
},
|
73
73
|
{
|
74
74
|
"indexed": true,
|
75
|
-
"internalType": "
|
75
|
+
"internalType": "uint256",
|
76
76
|
"name": "sourceChainId",
|
77
|
-
"type": "
|
77
|
+
"type": "uint256"
|
78
78
|
},
|
79
79
|
{
|
80
80
|
"indexed": false,
|
81
|
-
"internalType": "
|
81
|
+
"internalType": "uint256",
|
82
82
|
"name": "targetChainId",
|
83
|
-
"type": "
|
83
|
+
"type": "uint256"
|
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": "uint256", "name": "chainId_", "type": "uint256" }
|
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": "uint256", "name": "chainId_", "type": "uint256" }
|
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": "uint256", "name": "chainId_", "type": "uint256" },
|
164
164
|
{
|
165
165
|
"internalType": "bytes32",
|
166
166
|
"name": "transactionHash_",
|
package/dist/src/config/index.js
CHANGED
@@ -1,22 +1,16 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
3
|
const ethers_1 = require("ethers");
|
7
4
|
const types_1 = require("@/types");
|
8
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
9
|
-
const expand_home_dir_1 = __importDefault(require("expand-home-dir"));
|
10
5
|
class Config {
|
11
6
|
constructor() {
|
12
7
|
this.events = new types_1.EventBus();
|
13
|
-
this.maxPeers =
|
8
|
+
this.maxPeers = 10;
|
14
9
|
this.privateKey = process.env.PRIVATE_KEY;
|
15
10
|
this.staging = !!process.env.STAGING && process.env.STAGING === 'true';
|
16
11
|
this.autoUpdate = !!process.env.AUTO_UPDATE && process.env.AUTO_UPDATE === 'true';
|
17
12
|
this.wallet = new ethers_1.Wallet(this.privateKey);
|
18
13
|
this.leadNodeAddress = '0x910E413DBF3F6276Fe8213fF656726bDc142E08E';
|
19
|
-
this.baseConfigPath = (0, expand_home_dir_1.default)(`~/.interop-x`);
|
20
14
|
}
|
21
15
|
get publicAddress() {
|
22
16
|
return this.wallet.address;
|
@@ -24,8 +18,5 @@ class Config {
|
|
24
18
|
isLeadNode() {
|
25
19
|
return ethers_1.ethers.utils.getAddress(this.leadNodeAddress) === ethers_1.ethers.utils.getAddress(this.wallet.address);
|
26
20
|
}
|
27
|
-
isMaintenanceMode() {
|
28
|
-
return fs_extra_1.default.existsSync(this.baseConfigPath + '/maintenance');
|
29
|
-
}
|
30
21
|
}
|
31
22
|
exports.default = new Config();
|
@@ -15,6 +15,6 @@ exports.addresses = {
|
|
15
15
|
43114: {
|
16
16
|
gnosisSafe: '0x31d7a5194Fe60AC209Cf1Ce2d539C9A60662Ed6b',
|
17
17
|
multisend: '0x998739BFdAAdde7C933B942a68053933098f9EDa',
|
18
|
-
interopXGateway: '
|
18
|
+
interopXGateway: '0x8D27758751BA488690974B6Ccfcda771D462945f',
|
19
19
|
}
|
20
20
|
};
|
package/dist/src/index.js
CHANGED
@@ -4,8 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
const module_alias_1 = __importDefault(require("module-alias"));
|
7
|
-
const expand_home_dir_1 = __importDefault(require("expand-home-dir"));
|
8
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
9
7
|
module_alias_1.default.addAliases({
|
10
8
|
"@/": __dirname + "/",
|
11
9
|
"@/logger": __dirname + "/logger",
|
@@ -28,39 +26,18 @@ const package_json_1 = __importDefault(require("../package.json"));
|
|
28
26
|
dotenv_1.default.config();
|
29
27
|
const logger_1 = __importDefault(require("@/logger"));
|
30
28
|
const logger = new logger_1.default('Process');
|
31
|
-
const GIT_SHORT_HASH = 'f0a6281';
|
32
29
|
const printUsage = () => {
|
33
|
-
console.log();
|
34
|
-
console.log(`Interop X Node (v${package_json_1.default.version} - rev.${GIT_SHORT_HASH})`);
|
35
|
-
console.log();
|
36
30
|
console.log('Usage:');
|
37
|
-
console.log(' interop-x
|
38
|
-
console.log(' interop-x
|
39
|
-
console.log();
|
40
|
-
console.log(' interop-x
|
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();
|
31
|
+
console.log(' PRIVATE_KEY=abcd1234 interop-x');
|
32
|
+
console.log(' PRIVATE_KEY=abcd1234 STAGING=true interop-x');
|
33
|
+
console.log(' PRIVATE_KEY=abcd1234 AUTO_UPDATE=true interop-x');
|
34
|
+
console.log(' PRIVATE_KEY=abcd1234 API_HOST=0.0.0.0 API_PORT=8080 interop-x');
|
48
35
|
};
|
49
36
|
if (process.argv.at(-1) === 'help') {
|
50
37
|
printUsage();
|
51
38
|
process.exit(0);
|
52
39
|
}
|
53
|
-
const
|
54
|
-
if (process.argv.at(-1) === 'down') {
|
55
|
-
fs_extra_1.default.outputFileSync(basePath + '/maintenance', Date.now().toString());
|
56
|
-
console.log(chalk_1.default.red('Maintenance mode enabled'));
|
57
|
-
process.exit(0);
|
58
|
-
}
|
59
|
-
if (process.argv.at(-1) === 'up') {
|
60
|
-
fs_extra_1.default.removeSync(basePath + '/maintenance');
|
61
|
-
console.log(chalk_1.default.green('Maintenance mode disabled'));
|
62
|
-
process.exit(0);
|
63
|
-
}
|
40
|
+
const GIT_SHORT_HASH = 'fabee70';
|
64
41
|
if (process.argv.at(-1) === 'version') {
|
65
42
|
console.log(`Interop X Node (v${package_json_1.default.version} - rev.${GIT_SHORT_HASH})`);
|
66
43
|
process.exit(0);
|
package/dist/src/net/protocol/dial/{TransactionStatusDialProtocol.js → SignatureDialProtocol.1.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 SignatureDialProtocol_1_1 = require("./dial/SignatureDialProtocol.1");
|
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 SignatureDialProtocol_1_1.TransactionStatusDialProtocol(this.libp2p);
|
69
69
|
}
|
70
70
|
init() {
|
71
71
|
this.libp2p.pubsub.subscribe(this.topic);
|
@@ -5,19 +5,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
const BaseTask_1 = require("./BaseTask");
|
7
7
|
const logger_1 = __importDefault(require("@/logger"));
|
8
|
+
const utils_1 = require("@/utils");
|
8
9
|
const await_spawn_1 = __importDefault(require("await-spawn"));
|
9
|
-
const child_process_1 = require("child_process");
|
10
10
|
const config_1 = __importDefault(require("@/config"));
|
11
11
|
const waait_1 = __importDefault(require("waait"));
|
12
12
|
const package_json_1 = __importDefault(require("../../package.json"));
|
13
13
|
const currentVersion = package_json_1.default.version;
|
14
|
-
const tag = config_1.default.staging ? 'dev' : 'latest';
|
15
14
|
class AutoUpdateTask extends BaseTask_1.BaseTask {
|
16
15
|
constructor() {
|
17
16
|
super({
|
18
17
|
logger: new logger_1.default("AutoUpdateTask"),
|
19
18
|
});
|
20
|
-
this.pollIntervalMs = 60 *
|
19
|
+
this.pollIntervalMs = 60 * 5 * 1000;
|
21
20
|
}
|
22
21
|
prePollHandler() {
|
23
22
|
return config_1.default.autoUpdate && !config_1.default.isLeadNode();
|
@@ -32,24 +31,15 @@ class AutoUpdateTask extends BaseTask_1.BaseTask {
|
|
32
31
|
return currentVersion;
|
33
32
|
}
|
34
33
|
}
|
35
|
-
async getLatestVersion() {
|
36
|
-
try {
|
37
|
-
const stdout = await (0, await_spawn_1.default)('npm', ['view', `${package_json_1.default.name}@${tag}`, 'version']);
|
38
|
-
return stdout.toString().trim();
|
39
|
-
}
|
40
|
-
catch (error) {
|
41
|
-
this.logger.error(error);
|
42
|
-
return currentVersion;
|
43
|
-
}
|
44
|
-
}
|
45
34
|
async pollHandler() {
|
46
|
-
const
|
35
|
+
const { data } = await utils_1.http.get('https://registry.npmjs.org/@instadapp/interop-x');
|
36
|
+
const version = data['dist-tags'].latest;
|
47
37
|
if (version === currentVersion) {
|
48
38
|
return;
|
49
39
|
}
|
50
40
|
this.logger.warn(`New version ${version} available.`);
|
51
41
|
this.logger.info('Updating...');
|
52
|
-
await (0, await_spawn_1.default)('npm', ['-g', 'install',
|
42
|
+
await (0, await_spawn_1.default)('npm', ['-g', 'install', '@instadapp/interop-x', '-f']);
|
53
43
|
await (0, waait_1.default)(5000);
|
54
44
|
if (version !== await this.getInstalledVersion()) {
|
55
45
|
this.logger.warn(`failed to install ${version}, retrying in 5 minutes`);
|
@@ -57,13 +47,10 @@ class AutoUpdateTask extends BaseTask_1.BaseTask {
|
|
57
47
|
}
|
58
48
|
this.logger.warn(`Installed version ${version}`);
|
59
49
|
this.logger.warn(`Restarting...`);
|
60
|
-
|
61
|
-
const subprocess = (0, child_process_1.spawn)(process.argv[0], process.argv.slice(1), {
|
50
|
+
(0, await_spawn_1.default)(process.argv[0], process.argv.slice(1), {
|
62
51
|
cwd: process.cwd(),
|
63
|
-
stdio: "inherit"
|
64
|
-
// shell: process.env.SHELL,
|
52
|
+
stdio: "inherit"
|
65
53
|
});
|
66
|
-
subprocess.unref();
|
67
54
|
process.exit();
|
68
55
|
}
|
69
56
|
}
|
@@ -35,10 +35,6 @@ class BaseTask extends events_1.default {
|
|
35
35
|
}
|
36
36
|
}
|
37
37
|
prePollHandler() {
|
38
|
-
if (config_1.default.isMaintenanceMode()) {
|
39
|
-
this.logger.warn('Maintenance mode is enabled. Skipping task.');
|
40
|
-
return false;
|
41
|
-
}
|
42
38
|
if (this.exceptLeadNode) {
|
43
39
|
return !config_1.default.isLeadNode();
|
44
40
|
}
|
@@ -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, chainId } = event.args;
|
31
31
|
const uniqueIdentifier = {
|
32
32
|
action: 'withdraw',
|
33
33
|
submitTransactionHash: event.transactionHash,
|
34
|
-
sourceChainId:
|
35
|
-
targetChainId:
|
34
|
+
sourceChainId: this.chainId,
|
35
|
+
targetChainId: chainId.toNumber(),
|
36
36
|
};
|
37
37
|
if (await db_1.Transaction.findOne({ where: uniqueIdentifier })) {
|
38
38
|
continue;
|
@@ -44,14 +44,12 @@ class SyncWithdrawEvents extends BaseTask_1.BaseTask {
|
|
44
44
|
to,
|
45
45
|
amount: amount.toString(),
|
46
46
|
itoken: this.itokenAddress,
|
47
|
-
|
48
|
-
targetChainId: targetChainId,
|
47
|
+
chainId: chainId.toString()
|
49
48
|
}, sourceEvent: {
|
50
49
|
to,
|
51
50
|
amount: amount.toString(),
|
52
51
|
itoken: this.itokenAddress,
|
53
|
-
|
54
|
-
targetChainId: targetChainId,
|
52
|
+
chainId: chainId.toString(),
|
55
53
|
}, status: "pending" }));
|
56
54
|
this.logger.info(`Withdraw queued: ${event.transactionHash} ${event.blockNumber}`);
|
57
55
|
}
|
@@ -68,21 +68,9 @@ class ProcessDepositEvents extends BaseTask_1.BaseTask {
|
|
68
68
|
const safeContract = (0, utils_1.getContract)(safeAddress, abi_1.default.gnosisSafe, targetWallet);
|
69
69
|
const ownersThreshold = await safeContract.getThreshold();
|
70
70
|
await (0, waait_1.default)(10000);
|
71
|
-
let data;
|
72
|
-
try {
|
73
|
-
data = await (0, utils_1.buildDataForTransaction)(transaction);
|
74
|
-
}
|
75
|
-
catch (error) {
|
76
|
-
console.log(error);
|
77
|
-
transaction.targetStatus = 'failed';
|
78
|
-
transaction.targetErrors = [error.message];
|
79
|
-
await transaction.save();
|
80
|
-
net_1.protocol.sendTransaction(transaction);
|
81
|
-
return;
|
82
|
-
}
|
83
71
|
let gnosisTx = await generateGnosisTransaction({
|
84
72
|
baseGas: "0",
|
85
|
-
data,
|
73
|
+
data: await (0, utils_1.buildDataForTransaction)(transaction),
|
86
74
|
gasPrice: "0",
|
87
75
|
gasToken: "0x0000000000000000000000000000000000000000",
|
88
76
|
nonce: '0',
|
@@ -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.toNumber(),
|
35
|
+
targetChainId: targetChainId.toNumber(),
|
36
36
|
};
|
37
37
|
if (await db_1.Transaction.findOne({ where: uniqueIdentifier })) {
|
38
38
|
continue;
|
@@ -57,17 +57,11 @@ 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
|
-
},
|
66
60
|
{
|
67
61
|
indexed: true,
|
68
|
-
internalType: "
|
69
|
-
name: "
|
70
|
-
type: "
|
62
|
+
internalType: "uint256",
|
63
|
+
name: "chainId",
|
64
|
+
type: "uint256",
|
71
65
|
},
|
72
66
|
],
|
73
67
|
name: "Burn",
|
@@ -90,20 +84,14 @@ const _abi = [
|
|
90
84
|
},
|
91
85
|
{
|
92
86
|
indexed: true,
|
93
|
-
internalType: "
|
94
|
-
name: "
|
95
|
-
type: "
|
96
|
-
},
|
97
|
-
{
|
98
|
-
indexed: false,
|
99
|
-
internalType: "uint32",
|
100
|
-
name: "targetChainId",
|
101
|
-
type: "uint32",
|
87
|
+
internalType: "uint256",
|
88
|
+
name: "chainId",
|
89
|
+
type: "uint256",
|
102
90
|
},
|
103
91
|
{
|
104
92
|
indexed: true,
|
105
93
|
internalType: "bytes32",
|
106
|
-
name: "
|
94
|
+
name: "transactionHash",
|
107
95
|
type: "bytes32",
|
108
96
|
},
|
109
97
|
],
|
@@ -234,9 +222,9 @@ const _abi = [
|
|
234
222
|
type: "uint256",
|
235
223
|
},
|
236
224
|
{
|
237
|
-
internalType: "
|
225
|
+
internalType: "uint256",
|
238
226
|
name: "chainId",
|
239
|
-
type: "
|
227
|
+
type: "uint256",
|
240
228
|
},
|
241
229
|
],
|
242
230
|
name: "burn",
|
@@ -318,9 +306,9 @@ const _abi = [
|
|
318
306
|
type: "uint256",
|
319
307
|
},
|
320
308
|
{
|
321
|
-
internalType: "
|
309
|
+
internalType: "uint256",
|
322
310
|
name: "chainId",
|
323
|
-
type: "
|
311
|
+
type: "uint256",
|
324
312
|
},
|
325
313
|
{
|
326
314
|
internalType: "bytes32",
|
@@ -46,15 +46,15 @@ const _abi = [
|
|
46
46
|
},
|
47
47
|
{
|
48
48
|
indexed: false,
|
49
|
-
internalType: "
|
49
|
+
internalType: "uint256",
|
50
50
|
name: "sourceChainId",
|
51
|
-
type: "
|
51
|
+
type: "uint256",
|
52
52
|
},
|
53
53
|
{
|
54
54
|
indexed: true,
|
55
|
-
internalType: "
|
55
|
+
internalType: "uint256",
|
56
56
|
name: "targetChainId",
|
57
|
-
type: "
|
57
|
+
type: "uint256",
|
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: "uint256",
|
87
87
|
name: "sourceChainId",
|
88
|
-
type: "
|
88
|
+
type: "uint256",
|
89
89
|
},
|
90
90
|
{
|
91
91
|
indexed: false,
|
92
|
-
internalType: "
|
92
|
+
internalType: "uint256",
|
93
93
|
name: "targetChainId",
|
94
|
-
type: "
|
94
|
+
type: "uint256",
|
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: "uint256",
|
152
152
|
name: "chainId_",
|
153
|
-
type: "
|
153
|
+
type: "uint256",
|
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: "uint256",
|
180
180
|
name: "chainId_",
|
181
|
-
type: "
|
181
|
+
type: "uint256",
|
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: "uint256",
|
228
228
|
name: "chainId_",
|
229
|
-
type: "
|
229
|
+
type: "uint256",
|
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[sourceChainId].find(token => token.address.toLowerCase() === itokenAddress.toLowerCase());
|
170
|
+
const { to, amount, chainId, itoken: itokenAddress } = transaction.submitEvent;
|
171
|
+
const itoken = constants_1.itokens[transaction.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[chainId].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)(targetChainId));
|
179
|
+
const targetChainProvider = new ethers_1.ethers.providers.JsonRpcProvider((0, exports.getRpcProviderUrl)(transaction.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[chainId].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(sourceChainId.toString()), transaction.submitTransactionHash);
|
183
|
+
const { data } = await interopBridgeContract.populateTransaction.systemWithdraw(ethers_1.ethers.BigNumber.from(amount.toString()), to, token.address, ethers_1.ethers.BigNumber.from(transaction.sourceChainId.toString()), transaction.submitTransactionHash);
|
184
184
|
transactions.push({
|
185
185
|
to: gatewayAddress,
|
186
186
|
data: data,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@instadapp/interop-x",
|
3
|
-
"version": "0.0.0-dev.
|
3
|
+
"version": "0.0.0-dev.fabee70",
|
4
4
|
"license": "MIT",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"engines": {
|
@@ -28,6 +28,7 @@
|
|
28
28
|
"await-spawn": "^4.0.2",
|
29
29
|
"axios": "^0.27.1",
|
30
30
|
"axios-retry": "^3.2.4",
|
31
|
+
"bignumber.js": "^9.0.2",
|
31
32
|
"chalk": "4.1.2",
|
32
33
|
"dotenv": "^16.0.0",
|
33
34
|
"ethereumjs-util": "^7.1.4",
|
@@ -35,7 +36,6 @@
|
|
35
36
|
"ethers-multisend": "^2.1.1",
|
36
37
|
"expand-home-dir": "^0.0.3",
|
37
38
|
"fastify": "^3.28.0",
|
38
|
-
"fs-extra": "^10.1.0",
|
39
39
|
"libp2p": "^0.36.2",
|
40
40
|
"libp2p-bootstrap": "^0.14.0",
|
41
41
|
"libp2p-kad-dht": "^0.28.6",
|