diff --git a/src/config.ts b/src/config.ts index 4ee49df..ddb3db0 100644 --- a/src/config.ts +++ b/src/config.ts @@ -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"); diff --git a/src/dht.ts b/src/dht.ts index 31e214e..cf69835 100644 --- a/src/dht.ts +++ b/src/dht.ts @@ -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; diff --git a/src/dns.ts b/src/dns.ts index f7fac23..9614171 100644 --- a/src/dns.ts +++ b/src/dns.ts @@ -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"); diff --git a/src/error.ts b/src/error.ts new file mode 100644 index 0000000..8c4bac4 --- /dev/null +++ b/src/error.ts @@ -0,0 +1,6 @@ +export function errorExit(msg: string): void { + console.error(msg); + process.exit(1); +} + +export const ERR_NOT_READY = "NOT_READY"; diff --git a/src/rpc.ts b/src/rpc.ts index b33c9ed..f6ca874 100644 --- a/src/rpc.ts +++ b/src/rpc.ts @@ -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); diff --git a/src/util.ts b/src/util.ts index a8b832f..a354afc 100644 --- a/src/util.ts +++ b/src/util.ts @@ -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];