///
import { BorshCoder, Event, EventParser, Idl, Instruction } from '@coral-xyz/anchor';
import type { InstructionDisplay } from '@coral-xyz/anchor/dist/cjs/coder/borsh/instruction';
import type { AllAccountsMap } from '@coral-xyz/anchor/dist/cjs/program/namespace/types';
import { AccountInfo, CompiledInstruction, PublicKey, TransactionResponse } from '@solana/web3.js';
import { TransactionResponseJSON } from './transaction';
type Decoder = (buffer: Buffer) => any;
export type AcctDiscHexMap = Record;
}>;
export type ExtractedIx = {
rawIx: CompiledInstruction;
/** Index of top-level instruction. */
ixIdx: number;
/** If this is an inner instruction, the index within its parent top-level instruction. */
subIxIdx?: number;
/** Presence of field = it's a top-level ix; absence = inner ix itself. */
innerIxs?: CompiledInstruction[];
noopIxs?: CompiledInstruction[];
};
export type AnchorIxName = IDL['instructions'][number]['name'];
export type AnchorIx = Omit & {
name: AnchorIxName;
};
export type ParsedAnchorEvent = {
ixName: string | null;
/** Increments every time a new invocation of a program ix happens. */
ixSeq: number;
event: AnchorEvent;
};
export type AnchorEvent = Events extends any[] ? Event : undefined;
export type ParsedAnchorIx = {
ix: AnchorIx;
events: AnchorEvent[];
formatted: InstructionDisplay | null;
accountKeys: PublicKey[];
} & Pick;
export type ParsedAnchorAccount = InstructionDisplay['accounts'][number];
/** `capName` in the format of "InscriptionV3" */
export declare const getAcctDiscHexFromName: (capName: string) => string;
export declare const genAcctDiscHexMap: (idl: IDL) => AcctDiscHexMap;
export declare const getAcctDiscHex: (data: Buffer) => string;
export declare const decodeAnchorAcct: (acct: AccountInfo, discMap: AcctDiscHexMap) => {
name: import("@coral-xyz/anchor/dist/cjs/program/namespace/types").AllAccounts["name"];
account: any;
} | null;
/** `snakeCaseName` in the format of "sell_nft_token_pool" */
export declare const getIxDiscHexFromName: (snakeCaseName: string) => string;
export declare const genIxDiscHexMap: (idl: IDL) => Record, string>;
export declare const getIxDiscHex: (bs58Data: string) => string;
export declare const parseAnchorEvents: (eventParser: EventParser, programId: PublicKey, logs: string[] | undefined | null) => ParsedAnchorEvent[];
export declare const parseAnchorIxs: ({ coder, tx, programId, noopIxDiscHex, eventParser, formatIxPreprocess, }: {
coder: BorshCoder;
tx: TransactionResponse;
programId: PublicKey;
/** If passed, will match noopIxs to its parent ix and omits it in the top-level output */
noopIxDiscHex?: string | undefined;
/** If provided, will try to parse events. Do not initialize if there are no events defined! */
eventParser?: EventParser | undefined;
/** Useful if ix parser can't handle a complex defined arg type: removing the arg before formatter is called helps */
formatIxPreprocess?: ((ix: Instruction) => Instruction) | undefined;
}) => ParsedAnchorIx[];
export declare const getAnchorAcctByName: (ix: ParsedAnchorIx, suffix: AccountSuffix) => {
name?: string | undefined;
pubkey: PublicKey;
isSigner: boolean;
isWritable: boolean;
} | undefined;
export declare const extractAllIxs: ({ tx, programId, noopIxDiscHex, }: {
tx: TransactionResponse | TransactionResponseJSON;
/** If passed, will filter for ixs w/ this program ID. */
programId?: PublicKey | undefined;
/** If passed WITH programId, will attach self-CPI noop ixs to corresponding programId ixs. NB: noopIxs are included in the final array too. */
noopIxDiscHex?: string | undefined;
}) => ExtractedIx[];
export {};
//# sourceMappingURL=anchor.d.ts.map