@instadapp/interop-x 0.0.0-dev.234b8be → 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/api/index.js +1 -1
- package/dist/src/config/index.js +1 -10
- package/dist/src/index.js +1 -14
- package/dist/src/net/peer/index.js +1 -2
- package/dist/src/net/pool/index.js +2 -3
- package/dist/src/tasks/AutoUpdateTask.js +11 -32
- package/dist/src/tasks/BaseTask.js +0 -4
- package/dist/src/utils/index.js +1 -1
- package/package.json +2 -2
- package/src/api/index.ts +1 -1
- package/src/config/index.ts +1 -9
- package/src/index.ts +4 -20
- package/src/net/peer/index.ts +1 -2
- package/src/net/pool/index.ts +2 -3
- package/src/tasks/AutoUpdateTask.ts +14 -34
- package/src/tasks/BaseTask.ts +0 -5
- package/src/utils/index.ts +1 -1
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",
|
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();
|
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",
|
@@ -39,18 +37,7 @@ if (process.argv.at(-1) === 'help') {
|
|
39
37
|
printUsage();
|
40
38
|
process.exit(0);
|
41
39
|
}
|
42
|
-
const
|
43
|
-
if (process.argv.at(-1) === 'down') {
|
44
|
-
fs_extra_1.default.outputFileSync(basePath + '/maintenance', Date.now().toString());
|
45
|
-
console.log(chalk_1.default.red('Maintenance mode enabled'));
|
46
|
-
process.exit(0);
|
47
|
-
}
|
48
|
-
if (process.argv.at(-1) === 'up') {
|
49
|
-
fs_extra_1.default.removeSync(basePath + '/maintenance');
|
50
|
-
console.log(chalk_1.default.green('Maintenance mode disabled'));
|
51
|
-
process.exit(0);
|
52
|
-
}
|
53
|
-
const GIT_SHORT_HASH = '234b8be';
|
40
|
+
const GIT_SHORT_HASH = '30b0db0';
|
54
41
|
if (process.argv.at(-1) === 'version') {
|
55
42
|
console.log(`Interop X Node (v${package_json_1.default.version} - rev.${GIT_SHORT_HASH})`);
|
56
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
|
}
|
@@ -5,64 +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
|
-
|
41
|
+
(0, await_spawn_1.default)(process.argv[0], process.argv.slice(1), {
|
61
42
|
cwd: process.cwd(),
|
62
|
-
stdio: "inherit"
|
63
|
-
shell: process.env.SHELL,
|
43
|
+
stdio: "inherit"
|
64
44
|
});
|
65
|
-
subprocess.unref();
|
66
45
|
process.exit();
|
67
46
|
}
|
68
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
|
}
|
package/dist/src/utils/index.js
CHANGED
@@ -22,7 +22,7 @@ function shortenHash(hash, length = 4) {
|
|
22
22
|
if (hash.length < 12)
|
23
23
|
return hash;
|
24
24
|
const beginningChars = hash.startsWith("0x") ? length + 2 : length;
|
25
|
-
const shortened = hash.
|
25
|
+
const shortened = hash.substring(0, beginningChars) + "…" + hash.substring(-length);
|
26
26
|
return shortened;
|
27
27
|
}
|
28
28
|
exports.shortenHash = shortenHash;
|
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.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",
|
package/src/api/index.ts
CHANGED
package/src/config/index.ts
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
import { ethers, Wallet } from "ethers"
|
2
2
|
import { EventBus, EventBusType } from "@/types"
|
3
|
-
import fs from 'fs-extra'
|
4
|
-
import expandHomeDir from "expand-home-dir";
|
5
3
|
|
6
4
|
class Config {
|
7
5
|
public readonly events: EventBusType
|
@@ -11,17 +9,15 @@ class Config {
|
|
11
9
|
public readonly wallet: Wallet
|
12
10
|
public readonly staging: boolean
|
13
11
|
public readonly autoUpdate: boolean
|
14
|
-
public readonly baseConfigPath: string
|
15
12
|
|
16
13
|
constructor() {
|
17
14
|
this.events = new EventBus() as EventBusType
|
18
|
-
this.maxPeers =
|
15
|
+
this.maxPeers = 10
|
19
16
|
this.privateKey = process.env.PRIVATE_KEY as string;
|
20
17
|
this.staging = !! process.env.STAGING && process.env.STAGING === 'true';
|
21
18
|
this.autoUpdate = !! process.env.AUTO_UPDATE && process.env.AUTO_UPDATE === 'true';
|
22
19
|
this.wallet = new Wallet(this.privateKey);
|
23
20
|
this.leadNodeAddress = '0x910E413DBF3F6276Fe8213fF656726bDc142E08E'
|
24
|
-
this.baseConfigPath = expandHomeDir(`~/.interop-x`);
|
25
21
|
}
|
26
22
|
|
27
23
|
get publicAddress(){
|
@@ -31,10 +27,6 @@ class Config {
|
|
31
27
|
isLeadNode() {
|
32
28
|
return ethers.utils.getAddress(this.leadNodeAddress) === ethers.utils.getAddress(this.wallet.address)
|
33
29
|
}
|
34
|
-
|
35
|
-
isMaintenanceMode(){
|
36
|
-
return fs.existsSync(this.baseConfigPath + '/maintenance')
|
37
|
-
}
|
38
30
|
}
|
39
31
|
|
40
32
|
export default new Config()
|
package/src/index.ts
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import moduleAlias from 'module-alias';
|
2
|
-
|
3
|
-
import fs from 'fs-extra'
|
2
|
+
|
4
3
|
moduleAlias.addAliases({
|
5
4
|
"@/": __dirname + "/",
|
6
5
|
"@/logger": __dirname + "/logger",
|
@@ -39,21 +38,6 @@ if (process.argv.at(-1) === 'help') {
|
|
39
38
|
process.exit(0)
|
40
39
|
}
|
41
40
|
|
42
|
-
const basePath = expandHomeDir(`~/.interop-x`);
|
43
|
-
|
44
|
-
if (process.argv.at(-1) === 'down') {
|
45
|
-
fs.outputFileSync(basePath + '/maintenance', Date.now().toString())
|
46
|
-
console.log(chalk.red('Maintenance mode enabled'))
|
47
|
-
process.exit(0)
|
48
|
-
}
|
49
|
-
|
50
|
-
if (process.argv.at(-1) === 'up') {
|
51
|
-
fs.removeSync(basePath + '/maintenance')
|
52
|
-
console.log(chalk.green('Maintenance mode disabled'))
|
53
|
-
process.exit(0)
|
54
|
-
}
|
55
|
-
|
56
|
-
|
57
41
|
const GIT_SHORT_HASH = '@GIT_SHORT_HASH@';
|
58
42
|
|
59
43
|
if (process.argv.at(-1) === 'version') {
|
@@ -61,7 +45,7 @@ if (process.argv.at(-1) === 'version') {
|
|
61
45
|
process.exit(0)
|
62
46
|
}
|
63
47
|
|
64
|
-
if
|
48
|
+
if(! process.env.PRIVATE_KEY) {
|
65
49
|
console.error(chalk.bgRed.white.bold('Please provide a private key\n'))
|
66
50
|
printUsage()
|
67
51
|
process.exit(1)
|
@@ -96,10 +80,10 @@ async function main() {
|
|
96
80
|
if (!peerPool.isLeadNode(payload.peerId)) {
|
97
81
|
const peer = peerPool.getPeer(payload.peerId)
|
98
82
|
|
99
|
-
if
|
83
|
+
if(! peer) {
|
100
84
|
return;
|
101
85
|
}
|
102
|
-
|
86
|
+
|
103
87
|
logger.info(`ignored transaction status from ${payload.peerId} ${shortenHash(peer.publicAddress)} `)
|
104
88
|
return;
|
105
89
|
}
|
package/src/net/peer/index.ts
CHANGED
@@ -17,7 +17,6 @@ import KadDHT from "libp2p-kad-dht";
|
|
17
17
|
import PubsubPeerDiscovery from "libp2p-pubsub-peer-discovery";
|
18
18
|
import { protocol } from "@/net";
|
19
19
|
import config from "@/config";
|
20
|
-
import chalk from "chalk";
|
21
20
|
|
22
21
|
const logger = new Logger("Peer");
|
23
22
|
|
@@ -81,7 +80,7 @@ export const startPeer = async ({ }: IPeerOptions) => {
|
|
81
80
|
},
|
82
81
|
});
|
83
82
|
|
84
|
-
logger.info("Peer ID:",
|
83
|
+
logger.info("Peer ID:", node.peerId.toB58String());
|
85
84
|
|
86
85
|
await node.start();
|
87
86
|
|
package/src/net/pool/index.ts
CHANGED
@@ -3,7 +3,6 @@ import config from "@/config";
|
|
3
3
|
import Logger from "@/logger";
|
4
4
|
import { getAddress } from "ethers/lib/utils";
|
5
5
|
import { shortenHash } from "@/utils";
|
6
|
-
import chalk from "chalk";
|
7
6
|
|
8
7
|
|
9
8
|
const logger = new Logger('PeerPool')
|
@@ -89,7 +88,7 @@ export class PeerPool {
|
|
89
88
|
|
90
89
|
if (newPeer) {
|
91
90
|
config.events.emit(Event.POOL_PEER_ADDED, peer)
|
92
|
-
logger.info(`Peer ${
|
91
|
+
logger.info(`Peer ${peer.id} with address ${shortenHash(peer.publicAddress)} added to pool`)
|
93
92
|
}
|
94
93
|
}
|
95
94
|
}
|
@@ -104,7 +103,7 @@ export class PeerPool {
|
|
104
103
|
if (this.pool.delete(peer.id)) {
|
105
104
|
peer.pooled = false
|
106
105
|
config.events.emit(Event.POOL_PEER_REMOVED, peer)
|
107
|
-
logger.info(`Peer ${
|
106
|
+
logger.info(`Peer ${peer.id} with address ${shortenHash(peer.publicAddress)} removed from pool`)
|
108
107
|
}
|
109
108
|
}
|
110
109
|
}
|
@@ -1,16 +1,12 @@
|
|
1
1
|
import { BaseTask } from "./BaseTask";
|
2
2
|
import Logger from '@/logger';
|
3
|
-
import
|
4
|
-
import
|
3
|
+
import { http } from "@/utils";
|
4
|
+
import spawn from 'await-spawn';
|
5
5
|
import config from "@/config";
|
6
6
|
import wait from "waait";
|
7
|
-
import packageJson from "../../package.json";
|
8
|
-
|
9
|
-
const currentVersion = packageJson.version;
|
10
|
-
const tag = config.staging ? 'dev' : 'latest';
|
11
7
|
|
12
8
|
class AutoUpdateTask extends BaseTask {
|
13
|
-
pollIntervalMs: number = 60 *
|
9
|
+
pollIntervalMs: number = 60 * 5 * 1000
|
14
10
|
|
15
11
|
constructor() {
|
16
12
|
super({
|
@@ -22,28 +18,15 @@ class AutoUpdateTask extends BaseTask {
|
|
22
18
|
return config.autoUpdate && !config.isLeadNode();
|
23
19
|
}
|
24
20
|
|
25
|
-
|
26
|
-
|
27
|
-
const stdout = await spawnAsync('npm', ['-g', 'ls', '--depth=0', '--json'])
|
28
|
-
return JSON.parse(stdout.toString()).dependencies[packageJson.name].version
|
29
|
-
} catch (error) {
|
30
|
-
this.logger.error(error)
|
31
|
-
return currentVersion
|
32
|
-
}
|
21
|
+
getCurrentVersion() {
|
22
|
+
return require('../../package.json').version
|
33
23
|
}
|
24
|
+
async pollHandler() {
|
34
25
|
|
35
|
-
|
36
|
-
try {
|
37
|
-
const stdout = await spawnAsync('npm', ['view', `${packageJson.name}@${tag}`, 'version'])
|
38
|
-
return stdout.toString().trim()
|
39
|
-
} catch (error) {
|
40
|
-
this.logger.error(error)
|
41
|
-
return currentVersion
|
42
|
-
}
|
43
|
-
}
|
26
|
+
const { data } = await http.get('https://registry.npmjs.org/@instadapp/interop-x')
|
44
27
|
|
45
|
-
|
46
|
-
const
|
28
|
+
const version = data['dist-tags'].latest
|
29
|
+
const currentVersion = this.getCurrentVersion()
|
47
30
|
|
48
31
|
if (version === currentVersion) {
|
49
32
|
return;
|
@@ -51,13 +34,13 @@ class AutoUpdateTask extends BaseTask {
|
|
51
34
|
|
52
35
|
this.logger.warn(`New version ${version} available.`)
|
53
36
|
|
54
|
-
this.logger.info('Updating...')
|
55
37
|
|
56
|
-
await
|
38
|
+
await spawn('npm', ['-g', 'install', '@instadapp/interop-x', '-f']);
|
39
|
+
|
57
40
|
|
58
41
|
await wait(5000)
|
59
42
|
|
60
|
-
if (
|
43
|
+
if (currentVersion === this.getCurrentVersion()) {
|
61
44
|
this.logger.warn(`failed to install ${version}, retrying in 5 minutes`)
|
62
45
|
return;
|
63
46
|
}
|
@@ -65,14 +48,11 @@ class AutoUpdateTask extends BaseTask {
|
|
65
48
|
this.logger.warn(`Installed version ${version}`)
|
66
49
|
this.logger.warn(`Restarting...`)
|
67
50
|
|
68
|
-
|
51
|
+
spawn(process.argv[0], process.argv.slice(1), {
|
69
52
|
cwd: process.cwd(),
|
70
|
-
stdio: "inherit"
|
71
|
-
shell: process.env.SHELL,
|
53
|
+
stdio: "inherit"
|
72
54
|
});
|
73
55
|
|
74
|
-
subprocess.unref();
|
75
|
-
|
76
56
|
process.exit()
|
77
57
|
}
|
78
58
|
}
|
package/src/tasks/BaseTask.ts
CHANGED
@@ -46,11 +46,6 @@ export class BaseTask extends EventEmitter implements IBaseTask {
|
|
46
46
|
}
|
47
47
|
|
48
48
|
prePollHandler(): boolean {
|
49
|
-
if(config.isMaintenanceMode()){
|
50
|
-
this.logger.warn('Maintenance mode is enabled. Skipping task.')
|
51
|
-
return false
|
52
|
-
}
|
53
|
-
|
54
49
|
if (this.exceptLeadNode) {
|
55
50
|
return !config.isLeadNode();
|
56
51
|
}
|
package/src/utils/index.ts
CHANGED
@@ -24,7 +24,7 @@ export function shortenHash(hash: string, length: number = 4) {
|
|
24
24
|
|
25
25
|
const beginningChars = hash.startsWith("0x") ? length + 2 : length;
|
26
26
|
|
27
|
-
const shortened = hash.
|
27
|
+
const shortened = hash.substring(0, beginningChars) + "…" + hash.substring(-length);
|
28
28
|
|
29
29
|
return shortened;
|
30
30
|
}
|