import { AccountInfo, Commitment, Connection, PublicKey, SimulatedTransactionAccountInfo, Transaction, TransactionInstruction, VersionedTransaction } from "@solana/web3.js"; import BN from "bn.js"; import { Buffer } from "buffer"; import { SolanaPubkey } from "./interfaces"; type AmountType = string | number | BN | number[]; declare enum AccountState { Uninitialized = 0, Initialized = 1, Frozen = 2 } export type ExistingAccountBalance = { balance: number; spl?: { mint: PublicKey; owner: PublicKey; balance: bigint; isToken22: boolean; }; }; export type AccountBalance = ExistingAccountBalance | null; type SplDiff = { mint: PublicKey; owner: PublicKey; preBalance: number; postBalance: number; diff: bigint; }; type AccountBalanceDiff = { pubKey: PublicKey; preBalance: number; postBalance: number; diff: number; spl?: SplDiff; }; type RawAccount = { mint: PublicKey; owner: PublicKey; amount: bigint; delegateOption: 1 | 0; delegate: PublicKey; state: AccountState; isNativeOption: 1 | 0; isNative: bigint; delegatedAmount: bigint; closeAuthorityOption: 1 | 0; closeAuthority: PublicKey; }; export declare enum AccountType { System = 0, Token = 1, CorrectATA = 2, Unknown = 3, NotExists = 4 } export interface WalletInfo { /** Address of the account */ address: PublicKey; /** Mint associated with the account */ mint: PublicKey; /** Owner of the account */ owner: PublicKey; /** Number of tokens the account holds */ amount: BN; decimals: number; /** True if the account is initialized */ isInitialized: boolean; /** True if the account is a native token account */ isNative: boolean; /** True if the account is a token 2022 */ isToken22: boolean; } export interface TokenInfo { /** Address of the token mint */ address: PublicKey; /** Number of decimals in the token */ decimals: number; /** Name of the token */ name: string; /** Symbol of the token */ symbol: string; /** URI with more info about the token (usually link to json with image, description, etc) */ json: string; /** * Address of the token program (can be TOKEN_PROGRAM_ID or TOKEN_2022_PROGRAM_ID). Used to distinguish between token 2022 and legacy token, and to create correct associated accounts */ tokenProgram: PublicKey; } /** * Get name, symbol and decimals for provided token * @param connection solana web3 connection * @param tokenAddress address to get metaplex info for * @returns */ export declare function getTokenInfo(connection: Connection, tokenAddress: PublicKey, useCache?: boolean): Promise; /** * Builds instruction for creation of associated wallet for specified token * @param tokenMint mint account of SPL-token * @param associatedAccount associated account address * @param owner owner of the associated account * @param payer who pays for account creation * @param isToken2022 * @param associatedTokenProgramId */ export declare function createAssociatedWalletInstruction(tokenMint: SolanaPubkey, associatedAccount: PublicKey, owner: SolanaPubkey, payer: SolanaPubkey, isToken2022: boolean, associatedTokenProgramId?: PublicKey): TransactionInstruction; export declare function parseSplAccount(info: AccountInfo | null): null | RawAccount; export declare function parseSplAccount(data: Buffer): null | RawAccount; /** * Requests account from blockchain and returns result with account type * @param account address of account * @returns account info and account type */ export declare function getAccountWithType(connection: Connection, account: SolanaPubkey): Promise<[AccountInfo | null, AccountType]>; /** * Returns balance of associated wallet in SPL-tokens (finds correct ata (token/token22)) * @param originalWallet native tokens wallet address * @param tokenMint mint of SPL-Token */ export declare function getAssocSPLWalletBalance(connection: Connection, originalWallet: SolanaPubkey, tokenMint: SolanaPubkey): Promise; /** * Returns balance of specified wallets. null if account doesn't exist * @param wallet spl-tokens wallet address */ export declare function getWalletsBalances(connection: Connection, wallets: SolanaPubkey[], commitment?: Commitment): Promise; /** * Gets list of user's SPL-token accounts * @param owner owner of the SPL wallets * @returns list of accounts with amount on them */ export declare function getAllTokenAccountsWithBalances(connection: Connection, owner: SolanaPubkey): Promise; /** * Gets list of user's tokenMint token accounts * @param tokenMint * @param owner owner of the wallets * @returns list of accounts with amount on them */ export declare function getTokenAccountsWithBalance(connection: Connection, tokenMint: SolanaPubkey, owner: SolanaPubkey): Promise; /** * Builds transaction to transfer&wrap native sol from src wallet to dst wallet * @param amount number of lamports to transfer and wrap * @param transferFrom source native account * @param transferTo destination wallet * @returns transaction to transfer&wrap sol */ export declare function buildReplenishWsolBalanceTransaction(amount: AmountType, transferFrom: SolanaPubkey, transferTo: SolanaPubkey): Transaction; /** * Builds transaction that wraps specified amount of lamports into spl, if account is missing will create it * @param amount lamports to wrap, ATA will contain exact amount of lamports * @param owner owner of created wallet */ export declare function updateWsolBalance(connection: Connection, amount: AmountType, owner: SolanaPubkey): Promise; export declare function getTransactionAccountsForSimulationDiff(connection: Connection, tx: VersionedTransaction | Transaction): Promise; export declare function parseMultipleAccounts(accounts: (AccountInfo | null)[] | (SimulatedTransactionAccountInfo | null)[]): Array; export declare function getSplDiff(pre: ExistingAccountBalance["spl"], post: ExistingAccountBalance["spl"]): SplDiff; export declare function getTransactionDiff(connection: Connection, tx: VersionedTransaction, txAccounts?: PublicKey[]): Promise>; export {}; //# sourceMappingURL=spl.d.ts.map