UNPKG

@pushchain/core

Version:

Push Chain is a true universal L1 that is 100% EVM compatible. It allows developers to deploy once and make their apps instantly compatible with users from all other L1s (Ethereum, Solana, etc) with zero on-chain code change.

54 lines (53 loc) 2.08 kB
import { Keypair, TransactionInstruction } from '@solana/web3.js'; import { ClientOptions, ReadContractParams, WriteContractParams } from './vm-client.types'; import { UniversalSigner } from '../universal/universal.types'; /** * Solana-compatible VM client for reading and writing SVM-based chains. */ export declare class SvmClient { private readonly connections; private currentConnectionIndex; constructor({ rpcUrls }: ClientOptions); /** * Executes a function with automatic fallback to next RPC endpoint on failure */ private executeWithFallback; /** Build an AnchorProvider; if a signer is passed we wrap it, otherwise we give a no-op wallet. */ private createProvider; /** * Returns the balance (in lamports) of a Solana address. */ getBalance(address: string): Promise<bigint>; /** * Reads a full program account using Anchor IDL. * `functionName` must match the account layout name in the IDL. */ readContract<T = unknown>({ abi, functionName, args, }: ReadContractParams): Promise<T>; /** * Sends a Solana transaction using a smart contract instruction. */ writeContract({ abi, signer, functionName, args, accounts, extraSigners, }: WriteContractParams): Promise<string>; /** * Sends a set of instructions as a manually-signed Solana transaction. */ sendTransaction({ instruction, signer, extraSigners, }: { instruction: TransactionInstruction; signer: UniversalSigner; extraSigners?: Keypair[]; }): Promise<string>; /** * Waits for a transaction to be confirmed on the blockchain. */ confirmTransaction(signature: string, timeout?: number): Promise<void>; /** * Estimates the fee (in lamports) to send a transaction with the given instructions. */ estimateGas({ instructions, signer, }: { instructions: TransactionInstruction[]; signer: UniversalSigner; }): Promise<bigint>; /** * Sleeps for the given number of milliseconds. */ private sleep; }