@instadapp/interop-x 0.0.0-dev.f78418c → 0.0.0-dev.fd6776c

Sign up to get free protection for your applications and to get access to all the features.
package/.env.example CHANGED
@@ -1 +1,2 @@
1
- PRIVATE_KEY=
1
+ PRIVATE_KEY=
2
+ STAGING=
@@ -7,9 +7,13 @@ class Config {
7
7
  this.events = new types_1.EventBus();
8
8
  this.maxPeers = 10;
9
9
  this.privateKey = process.env.PRIVATE_KEY;
10
+ this.staging = !!process.env.STAGING && process.env.STAGING === 'true';
10
11
  this.wallet = new ethers_1.Wallet(this.privateKey);
11
12
  this.leadNodeAddress = '0x910E413DBF3F6276Fe8213fF656726bDc142E08E';
12
13
  }
14
+ get publicAddress() {
15
+ return this.wallet.address;
16
+ }
13
17
  isLeadNode() {
14
18
  return ethers_1.ethers.utils.getAddress(this.leadNodeAddress) === ethers_1.ethers.utils.getAddress(this.wallet.address);
15
19
  }
@@ -5,9 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.sequelize = void 0;
7
7
  //@ts-ignore
8
+ const config_1 = __importDefault(require("@/config"));
8
9
  const expand_home_dir_1 = __importDefault(require("expand-home-dir"));
9
10
  const sequelize_1 = require("sequelize");
