@instadapp/interop-x 0.0.0-dev.55abf28 → 0.0.0-dev.56aa23a

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instadapp/interop-x",
3
- "version": "0.0.0-dev.55abf28",
3
+ "version": "0.0.0-dev.56aa23a",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -24,7 +24,6 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@achingbrain/libp2p-gossipsub": "^0.12.2",
27
- "@fastify/cors": "^7.0.0",
28
27
  "axios": "^0.27.1",
29
28
  "axios-retry": "^3.2.4",
30
29
  "bignumber.js": "^9.0.2",
@@ -33,9 +32,9 @@
33
32
  "ethereumjs-util": "^7.1.4",
34
33
  "ethers": "^5.6.4",
35
34
  "ethers-multisend": "^2.1.1",
36
- "execa": "^6.1.0",
37
35
  "expand-home-dir": "^0.0.3",
38
36
  "fastify": "^3.28.0",
37
+ "fastify-cors": "^6.0.3",
39
38
  "libp2p": "^0.36.2",
40
39
  "libp2p-bootstrap": "^0.14.0",
41
40
  "libp2p-kad-dht": "^0.28.6",
@@ -5,12 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.startApiServer = void 0;
7
7
  const fastify_1 = __importDefault(require("fastify"));
8
- const cors_1 = __importDefault(require("@fastify/cors"));
8
+ const fastify_cors_1 = __importDefault(require("fastify-cors"));
9
9
  const logger_1 = __importDefault(require("@/logger"));
10
10
  const db_1 = require("@/db");
11
11
  const logger = new logger_1.default("RPC");
12
12
  const server = (0, fastify_1.default)({ logger: false });
13
- server.register(cors_1.default, {});
13
+ server.register(fastify_cors_1.default, {});
14
14
  server.get('/', async () => 'Interop X API');
