@instadapp/interop-x 0.0.0-dev.6088815 → 0.0.0-dev.62ea999

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.6088815",
3
+ "version": "0.0.0-dev.62ea999",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -46,8 +46,6 @@
46
46
  "libp2p-websockets": "^0.16.2",
47
47
  "luxon": "^2.3.2",
48
48
  "module-alias": "^2.2.2",
49
- "patch-package": "^6.4.7",
50
- "postinstall-postinstall": "^2.1.0",
51
49
  "sequelize": "6.18.0",
52
50
  "sqlite3": "^5.0.5",
53
51
  "waait": "^1.0.5"
@@ -62,6 +60,8 @@
62
60
  "@types/fs-extra": "^9.0.13",
63
61
  "@types/node": "^17.0.17",
64
62
  "nodemon": "^2.0.15",
63
+ "patch-package": "^6.4.7",
64
+ "postinstall-postinstall": "^2.1.0",
65
65
  "replace-in-file": "^6.3.2",
66
66
  "rimraf": "^3.0.2",
67
67
  "ts-node": "^10.5.0",
@@ -8,7 +8,6 @@ class Config {
8
8
  this.maxPeers = 10;
9
9
  this.privateKey = process.env.PRIVATE_KEY;
10
10
  this.staging = !!process.env.STAGING && process.env.STAGING === 'true';
11
- this.autoUpdate = !!process.env.AUTO_UPDATE && process.env.AUTO_UPDATE === 'true';
12
11
  this.wallet = new ethers_1.Wallet(this.privateKey);
13
12
  this.leadNodeAddress = '0x910E413DBF3F6276Fe8213fF656726bDc142E08E';
14
13
  }
package/dist/src/index.js CHANGED
@@ -19,43 +19,28 @@ module_alias_1.default.addAliases({
19
19
  "@/typechain": __dirname + "/typechain"
20
20
  });
21
21
  (0, module_alias_1.default)();
22
+ const assert_1 = __importDefault(require("assert"));
22
23
  const dotenv_1 = __importDefault(require("dotenv"));
23
- const chalk_1 = __importDefault(require("chalk"));
24
24
  const ethers_1 = require("ethers");
25
25
  const package_json_1 = __importDefault(require("../package.json"));
26
26
  dotenv_1.default.config();
27
27
  const logger_1 = __importDefault(require("@/logger"));
28
28
  const logger = new logger_1.default('Process');
