import { Wallet, web3 } from "@project-serum/anchor"; import { PublicKey, Signer } from "@solana/web3.js"; import { AccountByMint, PreferredTokenAccounts } from "../utils/tokens"; import { ActionPIDToActionUID, BuildActionMap } from "./common"; import { ActionVertexInfo, Construction, TxRequestsTyped } from "./contexts"; /** * * @param parallelSetup - if true, then the program will run token * setup in parallel * * @param retryTxOnTimeout - the maximum number of times to retry a tx if it times out * */ export interface RunConstructionOpts { commitment?: web3.ConfirmOptions; parallelSetup?: boolean; onTxDone?: OnTxDoneFn; customTxTimeoutMs?: number; retryTxOnTimeout?: number; propagationSleepMs?: number; } /** * @params solRecipient - the recipient to receive the rent from the cleaned up * accounts, if this is null, the provider's public key will be used */ export interface CleanupOpts { commitment?: web3.ConfirmOptions; solRecipient?: PublicKey; } /** * A compiled instruction ready to be sent to Solana * * @params txLengths: the number of transactions for the transaction type. * They should all be a number, except that for actions is an array (1 item for each action) */ export interface ConstructionCompiled { authority: Wallet | Signer; actionMap: BuildActionMap; txs: TxRequestsTyped[]; constructionSigner: Signer; construction: Construction; tokenAccounts: AccountByMint; actionPIDToUID: ActionPIDToActionUID; } export declare type ActionStatus = "succeeded" | "ready" | "notReady"; /** * The construction as represented on chain where the public keys * and numbers have been serialized * * @param authority - B58 Encoded public key of the authority * @param actions.tokenAccount - B58 Encoded public key of the token account */ export interface ConstructionOnChainSerialized { authority: string; actions: (ActionVertexInfo & { tokenAccount: string; })[]; actionCalls: { callAmounts: string[]; numbTimesHit: number; status: ActionStatus; }[]; } export interface BuildEphemeralOpts { preferredTokenAccounts?: PreferredTokenAccounts; authority?: Signer | Wallet; amountInAuthority?: Signer; cleanupAtEnd?: boolean; cleanupOpts?: CleanupOpts; constructionAccount?: Signer; } export declare type ConstructionInstr = { construction: Construction; actionMap: BuildActionMap; amountInAccounts: PublicKey[]; opts?: BuildEphemeralOpts; }; /** * Function which gets called after each transaction completes */ export declare type OnTxDoneFn = (completed: number, total: number, actionNames?: string[]) => void;