*Move errorExit to dedicated file
*Add ERR_NOT_READY constant which will represent a chain not ready
This commit is contained in:
parent
023b1387fc
commit
e0c0ee3f83
|
@ -1,9 +1,9 @@
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import BConfig from "bcfg";
|
import BConfig from "bcfg";
|
||||||
import { errorExit } from "./util.js";
|
|
||||||
import * as os from "os";
|
import * as os from "os";
|
||||||
import { createRequire } from "module";
|
import { createRequire } from "module";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
import { errorExit } from "./error.js";
|
||||||
|
|
||||||
const require = createRequire(import.meta.url);
|
const require = createRequire(import.meta.url);
|
||||||
const config = new BConfig("lumeweb-relay");
|
const config = new BConfig("lumeweb-relay");
|
||||||
|
|
|
@ -2,7 +2,6 @@ import { createRequire } from "module";
|
||||||
|
|
||||||
const require = createRequire(import.meta.url);
|
const require = createRequire(import.meta.url);
|
||||||
const DHT = require("@hyperswarm/dht");
|
const DHT = require("@hyperswarm/dht");
|
||||||
import { errorExit } from "./util.js";
|
|
||||||
import {
|
import {
|
||||||
deriveMyskyRootKeypair,
|
deriveMyskyRootKeypair,
|
||||||
Ed25519Keypair,
|
Ed25519Keypair,
|
||||||
|
@ -10,6 +9,7 @@ import {
|
||||||
validSeedPhrase,
|
validSeedPhrase,
|
||||||
} from "libskynet";
|
} from "libskynet";
|
||||||
import config from "./config.js";
|
import config from "./config.js";
|
||||||
|
import { errorExit } from "./error.js";
|
||||||
|
|
||||||
let node: {
|
let node: {
|
||||||
ready: () => any;
|
ready: () => any;
|
||||||
|
|
|
@ -5,10 +5,10 @@ import { overwriteRegistryEntry } from "libskynetnode";
|
||||||
import { Buffer } from "buffer";
|
import { Buffer } from "buffer";
|
||||||
import { Parser } from "xml2js";
|
import { Parser } from "xml2js";
|
||||||
import { URL } from "url";
|
import { URL } from "url";
|
||||||
import { errorExit } from "./util.js";
|
|
||||||
import { pack } from "msgpackr";
|
import { pack } from "msgpackr";
|
||||||
import config from "./config.js";
|
import config from "./config.js";
|
||||||
import { hashDataKey } from "@lumeweb/kernel-utils";
|
import { hashDataKey } from "@lumeweb/kernel-utils";
|
||||||
|
import { errorExit } from "./error.js";
|
||||||
|
|
||||||
const { createHash } = await import("crypto");
|
const { createHash } = await import("crypto");
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
export function errorExit(msg: string): void {
|
||||||
|
console.error(msg);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ERR_NOT_READY = "NOT_READY";
|
|
@ -10,12 +10,13 @@ import PocketPKG from "@pokt-network/pocket-js";
|
||||||
|
|
||||||
const { Configuration, HttpRpcProvider, PocketAAT, Pocket } = PocketPKG;
|
const { Configuration, HttpRpcProvider, PocketAAT, Pocket } = PocketPKG;
|
||||||
import {
|
import {
|
||||||
|
JSONRPCError,
|
||||||
JSONRPCRequest,
|
JSONRPCRequest,
|
||||||
JSONRPCResponseWithError,
|
JSONRPCResponseWithError,
|
||||||
JSONRPCResponseWithResult,
|
JSONRPCResponseWithResult,
|
||||||
} from "jayson";
|
} from "jayson";
|
||||||
import config, { updateUsePocketGateway, usePocketGateway } from "./config.js";
|
import config, { updateUsePocketGateway, usePocketGateway } from "./config.js";
|
||||||
import { errorExit } from "./util.js";
|
import { ERR_NOT_READY, errorExit } from "./error.js";
|
||||||
|
|
||||||
const require = createRequire(import.meta.url);
|
const require = createRequire(import.meta.url);
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,6 @@ import * as chainNetworks from "./networks.json" assert { type: "json" };
|
||||||
|
|
||||||
type networks = { [net: string]: string };
|
type networks = { [net: string]: string };
|
||||||
|
|
||||||
export function errorExit(msg: string): void {
|
|
||||||
console.error(msg);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function maybeMapChainId(chain: string): string | boolean {
|
export function maybeMapChainId(chain: string): string | boolean {
|
||||||
if (chain in chainNetworks) {
|
if (chain in chainNetworks) {
|
||||||
return (chainNetworks as networks)[chain];
|
return (chainNetworks as networks)[chain];
|
||||||
|
|
Loading…
Reference in New Issue