15
15
  const startApiServer = async () => {
16
16
  const HOST = process.env.API_HOST || '0.0.0.0';
package/dist/src/index.js CHANGED
@@ -37,9 +37,8 @@ if (process.argv.at(-1) === 'help') {
37
37
  printUsage();
38
38
  process.exit(0);
39
39
  }
40
- const GIT_SHORT_HASH = '55abf28';
41
40
  if (process.argv.at(-1) === 'version') {
42
- console.log(`Interop X Node (v${package_json_1.default.version} - rev.${GIT_SHORT_HASH})`);
41
+ console.log(`Interop X Node (v${package_json_1.default.version} - rev.56aa23a)`);
43
42
  process.exit(0);
44
43
  }
45
44
  if (!process.env.PRIVATE_KEY) {
@@ -55,7 +54,7 @@ catch (e) {
55
54
  printUsage();
56
55
  process.exit(1);
57
56
  }
58
- logger.debug(`Starting Interop X Node (v${package_json_1.default.version} - rev.${GIT_SHORT_HASH})`);
57
+ logger.debug(`Starting Interop X Node (v${package_json_1.default.version} - rev.@GIT_SHORT_HASH@)`);
59
58
  const tasks_1 = require("@/tasks");
60
59
  const net_1 = require("@/net");
61
60
  const api_1 = require("@/api");
@@ -5,50 +5,40 @@ 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 package_json_1 = __importDefault(require("../../package.json"));
8
9
  const utils_1 = require("@/utils");
10
+ const child_process_1 = require("child_process");
9
11
  const config_1 = __importDefault(require("@/config"));
10
- const waait_1 = __importDefault(require("waait"));
11
- const execa_1 = require("execa");
12
+ const currentVersion = package_json_1.default.version;
12
13
  class AutoUpdateTask extends BaseTask_1.BaseTask {
13
14
  constructor() {
14
15
  super({
15
16
  logger: new logger_1.default("AutoUpdateTask"),
16
17
  });
17
- this.pollIntervalMs = 60 * 5 * 1000;
18
+ this.pollIntervalMs = 60 * 1000;
18
19
  }
19
20
  prePollHandler() {
20
- return config_1.default.autoUpdate && !config_1.default.isLeadNode();
21
- }
22
- getCurrentVersion() {
23
- return require('../../package.json').version;
21
+ return config_1.default.autoUpdate;
24
22
  }
25
23
  async pollHandler() {
26
24
  const { data } = await utils_1.http.get('https://registry.npmjs.org/@instadapp/interop-x');
27
25
  const version = data['dist-tags'].latest;
28
- const currentVersion = this.getCurrentVersion();
29
26
  if (version === currentVersion) {
30
27
  return;
31
28
  }
32
- try {
33
- this.logger.warn(`New version ${version} available.`);
34
- await (0, execa_1.execa)('npm', ['-g', 'install', '@instadapp/interop-x@latest', '-f']);
35
- await (0, waait_1.default)(5000);
36
- if (currentVersion === this.getCurrentVersion()) {
37
- this.logger.warn(`failed to install ${version}, retrying in 5 minutes`);
38
- return;
39
- }
29
+ this.logger.warn(`New version ${version} available.`);
30
+ const update = (0, child_process_1.spawn)('npm', ['-g', 'install', '@instadapp/interop-x']);
31
+ update.on("close", () => {
40
32
  this.logger.warn(`Installed version ${version}`);
41
33
  this.logger.warn(`Restarting...`);
42
- (0, execa_1.execa)(process.argv[0], process.argv.slice(1), {
34
+ (0, child_process_1.spawn)(process.argv[0], process.argv.slice(1), {
43
35
  cwd: process.cwd(),
36
+ env: Object.create(process.env),
37
+ detached: true,
44
38
  stdio: "inherit"
45
39
  });
46
40
  process.exit();
47
- }
48
- catch (error) {
49
- this.logger.warn(`failed to install ${version}, retrying in 5 minutes`);
50
- console.log(error);
51
- }
41
+ });
52
42
  }
53
43
  }
54
44
  exports.default = AutoUpdateTask;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instadapp/interop-x",
3
- "version": "0.0.0-dev.55abf28",
3
+ "version": "0.0.0-dev.56aa23a",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -24,7 +24,6 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@achingbrain/libp2p-gossipsub": "^0.12.2",
27
- "@fastify/cors": "^7.0.0",
28
27
  "axios": "^0.27.1",
29
28
  "axios-retry": "^3.2.4",
30
29
  "bignumber.js": "^9.0.2",
@@ -33,9 +32,9 @@
33
32
  "ethereumjs-util": "^7.1.4",
34
33
  "ethers": "^5.6.4",
35
34
  "ethers-multisend": "^2.1.1",
36
- "execa": "^6.1.0",
37
35
  "expand-home-dir": "^0.0.3",
38
36
  "fastify": "^3.28.0",
37
+ "fastify-cors": "^6.0.3",
39
38
  "libp2p": "^0.36.2",
40
39
  "libp2p-bootstrap": "^0.14.0",
41
40
  "libp2p-kad-dht": "^0.28.6",
package/src/api/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import fastify from "fastify"
2
- import cors from '@fastify/cors'
2
+ import cors from 'fastify-cors'
3
3
  import Logger from "@/logger"
4
4
  import { Transaction } from "@/db";
5
5
 
package/src/index.ts CHANGED
@@ -38,10 +38,8 @@ if (process.argv.at(-1) === 'help') {
38
38
  process.exit(0)
39
39
  }
40
40
 
41
- const GIT_SHORT_HASH = '@GIT_SHORT_HASH@';
42
-
43
41
  if (process.argv.at(-1) === 'version') {
44
- console.log(`Interop X Node (v${packageJson.version} - rev.${GIT_SHORT_HASH})`)
42
+ console.log(`Interop X Node (v${packageJson.version} - rev.@GIT_SHORT_HASH@)`)
45
43
  process.exit(0)
46
44
  }
47
45
 
@@ -58,7 +56,7 @@ try {
58
56
  process.exit(1)
59
57
  }
60
58
 
61
- logger.debug(`Starting Interop X Node (v${packageJson.version} - rev.${GIT_SHORT_HASH})`)
59
+ logger.debug(`Starting Interop X Node (v${packageJson.version} - rev.@GIT_SHORT_HASH@)`)
62
60
 
63
61
  import { Tasks } from "@/tasks";
64
62
  import { startPeer, protocol, peerPool } from "@/net";
@@ -1,12 +1,13 @@
1
1
  import { BaseTask } from "./BaseTask";
2
2
  import Logger from '@/logger';
3
+ import packageJson from '../../package.json'
3
4
  import { http } from "@/utils";
5
+ import { spawn } from 'child_process';
4
6
  import config from "@/config";
5
- import wait from "waait";
6
- import { execa } from "execa";
7
+ const currentVersion = packageJson.version;
7
8
 
8
9
  class AutoUpdateTask extends BaseTask {
9
- pollIntervalMs: number = 60 * 5 * 1000
10
+ pollIntervalMs: number = 60 * 1000
10
11
 
11
12
  constructor() {
12
13
  super({
@@ -14,49 +15,39 @@ class AutoUpdateTask extends BaseTask {
14
15
  })
15
16
  }
16
17
 
18
+
17
19
  prePollHandler(): boolean {
18
- return config.autoUpdate && !config.isLeadNode();
20
+ return config.autoUpdate;
19
21
  }
20
22
 
21
- getCurrentVersion() {
22
- return require('../../package.json').version
23
- }
24
23
  async pollHandler() {
25
24
 
26
25
  const { data } = await http.get('https://registry.npmjs.org/@instadapp/interop-x')
27
26
 
28
27
  const version = data['dist-tags'].latest
29
- const currentVersion = this.getCurrentVersion()
30
28
 
31
29
  if (version === currentVersion) {
32
30
  return;
33
31
  }
34
32
 
35
- try {
36
- this.logger.warn(`New version ${version} available.`)
37
-
38
- await execa('npm', ['-g', 'install', '@instadapp/interop-x@latest', '-f'])
33
+ this.logger.warn(`New version ${version} available.`)
39
34
 
40
- await wait(5000)
41
35
 
42
- if (currentVersion === this.getCurrentVersion()) {
43
- this.logger.warn(`failed to install ${version}, retrying in 5 minutes`)
44
- return;
45
- }
36
+ const update = spawn('npm', ['-g', 'install', '@instadapp/interop-x']);
46
37
 
38
+ update.on("close", () => {
47
39
  this.logger.warn(`Installed version ${version}`)
48
40
  this.logger.warn(`Restarting...`)
49
41
 
50
- execa(process.argv[0], process.argv.slice(1), {
42
+ spawn(process.argv[0], process.argv.slice(1), {
51
43
  cwd: process.cwd(),
44
+ env: Object.create(process.env),
45
+ detached: true,
52
46
  stdio: "inherit"
53
47
  });
54
48
 
55
49
  process.exit()
56
- } catch (error) {
57
- this.logger.warn(`failed to install ${version}, retrying in 5 minutes`)
58
- console.log(error)
59
- }
50
+ })
60
51
  }
61
52
  }
62
53