import { BN } from "@project-serum/anchor"; import { Provider, Wallet } from "@project-serum/anchor"; import { AccountInfo, MintInfo, u64 } from "@solana/spl-token"; import { Connection, PublicKey, Signer, TransactionInstruction } from "@solana/web3.js"; import type { Action } from "../interfaces"; import type { SendTxRequest } from "@project-serum/anchor/dist/provider"; export declare const tryCreateAssociatedAccountInst: (mint: PublicKey, owner: PublicKey, connection: Connection, payer: PublicKey) => Promise<{ associateTokAccount: PublicKey; instr?: TransactionInstruction; }>; export declare const tryCreateAssociatedAccount: (mint: PublicKey, owner: PublicKey, provider: Provider) => Promise; export interface AccountByMint { [mint: string]: { publicKey: PublicKey; }; } /** * Transfer to the token account being used by a construction input. * If the source account does not have enough balance, then throw an error. * This will also return null if the source equals the destination. * Transfer checked will also check if the mint is Wrapped Sol. If it is * and the source account is not a token account, the returned tx will transfer Native Solana * from the source */ export declare const transferToTxChecked: (source: PublicKey, destination: PublicKey, amount: BN, authority: Signer | Wallet, mint: PublicKey, connection: Connection) => Promise; export declare type PreferredTokenAccounts = { [mint: string]: PublicKey; }; /** * Get the token account which the malloc sdk will use for a mint * * @param preferredTokenAccounts - a map of mints to token accounts which the caller would prefer to use per mint. If the account does not exist, * and is needed it will be created in the the returned txs */ export declare const getTokenAccountUsedByMalloc: (tokenAuthority: PublicKey | string, mintAccount: PublicKey | string, preferredTokenAccounts?: PreferredTokenAccounts) => Promise; /** * Takes in a mapping of mints to token accounts. If a token account has yet to exist, one will be made * which is associated to the authority's address * * @param preferredTokenAccounts - a map of mints to token accounts which the caller would prefer to use per mint. If the account does not exist, * and is needed it will be created in the the returned txs */ export declare const createTokenAccountsForActions: (provider: Provider, tokenAuthority: Signer | Wallet, actions: Action[], fundingAccount: Signer | Wallet, preferredTokenAccounts?: PreferredTokenAccounts) => Promise<{ accounts: AccountByMint; txs: SendTxRequest[]; }>; export declare const removeDuplicateMints: (mints: PublicKey[]) => string[]; export declare const removeMints: (mints: PublicKey[], toRemove: PublicKey[]) => PublicKey[]; export declare const toReadableNumber: (number: u64, decimals: number) => string; export declare const fromReadableNumber: (number: number, decimals: number) => string; /** * Split the amounts and add the remainder to the last amount */ export declare const splitTokensByFractions: (amount: BN, splits: number[]) => BN[]; export declare const getMintInfo: (connection: Connection, mintAddr: PublicKey) => Promise; export declare const getTokenAccountInfo: (connection: Connection, tokenAccount: PublicKey) => Promise; export declare const checkInMintsAreTheSame: (actions: Action[]) => boolean;