UNPKG

whoisens-lib

Version:

Whois for ENS (Ethereum Name Service) lookup service

73 lines 2.91 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const config_js_1 = __importDefault(require("./../config.js")); const index_js_1 = __importDefault(require("../utils/index.js")); const json_rpc_js_1 = __importDefault(require("../utils/json-rpc.js")); const BaseClass_js_1 = __importDefault(require("./BaseClass.js")); const Config_js_1 = __importDefault(require("./Config.js")); class ENSRoot extends BaseClass_js_1.default { constructor() { super(); } async getController(address) { await this.init(); const method = 'owner(bytes32)'; const methodId = index_js_1.default.getMethodID(method); const addressNode = index_js_1.default.remove0x(index_js_1.default.node(address)); const data = `${methodId}${addressNode}`; const result = await json_rpc_js_1.default.getInstance().makeRequest({ to: this.contractAddress, data }); return this.returnResult({ contractAddress: this.contractAddress, contractMethod: method, payload: data, parameters: { methodId, addressNode }, jsonRCPResult: result, result: index_js_1.default.normalizeHex(result.result) }); } async getResolver(address) { await this.init(); const method = 'resolver(bytes32)'; const methodId = index_js_1.default.getMethodID(method); const addressNode = index_js_1.default.remove0x(index_js_1.default.node(address)); const data = [methodId, addressNode].join(''); const result = await json_rpc_js_1.default.getInstance().makeRequest({ to: this.contractAddress, data }); return this.returnResult({ contractAddress: this.contractAddress, contractMethod: method, payload: data, parameters: { methodId, addressNode }, jsonRCPResult: result, result: index_js_1.default.normalizeHex(result.result) }); } async findContractAddress() { const networkId = await json_rpc_js_1.default.getInstance().getNetworkID(); Config_js_1.default.getInstance().currentNetworkId = networkId; return config_js_1.default.networkContract[networkId]; } async init() { this.contractAddress = Config_js_1.default.getInstance().contractAddress; if (!this.contractAddress) { this.contractAddress = await this.findContractAddress(); Config_js_1.default.getInstance().contractAddress = this.contractAddress; } } } exports.default = ENSRoot; //# sourceMappingURL=ENSRoot.js.map