{"version":3,"sources":["../src/decode-rpc-transaction.ts","../src/get-inner-instructions.ts","../src/get-instructions.ts","../src/walk-instructions.ts"],"names":["getBase58Encoder","SolanaError","SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_NOT_SUPPORTED","SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND","SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_ACCOUNT_INDEX_OUT_OF_RANGE"],"mappings":";;;;;;;AAkHA,IAAM,yBAA0C,EAAE,QAAA,EAAU,EAAC,EAAG,QAAA,EAAU,EAAC,EAAE;AAQ7E,SAAS,mBAAmB,IAAA,EAAgC;AACxD,EAAA,MAAM,SAAU,IAAA,EAAmE,eAAA;AACnF,EAAA,OAAO,MAAA,IAAU,sBAAA;AACrB;AAEA,SAAS,eAAe,SAAA,EAGtB;AACE,EAAA,MAAM,WAAA,GAAc,qBAAA,EAAsB,CAAE,MAAA,CAAO,SAAS,CAAA;AAC5D,EAAA,MAAM,eAAA,GAAkB,oCAAA,EAAqC,CAAE,MAAA,CAAO,YAAY,YAAY,CAAA;AAC9F,EAAA,OAAO,EAAE,iBAAiB,WAAA,EAAY;AAC1C;AAEA,SAAS,iBAAiB,KAAA,EAAgE;AACtF,EAAA,MAAM,CAAC,GAAG,CAAA,GAAI,KAAA,CAAM,WAAA;AACpB,EAAA,MAAM,EAAE,iBAAiB,WAAA,EAAY,GAAI,eAAe,gBAAA,EAAiB,CAAE,MAAA,CAAO,GAAG,CAAe,CAAA;AACpG,EAAA,OAAO,EAAE,eAAA,EAAiB,eAAA,EAAiB,mBAAmB,KAAA,CAAM,IAAI,GAAG,WAAA,EAAY;AAC3F;AAEA,SAAS,iBAAiB,KAAA,EAAgE;AACtF,EAAA,MAAM,CAAC,GAAG,CAAA,GAAI,KAAA,CAAM,WAAA;AACpB,EAAA,MAAM,EAAE,iBAAiB,WAAA,EAAY,GAAI,eAAe,gBA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AO,IAAA,EAAM,OAAA,EAAQ,EAAG,CAAA;AAC/D,IAAA,MAAM,KAAA,GAAQ,iBAAA,CAAkB,GAAA,CAAI,KAAK,CAAA;AACzC,IAAA,IAAI,KAAA,EAAO;AACP,MAAA,MAAA,CAAO,IAAA,CAAK,GAAG,KAAK,CAAA;AACpB,MAAA,iBAAA,CAAkB,OAAO,KAAK,CAAA;AAAA,IAClC;AAAA,EACJ,CAAC,CAAA;AAID,EAAA,KAAA,MAAW,KAAA,IAAS,iBAAA,CAAkB,MAAA,EAAO,EAAG;AAC5C,IAAA,MAAA,CAAO,IAAA,CAAK,GAAG,KAAK,CAAA;AAAA,EACxB;AACA,EAAA,OAAO,MAAA;AACX","file":"index.browser.mjs","sourcesContent":["import type { Address } from '@solana/addresses';\nimport { getBase58Encoder, getBase64Encoder } from '@solana/codecs-strings';\nimport {\n    SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_NOT_SUPPORTED,\n    SOLANA_ERROR__TRANSACTION_INTROSPECTION__CANNOT_DECODE_JSON_PARSED_TRANSACTION,\n    SOLANA_ERROR__TRANSACTION_INTROSPECTION__UNRECOGNIZED_GET_TRANSACTION_RESPONSE,\n    SolanaError,\n} from '@solana/errors';\nimport type {\n    Base58EncodedBytes,\n    Base58EncodedDataResponse,\n    Base64EncodedDataResponse,\n    Blockhash,\n} from '@solana/rpc-types';\nimport type {\n    CompiledTransactionMessage,\n    CompiledTransactionMessageWithLifetime,\n    LegacyCompiledTransactionMessage,\n    TransactionVersion,\n    V0CompiledTransactionMessage,\n    V1CompiledTransactionMessage,\n} from '@solana/transaction-messages';\nimport { getCompiledTransactionMessageDecoder } from '@solana/transaction-messages';\nimport type { Transaction } from '@solana/transactions';\nimport { getTransactionDecoder } from '@solana/transactions';\n\nimport type { LoadedAddresses } from './loaded-addresses';\n\n/**\n * The subset of a wire-format transaction response (`encoding: 'base58'` or\n * `'base64'`) that {@link decodeTransactionFromRpcResponse} reads: the\n * base-encoded wire-transaction tuple, plus the optional `meta` (carrying\n * `loadedAddresses`) and `version`.\n *\n * Only these fields are modeled — not the full RPC response envelope — so any\n * response carrying a compatible wire-transaction tuple satisfies it\n * structurally, regardless of which method produced it (`getTransaction`,\n * `getTransactionsForAddress`, or a future one).\n */\ntype DecodableWireTransactionResponse = Readonly<{\n    meta?: unknown;\n    transaction: Base58EncodedDataResponse | Base64EncodedDataResponse;\n    version?: TransactionVersion;\n}>;\n\n/**\n * The subset of an `encoding: 'json'` transaction response that\n * {@link decodeTransactionFromRpcResponse} reads. Only the message fields the\n * decoder actually consumes are modeled, so any response carrying a compatible\n * `transaction.message` satisfies it structurally, regardless of which method\n * produced it.\n */\ntype DecodableJsonTransactionResponse = Readonly<{\n    meta?: unknown;\n    transaction: Readonly<{\n        message: Readonly<{\n            accountKeys: readonly Address[];\n            // Nullable to match the RPC types\n            addressTableLookups?:\n                | readonly Readonly<{\n                      accountKey: Address;\n                      readonlyIndexes: readonly number[];\n                      writableIndexes: readonly number[];\n                  }>[]\n                | null;\n            header: Readonly<{\n                numReadonlySignedAccounts: number;\n                numReadonlyUnsignedAccounts: number;\n                numRequiredSignatures: number;\n            }>;\n            instructions: readonly Readonly<{\n                accounts: readonly number[];\n                data: Base58EncodedBytes;\n                programIdIndex: number;\n            }>[];\n            recentBlockhash: Blockhash;\n        }>;\n    }>;\n    version?: TransactionVersion;\n}>;\n\n/**\n * Any confirmed-transaction RPC response that\n * {@link decodeTransactionFromRpcResponse} can decode, regardless of which\n * method produced it. The wire and JSON members are disjoint on the shape of\n * `transaction` (a base-encoded tuple vs. a structured message), which is what\n * lets the overloads resolve the correct return type per encoding.\n */\ntype DecodableTransactionResponse = DecodableJsonTransactionResponse | DecodableWireTransactionResponse;\n\n/**\n * The result of decoding a confirmed-transaction RPC response: the\n * {@link CompiledTransactionMessage} (always with a `lifetimeToken` carrying\n * the recent blockhash), the loaded ALT addresses pulled from `meta` (if\n * any), and — for `'base64'` and `'base58'` responses — the wire-format\n * {@link Transaction}.\n *\n * `transaction` is omitted for `encoding: 'json'` responses: the server\n * has already decompiled the wire format, so there are no message bytes\n * to round-trip. If you need a re-encodable {@link Transaction}, fetch\n * the response with `encoding: 'base64'`.\n *\n * @example\n * ```ts\n * const { compiledMessage, loadedAddresses, transaction } =\n *     decodeTransactionFromRpcResponse(rpcResponse);\n * ```\n */\nexport type DecodedRpcTransaction = Readonly<{\n    compiledMessage: CompiledTransactionMessage & CompiledTransactionMessageWithLifetime;\n    loadedAddresses: LoadedAddresses;\n    transaction?: Transaction;\n}>;\n\nconst EMPTY_LOADED_ADDRESSES: LoadedAddresses = { readonly: [], writable: [] };\n\n/**\n * Pulls `loadedAddresses` off a response `meta` field if present, regardless of\n * which encoding produced it. The conditional types in the RPC API mean some\n * `meta` shapes statically lack the field (legacy responses fetched without\n * `maxSupportedTransactionVersion`); we still need a uniform runtime extraction.\n */\nfunction getLoadedAddresses(meta: unknown): LoadedAddresses {\n    const loaded = (meta as { loadedAddresses?: LoadedAddresses } | null | undefined)?.loadedAddresses;\n    return loaded ?? EMPTY_LOADED_ADDRESSES;\n}\n\nfunction decodeFromWire(wireBytes: Uint8Array): {\n    compiledMessage: CompiledTransactionMessage & CompiledTransactionMessageWithLifetime;\n    transaction: Transaction;\n} {\n    const transaction = getTransactionDecoder().decode(wireBytes);\n    const compiledMessage = getCompiledTransactionMessageDecoder().decode(transaction.messageBytes);\n    return { compiledMessage, transaction };\n}\n\nfunction decodeFromBase64(rpcTx: DecodableWireTransactionResponse): DecodedRpcTransaction {\n    const [b64] = rpcTx.transaction;\n    const { compiledMessage, transaction } = decodeFromWire(getBase64Encoder().encode(b64) as Uint8Array);\n    return { compiledMessage, loadedAddresses: getLoadedAddresses(rpcTx.meta), transaction };\n}\n\nfunction decodeFromBase58(rpcTx: DecodableWireTransactionResponse): DecodedRpcTransaction {\n    const [b58] = rpcTx.transaction;\n    const { compiledMessage, transaction } = decodeFromWire(getBase58Encoder().encode(b58) as Uint8Array);\n    return { compiledMessage, loadedAddresses: getLoadedAddresses(rpcTx.meta), transaction };\n}\n\nfunction decodeFromJson(rpcTx: DecodableJsonTransactionResponse): DecodedRpcTransaction {\n    const base58 = getBase58Encoder();\n    const { message } = rpcTx.transaction;\n    const staticAccounts: Address[] = [...message.accountKeys];\n\n    // The wire decoder omits `accountIndices` and `data` when they are\n    // empty; do the same here so a JSON-derived message has the same shape\n    // as a wire-derived one. Only the legacy/v0 shapes use this form — the\n    // v1 branch builds instruction headers and payloads instead.\n    const getCompiledInstructions = () =>\n        message.instructions.map(ix => ({\n            ...(ix.accounts.length ? { accountIndices: [...ix.accounts] } : null),\n            ...(ix.data.length ? { data: base58.encode(ix.data) } : null),\n            programAddressIndex: ix.programIdIndex,\n        }));\n\n    const header = {\n        numReadonlyNonSignerAccounts: message.header.numReadonlyUnsignedAccounts,\n        numReadonlySignerAccounts: message.header.numReadonlySignedAccounts,\n        numSignerAccounts: message.header.numRequiredSignatures,\n    };\n\n    // The envelope only carries `version` when `maxSupportedTransactionVersion`\n    // was set on the request; otherwise the response is necessarily legacy.\n    // `??` (not `||`) so a legitimate `0` (v0) is not treated as absent.\n    const version: TransactionVersion = rpcTx.version ?? 'legacy';\n\n    // For transactions whose lifetime is specified by a durable nonce,\n    // `message.recentBlockhash` is the nonce value, not a blockhash (see\n    // `GetTransactionApi`). Either way it is the message's lifetime token,\n    // so it maps onto `lifetimeToken` below — the same field the\n    // wire-decoder path produces — and consumers see the same shape on\n    // both encodings.\n    let compiledMessage: CompiledTransactionMessage & CompiledTransactionMessageWithLifetime;\n    switch (version) {\n        case 'legacy':\n            compiledMessage = {\n                header,\n                instructions: getCompiledInstructions(),\n                lifetimeToken: message.recentBlockhash,\n                staticAccounts,\n                version: 'legacy',\n            } satisfies CompiledTransactionMessageWithLifetime & LegacyCompiledTransactionMessage;\n            break;\n        case 0: {\n            // The wire decoder omits `addressTableLookups` when the message\n            // has none; match that here for shape parity.\n            const addressTableLookups = message.addressTableLookups\n                ? message.addressTableLookups.map(l => ({\n                      lookupTableAddress: l.accountKey,\n                      readonlyIndexes: l.readonlyIndexes,\n                      writableIndexes: l.writableIndexes,\n                  }))\n                : [];\n            compiledMessage = {\n                ...(addressTableLookups.length ? { addressTableLookups } : null),\n                header,\n                instructions: getCompiledInstructions(),\n                lifetimeToken: message.recentBlockhash,\n                staticAccounts,\n                version: 0,\n            } satisfies CompiledTransactionMessageWithLifetime & V0CompiledTransactionMessage;\n            break;\n        }\n        case 1: {\n            const instructionData = message.instructions.map(ix => base58.encode(ix.data));\n            compiledMessage = {\n                // The `'json'` encoding does not carry the v1 transaction\n                // config, so the synthesized message always reports an\n                // empty one.\n                configMask: 0,\n                configValues: [],\n                header,\n                instructionHeaders: message.instructions.map((ix, i) => ({\n                    numInstructionAccounts: ix.accounts.length,\n                    numInstructionDataBytes: instructionData[i].byteLength,\n                    programAccountIndex: ix.programIdIndex,\n                })),\n                instructionPayloads: message.instructions.map((ix, i) => ({\n                    instructionAccountIndices: [...ix.accounts],\n                    instructionData: instructionData[i],\n                })),\n                lifetimeToken: message.recentBlockhash,\n                numInstructions: message.instructions.length,\n                numStaticAccounts: staticAccounts.length,\n                staticAccounts,\n                version: 1,\n            } satisfies CompiledTransactionMessageWithLifetime & V1CompiledTransactionMessage;\n            break;\n        }\n        default: {\n            // Compile-time exhaustiveness: a new `TransactionVersion`\n            // member will fail to typecheck here, forcing this switch to\n            // handle it explicitly.\n            const _exhaustiveCheck: never = version;\n            throw new SolanaError(SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_NOT_SUPPORTED, {\n                unsupportedVersion: _exhaustiveCheck as number,\n            });\n        }\n    }\n\n    return { compiledMessage, loadedAddresses: getLoadedAddresses(rpcTx.meta) };\n}\n\nfunction isBase64Response(rpcTx: DecodableTransactionResponse): rpcTx is DecodableWireTransactionResponse {\n    const t = rpcTx.transaction;\n    return Array.isArray(t) && t[1] === 'base64';\n}\n\nfunction isBase58Response(rpcTx: DecodableTransactionResponse): rpcTx is DecodableWireTransactionResponse {\n    const t = rpcTx.transaction;\n    return Array.isArray(t) && t[1] === 'base58';\n}\n\nfunction getJsonShapedMessage(rpcTx: DecodableTransactionResponse): Record<string, unknown> | undefined {\n    const t = rpcTx.transaction;\n    if (typeof t !== 'object' || t === null || Array.isArray(t) || !('message' in t)) return undefined;\n    const message = (t as { message?: { instructions?: readonly unknown[] } }).message;\n    if (!message || typeof message !== 'object' || !Array.isArray(message.instructions)) return undefined;\n    return message as Record<string, unknown>;\n}\n\n/**\n * Detects an `encoding: 'json'` response specifically: its message carries\n * the compiled-message `header` (signer/readonly counts). A `jsonParsed`\n * message has no `header` — the server has already resolved the roles onto\n * each of its `accountKeys` — so checking for it distinguishes the two\n * encodings regardless of how many instructions the transaction has.\n */\nfunction isJsonResponse(rpcTx: DecodableTransactionResponse): rpcTx is DecodableJsonTransactionResponse {\n    const message = getJsonShapedMessage(rpcTx);\n    return message != null && typeof message.header === 'object' && message.header !== null;\n}\n\n/**\n * Detects an `encoding: 'jsonParsed'` response: structurally a JSON message\n * but without the compiled-message `header` that the `'json'` encoding\n * carries. Its instructions arrive pre-parsed (with a `programId` address\n * rather than a `programIdIndex`) and are not round-trippable through the\n * kit codecs, so these responses are rejected.\n */\nfunction isJsonParsedResponse(rpcTx: DecodableTransactionResponse): boolean {\n    const message = getJsonShapedMessage(rpcTx);\n    return message != null && !('header' in message);\n}\n\n/**\n * Decodes a confirmed-transaction RPC response (any of `encoding: 'base64'`,\n * `'base58'`, or `'json'`) into a {@link CompiledTransactionMessage} plus,\n * for `'base64'` and `'base58'`, a re-encodable {@link Transaction}. The\n * JSON path does not produce a `Transaction`: the server has already\n * decompiled the wire format, so there are no message bytes to carry.\n *\n * Because it reads only the `transaction` / `meta` / `version` envelope —\n * not a method-specific response shape — it accepts results from any method\n * that returns confirmed transactions in these encodings: `getTransaction`,\n * `getTransactionsForAddress`, and `getBlock` (the latter two with\n * `transactionDetails: 'full'`). The array-returning methods just need a map:\n *\n * ```ts\n * const { data } = await rpc.getTransactionsForAddress(address, {\n *     encoding: 'base64',\n *     maxSupportedTransactionVersion: 0,\n *     transactionDetails: 'full',\n * }).send();\n * const decoded = data.map(tx => decodeTransactionFromRpcResponse(tx));\n *\n * const block = await rpc.getBlock(slot, {\n *     encoding: 'base64',\n *     maxSupportedTransactionVersion: 0,\n *     transactionDetails: 'full',\n * }).send();\n * const decodedBlockTxs = block?.transactions.map(tx => decodeTransactionFromRpcResponse(tx)) ?? [];\n * ```\n *\n * `'jsonParsed'` is **not** supported — its instructions arrive\n * pre-parsed by the server and lack raw bytes, so they cannot be\n * round-tripped through the auto-generated `parseXInstruction` clients.\n * Passing a `'jsonParsed'` response throws\n * {@link SOLANA_ERROR__TRANSACTION_INTROSPECTION__CANNOT_DECODE_JSON_PARSED_TRANSACTION};\n * any other unrecognized input throws\n * {@link SOLANA_ERROR__TRANSACTION_INTROSPECTION__UNRECOGNIZED_GET_TRANSACTION_RESPONSE}.\n *\n * A response carrying a transaction version this package cannot decode\n * throws {@link SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_NOT_SUPPORTED} —\n * raised by the JSON path for an unrecognized `version`, and by the wire\n * decoders for malformed binary input.\n *\n * Use this together with {@link getInstructionsFromCompiledTransactionMessage}\n * (or {@link walkInstructions}) to inspect a confirmed transaction's\n * instructions in a form the auto-generated `@solana-program/*` clients\n * can `parse` directly.\n *\n * Prefer `encoding: 'base64'` when bandwidth allows — it is the most\n * compact, the wire bytes round-trip cleanly through the kit codecs, and\n * the return type statically guarantees a re-encodable `transaction`.\n *\n * @example\n * ```ts\n * const rpcResponse = await rpc.getTransaction(signature(txid), {\n *     commitment: 'confirmed',\n *     encoding: 'base64',\n *     maxSupportedTransactionVersion: 0,\n * }).send();\n * if (!rpcResponse) throw new Error('not found');\n *\n * const { compiledMessage, loadedAddresses } = decodeTransactionFromRpcResponse(rpcResponse);\n * const instructions = getInstructionsFromCompiledTransactionMessage(compiledMessage, loadedAddresses);\n * ```\n */\nexport function decodeTransactionFromRpcResponse(\n    rpcTx: DecodableWireTransactionResponse,\n): DecodedRpcTransaction & { transaction: Transaction };\nexport function decodeTransactionFromRpcResponse(\n    rpcTx: DecodableJsonTransactionResponse,\n): DecodedRpcTransaction & { transaction?: never };\nexport function decodeTransactionFromRpcResponse(rpcTx: DecodableTransactionResponse): DecodedRpcTransaction {\n    if (isBase64Response(rpcTx)) return decodeFromBase64(rpcTx);\n    if (isBase58Response(rpcTx)) return decodeFromBase58(rpcTx);\n    if (isJsonResponse(rpcTx)) return decodeFromJson(rpcTx);\n    if (isJsonParsedResponse(rpcTx)) {\n        throw new SolanaError(SOLANA_ERROR__TRANSACTION_INTROSPECTION__CANNOT_DECODE_JSON_PARSED_TRANSACTION);\n    }\n    throw new SolanaError(SOLANA_ERROR__TRANSACTION_INTROSPECTION__UNRECOGNIZED_GET_TRANSACTION_RESPONSE);\n}\n","import { getBase58Encoder } from '@solana/codecs-strings';\nimport {\n    SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_ACCOUNT_INDEX_OUT_OF_RANGE,\n    SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND,\n    SolanaError,\n} from '@solana/errors';\nimport type { AccountMeta } from '@solana/instructions';\nimport type { TransactionForFullMetaInnerInstructionsUnparsed } from '@solana/rpc-types';\n\nimport type { TracedInstruction } from './types';\n\n/**\n * The shape of an inner-instructions group as returned by any JSON-RPC method\n * that includes transaction `meta` when not using `jsonParsed` encoding (e.g.\n * `getTransaction`, `getTransactionsForAddress`, `getBlock`). Derived from the\n * shared leaf type in `@solana/rpc-types` via indexed access so the two stay in\n * sync, without coupling to a specific method's response envelope.\n */\ntype RpcInnerInstructionsGroup = TransactionForFullMetaInnerInstructionsUnparsed['innerInstructions'][number];\n\n/**\n * The minimum shape of `getTransaction`'s `meta` field that this helper\n * needs. Accepting a structural type keeps callers free to pass the full\n * RPC response without coupling to a specific overload.\n *\n * @example\n * ```ts\n * const inner = getInnerInstructionsFromMeta(rpcResponse.meta, accountMetas);\n * ```\n */\nexport type MetaWithInnerInstructions = Readonly<{\n    innerInstructions?: readonly RpcInnerInstructionsGroup[] | null;\n}>;\n\n/**\n * Returns the inner instructions in a `getTransaction` response as\n * {@link TracedInstruction}s.\n *\n * The RPC returns inner instructions in a different shape from the wire\n * format: indices reference the same flat account list as the outer\n * instructions, but `data` is a base58-encoded string. This helper decodes\n * the data, resolves the indices against the supplied {@link AccountMeta}\n * list, and tags each instruction with an `inner` trace.\n *\n * Throws if any `programIdIndex` or account index falls outside the\n * supplied `accountMetas` list.\n *\n * @example\n * ```ts\n * const accountMetas = getAccountMetasFromCompiledTransactionMessage(compiledMessage, loadedAddresses);\n * const inner = getInnerInstructionsFromMeta(rpcResponse.meta, accountMetas);\n * ```\n */\nexport function getInnerInstructionsFromMeta(\n    meta: MetaWithInnerInstructions,\n    accountMetas: readonly AccountMeta[],\n): TracedInstruction[] {\n    if (!meta.innerInstructions) return [];\n    const base58 = getBase58Encoder();\n    const result: TracedInstruction[] = [];\n    for (const group of meta.innerInstructions) {\n        for (let innerIndex = 0; innerIndex < group.instructions.length; innerIndex++) {\n            const ix = group.instructions[innerIndex];\n            const programMeta = accountMetas[ix.programIdIndex];\n            if (!programMeta) {\n                throw new SolanaError(\n                    SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND,\n                    { index: ix.programIdIndex },\n                );\n            }\n            const accounts: AccountMeta[] = ix.accounts.map(i => {\n                const accountMeta = accountMetas[i];\n                if (!accountMeta) {\n                    throw new SolanaError(\n                        SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_ACCOUNT_INDEX_OUT_OF_RANGE,\n                        { index: i },\n                    );\n                }\n                return accountMeta;\n            });\n            const data = base58.encode(ix.data);\n            result.push({\n                ...(accounts.length ? { accounts } : null),\n                ...(data.byteLength ? { data } : null),\n                programAddress: programMeta.address,\n                trace: {\n                    innerIndex,\n                    kind: 'inner',\n                    outerIndex: group.index,\n                    ...(ix.stackHeight != null ? { stackHeight: ix.stackHeight } : {}),\n                },\n            });\n        }\n    }\n    return result;\n}\n","import type { Address } from '@solana/addresses';\nimport type { ReadonlyUint8Array } from '@solana/codecs-core';\nimport {\n    SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_ACCOUNT_INDEX_OUT_OF_RANGE,\n    SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND,\n    SOLANA_ERROR__TRANSACTION__INSTRUCTION_HEADERS_PAYLOADS_MISMATCH,\n    SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_NOT_SUPPORTED,\n    SolanaError,\n} from '@solana/errors';\nimport { type AccountMeta, AccountRole, type Instruction } from '@solana/instructions';\nimport type { CompiledTransactionMessage } from '@solana/transaction-messages';\n\nimport type { LoadedAddresses } from './loaded-addresses';\n\n/**\n * An outer transaction instruction with its account indices resolved to\n * full {@link AccountMeta}s and its data exposed as a `ReadonlyUint8Array`.\n *\n * Following the kit `Instruction` conventions, `accounts` and `data` are\n * present only when non-empty, so `isInstructionWithAccounts` and\n * `isInstructionWithData` from `@solana/instructions` behave as expected\n * and can be used to narrow before passing the instruction to the\n * auto-generated `parseXInstruction` helpers.\n *\n * @example\n * ```ts\n * for (const ix of getInstructionsFromCompiledTransactionMessage(compiled)) {\n *     // `ix` is a `ResolvedInstruction` — usable with `isInstructionForProgram`\n *     // directly, and with the auto-generated `identifyXInstruction` helpers\n *     // after narrowing `data`.\n *     if (isInstructionWithData(ix)) {\n *         identifyTokenInstruction(ix);\n *     }\n * }\n * ```\n */\nexport type ResolvedInstruction<TProgramAddress extends string = string> = Instruction<\n    TProgramAddress,\n    readonly AccountMeta[]\n>;\n\n/**\n * The normalized shape of an instruction inside a compiled transaction\n * message — `legacy`, `0`, and `1` are all reduced to this form before\n * resolution.\n */\ntype NormalizedCompiledInstruction = Readonly<{\n    accountIndices: readonly number[];\n    data: ReadonlyUint8Array;\n    programAddressIndex: number;\n}>;\n\n/**\n * Builds the full ordered list of {@link AccountMeta}s for a compiled\n * transaction message.\n *\n * The order matches the runtime's resolution order:\n *\n * 1. Static accounts, with role bits derived from the message header\n *    (writable signers, readonly signers, writable non-signers, readonly\n *    non-signers).\n * 2. ALT-loaded writable accounts (always non-signer, writable).\n * 3. ALT-loaded readonly accounts (always non-signer, readonly).\n *\n * Inner-instruction account indices reference the same flat list, so this\n * helper is also useful for resolving inner instructions.\n */\nexport function getAccountMetasFromCompiledTransactionMessage(\n    compiledMessage: CompiledTransactionMessage,\n    loadedAddresses?: LoadedAddresses | null,\n): AccountMeta[] {\n    const { header, staticAccounts } = compiledMessage;\n    const numWritableSignerAccounts = header.numSignerAccounts - header.numReadonlySignerAccounts;\n    const numWritableNonSignerAccounts =\n        staticAccounts.length - header.numSignerAccounts - header.numReadonlyNonSignerAccounts;\n\n    const metas: AccountMeta[] = [];\n    let i = 0;\n    for (let n = 0; n < numWritableSignerAccounts; n++, i++) {\n        metas.push({ address: staticAccounts[i], role: AccountRole.WRITABLE_SIGNER });\n    }\n    for (let n = 0; n < header.numReadonlySignerAccounts; n++, i++) {\n        metas.push({ address: staticAccounts[i], role: AccountRole.READONLY_SIGNER });\n    }\n    for (let n = 0; n < numWritableNonSignerAccounts; n++, i++) {\n        metas.push({ address: staticAccounts[i], role: AccountRole.WRITABLE });\n    }\n    for (let n = 0; n < header.numReadonlyNonSignerAccounts; n++, i++) {\n        metas.push({ address: staticAccounts[i], role: AccountRole.READONLY });\n    }\n\n    if (loadedAddresses) {\n        for (const address of loadedAddresses.writable) {\n            metas.push({ address, role: AccountRole.WRITABLE });\n        }\n        for (const address of loadedAddresses.readonly) {\n            metas.push({ address, role: AccountRole.READONLY });\n        }\n    }\n\n    return metas;\n}\n\n/**\n * Returns the outer instructions of a compiled transaction message as kit\n * {@link Instruction} objects.\n *\n * Each returned instruction has its account indices resolved to\n * {@link AccountMeta}s (with the proper signer/writable bits) and its data\n * exposed as a `ReadonlyUint8Array` — the form the auto-generated\n * `@solana-program/*` `parseXInstruction` functions expect. `accounts` and\n * `data` are omitted when empty.\n *\n * Supports `legacy`, `v0`, and `v1` compiled messages. Throws\n * {@link SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_NOT_SUPPORTED} for any\n * other version,\n * {@link SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND}\n * if a `programAddressIndex` falls outside the resolved account list, and\n * {@link SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_ACCOUNT_INDEX_OUT_OF_RANGE}\n * if an account index does.\n *\n * @example\n * ```ts\n * const instructions = getInstructionsFromCompiledTransactionMessage(\n *     compiled,\n *     rpcResponse.meta?.loadedAddresses,\n * );\n * for (const ix of instructions) {\n *     if (ix.programAddress === TOKEN_PROGRAM_ADDRESS && isInstructionWithData(ix)) {\n *         const kind = identifyTokenInstruction(ix);\n *         // ...\n *     }\n * }\n * ```\n */\nexport function getInstructionsFromCompiledTransactionMessage(\n    compiledMessage: CompiledTransactionMessage,\n    loadedAddresses?: LoadedAddresses | null,\n): ResolvedInstruction[] {\n    const metas = getAccountMetasFromCompiledTransactionMessage(compiledMessage, loadedAddresses);\n    return normalizeCompiledInstructions(compiledMessage).map(ix => resolveInstruction(ix, metas));\n}\n\n/**\n * Internal variant of {@link getInstructionsFromCompiledTransactionMessage}\n * that takes pre-built {@link AccountMeta}s. Used by {@link walkInstructions}\n * to avoid rebuilding the meta list when it is already needed for resolving\n * inner instructions.\n *\n * @internal\n */\nexport function getInstructionsFromCompiledTransactionMessageWithMetas(\n    compiledMessage: CompiledTransactionMessage,\n    accountMetas: readonly AccountMeta[],\n): ResolvedInstruction[] {\n    return normalizeCompiledInstructions(compiledMessage).map(ix => resolveInstruction(ix, accountMetas));\n}\n\nfunction normalizeCompiledInstructions(compiledMessage: CompiledTransactionMessage): NormalizedCompiledInstruction[] {\n    if (compiledMessage.version === 'legacy' || compiledMessage.version === 0) {\n        return compiledMessage.instructions.map(ix => ({\n            accountIndices: ix.accountIndices ?? [],\n            data: ix.data ?? new Uint8Array(),\n            programAddressIndex: ix.programAddressIndex,\n        }));\n    }\n    if (compiledMessage.version === 1) {\n        const { instructionHeaders, instructionPayloads } = compiledMessage;\n        if (instructionHeaders.length !== instructionPayloads.length) {\n            throw new SolanaError(SOLANA_ERROR__TRANSACTION__INSTRUCTION_HEADERS_PAYLOADS_MISMATCH, {\n                numInstructionHeaders: instructionHeaders.length,\n                numInstructionPayloads: instructionPayloads.length,\n            });\n        }\n        return instructionHeaders.map((header, i) => ({\n            accountIndices: instructionPayloads[i].instructionAccountIndices,\n            data: instructionPayloads[i].instructionData,\n            programAddressIndex: header.programAccountIndex,\n        }));\n    }\n    // Compile-time exhaustiveness: if a future `CompiledTransactionMessage`\n    // variant is added, `compiledMessage` will no longer narrow to `never`\n    // here and this assignment will fail to typecheck — forcing us to handle\n    // the new version explicitly.\n    const _exhaustiveCheck: never = compiledMessage;\n    throw new SolanaError(SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_NOT_SUPPORTED, {\n        unsupportedVersion: (_exhaustiveCheck as { version: number }).version,\n    });\n}\n\nfunction resolveInstruction(ix: NormalizedCompiledInstruction, metas: readonly AccountMeta[]): ResolvedInstruction {\n    const programMeta = metas[ix.programAddressIndex];\n    if (!programMeta) {\n        throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND, {\n            index: ix.programAddressIndex,\n        });\n    }\n    const accounts: AccountMeta[] = ix.accountIndices.map(i => {\n        const accountMeta = metas[i];\n        if (!accountMeta) {\n            throw new SolanaError(\n                SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_ACCOUNT_INDEX_OUT_OF_RANGE,\n                {\n                    index: i,\n                },\n            );\n        }\n        return accountMeta;\n    });\n    return {\n        ...(accounts.length ? { accounts } : null),\n        ...(ix.data.byteLength ? { data: ix.data } : null),\n        programAddress: programMeta.address as Address,\n    };\n}\n","import type { CompiledTransactionMessage } from '@solana/transaction-messages';\n\nimport { getInnerInstructionsFromMeta, type MetaWithInnerInstructions } from './get-inner-instructions';\nimport {\n    getAccountMetasFromCompiledTransactionMessage,\n    getInstructionsFromCompiledTransactionMessageWithMetas,\n} from './get-instructions';\nimport type { LoadedAddresses } from './loaded-addresses';\nimport type { TracedInstruction } from './types';\n\n/**\n * Returns every instruction in a confirmed transaction as\n * {@link TracedInstruction}s, in the order an explorer displays them: each\n * outer instruction followed immediately by the inner instructions its CPIs\n * produced.\n *\n * Each returned instruction has its account indices resolved to\n * {@link AccountMeta}s and its data exposed as a `ReadonlyUint8Array`\n * (omitted when empty), making it directly usable with the auto-generated\n * `@solana-program/*` `identifyXInstruction` and `parseXInstruction`\n * functions, and with `isInstructionForProgram` from `@solana/instructions`.\n *\n * If `meta` is omitted, only outer instructions are returned. If\n * `loadedAddresses` is omitted, only static accounts are used to resolve\n * indices — pass `meta?.loadedAddresses` for v0 transactions that load\n * accounts from address lookup tables.\n *\n * @example\n * ```ts\n * import { isInstructionForProgram, isInstructionWithData } from '@solana/instructions';\n * import { TOKEN_PROGRAM_ADDRESS, identifyTokenInstruction, TokenInstruction } from '@solana-program/token';\n *\n * const instructions = walkInstructions({ compiledMessage, meta, loadedAddresses });\n * for (const ix of instructions) {\n *     if (isInstructionForProgram(ix, TOKEN_PROGRAM_ADDRESS) &&\n *         isInstructionWithData(ix) &&\n *         identifyTokenInstruction(ix) === TokenInstruction.SyncNative) {\n *         console.log(ix.trace);\n *     }\n * }\n * ```\n */\nexport function walkInstructions(args: {\n    compiledMessage: CompiledTransactionMessage;\n    loadedAddresses?: LoadedAddresses | null;\n    meta?: MetaWithInnerInstructions | null;\n}): TracedInstruction[] {\n    const { compiledMessage, loadedAddresses, meta } = args;\n    const accountMetas = getAccountMetasFromCompiledTransactionMessage(compiledMessage, loadedAddresses);\n    const outerInstructions = getInstructionsFromCompiledTransactionMessageWithMetas(compiledMessage, accountMetas);\n\n    const innerByOuterIndex = new Map<number, TracedInstruction[]>();\n    if (meta) {\n        for (const inner of getInnerInstructionsFromMeta(meta, accountMetas)) {\n            if (inner.trace.kind !== 'inner') continue;\n            const group = innerByOuterIndex.get(inner.trace.outerIndex);\n            if (group) {\n                group.push(inner);\n            } else {\n                innerByOuterIndex.set(inner.trace.outerIndex, [inner]);\n            }\n        }\n    }\n\n    const result: TracedInstruction[] = [];\n    outerInstructions.forEach((instruction, index) => {\n        result.push({ ...instruction, trace: { index, kind: 'outer' } });\n        const group = innerByOuterIndex.get(index);\n        if (group) {\n            result.push(...group);\n            innerByOuterIndex.delete(index);\n        }\n    });\n    // Inner groups whose index matches no outer instruction can only come\n    // from malformed input (e.g. `meta` paired with the wrong message).\n    // Append them rather than dropping them so no instruction is ever lost.\n    for (const group of innerByOuterIndex.values()) {\n        result.push(...group);\n    }\n    return result;\n}\n"]}