UNPKG

staker

Version:

Command line Utillity for Ethereum stakers

31 lines (22 loc) 834 B
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.maticFetch = exports.getMaticNodeURL = void 0; var _stakerFreenodes = require("staker-freenodes"); var _utils = require("../utils"); var _jsonRpc = require("../helpers/jsonRpc"); let cachedMaticNodeUrl = ''; /** * Random pick a MATIC node. * * can set yours via set SAIHUBOT_MATIC_NODE_URL environment variable. */ const getMaticNodeURL = () => { if (cachedMaticNodeUrl) return cachedMaticNodeUrl; cachedMaticNodeUrl = (0, _utils.getConfig)('MATIC_NODE_URL', (0, _stakerFreenodes.getRandomItem)(_stakerFreenodes.MATIC_NODES)); return cachedMaticNodeUrl; }; exports.getMaticNodeURL = getMaticNodeURL; const maticFetch = (fetch, body) => (0, _jsonRpc.jsonRpcFetch)(fetch, getMaticNodeURL(), body); exports.maticFetch = maticFetch;