10
- const basePath = (0, expand_home_dir_1.default)('~/.interop-x/data');
11
+ const basePath = (0, expand_home_dir_1.default)(`~/.interop-x/data/${config_1.default.publicAddress}/${config_1.default.staging ? 'staging' : ''}`);
11
12
  exports.sequelize = new sequelize_1.Sequelize({
12
13
  dialect: 'sqlite',
13
14
  storage: `${basePath}/localDB.sqlite`,
package/dist/index.js CHANGED
@@ -3,13 +3,33 @@ 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
- require("module-alias/register");
6
+ const module_alias_1 = __importDefault(require("module-alias"));
7
+ module_alias_1.default.addAliases({
8
+ "@/": __dirname + "/",
9
+ "@/logger": __dirname + "/logger",
10
+ "@/tasks": __dirname + "/tasks",
11
+ "@/utils": __dirname + "/utils",
12
+ "@/net": __dirname + "/net",
13
+ "@/db": __dirname + "/db",
14
+ "@/config": __dirname + "/config",
15
+ "@/types": __dirname + "/types",
16
+ "@/abi": __dirname + "/abi",
17
+ "@/constants": __dirname + "/constants",
18
+ "@/typechain": __dirname + "/typechain"
19
+ });
20
+ (0, module_alias_1.default)();
7
21
  const assert_1 = __importDefault(require("assert"));
8
22
  const dotenv_1 = __importDefault(require("dotenv"));
9
23
  const ethers_1 = require("ethers");
10
24
  dotenv_1.default.config();
11
25
  const logger_1 = __importDefault(require("@/logger"));
12
26
  const logger = new logger_1.default('Process');
27
+ if (process.argv.at(-1) === 'help') {
28
+ console.log('Usage:');
29
+ console.log(' PRIVATE_KEY=abcd1234 interop-x');
30
+ console.log(' PRIVATE_KEY=abcd1234 STAGING=true interop-x');
31
+ process.exit(0);
32
+ }
13
33
  (0, assert_1.default)(process.env.PRIVATE_KEY, "PRIVATE_KEY is not defined");
14
34
  try {
15
35
  new ethers_1.ethers.Wallet(process.env.PRIVATE_KEY);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instadapp/interop-x",
3
- "version": "0.0.0-dev.f78418c",
3
+ "version": "0.0.0-dev.fd6776c",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -62,18 +62,5 @@
62
62
  "tsconfig-paths": "^3.12.0",
63
63
  "typechain": "^8.0.0",
64
64
  "typescript": "^4.5.5"
65
- },
66
- "_moduleAliases": {
67
- "@/": "./dist",
68
- "@/logger": "./dist/logger",
69
- "@/tasks": "./dist/tasks",
70
- "@/utils": "./dist/utils",
71
- "@/net": "./dist/net",
72
- "@/db": "./dist/db",
73
- "@/config": "./dist/config",
74
- "@/types": "./dist/types",
75
- "@/abi": "./dist/abi",
76
- "@/constants": "./dist/constants",
77
- "@/typechain": "./dist/typechain"
78
65
  }
79
66
  }
@@ -7,15 +7,21 @@ class Config {
7
7
  public readonly leadNodeAddress: string
8
8
  public readonly privateKey: string
9
9
  public readonly wallet: Wallet
10
+ public readonly staging: boolean
10
11
 
11
12
  constructor() {
12
13
  this.events = new EventBus() as EventBusType
13
14
  this.maxPeers = 10
14
15
  this.privateKey = process.env.PRIVATE_KEY as string;
16
+ this.staging = !! process.env.STAGING && process.env.STAGING === 'true';
15
17
  this.wallet = new Wallet(this.privateKey);
16
18
  this.leadNodeAddress = '0x910E413DBF3F6276Fe8213fF656726bDc142E08E'
17
19
  }
18
20
 
21
+ get publicAddress(){
22
+ return this.wallet.address
23
+ }
24
+
19
25
  isLeadNode() {
20
26
  return ethers.utils.getAddress(this.leadNodeAddress) === ethers.utils.getAddress(this.wallet.address)
21
27
  }
@@ -1,9 +1,10 @@
1
1
  //@ts-ignore
2
+ import config from "@/config";
2
3
  import expandHomeDir from "expand-home-dir";
3
4
 
4
5
  import { Sequelize } from 'sequelize';
5
6
 
6
- const basePath = expandHomeDir('~/.interop-x/data');
7
+ const basePath = expandHomeDir(`~/.interop-x/data/${config.publicAddress}/${config.staging ? 'staging' : ''}`);
7
8
 
8
9
  export const sequelize = new Sequelize({
9
10
  dialect: 'sqlite',
package/src/index.ts CHANGED
@@ -1,4 +1,20 @@
1
- import 'module-alias/register';
1
+ import moduleAlias from 'module-alias';
2
+
3
+ moduleAlias.addAliases({
4
+ "@/": __dirname + "/",
5
+ "@/logger": __dirname + "/logger",
6
+ "@/tasks": __dirname + "/tasks",
7
+ "@/utils": __dirname + "/utils",
8
+ "@/net": __dirname + "/net",
9
+ "@/db": __dirname + "/db",
10
+ "@/config": __dirname + "/config",
11
+ "@/types": __dirname + "/types",
12
+ "@/abi": __dirname + "/abi",
13
+ "@/constants": __dirname + "/constants",
14
+ "@/typechain": __dirname + "/typechain"
15
+ })
16
+
17
+ moduleAlias();
2
18
  import assert from "assert";
3
19
  import dotenv from "dotenv";
4
20
  import { ethers } from "ethers";
@@ -7,6 +23,14 @@ dotenv.config();
7
23
  import Logger from "@/logger";
8
24
  const logger = new Logger('Process')
9
25
 
26
+
27
+ if (process.argv.at(-1) === 'help') {
28
+ console.log('Usage:')
29
+ console.log(' PRIVATE_KEY=abcd1234 interop-x')
30
+ console.log(' PRIVATE_KEY=abcd1234 STAGING=true interop-x')
31
+ process.exit(0)
32
+ }
33
+
10
34
  assert(process.env.PRIVATE_KEY, "PRIVATE_KEY is not defined");
11
35
 
12
36
  try {
@@ -19,7 +43,6 @@ try {
19
43
  import { Tasks } from "@/tasks";
20
44
  import { startPeer } from "@/net";
21
45
 
22
-
23
46
  async function main() {
24
47
 
25
48
  startPeer({})