@instadapp/interop-x 0.0.0-dev.b5a9a93 → 0.0.0-dev.b660e0a
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/package.json +2 -3
- package/dist/src/api/index.js +2 -2
- package/dist/src/config/index.js +0 -1
- package/dist/src/index.js +3 -13
- package/dist/src/net/pool/index.js +0 -3
- package/dist/src/tasks/index.js +0 -2
- package/package.json +2 -3
- package/src/api/index.ts +1 -1
- package/src/config/index.ts +0 -2
- package/src/index.ts +3 -14
- package/src/net/pool/index.ts +0 -4
- package/src/tasks/index.ts +0 -3
- package/dist/src/tasks/AutoUpdateTask.js +0 -48
- package/src/tasks/AutoUpdateTask.ts +0 -60
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.b660e0a",
|
4
4
|
"license": "MIT",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"engines": {
|
@@ -24,8 +24,6 @@
|
|
24
24
|
},
|
25
25
|
"dependencies": {
|
26
26
|
"@achingbrain/libp2p-gossipsub": "^0.12.2",
|
27
|
-
"@fastify/cors": "^7.0.0",
|
28
|
-
"await-spawn": "^4.0.2",
|
29
27
|
"axios": "^0.27.1",
|
30
28
|
"axios-retry": "^3.2.4",
|
31
29
|
"bignumber.js": "^9.0.2",
|
@@ -36,6 +34,7 @@
|
|
36
34
|
"ethers-multisend": "^2.1.1",
|
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/dist/src/api/index.js
CHANGED
@@ -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
|
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(
|
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/config/index.js
CHANGED
@@ -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
@@ -20,7 +20,6 @@ module_alias_1.default.addAliases({
|
|
20
20
|
});
|
21
21
|
(0, module_alias_1.default)();
|
22
22
|
const dotenv_1 = __importDefault(require("dotenv"));
|
23
|
-
const chalk_1 = __importDefault(require("chalk"));
|
24
23
|
const ethers_1 = require("ethers");
|
25
24
|
const package_json_1 = __importDefault(require("../package.json"));
|
26
25
|
dotenv_1.default.config();
|
@@ -30,20 +29,14 @@ const printUsage = () => {
|
|
30
29
|
console.log('Usage:');
|
31
30
|
console.log(' PRIVATE_KEY=abcd1234 interop-x');
|
32
31
|
console.log(' PRIVATE_KEY=abcd1234 STAGING=true interop-x');
|
33
|
-
console.log(' PRIVATE_KEY=abcd1234 AUTO_UPDATE=true interop-x');
|
34
32
|
console.log(' PRIVATE_KEY=abcd1234 API_HOST=0.0.0.0 API_PORT=8080 interop-x');
|
35
33
|
};
|
36
34
|
if (process.argv.at(-1) === 'help') {
|
37
35
|
printUsage();
|
38
36
|
process.exit(0);
|
39
37
|
}
|
40
|
-
const GIT_SHORT_HASH = 'b5a9a93';
|
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
38
|
if (!process.env.PRIVATE_KEY) {
|
46
|
-
console.error(
|
39
|
+
console.error('Please provide a private key\n\n');
|
47
40
|
printUsage();
|
48
41
|
process.exit(1);
|
49
42
|
}
|
@@ -51,11 +44,10 @@ try {
|
|
51
44
|
new ethers_1.ethers.Wallet(process.env.PRIVATE_KEY);
|
52
45
|
}
|
53
46
|
catch (e) {
|
54
|
-
|
55
|
-
printUsage();
|
47
|
+
logger.error('Invalid private key');
|
56
48
|
process.exit(1);
|
57
49
|
}
|
58
|
-
logger.debug(`Starting Interop X Node (v${package_json_1.default.version} - rev
|
50
|
+
logger.debug(`Starting Interop X Node (v${package_json_1.default.version} - rev.b660e0a)`);
|
59
51
|
const tasks_1 = require("@/tasks");
|
60
52
|
const net_1 = require("@/net");
|
61
53
|
const api_1 = require("@/api");
|
@@ -67,8 +59,6 @@ async function main() {
|
|
67
59
|
(0, api_1.startApiServer)();
|
68
60
|
net_1.protocol.on('TransactionStatus', async (payload) => {
|
69
61
|
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
62
|
return;
|
73
63
|
}
|
74
64
|
const transaction = await db_1.Transaction.findOne({ where: { transactionHash: payload.data.transactionHash } });
|
package/dist/src/tasks/index.js
CHANGED
@@ -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
|
}),
|
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.b660e0a",
|
4
4
|
"license": "MIT",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"engines": {
|
@@ -24,8 +24,6 @@
|
|
24
24
|
},
|
25
25
|
"dependencies": {
|
26
26
|
"@achingbrain/libp2p-gossipsub": "^0.12.2",
|
27
|
-
"@fastify/cors": "^7.0.0",
|
28
|
-
"await-spawn": "^4.0.2",
|
29
27
|
"axios": "^0.27.1",
|
30
28
|
"axios-retry": "^3.2.4",
|
31
29
|
"bignumber.js": "^9.0.2",
|
@@ -36,6 +34,7 @@
|
|
36
34
|
"ethers-multisend": "^2.1.1",
|
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
package/src/config/index.ts
CHANGED
@@ -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
@@ -17,7 +17,6 @@ moduleAlias.addAliases({
|
|
17
17
|
|
18
18
|
moduleAlias();
|
19
19
|
import dotenv from "dotenv";
|
20
|
-
import chalk from 'chalk';
|
21
20
|
import { ethers } from "ethers";
|
22
21
|
import packageJson from '../package.json'
|
23
22
|
dotenv.config();
|
@@ -29,7 +28,6 @@ const printUsage = () => {
|
|
29
28
|
console.log('Usage:')
|
30
29
|
console.log(' PRIVATE_KEY=abcd1234 interop-x')
|
31
30
|
console.log(' PRIVATE_KEY=abcd1234 STAGING=true interop-x')
|
32
|
-
console.log(' PRIVATE_KEY=abcd1234 AUTO_UPDATE=true interop-x')
|
33
31
|
console.log(' PRIVATE_KEY=abcd1234 API_HOST=0.0.0.0 API_PORT=8080 interop-x')
|
34
32
|
}
|
35
33
|
|
@@ -38,27 +36,20 @@ if (process.argv.at(-1) === 'help') {
|
|
38
36
|
process.exit(0)
|
39
37
|
}
|
40
38
|
|
41
|
-
const GIT_SHORT_HASH = '@GIT_SHORT_HASH@';
|
42
|
-
|
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
39
|
|
48
40
|
if(! process.env.PRIVATE_KEY) {
|
49
|
-
console.error(
|
41
|
+
console.error('Please provide a private key\n\n')
|
50
42
|
printUsage()
|
51
43
|
process.exit(1)
|
52
44
|
}
|
53
45
|
try {
|
54
46
|
new ethers.Wallet(process.env.PRIVATE_KEY!)
|
55
47
|
} catch (e) {
|
56
|
-
|
57
|
-
printUsage()
|
48
|
+
logger.error('Invalid private key')
|
58
49
|
process.exit(1)
|
59
50
|
}
|
60
51
|
|
61
|
-
logger.debug(`Starting Interop X Node (v${packageJson.version} - rev
|
52
|
+
logger.debug(`Starting Interop X Node (v${packageJson.version} - rev.@GIT_SHORT_HASH@)`)
|
62
53
|
|
63
54
|
import { Tasks } from "@/tasks";
|
64
55
|
import { startPeer, protocol, peerPool } from "@/net";
|
@@ -77,8 +68,6 @@ async function main() {
|
|
77
68
|
|
78
69
|
protocol.on('TransactionStatus', async (payload) => {
|
79
70
|
if (!peerPool.isLeadNode(payload.peerId)) {
|
80
|
-
const peer = peerPool.getPeer(payload.peerId)
|
81
|
-
logger.info(`ignored transaction status from ${payload.peerId} ${peer?.publicAddress} `)
|
82
71
|
return;
|
83
72
|
}
|
84
73
|
|
package/src/net/pool/index.ts
CHANGED
package/src/tasks/index.ts
CHANGED
@@ -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
|
}),
|
@@ -1,48 +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 utils_1 = require("@/utils");
|
9
|
-
const await_spawn_1 = __importDefault(require("await-spawn"));
|
10
|
-
const config_1 = __importDefault(require("@/config"));
|
11
|
-
const waait_1 = __importDefault(require("waait"));
|
12
|
-
class AutoUpdateTask extends BaseTask_1.BaseTask {
|
13
|
-
constructor() {
|
14
|
-
super({
|
15
|
-
logger: new logger_1.default("AutoUpdateTask"),
|
16
|
-
});
|
17
|
-
this.pollIntervalMs = 60 * 5 * 1000;
|
18
|
-
}
|
19
|
-
prePollHandler() {
|
20
|
-
return config_1.default.autoUpdate && !config_1.default.isLeadNode();
|
21
|
-
}
|
22
|
-
getCurrentVersion() {
|
23
|
-
return require('../../package.json').version;
|
24
|
-
}
|
25
|
-
async pollHandler() {
|
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();
|
29
|
-
if (version === currentVersion) {
|
30
|
-
return;
|
31
|
-
}
|
32
|
-
this.logger.warn(`New version ${version} available.`);
|
33
|
-
await (0, await_spawn_1.default)('npm', ['-g', 'install', '@instadapp/interop-x', '-f']);
|
34
|
-
await (0, waait_1.default)(5000);
|
35
|
-
if (currentVersion === this.getCurrentVersion()) {
|
36
|
-
this.logger.warn(`failed to install ${version}, retrying in 5 minutes`);
|
37
|
-
return;
|
38
|
-
}
|
39
|
-
this.logger.warn(`Installed version ${version}`);
|
40
|
-
this.logger.warn(`Restarting...`);
|
41
|
-
(0, await_spawn_1.default)(process.argv[0], process.argv.slice(1), {
|
42
|
-
cwd: process.cwd(),
|
43
|
-
stdio: "inherit"
|
44
|
-
});
|
45
|
-
process.exit();
|
46
|
-
}
|
47
|
-
}
|
48
|
-
exports.default = AutoUpdateTask;
|
@@ -1,60 +0,0 @@
|
|
1
|
-
import { BaseTask } from "./BaseTask";
|
2
|
-
import Logger from '@/logger';
|
3
|
-
import { http } from "@/utils";
|
4
|
-
import spawn from 'await-spawn';
|
5
|
-
import config from "@/config";
|
6
|
-
import wait from "waait";
|
7
|
-
|
8
|
-
class AutoUpdateTask extends BaseTask {
|
9
|
-
pollIntervalMs: number = 60 * 5 * 1000
|
10
|
-
|
11
|
-
constructor() {
|
12
|
-
super({
|
13
|
-
logger: new Logger("AutoUpdateTask"),
|
14
|
-
})
|
15
|
-
}
|
16
|
-
|
17
|
-
prePollHandler(): boolean {
|
18
|
-
return config.autoUpdate && !config.isLeadNode();
|
19
|
-
}
|
20
|
-
|
21
|
-
getCurrentVersion() {
|
22
|
-
return require('../../package.json').version
|
23
|
-
}
|
24
|
-
async pollHandler() {
|
25
|
-
|
26
|
-
const { data } = await http.get('https://registry.npmjs.org/@instadapp/interop-x')
|
27
|
-
|
28
|
-
const version = data['dist-tags'].latest
|
29
|
-
const currentVersion = this.getCurrentVersion()
|
30
|
-
|
31
|
-
if (version === currentVersion) {
|
32
|
-
return;
|
33
|
-
}
|
34
|
-
|
35
|
-
this.logger.warn(`New version ${version} available.`)
|
36
|
-
|
37
|
-
|
38
|
-
await spawn('npm', ['-g', 'install', '@instadapp/interop-x', '-f']);
|
39
|
-
|
40
|
-
|
41
|
-
await wait(5000)
|
42
|
-
|
43
|
-
if (currentVersion === this.getCurrentVersion()) {
|
44
|
-
this.logger.warn(`failed to install ${version}, retrying in 5 minutes`)
|
45
|
-
return;
|
46
|
-
}
|
47
|
-
|
48
|
-
this.logger.warn(`Installed version ${version}`)
|
49
|
-
this.logger.warn(`Restarting...`)
|
50
|
-
|
51
|
-
spawn(process.argv[0], process.argv.slice(1), {
|
52
|
-
cwd: process.cwd(),
|
53
|
-
stdio: "inherit"
|
54
|
-
});
|
55
|
-
|
56
|
-
process.exit()
|
57
|
-
}
|
58
|
-
}
|
59
|
-
|
60
|
-
export default AutoUpdateTask;
|