UNPKG

@tan_hoang/test2

Version:
42 lines (41 loc) 1.82 kB
import { JsonRpcProvider as EthersJsonRpcProvider, Web3Provider as EthersWeb3Provider } from "@ethersproject/providers"; import { asyncOpenApi } from "@kaiachain/js-ext-core"; // @ts-ignore: package @kaiachain/web3rpc has no .d.ts file. import { AdminApi, DebugApi, GovernanceApi, KlayApi, NetApi, PersonalApi, TxpoolApi } from "@kaiachain/web3rpc"; import { JsonRpcSigner } from "./signer"; /* eslint-disable no-multi-spaces */ export class JsonRpcProvider extends EthersJsonRpcProvider { constructor(url, network) { super(url, network); const send = (method, params) => { return this.send(method, params); }; this.admin = asyncOpenApi(send, AdminApi); this.debug = asyncOpenApi(send, DebugApi); this.governance = asyncOpenApi(send, GovernanceApi); this.klay = asyncOpenApi(send, KlayApi); this.kaia = asyncOpenApi(send, KlayApi); this.net = asyncOpenApi(send, NetApi); this.personal = asyncOpenApi(send, PersonalApi); this.txpool = asyncOpenApi(send, TxpoolApi); } } export class Web3Provider extends EthersWeb3Provider { constructor(provider, network) { super(provider, network); const send = (method, params) => { return this.send(method, params); }; this.admin = asyncOpenApi(send, AdminApi); this.debug = asyncOpenApi(send, DebugApi); this.governance = asyncOpenApi(send, GovernanceApi); this.klay = asyncOpenApi(send, KlayApi); this.kaia = asyncOpenApi(send, KlayApi); this.net = asyncOpenApi(send, NetApi); this.personal = asyncOpenApi(send, PersonalApi); this.txpool = asyncOpenApi(send, TxpoolApi); } getSigner(addressOrIndex) { return new JsonRpcSigner(this, addressOrIndex); } }