@instadapp/interop-x 0.0.0-dev.2c0a756 → 0.0.0-dev.30b0db0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/api/index.js +1 -1
- 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/peer/index.js +1 -2
- package/dist/src/net/pool/index.js +2 -3
- 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 +11 -33
- 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 +7 -7
- package/package.json +2 -2
- package/src/abi/interopBridgeToken.json +9 -21
- package/src/abi/interopXGateway.json +11 -11
- package/src/api/index.ts +1 -1
- 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/peer/index.ts +1 -2
- package/src/net/pool/index.ts +2 -3
- 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 +14 -36
- 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 +7 -7
- 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
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.30b0db0",
|
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/api/index.js
CHANGED
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 = '2c0a756';
|
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 = '30b0db0';
|
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);
|
@@ -23,7 +23,6 @@ const libp2p_kad_dht_1 = __importDefault(require("libp2p-kad-dht"));
|
|
23
23
|
const libp2p_pubsub_peer_discovery_1 = __importDefault(require("libp2p-pubsub-peer-discovery"));
|
24
24
|
const net_1 = require("@/net");
|
25
25
|
const config_1 = __importDefault(require("@/config"));
|
26
|
-
const chalk_1 = __importDefault(require("chalk"));
|
27
26
|
const logger = new logger_1.default("Peer");
|
28
27
|
let node;
|
29
28
|
// Known peers addresses
|
@@ -78,7 +77,7 @@ const startPeer = async ({}) => {
|
|
78
77
|
persistence: true,
|
79
78
|
},
|
80
79
|
});
|
81
|
-
logger.info("Peer ID:",
|
80
|
+
logger.info("Peer ID:", node.peerId.toB58String());
|
82
81
|
await node.start();
|
83
82
|
net_1.protocol.start({
|
84
83
|
libp2p: node
|
@@ -9,7 +9,6 @@ const config_1 = __importDefault(require("@/config"));
|
|
9
9
|
const logger_1 = __importDefault(require("@/logger"));
|
10
10
|
const utils_1 = require("ethers/lib/utils");
|
11
11
|
const utils_2 = require("@/utils");
|
12
|
-
const chalk_1 = __importDefault(require("chalk"));
|
13
12
|
const logger = new logger_1.default('PeerPool');
|
14
13
|
class PeerPool {
|
15
14
|
constructor() {
|
@@ -73,7 +72,7 @@ class PeerPool {
|
|
73
72
|
peer.pooled = true;
|
74
73
|
if (newPeer) {
|
75
74
|
config_1.default.events.emit(types_1.Event.POOL_PEER_ADDED, peer);
|
76
|
-
logger.info(`Peer ${
|
75
|
+
logger.info(`Peer ${peer.id} with address ${(0, utils_2.shortenHash)(peer.publicAddress)} added to pool`);
|
77
76
|
}
|
78
77
|
}
|
79
78
|
}
|
@@ -87,7 +86,7 @@ class PeerPool {
|
|
87
86
|
if (this.pool.delete(peer.id)) {
|
88
87
|
peer.pooled = false;
|
89
88
|
config_1.default.events.emit(types_1.Event.POOL_PEER_REMOVED, peer);
|
90
|
-
logger.info(`Peer ${
|
89
|
+
logger.info(`Peer ${peer.id} with address ${(0, utils_2.shortenHash)(peer.publicAddress)} removed from pool`);
|
91
90
|
}
|
92
91
|
}
|
93
92
|
}
|
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);
|
@@ -31,20 +31,20 @@ class Protocol extends stream_1.EventEmitter {
|
|
31
31
|
encode: (transaction) => [
|
32
32
|
Buffer.from(transaction.transactionHash),
|
33
33
|
Buffer.from(transaction.sourceStatus),
|
34
|
-
Buffer.from(transaction.sourceTransactionHash
|
34
|
+
Buffer.from(transaction.sourceTransactionHash),
|
35
35
|
transaction.sourceErrors ? transaction.sourceErrors.map((e) => Buffer.from(e)) : [],
|
36
36
|
Buffer.from(transaction.targetStatus),
|
37
|
-
Buffer.from(transaction.targetTransactionHash
|
37
|
+
Buffer.from(transaction.targetTransactionHash),
|
38
38
|
transaction.targetErrors ? transaction.targetErrors.map((e) => Buffer.from(e)) : [],
|
39
39
|
Buffer.from(transaction.status),
|
40
40
|
],
|
41
41
|
decode: ([transactionHash, sourceStatus, sourceTransactionHash, sourceErrors, targetStatus, targetTransactionHash, targetErrors, status]) => ({
|
42
42
|
transactionHash: transactionHash.toString(),
|
43
43
|
sourceStatus: sourceStatus.toString(),
|
44
|
-
sourceTransactionHash: sourceTransactionHash.toString()
|
44
|
+
sourceTransactionHash: sourceTransactionHash.toString(),
|
45
45
|
sourceErrors: sourceErrors.map((e) => e.toString()),
|
46
46
|
targetStatus: targetStatus.toString(),
|
47
|
-
targetTransactionHash: targetTransactionHash.toString()
|
47
|
+
targetTransactionHash: targetTransactionHash.toString(),
|
48
48
|
targetErrors: targetErrors.map((e) => e.toString()),
|
49
49
|
status: status.toString(),
|
50
50
|
}),
|
@@ -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,65 +5,43 @@ 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
|
-
const package_json_1 = __importDefault(require("../../package.json"));
|
13
|
-
const currentVersion = package_json_1.default.version;
|
14
|
-
const tag = config_1.default.staging ? 'dev' : 'latest';
|
15
12
|
class AutoUpdateTask extends BaseTask_1.BaseTask {
|
16
13
|
constructor() {
|
17
14
|
super({
|
18
15
|
logger: new logger_1.default("AutoUpdateTask"),
|
19
16
|
});
|
20
|
-
this.pollIntervalMs = 60 *
|
17
|
+
this.pollIntervalMs = 60 * 5 * 1000;
|
21
18
|
}
|
22
19
|
prePollHandler() {
|
23
20
|
return config_1.default.autoUpdate && !config_1.default.isLeadNode();
|
24
21
|
}
|
25
|
-
|
26
|
-
|
27
|
-
const stdout = await (0, await_spawn_1.default)('npm', ['-g', 'ls', '--depth=0', '--json']);
|
28
|
-
return JSON.parse(stdout.toString()).dependencies[package_json_1.default.name].version;
|
29
|
-
}
|
30
|
-
catch (error) {
|
31
|
-
this.logger.error(error);
|
32
|
-
return currentVersion;
|
33
|
-
}
|
34
|
-
}
|
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
|
-
}
|
22
|
+
getCurrentVersion() {
|
23
|
+
return require('../../package.json').version;
|
44
24
|
}
|
45
25
|
async pollHandler() {
|
46
|
-
const
|
26
|
+
const { data } = await utils_1.http.get('https://registry.npmjs.org/@instadapp/interop-x');
|
27
|
+
const version = data['dist-tags'].latest;
|
28
|
+
const currentVersion = this.getCurrentVersion();
|
47
29
|
if (version === currentVersion) {
|
48
30
|
return;
|
49
31
|
}
|
50
32
|
this.logger.warn(`New version ${version} available.`);
|
51
|
-
|
52
|
-
await (0, await_spawn_1.default)('npm', ['-g', 'install', `@instadapp/interop-x@${tag}`, '-f']);
|
33
|
+
await (0, await_spawn_1.default)('npm', ['-g', 'install', '@instadapp/interop-x', '-f']);
|
53
34
|
await (0, waait_1.default)(5000);
|
54
|
-
if (
|
35
|
+
if (currentVersion === this.getCurrentVersion()) {
|
55
36
|
this.logger.warn(`failed to install ${version}, retrying in 5 minutes`);
|
56
37
|
return;
|
57
38
|
}
|
58
39
|
this.logger.warn(`Installed version ${version}`);
|
59
40
|
this.logger.warn(`Restarting...`);
|
60
|
-
|
61
|
-
const subprocess = (0, child_process_1.spawn)(process.argv[0], process.argv.slice(1), {
|
41
|
+
(0, await_spawn_1.default)(process.argv[0], process.argv.slice(1), {
|
62
42
|
cwd: process.cwd(),
|
63
|
-
stdio: "inherit"
|
64
|
-
// shell: process.env.SHELL,
|
43
|
+
stdio: "inherit"
|
65
44
|
});
|
66
|
-
subprocess.unref();
|
67
45
|
process.exit();
|
68
46
|
}
|
69
47
|
}
|
@@ -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
|
}
|
@@ -10,10 +10,10 @@ const abi_1 = __importDefault(require("@/abi"));
|
|
10
10
|
const db_1 = require("@/db");
|
11
11
|
const utils_1 = require("@/utils");
|
12
12
|
const config_1 = __importDefault(require("@/config"));
|
13
|
-
class
|
13
|
+
class SyncWithdrawEvents extends BaseTask_1.BaseTask {
|
14
14
|
constructor({ chainId, itokenAddress }) {
|
15
15
|
super({
|
16
|
-
logger: new logger_1.default("InteropBridgeToken::
|
16
|
+
logger: new logger_1.default("InteropBridgeToken::SyncWithdrawEvents"),
|
17
17
|
});
|
18
18
|
this.chainId = chainId;
|
19
19
|
this.itokenAddress = itokenAddress;
|
@@ -27,12 +27,12 @@ class SyncBurnEvents 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 SyncBurnEvents 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,4 +66,4 @@ class SyncBurnEvents extends BaseTask_1.BaseTask {
|
|
68
66
|
await super.start();
|
69
67
|
}
|
70
68
|
}
|
71
|
-
exports.default =
|
69
|
+
exports.default = SyncWithdrawEvents;
|
@@ -68,22 +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
|
-
transaction.status = 'failed';
|
80
|
-
await transaction.save();
|
81
|
-
net_1.protocol.sendTransaction(transaction);
|
82
|
-
return;
|
83
|
-
}
|
84
71
|
let gnosisTx = await generateGnosisTransaction({
|
85
72
|
baseGas: "0",
|
86
|
-
data,
|
73
|
+
data: await (0, utils_1.buildDataForTransaction)(transaction),
|
87
74
|
gasPrice: "0",
|
88
75
|
gasToken: "0x0000000000000000000000000000000000000000",
|
89
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;
|
package/dist/src/tasks/index.js
CHANGED
@@ -6,39 +6,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Tasks = void 0;
|
7
7
|
const ProcessDepositEvents_1 = __importDefault(require("./InteropXGateway/ProcessDepositEvents"));
|
8
8
|
const SyncDepositEvents_1 = __importDefault(require("./InteropXGateway/SyncDepositEvents"));
|
9
|
-
const
|
10
|
-
const
|
11
|
-
const SyncBurnEvents_2 = __importDefault(require("./InteropBridge/SyncBurnEvents"));
|
12
|
-
const SyncMintEvents_1 = __importDefault(require("./InteropBridge/SyncMintEvents"));
|
13
|
-
const SyncTransactionStatusTask_1 = __importDefault(require("./Transactions/SyncTransactionStatusTask"));
|
9
|
+
const SyncWithdrawEvents_1 = __importDefault(require("./InteropBridge/SyncWithdrawEvents"));
|
10
|
+
const ProcessWithdrawEvents_1 = __importDefault(require("./InteropBridge/ProcessWithdrawEvents"));
|
14
11
|
const AutoUpdateTask_1 = __importDefault(require("./AutoUpdateTask"));
|
12
|
+
const SyncTransactionStatusTask_1 = __importDefault(require("./Transactions/SyncTransactionStatusTask"));
|
15
13
|
class Tasks {
|
16
14
|
constructor() {
|
17
15
|
this.tasks = [
|
18
16
|
new SyncTransactionStatusTask_1.default(),
|
19
17
|
new AutoUpdateTask_1.default(),
|
20
|
-
// InteropXGateway
|
21
18
|
new SyncDepositEvents_1.default({
|
22
19
|
chainId: 43114
|
23
20
|
}),
|
24
21
|
new ProcessDepositEvents_1.default({
|
25
22
|
chainId: 43114
|
26
23
|
}),
|
27
|
-
new
|
28
|
-
chainId: 43114
|
29
|
-
}),
|
30
|
-
// InteropBridge
|
31
|
-
new SyncBurnEvents_1.default({
|
24
|
+
new SyncWithdrawEvents_1.default({
|
32
25
|
chainId: 137,
|
33
26
|
itokenAddress: '0xEab02fe1F016eE3e4106c1C6aad35FeEe657268E',
|
34
27
|
}),
|
35
|
-
new
|
28
|
+
new ProcessWithdrawEvents_1.default({
|
36
29
|
chainId: 137,
|
37
|
-
itokenAddress: '0xEab02fe1F016eE3e4106c1C6aad35FeEe657268E',
|
38
|
-
}),
|
39
|
-
new SyncBurnEvents_2.default({
|
40
|
-
chainId: 137,
|
41
|
-
itokenAddress: '0xEab02fe1F016eE3e4106c1C6aad35FeEe657268E',
|
42
30
|
})
|
43
31
|
];
|
44
32
|
}
|