/** * @module parser/transaction * @description Decode SAP instruction names from a raw `TransactionResponse`. * * This is "Case 2A": you have a transaction response object obtained * from `connection.getTransaction(signature, ...)` and need to extract * the SAP instruction names, arguments, and account keys. * * The function handles both legacy and versioned (v0) transactions * by decompiling the message into `TransactionInstruction[]` and then * filtering for instructions whose `programId` matches the SAP program. * * @category Parser * @since v0.5.0 * * @example * ```ts * import { parseSapInstructionsFromTransaction } from "@synapse-sap/sdk/parser"; * import { SAP_PROGRAM_ID } from "@synapse-sap/sdk"; * * const tx = await connection.getTransaction(sig, { * commitment: "confirmed", * maxSupportedTransactionVersion: 0, * }); * if (!tx) throw new Error("Transaction not found"); * * const decoded = parseSapInstructionsFromTransaction( * tx, * program.coder.instruction, * SAP_PROGRAM_ID, * ); * for (const ix of decoded) { * console.log(ix.name, ix.args); * } * ``` */ import { AddressLookupTableAccount, type PublicKey, type VersionedTransactionResponse, type TransactionResponse } from "@solana/web3.js"; import type { DecodedSapInstruction, SapInstructionCoder } from "./types"; /** * Extract and decode SAP instructions from a transaction response. * * Supports both legacy (`TransactionResponse`) and versioned * (`VersionedTransactionResponse`) formats. For versioned * transactions that use address lookup tables, pass the resolved * lookup table accounts so that `TransactionMessage.decompile` * can reconstruct the full account list. * * @param tx - The transaction response from `connection.getTransaction`. * @param coder - An Anchor instruction coder built from the SAP IDL. * @param sapProgramId - The SAP program public key to filter by. * @param addressLookupTables - Resolved lookup table accounts for v0 transactions. * Required when the transaction uses address lookup tables; omit for legacy txs. * @returns An array of decoded SAP instructions found in the transaction. * * @throws {Error} When the transaction message cannot be decompiled. * * @category Parser * @since v0.5.0 */ export declare function parseSapInstructionsFromTransaction(tx: TransactionResponse | VersionedTransactionResponse, coder: SapInstructionCoder, sapProgramId: PublicKey, addressLookupTables?: AddressLookupTableAccount[]): DecodedSapInstruction[]; /** * Extract only the SAP instruction names from a transaction response. * * Lighter-weight alternative to {@link parseSapInstructionsFromTransaction} * when you only need the instruction names without decoded arguments. * * @param tx - The transaction response. * @param coder - An Anchor instruction coder built from the SAP IDL. * @param sapProgramId - The SAP program public key. * @param addressLookupTables - Resolved lookup table accounts for v0 transactions. * @returns An array of instruction name strings. * * @category Parser * @since v0.5.0 */ export declare function parseSapInstructionNamesFromTransaction(tx: TransactionResponse | VersionedTransactionResponse, coder: SapInstructionCoder, sapProgramId: PublicKey, addressLookupTables?: AddressLookupTableAccount[]): string[]; //# sourceMappingURL=transaction.d.ts.map