@instadapp/interop-x 0.0.0-dev.75809ae → 0.0.0-dev.ef78459

Sign up to get free protection for your applications and to get access to all the features.
package/bin/interop-x CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- require('../dist/src/index')
2
+ require('../dist/index')
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const ethers_1 = require("ethers");
4
- const types_1 = require("types");
4
+ const types_1 = require("@/types");
5
5
  class Config {
6
6
  constructor() {
7
7
  this.events = new types_1.EventBus();
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Execution = void 0;
4
- const sequelize_1 = require("../sequelize");
4
+ const sequelize_1 = require("@/db/sequelize");
5
5
  const sequelize_2 = require("sequelize");
6
6
  class Execution extends sequelize_2.Model {
7
7
  }
package/dist/index.js CHANGED
@@ -3,14 +3,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const console_1 = require("console");
6
+ require("module-alias/register");
7
+ const assert_1 = __importDefault(require("assert"));
7
8
  const dotenv_1 = __importDefault(require("dotenv"));
8
- const tasks_1 = require("tasks");
9
- const logger_1 = __importDefault(require("./logger"));
10
- const net_1 = require("./net");
9
+ const logger_1 = __importDefault(require("@/logger"));
10
+ const ethers_1 = require("ethers");
11
11
  dotenv_1.default.config();
12
- (0, console_1.assert)(process.env.PRIVATE_KEY, "PRIVATE_KEY is not defined");
13
12
  const logger = new logger_1.default('Process');
13
+ (0, assert_1.default)(process.env.PRIVATE_KEY, "PRIVATE_KEY is not defined");
14
+ try {
15
+ new ethers_1.ethers.Wallet(process.env.PRIVATE_KEY);
16
+ }
17
+ catch (e) {
18
+ logger.error('Invalid private key');
19
+ process.exit(1);
20
+ }
21
+ const tasks_1 = require("@/tasks");
22
+ const net_1 = require("@/net");
14
23
  async function main() {
15
24
  (0, net_1.startPeer)({});
16
25
  const tasks = new tasks_1.Tasks();
@@ -11,7 +11,7 @@ const libp2p_websockets_1 = __importDefault(require("libp2p-websockets"));
11
11
  //@ts-ignore
12
12
  const libp2p_mplex_1 = __importDefault(require("libp2p-mplex"));
13
13
  const libp2p_noise_1 = require("libp2p-noise");
14
- const logger_1 = __importDefault(require("../../logger"));
14
+ const logger_1 = __importDefault(require("@/logger"));
15
15
  const libp2p_bootstrap_1 = __importDefault(require("libp2p-bootstrap"));
16
16
  const waait_1 = __importDefault(require("waait"));
17
17
  const libp2p_gossipsub_1 = __importDefault(require("@achingbrain/libp2p-gossipsub"));
@@ -21,8 +21,8 @@ const libp2p_mdns_1 = __importDefault(require("libp2p-mdns"));
21
21
  const libp2p_kad_dht_1 = __importDefault(require("libp2p-kad-dht"));
22
22
  //@ts-ignore
23
23
  const libp2p_pubsub_peer_discovery_1 = __importDefault(require("libp2p-pubsub-peer-discovery"));
24
- const protocol_1 = require("../protocol");
25
- const config_1 = __importDefault(require("../../config"));
24
+ const net_1 = require("@/net");
25
+ const config_1 = __importDefault(require("@/config"));
26
26
  const logger = new logger_1.default("Peer");
27
27
  let node;
28
28
  // Known peers addresses
@@ -79,14 +79,14 @@ const startPeer = async ({}) => {
79
79
  });
80
80
  logger.info("Peer ID:", node.peerId.toB58String());
81
81
  await node.start();
82
- protocol_1.protocol.start({
82
+ net_1.protocol.start({
83
83
  libp2p: node
84
84
  });
85
85
  node.on("peer:discovery", (peer) => logger.log(`Discovered peer ${peer}`)); // peer disc.
86
86
  node.connectionManager.on("peer:connect", (connection) => logger.log(`Connected to ${connection.remotePeer.toB58String()}`));
87
87
  logger.log("Peer discovery started");
88
88
  await (0, waait_1.default)(1000);
89
- setInterval(() => protocol_1.protocol.sendPeerInfo({
89
+ setInterval(() => net_1.protocol.sendPeerInfo({
90
90
  publicAddress: config_1.default.wallet.address,
91
91
  }), 5000);
92
92
  };
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.peerPool = exports.PeerPool = void 0;
7
- const types_1 = require("../../types");
8
- const config_1 = __importDefault(require("../../config"));
7
+ const types_1 = require("@/types");
8
+ const config_1 = __importDefault(require("@/config"));
9
9
  class PeerPool {
10
10
  constructor() {
11
11
  this.PEERS_CLEANUP_TIME_LIMIT = 1;
@@ -13,7 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.BaseDialProtocol = void 0;
14
14
  const it_pipe_1 = __importDefault(require("it-pipe"));
15
15
  const peer_id_1 = __importDefault(require("peer-id"));
16
- const utils_1 = require("../../../utils");
16
+ const utils_1 = require("@/utils");
17
17
  const waait_1 = __importDefault(require("waait"));
18
18
  class BaseDialProtocol {
19
19
  constructor(libp2p, protocol) {
@@ -4,11 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.SignatureDialProtocol = void 0;
7
- const utils_1 = require("../../../utils");
7
+ const utils_1 = require("@/utils");
8
8
  const BaseDialProtocol_1 = require("./BaseDialProtocol");
9
9
  const waait_1 = __importDefault(require("waait"));
10
- const config_1 = __importDefault(require("config"));
11
- const constants_1 = require("../../../constants");
10
+ const config_1 = __importDefault(require("@/config"));
11
+ const constants_1 = require("@/constants");
12
12
  const db_1 = require("db");
13
13
  class SignatureDialProtocol extends BaseDialProtocol_1.BaseDialProtocol {
14
14
  constructor(libp2p) {
@@ -7,7 +7,7 @@ exports.BaseTask = void 0;
7
7
  const config_1 = __importDefault(require("config"));
8
8
  const events_1 = __importDefault(require("events"));
9
9
  const waait_1 = __importDefault(require("waait"));
10
- const logger_1 = __importDefault(require("../logger"));
10
+ const logger_1 = __importDefault(require("@/logger"));
11
11
  class BaseTask extends events_1.default {
12
12
  constructor({ logger }) {
13
13
  super();
@@ -9,7 +9,7 @@ exports.asyncCallWithTimeout = exports.buildSignatureBytes = exports.getRpcProvi
9
9
  */
10
10
  const axios_1 = __importDefault(require("axios"));
11
11
  const axios_retry_1 = __importDefault(require("axios-retry"));
12
- const constants_1 = require("../constants");
12
+ const constants_1 = require("@/constants");
13
13
  exports.http = axios_1.default.create();
14
14
  (0, axios_retry_1.default)(exports.http, { retries: 3, retryDelay: axios_retry_1.default.exponentialDelay });
15
15
  function short(buffer) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instadapp/interop-x",
3
- "version": "0.0.0-dev.75809ae",
3
+ "version": "0.0.0-dev.ef78459",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "scripts": {
11
11
  "start": "yarn build && node bin/interop-x",
12
- "build": "export GIT_REF=$(git rev-parse --short HEAD) && rimraf ./dist && tsc -p tsconfig.json && replace-in-file '@GIT_SHORT_HASH@' $GIT_REF ./dist/src/**/*.js",
12
+ "build": "export GIT_REF=$(git rev-parse --short HEAD) && rimraf ./dist && tsc -p tsconfig.json && replace-in-file '@GIT_SHORT_HASH@' $GIT_REF ./dist/**/*.js",
13
13
  "dev": "NODE_ENV=development nodemon",
14
14
  "prepublishOnly": "yarn build"
15
15
  },
@@ -30,6 +30,7 @@
30
30
  "ethereumjs-util": "^7.1.4",
31
31
  "ethers": "^5.6.4",
32
32
  "ethers-multisend": "^2.1.1",
33
+ "expand-home-dir": "^0.0.3",
33
34
  "libp2p": "^0.36.2",
34
35
  "libp2p-bootstrap": "^0.14.0",
35
36
  "libp2p-kad-dht": "^0.28.6",
@@ -40,7 +41,9 @@
40
41
  "libp2p-tcp": "^0.17.2",
41
42
  "libp2p-websockets": "^0.16.2",
42
43
  "luxon": "^2.3.2",
44
+ "module-alias": "^2.2.2",
43
45
  "sequelize": "^6.19.0",
46
+ "sqlite3": "^5.0.5",
44
47
  "waait": "^1.0.5"
45
48
  },
46
49
  "bin": {
@@ -55,5 +58,8 @@
55
58
  "ts-node": "^10.5.0",
56
59
  "tsconfig-paths": "^3.12.0",
57
60
  "typescript": "^4.5.5"
61
+ },
62
+ "_moduleAliases": {
63
+ "@/": "./"
58
64
  }
59
65
  }
@@ -1,5 +1,5 @@
1
1
  import { ethers, Wallet } from "ethers"
2
- import { EventBus, EventBusType } from "types"
2
+ import { EventBus, EventBusType } from "@/types"
3
3
 
4
4
  class Config {
5
5
  public readonly events: EventBusType
package/src/db/index.ts CHANGED
@@ -1 +1 @@
1
- export * from "./models"
1
+ export * from "./models"
@@ -1,4 +1,4 @@
1
- import { sequelize } from '../sequelize'
1
+ import { sequelize } from '@/db/sequelize'
2
2
  import { CreationOptional, InferAttributes, InferCreationAttributes, Model, DataTypes } from 'sequelize';
3
3
 
4
4
  export class Execution extends Model<InferAttributes<Execution>, InferCreationAttributes<Execution>> {
package/src/index.ts CHANGED
@@ -1,13 +1,23 @@
1
- import { assert } from "console";
1
+ import 'module-alias/register';
2
+ import assert from "assert";
2
3
  import dotenv from "dotenv";
3
- import { Tasks } from "tasks";
4
- import Logger from "./logger";
5
- import { startPeer } from "./net";
4
+ import Logger from "@/logger";
5
+ import { ethers } from "ethers";
6
6
  dotenv.config();
7
+ const logger = new Logger('Process')
7
8
 
8
9
  assert(process.env.PRIVATE_KEY, "PRIVATE_KEY is not defined");
9
10
 
10
- const logger = new Logger('Process')
11
+ try {
12
+ new ethers.Wallet(process.env.PRIVATE_KEY!)
13
+ } catch (e) {
14
+ logger.error('Invalid private key')
15
+ process.exit(1)
16
+ }
17
+
18
+ import { Tasks } from "@/tasks";
19
+ import { startPeer } from "@/net";
20
+
11
21
 
12
22
  async function main() {
13
23
 
@@ -5,7 +5,7 @@ import WS from "libp2p-websockets";
5
5
  //@ts-ignore
6
6
  import Mplex from "libp2p-mplex";
7
7
  import { NOISE } from "libp2p-noise";
8
- import Logger from "../../logger";
8
+ import Logger from "@/logger";
9
9
  import Bootstrap from "libp2p-bootstrap";
10
10
  import wait from "waait";
11
11
  import Gossipsub from "@achingbrain/libp2p-gossipsub";
@@ -15,8 +15,8 @@ import MulticastDNS from "libp2p-mdns";
15
15
  import KadDHT from "libp2p-kad-dht";
16
16
  //@ts-ignore
17
17
  import PubsubPeerDiscovery from "libp2p-pubsub-peer-discovery";
18
- import { protocol } from "../protocol";
19
- import config from "../../config";
18
+ import { protocol } from "@/net";
19
+ import config from "@/config";
20
20
 
21
21
  const logger = new Logger("Peer");
22
22
 
@@ -1,5 +1,5 @@
1
- import { Event } from "../../types";
2
- import config from "../../config";
1
+ import { Event } from "@/types";
2
+ import config from "@/config";
3
3
 
4
4
  export interface IPeerInfo {
5
5
  id: string;
@@ -1,7 +1,7 @@
1
1
  import pipe from 'it-pipe';
2
2
  import Libp2p from 'libp2p';
3
3
  import PeerId from 'peer-id';
4
- import { asyncCallWithTimeout } from '../../../utils';
4
+ import { asyncCallWithTimeout } from '@/utils';
5
5
  import wait from 'waait';
6
6
 
7
7
  export class BaseDialProtocol<TRequest extends any, TResponse extends any> {
@@ -1,9 +1,9 @@
1
- import { signGnosisSafeTx } from "../../../utils";
1
+ import { signGnosisSafeTx } from "@/utils";
2
2
  import { BaseDialProtocol } from "./BaseDialProtocol";
3
3
  import wait from "waait";
4
- import { ChainId } from "../../../types";
5
- import config from "config";
6
- import { addresses } from "../../../constants";
4
+ import { ChainId } from "@/types";
5
+ import config from "@/config";
6
+ import { addresses } from "@/constants";
7
7
  import { Execution } from "db";
8
8
 
9
9
  export interface ISignatureRequest {
@@ -2,7 +2,7 @@ import config from "config";
2
2
  import { ethers } from "ethers";
3
3
  import EventEmitter from "events";
4
4
  import wait from "waait";
5
- import Logger from "../logger";
5
+ import Logger from "@/logger";
6
6
 
7
7
  export interface IBaseTask {
8
8
  pollCheck(): Promise<void>
package/src/types.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { EventEmitter } from 'events'
2
- import { IPeerInfo } from './net'
2
+ import { IPeerInfo } from '@/net'
3
3
 
4
4
  /**
5
5
  * Types for the central event bus, emitted
@@ -3,8 +3,8 @@
3
3
  */
4
4
  import axios from 'axios'
5
5
  import axiosRetry from "axios-retry";
6
- import { addresses } from '../constants';
7
- import { ChainId } from '../types'
6
+ import { addresses } from '@/constants';
7
+ import { ChainId } from '@/types'
8
8
 
9
9
  export const http = axios.create();
10
10
 
package/tsconfig.json CHANGED
@@ -16,6 +16,9 @@
16
16
  "noEmit": false,
17
17
  "outDir": "dist",
18
18
  "baseUrl": "src",
19
+ "paths": {
20
+ "@/*" : ["./*" ]
21
+ },
19
22
  "typeRoots": [
20
23
  "./node_modules/@types",
21
24
  "./@types"