*refactor loading networks.json
This commit is contained in:
parent
6a2ea8b4f2
commit
7c13ab7f3f
|
@ -5,8 +5,6 @@ import { Connection } from "@solana/web3.js";
|
||||||
import { getAat, getPocketServer } from "../rpc.js";
|
import { getAat, getPocketServer } from "../rpc.js";
|
||||||
import config, { usePocketGateway } from "../config.js";
|
import config, { usePocketGateway } from "../config.js";
|
||||||
|
|
||||||
export const chainNetworks = require("../../networks.json");
|
|
||||||
|
|
||||||
type RpcProviderMethod = (method: string, params: Array<any>) => Promise<any>;
|
type RpcProviderMethod = (method: string, params: Array<any>) => Promise<any>;
|
||||||
|
|
||||||
const gatewayProviders: { [name: string]: RpcProviderMethod } = {};
|
const gatewayProviders: { [name: string]: RpcProviderMethod } = {};
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { chainNetworks, proxyRpcMethod } from "./common.js";
|
import { proxyRpcMethod } from "./common.js";
|
||||||
import { RpcMethodList } from "./index.js";
|
import { RpcMethodList } from "./index.js";
|
||||||
|
import * as chainNetworks from "../networks.json";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
getAccountInfo: proxyRpcMethod("getAccountInfo", [
|
getAccountInfo: proxyRpcMethod("getAccountInfo", [
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import { chainNetworks } from "./rpc/index.js";
|
import * as chainNetworks from "./networks.json";
|
||||||
|
|
||||||
|
type networks = { [net: string]: string };
|
||||||
|
|
||||||
export function errorExit(msg: string): void {
|
export function errorExit(msg: string): void {
|
||||||
console.error(msg);
|
console.error(msg);
|
||||||
|
@ -7,7 +9,7 @@ export function errorExit(msg: string): void {
|
||||||
|
|
||||||
export function maybeMapChainId(chain: string): string | boolean {
|
export function maybeMapChainId(chain: string): string | boolean {
|
||||||
if (chain in chainNetworks) {
|
if (chain in chainNetworks) {
|
||||||
return chainNetworks[chain];
|
return (chainNetworks as networks)[chain];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"skipLibCheck": true
|
"skipLibCheck": true,
|
||||||
|
"resolveJsonModule": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue