UNPKG

@avalanche-sdk/client

Version:

A TypeScript SDK for interacting with the Avalanche network through JSON-RPC APIs. This SDK provides a comprehensive set of tools to interact with all Avalanche chains (P-Chain, X-Chain, C-Chain) and various APIs, including wallet functionality for transa

47 lines 3.45 kB
import { Account, Chain, Client, CreatePublicClientErrorType, Prettify, RpcSchema, Transport, WalletActions, WalletRpcSchema } from "viem"; import { XPAccount } from "../accounts/avalancheAccount.js"; import { AvalancheWalletRpcSchema } from "../methods/wallet/avalancheWalletRPCSchema.js"; import { AvalancheCoreClient } from "./createAvalancheCoreClient.js"; import { AvalancheWalletCoreClient, AvalancheWalletCoreClientConfig } from "./createAvalancheWalletCoreClient.js"; import { AvalancheWalletActions } from "./decorators/avalancheWallet.js"; import { CChainWalletActions } from "./decorators/cChainWallet.js"; import { Erc20Actions } from "./decorators/erc20.js"; import { PChainWalletActions } from "./decorators/pChainWallet.js"; import { XChainWalletActions } from "./decorators/xChainWallet.js"; export type AvalancheWalletClientConfig<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = undefined, rpcSchema extends RpcSchema | undefined = undefined, raw extends boolean = false> = Prettify<AvalancheWalletCoreClientConfig<transport, chain, account, rpcSchema, raw>>; export type AvalancheWalletClient<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = undefined, rpcSchema extends RpcSchema | undefined = undefined> = Prettify<Client<transport, chain, account, rpcSchema extends RpcSchema ? [...WalletRpcSchema, ...AvalancheWalletRpcSchema, ...rpcSchema] : [...WalletRpcSchema, ...AvalancheWalletRpcSchema], WalletActions<chain, account> & AvalancheWalletActions> & { xpAccount?: XPAccount; pChainClient: AvalancheCoreClient; cChainClient: AvalancheCoreClient; xChainClient: AvalancheCoreClient; } & { erc20: AvalancheWalletCoreClient<transport, chain, account, rpcSchema, Erc20Actions>; cChain: AvalancheWalletCoreClient<transport, chain, account, rpcSchema, CChainWalletActions>; pChain: AvalancheWalletCoreClient<transport, chain, account, rpcSchema, PChainWalletActions>; xChain: AvalancheWalletCoreClient<transport, chain, account, rpcSchema, XChainWalletActions>; }>; export type CreateAvalancheWalletClientErrorType = CreatePublicClientErrorType; /** * Creates an Avalanche Wallet Client with a given transport configured for a Chain. * * The Avalanche Wallet Client is an interface to interact with the Core Wallet API through Avalanche-specific JSON-RPC API methods. * @see https://docs.core.app/docs/reference/json-rpc-api * * @param parameters - {@link AvalancheWalletClientConfig} * @returns A Avalanche Wallet Client. {@link AvalancheWalletClient} * * @example * ```ts * import { createAvalancheWalletClient } from '@avalanche-sdk/client' * import { avalanche } from '@avalanche-sdk/client/chains' * * const client = createAvalancheWalletClient({ * chain: avalanche, * transport: { type: "http" }, * }) * * const pubKey = await client.getAccountPubKey() * ``` */ export declare function createAvalancheWalletClient<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = undefined, rpcSchema extends RpcSchema | undefined = undefined>(parameters: AvalancheWalletClientConfig<transport, chain, account, rpcSchema>): AvalancheWalletClient<transport, chain, account, rpcSchema>; //# sourceMappingURL=createAvalancheWalletClient.d.ts.map