UNPKG

@kaiachain/web3js-ext

Version:
27 lines (26 loc) 1.04 kB
"use strict"; // Analogous to https://github.com/web3/web3.js/blob/v4.3.0/packages/web3-rpc-methods/src/eth_rpc_methods.ts // RPC method wrappers. Object.defineProperty(exports, "__esModule", { value: true }); exports.getProtocolVersion = void 0; // Wrapper for _protocolVersion RPC that works for both Klaytn and Ethereum nodes. async function getProtocolVersion(requestManager) { try { // First try klay API, because the user of web3js-ext is // likely connected Klaytn node or Klaytn wallet. // If this fails, retry with eth API. return requestManager.send({ method: "klay_protocolVersion", params: [], }); } catch (_e) { // Then try eth API, in case the provider is MetaMask or non-Klaytn node. // If this fails, then the error will be thrown as if there was no try-catch. return requestManager.send({ method: "eth_protocolVersion", params: [], }); } } exports.getProtocolVersion = getProtocolVersion;