opstack-kit-chains
Version:
Support your OP-Stack network with 'opstack-kit'
17 lines • 773 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBlockNumber = exports.getBlockNumberCache = void 0;
const withCache_js_1 = require("../../utils/promise/withCache.js");
const cacheKey = (id) => `blockNumber.${id}`;
function getBlockNumberCache(id) {
return (0, withCache_js_1.getCache)(cacheKey(id));
}
exports.getBlockNumberCache = getBlockNumberCache;
async function getBlockNumber(client, { cacheTime = client.cacheTime } = {}) {
const blockNumberHex = await (0, withCache_js_1.withCache)(() => client.request({
method: 'eth_blockNumber',
}), { cacheKey: cacheKey(client.uid), cacheTime });
return BigInt(blockNumberHex);
}
exports.getBlockNumber = getBlockNumber;
//# sourceMappingURL=getBlockNumber.js.map
;