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

88 lines 4.59 kB
import { avaxSerial, Common, Context as ContextType, PChainOwner, TransferableOutput, UnsignedTx } from "@avalabs/avalanchejs"; import { Address as AddressType } from "viem"; import { AvalancheAccount } from "../../accounts/index.js"; import { AvalancheWalletCoreClient } from "../../clients/createAvalancheWalletCoreClient.js"; import { C_CHAIN_ALIAS, P_CHAIN_ALIAS, X_CHAIN_ALIAS } from "../consts.js"; import { CommonTxParams, FormattedCommonAVMTxParams, FormattedCommonPVMTxParams, Output, TransferableOutputFull } from "./types/common.js"; export declare function getBaseUrl(client: AvalancheWalletCoreClient): string; export declare function getBech32AddressFromAccountOrClient(client: AvalancheWalletCoreClient, account: AvalancheAccount | AddressType | undefined, chainAlias: typeof P_CHAIN_ALIAS | typeof X_CHAIN_ALIAS | typeof C_CHAIN_ALIAS, hrp: string): Promise<string>; export declare function getEVMAddressFromAccountOrClient(client: AvalancheWalletCoreClient, account: AvalancheAccount | undefined): Promise<string>; export declare function evmAddressToBytes(address: string): Uint8Array<ArrayBufferLike>; export declare function bech32AddressToBytes(address: string): Uint8Array<ArrayBufferLike>; export declare function evmOrBech32AddressToBytes(address: string): Uint8Array<ArrayBufferLike>; /** * Convert AVAX to wei * @param amount - The amount of AVAX to convert * @returns The amount in wei */ export declare function avaxToWei(amount: number): bigint; /** * Convert wei to AVAX * @param amount - The amount of wei to convert * @returns The amount in AVAX */ export declare function weiToAvax(amount: bigint): bigint; /** * Convert AVAX to nanoAVAX * @param amount - The amount of AVAX to convert * @returns The amount in nanoAVAX */ export declare function avaxToNanoAvax(amount: number): bigint; /** * Convert wei to nanoAVAX * @param amount - The amount of wei to convert * @returns The amount in nanoAVAX */ export declare function weiToNanoAvax(amount: bigint): bigint; /** * Convert nanoAVAX to wei * @param amount - The amount of nanoAVAX to convert * @returns The amount in wei */ export declare function nanoAvaxToWei(amount: bigint): bigint; /** * Convert nanoAVAX to AVAX * @param amount - The amount of nanoAVAX to convert * @returns The amount in AVAX */ export declare function nanoAvaxToAvax(amount: bigint): number; export declare function getChainIdFromAlias(alias: typeof P_CHAIN_ALIAS | typeof X_CHAIN_ALIAS | typeof C_CHAIN_ALIAS, networkId: number): "2oYMBNV4eNHyqk2fjjV5nVQLDbtmNJzq5s3qs3Lo6ftnC6FByM" | "2JVSBoinj9C2J33VntvzYtVJNZdN2NKiwwKjcumHUWEb5DbBrm" | "2q9e4r6Mu3U68nU1fYjgbR6JvwrRx36CohpAX5UQxse55x1Q5" | "yH8D7ThNJkxmtkuv2jgBa4P1Rn3Qpr4pPr7QYNfcdoS6k6HWp" | "11111111111111111111111111111111LpoYY"; export declare function fetchCommonPVMTxParams(client: AvalancheWalletCoreClient, params: { txParams: CommonTxParams; sourceChain?: string; chainAlias?: typeof P_CHAIN_ALIAS | typeof X_CHAIN_ALIAS | typeof C_CHAIN_ALIAS; subnetId?: string; l1ValidationId?: string; account?: AvalancheAccount | AddressType | undefined; context: ContextType.Context; }): Promise<{ commonTxParams: FormattedCommonPVMTxParams; subnetOwners: PChainOwner | undefined; disableOwners: PChainOwner | undefined; }>; export declare function fetchCommonAVMTxParams(client: AvalancheWalletCoreClient, params: { txParams: CommonTxParams; sourceChain?: string; chainAlias?: typeof P_CHAIN_ALIAS | typeof X_CHAIN_ALIAS | typeof C_CHAIN_ALIAS; account?: AvalancheAccount | AddressType | undefined; context: ContextType.Context; }): Promise<{ commonTxParams: FormattedCommonAVMTxParams; }>; export declare function formatOutput(output: Output, context: ContextType.Context): avaxSerial.TransferableOutput; export type PChainOwnerJSON = { /** * Addresses who can sign the transaction. */ addresses: string[]; /** * Optional. Number of signatures required to sign the transaction. * @default 1 */ threshold?: number; }; export declare function isTxImportExport(tx: Common.Transaction): boolean; export declare function addPChainOwnerAuthSignature(unsignedTx: UnsignedTx, owners: PChainOwner, authIndices: number[], signature: Uint8Array<ArrayBufferLike>, publicKey: string): Promise<void>; export declare function toTransferableOutput(output: TransferableOutput): TransferableOutputFull; export declare function addOrModifyXPAddressesAlias(address: string[] | undefined, alias: string): string[] | undefined; //# sourceMappingURL=utils.d.ts.map