UNPKG

whoisens-lib

Version:

Whois for ENS (Ethereum Name Service) lookup service

41 lines 1.37 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const json_rpc3_1 = __importDefault(require("json-rpc3/dist/cjs/index.js")); const Config_js_1 = __importDefault(require("../lib/Config.js")); class JSONRPCRequest { constructor() { this.jsonRPC = new json_rpc3_1.default({ url: Config_js_1.default.getInstance().currentNetworkURL }); } static getInstance() { if (!JSONRPCRequest.instance) JSONRPCRequest.instance = new JSONRPCRequest(); return JSONRPCRequest.instance; } /** * Make a JSON-RCP call * @link https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_call * @link https://solidity.readthedocs.io/en/latest/abi-spec.html#examples */ async makeRequest({ to, data }) { return (await this.jsonRPC.calls({ method: 'eth_call', params: [{ to, data }, 'latest'] })).get(); } async getNetworkID() { return (await this.jsonRPC.calls({ method: 'net_version', params: [] })).get().result; } } exports.default = JSONRPCRequest; //# sourceMappingURL=json-rpc.js.map