UNPKG

@gorbchain-xyz/chaindecode

Version:

GorbchainSDK V1.3+ - Complete Solana development toolkit with advanced cryptography, messaging, and collaboration features. Build secure applications with blockchain, DeFi, and end-to-end encryption.

28 lines (27 loc) 1.02 kB
// Decoders for transaction instructions using internal utils import { decodeInstruction, decodeInstructions } from '../utils/decodeInstructions.js'; /** * Convert IInstruction to RawInstruction format */ function convertToRawInstruction(ix) { var _a, _b; return { programId: ix.programAddress, data: ix.data ? new Uint8Array(ix.data) : new Uint8Array(0), accounts: (_b = (_a = ix.accounts) === null || _a === void 0 ? void 0 : _a.map(acc => 'address' in acc ? acc.address : String(acc))) !== null && _b !== void 0 ? _b : [] }; } /** * Decode a single IInstruction using all available decoders */ export function decodeTransactionInstruction(ix) { const rawInstruction = convertToRawInstruction(ix); return decodeInstruction(rawInstruction); } /** * Decode an array of IInstructions */ export function decodeTransactionInstructions(instructions) { const rawInstructions = instructions.map(convertToRawInstruction); return decodeInstructions(rawInstructions); }