*Move errorExit to dedicated file

*Add ERR_NOT_READY constant which will represent a chain not ready
This commit is contained in:
Derrick Hammer 2022-07-22 20:57:12 -04:00
parent 023b1387fc
commit e0c0ee3f83
6 changed files with 11 additions and 9 deletions

View File

@ -1,9 +1,9 @@
// @ts-ignore
import BConfig from "bcfg";
import { errorExit } from "./util.js";
import * as os from "os";
import { createRequire } from "module";
import path from "path";
import { errorExit } from "./error.js";
const require = createRequire(import.meta.url);
const config = new BConfig("lumeweb-relay");

View File

@ -2,7 +2,6 @@ import { createRequire } from "module";
const require = createRequire(import.meta.url);
const DHT = require("@hyperswarm/dht");
import { errorExit } from "./util.js";
import {
deriveMyskyRootKeypair,
Ed25519Keypair,
@ -10,6 +9,7 @@ import {
validSeedPhrase,
} from "libskynet";
import config from "./config.js";
import { errorExit } from "./error.js";
let node: {
ready: () => any;

View File

@ -5,10 +5,10 @@ import { overwriteRegistryEntry } from "libskynetnode";
import { Buffer } from "buffer";
import { Parser } from "xml2js";
import { URL } from "url";
import { errorExit } from "./util.js";
import { pack } from "msgpackr";
import config from "./config.js";
import { hashDataKey } from "@lumeweb/kernel-utils";
import { errorExit } from "./error.js";
const { createHash } = await import("crypto");

6
src/error.ts Normal file
View File

@ -0,0 +1,6 @@
export function errorExit(msg: string): void {
console.error(msg);
process.exit(1);
}
export const ERR_NOT_READY = "NOT_READY";

View File

@ -10,12 +10,13 @@ import PocketPKG from "@pokt-network/pocket-js";
const { Configuration, HttpRpcProvider, PocketAAT, Pocket } = PocketPKG;
import {
JSONRPCError,
JSONRPCRequest,
JSONRPCResponseWithError,
JSONRPCResponseWithResult,
} from "jayson";
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);

View File

@ -2,11 +2,6 @@ import * as chainNetworks from "./networks.json" assert { type: "json" };
type networks = { [net: string]: string };
export function errorExit(msg: string): void {
console.error(msg);
process.exit(1);
}
export function maybeMapChainId(chain: string): string | boolean {
if (chain in chainNetworks) {
return (chainNetworks as networks)[chain];