29
- const printUsage = () => {
29
+ if (process.argv.at(-1) === 'help') {
30
30
  console.log('Usage:');
31
31
  console.log(' PRIVATE_KEY=abcd1234 interop-x');
32
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');
35
- };
36
- if (process.argv.at(-1) === 'help') {
37
- printUsage();
38
33
  process.exit(0);
39
34
  }
40
- const GIT_SHORT_HASH = '6088815';
41
- if (process.argv.at(-1) === 'version') {
42
- console.log(`Interop X Node (v${package_json_1.default.version} - rev.${GIT_SHORT_HASH})`);
43
- process.exit(0);
44
- }
45
- if (!process.env.PRIVATE_KEY) {
46
- console.error(chalk_1.default.bgRed.white.bold('Please provide a private key\n'));
47
- printUsage();
48
- process.exit(1);
49
- }
35
+ (0, assert_1.default)(process.env.PRIVATE_KEY, "PRIVATE_KEY is not defined");
50
36
  try {
51
37
  new ethers_1.ethers.Wallet(process.env.PRIVATE_KEY);
52
38
  }
53
39
  catch (e) {
54
- console.error(chalk_1.default.bgRed.white('Invalid private key\n'));
55
- printUsage();
40
+ logger.error('Invalid private key');
56
41
  process.exit(1);
57
42
  }
58
- logger.debug(`Starting Interop X Node (v${package_json_1.default.version} - rev.${GIT_SHORT_HASH})`);
43
+ logger.debug(`Starting Interop X Node (v${package_json_1.default.version} - rev.62ea999)`);
59
44
  const tasks_1 = require("@/tasks");
60
45
  const net_1 = require("@/net");
61
46
  const api_1 = require("@/api");
@@ -67,8 +52,6 @@ async function main() {
67
52
  (0, api_1.startApiServer)();
68
53
  net_1.protocol.on('TransactionStatus', async (payload) => {
69
54
  if (!net_1.peerPool.isLeadNode(payload.peerId)) {
70
- const peer = net_1.peerPool.getPeer(payload.peerId);
71
- logger.info(`ignored transaction status from ${payload.peerId} ${peer === null || peer === void 0 ? void 0 : peer.publicAddress} `);
72
55
  return;
73
56
  }
74
57
  const transaction = await db_1.Transaction.findOne({ where: { transactionHash: payload.data.transactionHash } });
@@ -101,9 +101,6 @@ class PeerPool {
101
101
  get activePeerIds() {
102
102
  return this.activePeers.map((p) => p.id);
103
103
  }
104
- getPeer(id) {
105
- return this.pool.get(id);
106
- }
107
104
  isLeadNode(id) {
108
105
  const peer = this.pool.get(id);
109
106
  if (!peer) {
@@ -8,11 +8,9 @@ const ProcessDepositEvents_1 = __importDefault(require("./InteropXGateway/Proces
8
8
  const SyncDepositEvents_1 = __importDefault(require("./InteropXGateway/SyncDepositEvents"));
9
9
  const SyncWithdrawEvents_1 = __importDefault(require("./InteropBridge/SyncWithdrawEvents"));
10
10
  const ProcessWithdrawEvents_1 = __importDefault(require("./InteropBridge/ProcessWithdrawEvents"));
11
- const AutoUpdateTask_1 = __importDefault(require("./AutoUpdateTask"));
12
11
  class Tasks {
13
12
  constructor() {
14
13
  this.tasks = [
15
- new AutoUpdateTask_1.default(),
16
14
  new SyncDepositEvents_1.default({
17
15
  chainId: 43114
18
16
  }),
@@ -185,11 +185,6 @@ function getContract(address, contractInterface, signerOrProvider) {
185
185
  throw Error(`Invalid 'address' parameter '${address}'.`);
186
186
  }
187
187
  const contract = new ethers_1.ethers.Contract(address, contractInterface, signerOrProvider);
188
- // Make sure the contract properties is writable
189
- const desc = Object.getOwnPropertyDescriptor(contract, 'functions');
190
- if (!desc || desc.writable !== true) {
191
- return contract;
192
- }
193
188
  return new Proxy(contract, {
194
189
  get(target, prop, receiver) {
195
190
  const value = Reflect.get(target, prop, receiver);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instadapp/interop-x",
3
- "version": "0.0.0-dev.6088815",
3
+ "version": "0.0.0-dev.62ea999",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -46,8 +46,6 @@
46
46
  "libp2p-websockets": "^0.16.2",
47
47
  "luxon": "^2.3.2",
48
48
  "module-alias": "^2.2.2",
49
- "patch-package": "^6.4.7",
50
- "postinstall-postinstall": "^2.1.0",
51
49
  "sequelize": "6.18.0",
52
50
  "sqlite3": "^5.0.5",
53
51
  "waait": "^1.0.5"
@@ -62,6 +60,8 @@
62
60
  "@types/fs-extra": "^9.0.13",
63
61
  "@types/node": "^17.0.17",
64
62
  "nodemon": "^2.0.15",
63
+ "patch-package": "^6.4.7",
64
+ "postinstall-postinstall": "^2.1.0",
65
65
  "replace-in-file": "^6.3.2",
66
66
  "rimraf": "^3.0.2",
67
67
  "ts-node": "^10.5.0",
@@ -8,14 +8,12 @@ class Config {
8
8
  public readonly privateKey: string
9
9
  public readonly wallet: Wallet
10
10
  public readonly staging: boolean
11
- public readonly autoUpdate: boolean
12
11
 
13
12
  constructor() {
14
13
  this.events = new EventBus() as EventBusType
15
14
  this.maxPeers = 10
16
15
  this.privateKey = process.env.PRIVATE_KEY as string;
17
16
  this.staging = !! process.env.STAGING && process.env.STAGING === 'true';
18
- this.autoUpdate = !! process.env.AUTO_UPDATE && process.env.AUTO_UPDATE === 'true';
19
17
  this.wallet = new Wallet(this.privateKey);
20
18
  this.leadNodeAddress = '0x910E413DBF3F6276Fe8213fF656726bDc142E08E'
21
19
  }
package/src/index.ts CHANGED
@@ -16,8 +16,8 @@ moduleAlias.addAliases({
16
16
  })
17
17
 
18
18
  moduleAlias();
19
+ import assert from "assert";
19
20
  import dotenv from "dotenv";
20
- import chalk from 'chalk';
21
21
  import { ethers } from "ethers";
22
22
  import packageJson from '../package.json'
23
23
  dotenv.config();
@@ -25,40 +25,24 @@ dotenv.config();
25
25
  import Logger from "@/logger";
26
26
  const logger = new Logger('Process')
27
27
 
28
- const printUsage = () => {
28
+
29
+ if (process.argv.at(-1) === 'help') {
29
30
  console.log('Usage:')
30
31
  console.log(' PRIVATE_KEY=abcd1234 interop-x')
31
32
  console.log(' PRIVATE_KEY=abcd1234 STAGING=true interop-x')
32
- console.log(' PRIVATE_KEY=abcd1234 AUTO_UPDATE=true interop-x')
33
- console.log(' PRIVATE_KEY=abcd1234 API_HOST=0.0.0.0 API_PORT=8080 interop-x')
34
- }
35
-
36
- if (process.argv.at(-1) === 'help') {
37
- printUsage()
38
33
  process.exit(0)
39
34
  }
40
35
 
41
- const GIT_SHORT_HASH = '@GIT_SHORT_HASH@';
36
+ assert(process.env.PRIVATE_KEY, "PRIVATE_KEY is not defined");
42
37
 
43
- if (process.argv.at(-1) === 'version') {
44
- console.log(`Interop X Node (v${packageJson.version} - rev.${GIT_SHORT_HASH})`)
45
- process.exit(0)
46
- }
47
-
48
- if(! process.env.PRIVATE_KEY) {
49
- console.error(chalk.bgRed.white.bold('Please provide a private key\n'))
50
- printUsage()
51
- process.exit(1)
52
- }
53
38
  try {
54
39
  new ethers.Wallet(process.env.PRIVATE_KEY!)
55
40
  } catch (e) {
56
- console.error(chalk.bgRed.white('Invalid private key\n'))
57
- printUsage()
41
+ logger.error('Invalid private key')
58
42
  process.exit(1)
59
43
  }
60
44
 
61
- logger.debug(`Starting Interop X Node (v${packageJson.version} - rev.${GIT_SHORT_HASH})`)
45
+ logger.debug(`Starting Interop X Node (v${packageJson.version} - rev.@GIT_SHORT_HASH@)`)
62
46
 
63
47
  import { Tasks } from "@/tasks";
64
48
  import { startPeer, protocol, peerPool } from "@/net";
@@ -77,8 +61,6 @@ async function main() {
77
61
 
78
62
  protocol.on('TransactionStatus', async (payload) => {
79
63
  if (!peerPool.isLeadNode(payload.peerId)) {
80
- const peer = peerPool.getPeer(payload.peerId)
81
- logger.info(`ignored transaction status from ${payload.peerId} ${peer?.publicAddress} `)
82
64
  return;
83
65
  }
84
66
 
@@ -124,10 +124,6 @@ export class PeerPool {
124
124
  }
125
125
 
126
126
 
127
- getPeer(id: string){
128
- return this.pool.get(id);
129
- }
130
-
131
127
  isLeadNode(id: string) {
132
128
  const peer = this.pool.get(id);
133
129
 
@@ -4,13 +4,10 @@ import InteropXGatewaySyncDepositEvents from "./InteropXGateway/SyncDepositEvent
4
4
 
5
5
  import InteropBridgeSyncWithdrawEvents from "./InteropBridge/SyncWithdrawEvents";
6
6
  import InteropBridgeProcessWithdrawEvents from "./InteropBridge/ProcessWithdrawEvents";
7
- import AutoUpdateTask from "./AutoUpdateTask";
8
7
 
9
8
  export class Tasks {
10
9
 
11
10
  tasks: BaseTask[] = [
12
- new AutoUpdateTask(),
13
-
14
11
  new InteropXGatewaySyncDepositEvents({
15
12
  chainId: 43114
16
13
  }),
@@ -259,12 +259,6 @@ export function getContract<TContract extends ethers.Contract>(address: string,
259
259
  signerOrProvider
260
260
  ) as TContract
261
261
 
262
- // Make sure the contract properties is writable
263
- const desc = Object.getOwnPropertyDescriptor(contract, 'functions');
264
-
265
- if (!desc || desc.writable !== true) {
266
- return contract
267
- }
268
262
 
269
263
  return new Proxy(contract, {
270
264
  get(target, prop, receiver) {
@@ -1,46 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const BaseTask_1 = require("./BaseTask");
7
- const logger_1 = __importDefault(require("@/logger"));
8
- const package_json_1 = __importDefault(require("../../package.json"));
9
- const utils_1 = require("@/utils");
10
- const child_process_1 = require("child_process");
11
- const config_1 = __importDefault(require("@/config"));
12
- const currentVersion = package_json_1.default.version;
13
- class AutoUpdateTask extends BaseTask_1.BaseTask {
14
- constructor() {
15
- super({
16
- logger: new logger_1.default("AutoUpdateTask"),
17
- });
18
- this.pollIntervalMs = 60 * 1000;
19
- }
20
- prePollHandler() {
21
- return config_1.default.autoUpdate && !config_1.default.isLeadNode();
22
- }
23
- async pollHandler() {
24
- const { data } = await utils_1.http.get('https://registry.npmjs.org/@instadapp/interop-x');
25
- const version = data['dist-tags'].latest;
26
- if (version === currentVersion) {
27
- return;
28
- }
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", () => {
32
- this.logger.warn(`Installed version ${version}`);
33
- this.logger.warn(`Restarting...`);
34
- const restart = (0, child_process_1.spawn)(process.argv[0], process.argv.slice(1), {
35
- cwd: process.cwd(),
36
- env: Object.create(process.env),
37
- detached: true,
38
- stdio: "inherit"
39
- });
40
- restart.on("close", () => {
41
- process.exit();
42
- });
43
- });
44
- }
45
- }
46
- exports.default = AutoUpdateTask;
@@ -1,55 +0,0 @@
1
- import { BaseTask } from "./BaseTask";
2
- import Logger from '@/logger';
3
- import packageJson from '../../package.json'
4
- import { http } from "@/utils";
5
- import { spawn } from 'child_process';
6
- import config from "@/config";
7
- const currentVersion = packageJson.version;
8
-
9
- class AutoUpdateTask extends BaseTask {
10
- pollIntervalMs: number = 60 * 1000
11
-
12
- constructor() {
13
- super({
14
- logger: new Logger("AutoUpdateTask"),
15
- })
16
- }
17
-
18
- prePollHandler(): boolean {
19
- return config.autoUpdate && !config.isLeadNode();
20
- }
21
-
22
- async pollHandler() {
23
-
24
- const { data } = await http.get('https://registry.npmjs.org/@instadapp/interop-x')
25
-
26
- const version = data['dist-tags'].latest
27
-
28
- if (version === currentVersion) {
29
- return;
30
- }
31
-
32
- this.logger.warn(`New version ${version} available.`)
33
-
34
-
35
- const update = spawn('npm', ['-g', 'install', '@instadapp/interop-x']);
36
-
37
- update.on("close", () => {
38
- this.logger.warn(`Installed version ${version}`)
39
- this.logger.warn(`Restarting...`)
40
-
41
- const restart = spawn(process.argv[0], process.argv.slice(1), {
42
- cwd: process.cwd(),
43
- env: Object.create(process.env),
44
- detached: true,
45
- stdio: "inherit"
46
- });
47
-
48
- restart.on("close", () => {
49
- process.exit()
50
- })
51
- })
52
- }
53
- }
54
-
55
- export default AutoUpdateTask;