UNPKG

@metaplex-foundation/umi-rpc-web3js

Version:

An RPC implementation relying on Solana's web3.js

23 lines (21 loc) 715 B
import { UmiPlugin } from '@metaplex-foundation/umi'; import type { Connection as Web3JsConnection } from '@solana/web3.js'; import { createWeb3JsRpc, Web3JsRpcOptions } from './createWeb3JsRpc'; export function web3JsRpc( endpoint: string, rpcOptions?: Web3JsRpcOptions ): UmiPlugin; export function web3JsRpc(connection: Web3JsConnection): UmiPlugin; export function web3JsRpc( endpointOrConnection: string | Web3JsConnection, rpcOptions?: Web3JsRpcOptions ): UmiPlugin { return { install(umi) { umi.rpc = typeof endpointOrConnection === 'string' ? createWeb3JsRpc(umi, endpointOrConnection, rpcOptions) : createWeb3JsRpc(umi, endpointOrConnection); }, }; }