@ledgerhq/device-signer-kit-solana 0.0.0-patch-transactionInspector-20250909141112 → 0.0.0-patch-transactionInspector-20250911081347
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/api/app-binder/SignTransactionDeviceActionTypes.js.map +1 -1
- package/lib/cjs/internal/app-binder/device-action/SignTransactionDeviceAction.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/SignTransactionDeviceAction.js.map +2 -2
- package/lib/cjs/internal/app-binder/services/TransactionInspector.js +1 -1
- package/lib/cjs/internal/app-binder/services/TransactionInspector.js.map +3 -3
- package/lib/cjs/internal/app-binder/services/utils/transactionDecoders.js +2 -0
- package/lib/cjs/internal/app-binder/services/utils/transactionDecoders.js.map +7 -0
- package/lib/esm/internal/app-binder/device-action/SignTransactionDeviceAction.js +1 -1
- package/lib/esm/internal/app-binder/device-action/SignTransactionDeviceAction.js.map +2 -2
- package/lib/esm/internal/app-binder/services/TransactionInspector.js +1 -1
- package/lib/esm/internal/app-binder/services/TransactionInspector.js.map +3 -3
- package/lib/esm/internal/app-binder/services/utils/transactionDecoders.js +2 -0
- package/lib/esm/internal/app-binder/services/utils/transactionDecoders.js.map +7 -0
- package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts +1 -1
- package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/SignTransactionDeviceAction.d.ts +1 -1
- package/lib/types/internal/app-binder/device-action/SignTransactionDeviceAction.d.ts.map +1 -1
- package/lib/types/internal/app-binder/services/TransactionInspector.d.ts +12 -23
- package/lib/types/internal/app-binder/services/TransactionInspector.d.ts.map +1 -1
- package/lib/types/internal/app-binder/services/utils/transactionDecoders.d.ts +25 -0
- package/lib/types/internal/app-binder/services/utils/transactionDecoders.d.ts.map +1 -0
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +7 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/services/TransactionInspector.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n ASSOCIATED_TOKEN_PROGRAM_ID,\n decodeInitializeAccountInstruction,\n decodeTransferCheckedInstruction,\n decodeTransferInstruction,\n TOKEN_2022_PROGRAM_ID,\n TOKEN_PROGRAM_ID,\n TokenInstruction,\n} from \"@solana/spl-token\";\nimport {\n type PublicKey,\n Transaction,\n TransactionInstruction,\n VersionedMessage,\n VersionedTransaction,\n} from \"@solana/web3.js\";\nimport { Buffer } from \"buffer\";\n\nexport enum SolanaTransactionTypes {\n STANDARD = \"Standard\",\n SPL = \"SPL\",\n}\n\nexport interface TxInspectorResult {\n transactionType: SolanaTransactionTypes;\n data: {\n tokenAddress?: string;\n mintAddress?: string;\n createATA?: {\n address: string;\n mintAddress: string;\n };\n };\n}\n\ntype NormalizedCompiledIx = {\n programIdIndex: number;\n accountKeyIndexes: number[];\n data: Uint8Array;\n};\n\ntype NormalizedMessage = {\n compiledInstructions: NormalizedCompiledIx[];\n allKeys: PublicKey[]; // may exclude LUT keys if not provided\n};\n\ntype LoadedAddresses = { writable: PublicKey[]; readonly: PublicKey[] };\n\nexport class TransactionInspector {\n /**\n * @param rawTransactionBytes - raw bytes of the transaction to inspect\n * @param lookedUpAddresses - optional hydrated LUT keys\n */\n constructor(\n private readonly rawTransactionBytes: Uint8Array,\n private readonly lookedUpAddresses?: LoadedAddresses,\n ) {}\n\n public inspectTransactionType(): TxInspectorResult {\n try {\n const message = this.normaliseMessage(this.rawTransactionBytes);\n\n for (const ixMeta of message.compiledInstructions) {\n const programId = message.allKeys[ixMeta.programIdIndex];\n const instructionType = ixMeta.data?.[0];\n\n const isTokenProgram =\n !!programId &&\n (programId.equals(TOKEN_PROGRAM_ID) ||\n programId.equals(TOKEN_2022_PROGRAM_ID));\n\n // exact decode when we know it's the token program (classic or 2022)\n if (isTokenProgram) {\n try {\n const instruction = new TransactionInstruction({\n programId,\n keys: ixMeta.accountKeyIndexes.map((i) => {\n const pk = message.allKeys[i];\n if (!pk) {\n throw new Error(\n `TransactionInspector: missing key at index ${i} in allKeys`,\n );\n }\n return { pubkey: pk, isSigner: false, isWritable: false };\n }),\n data: Buffer.from(ixMeta.data),\n });\n\n switch (instruction.data[0]) {\n case TokenInstruction.Transfer: {\n const {\n keys: { destination },\n } = decodeTransferInstruction(instruction);\n return {\n transactionType: SolanaTransactionTypes.SPL,\n data: { tokenAddress: destination.pubkey.toBase58() },\n };\n }\n case TokenInstruction.TransferChecked: {\n const {\n keys: { destination, mint },\n } = decodeTransferCheckedInstruction(instruction);\n return {\n transactionType: SolanaTransactionTypes.SPL,\n data: {\n tokenAddress: destination.pubkey.toBase58(),\n mintAddress: mint.pubkey.toBase58(),\n },\n };\n }\n case TokenInstruction.InitializeAccount: {\n const {\n keys: { account, mint },\n } = decodeInitializeAccountInstruction(instruction);\n return {\n transactionType: SolanaTransactionTypes.SPL,\n data: {\n createATA: {\n address: account.pubkey.toBase58(),\n mintAddress: mint.pubkey.toBase58(),\n },\n },\n };\n }\n default:\n // keep scanning\n break;\n }\n } catch {\n // if the decoder throws, keep scanning other instructions\n }\n }\n\n // detect ATA creation (exact: only when programId is present & matches)\n if (programId && programId.equals(ASSOCIATED_TOKEN_PROGRAM_ID)) {\n // expected accounts: [payer, ata, owner, mint, systemProgram, tokenProgram, rent?]\n const getPk = (idx: number) => {\n const keyIndex = ixMeta.accountKeyIndexes[idx];\n return keyIndex !== undefined\n ? message.allKeys[keyIndex]\n : undefined;\n };\n const ataPk = getPk(1);\n const mintPk = getPk(3);\n if (ataPk && mintPk) {\n return {\n transactionType: SolanaTransactionTypes.SPL,\n data: {\n createATA: {\n address: ataPk.toBase58(),\n mintAddress: mintPk.toBase58(),\n },\n },\n };\n }\n }\n\n // fallback when programId is unresolved\n // map account positions directly and return any addresses that are available in the static set\n const looksLikeSplOpcode =\n instructionType === TokenInstruction.Transfer ||\n instructionType === TokenInstruction.TransferChecked ||\n instructionType === TokenInstruction.InitializeAccount;\n\n if (!programId && looksLikeSplOpcode) {\n const keys = ixMeta.accountKeyIndexes;\n\n const keyAt = (pos: number): string | undefined => {\n const keyIndex = keys[pos];\n if (keyIndex === undefined) return undefined;\n const pk = message.allKeys[keyIndex];\n return pk ? pk.toBase58() : undefined;\n };\n\n if (instructionType === TokenInstruction.Transfer) {\n // accounts: [source, destination, owner, (...signers)]\n const destination = keyAt(1);\n if (destination) {\n return {\n transactionType: SolanaTransactionTypes.SPL,\n data: { tokenAddress: destination },\n };\n }\n // if can't resolve any useful address, still mark SPL\n return { transactionType: SolanaTransactionTypes.SPL, data: {} };\n }\n\n if (instructionType === TokenInstruction.TransferChecked) {\n // accounts: [source, mint, destination, owner, (...signers)]\n const mint = keyAt(1);\n const destination = keyAt(2);\n if (destination || mint) {\n return {\n transactionType: SolanaTransactionTypes.SPL,\n data: {\n ...(destination ? { tokenAddress: destination } : {}),\n ...(mint ? { mintAddress: mint } : {}),\n },\n };\n }\n return { transactionType: SolanaTransactionTypes.SPL, data: {} };\n }\n\n if (instructionType === TokenInstruction.InitializeAccount) {\n // accounts: [account, mint, owner, rent]\n const account = keyAt(0);\n const mint = keyAt(1);\n if (account || mint) {\n return {\n transactionType: SolanaTransactionTypes.SPL,\n data: {\n createATA: {\n address: account ?? \"\",\n mintAddress: mint ?? \"\",\n },\n },\n };\n }\n return { transactionType: SolanaTransactionTypes.SPL, data: {} };\n }\n }\n }\n\n // nothing matched\n return { transactionType: SolanaTransactionTypes.STANDARD, data: {} };\n } catch {\n return { transactionType: SolanaTransactionTypes.STANDARD, data: {} };\n }\n }\n\n /**\n * normalize legacy or v0 messages into { compiledInstructions, allKeys }.\n * if `lookedUpAddresses` is provided, it will be included; otherwise only static keys are present.\n */\n private normaliseMessage(rawBytes: Uint8Array): NormalizedMessage {\n const vtx = this.tryDeserialiseVersioned(rawBytes);\n if (vtx) {\n const msg = vtx.message as VersionedMessage & {\n getAccountKeys?: (opts?: {\n accountKeysFromLookups?: LoadedAddresses;\n }) => {\n staticAccountKeys: PublicKey[];\n accountKeysFromLookups?: LoadedAddresses;\n keySegments: () => PublicKey[][];\n };\n compiledInstructions: Array<{\n programIdIndex: number;\n accountKeyIndexes?: number[];\n accounts?: number[];\n data: Uint8Array | string | number[];\n }>;\n staticAccountKeys: PublicKey[];\n };\n\n // build key list in the exact index order used by compiledInstructions.\n let allKeys: PublicKey[];\n if (typeof msg.getAccountKeys === \"function\") {\n const mak = msg.getAccountKeys({\n accountKeysFromLookups: this.lookedUpAddresses, // may be undefined\n });\n allKeys = mak.keySegments().flat(); // static + (optionally) looked-up, in correct order\n } else {\n allKeys = [...msg.staticAccountKeys];\n }\n\n const compiledInstructions: NormalizedCompiledIx[] =\n msg.compiledInstructions.map((ix) => ({\n programIdIndex: ix.programIdIndex,\n accountKeyIndexes: Array.from(ix.accountKeyIndexes ?? []),\n data:\n ix.data instanceof Uint8Array\n ? ix.data\n : Buffer.from(ix.data ?? []),\n }));\n\n return { compiledInstructions, allKeys };\n }\n\n // legacy fallback\n const legacy = Transaction.from(rawBytes);\n\n const allKeyMap = new Map<string, PublicKey>();\n const add = (pk?: PublicKey | null) => {\n if (!pk) return;\n const k = pk.toBase58();\n if (!allKeyMap.has(k)) allKeyMap.set(k, pk);\n };\n\n add(legacy.feePayer ?? null);\n for (const ix of legacy.instructions) {\n add(ix.programId);\n for (const k of ix.keys) add(k.pubkey);\n }\n const allKeys = Array.from(allKeyMap.values());\n const indexByB58 = new Map(allKeys.map((pk, i) => [pk.toBase58(), i]));\n\n const compiledInstructions: NormalizedCompiledIx[] =\n legacy.instructions.map((ix) => ({\n programIdIndex: indexByB58.get(ix.programId.toBase58()) ?? -1,\n accountKeyIndexes: ix.keys.map(\n (k) => indexByB58.get(k.pubkey.toBase58()) ?? -1,\n ),\n data: ix.data,\n }));\n\n return { compiledInstructions, allKeys };\n }\n\n private tryDeserialiseVersioned(\n rawBytes: Uint8Array,\n ): VersionedTransaction | null {\n try {\n return VersionedTransaction.deserialize(rawBytes);\n } catch {\n try {\n const msg = VersionedMessage.deserialize(rawBytes);\n return { message: msg } as VersionedTransaction;\n } catch {\n return null;\n }\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OACE,+BAAAA,EACA,
|
|
6
|
-
"names": ["ASSOCIATED_TOKEN_PROGRAM_ID", "
|
|
4
|
+
"sourcesContent": ["import {\n ASSOCIATED_TOKEN_PROGRAM_ID,\n TOKEN_2022_PROGRAM_ID,\n TOKEN_PROGRAM_ID,\n} from \"@solana/spl-token\";\nimport {\n type PublicKey,\n Transaction,\n TransactionInstruction,\n VersionedMessage,\n VersionedTransaction,\n} from \"@solana/web3.js\";\nimport { Buffer } from \"buffer\";\n\nimport {\n DECODERS,\n type IxContext,\n type TxInspectorResult,\n} from \"@internal/app-binder/services/utils/transactionDecoders\";\n\nexport enum SolanaTransactionTypes {\n STANDARD = \"Standard\",\n SPL = \"SPL\",\n}\n\nexport type NormalizedCompiledIx = {\n programIdIndex: number;\n accountKeyIndexes: number[];\n data: Uint8Array;\n};\n\nexport type NormalizedMessage = {\n compiledInstructions: NormalizedCompiledIx[];\n allKeys: PublicKey[];\n};\n\ntype LoadedAddresses = { writable: PublicKey[]; readonly: PublicKey[] };\n\nconst isSPLProgramId = (pid: PublicKey | undefined) =>\n !!pid &&\n (pid.equals(ASSOCIATED_TOKEN_PROGRAM_ID) ||\n pid.equals(TOKEN_PROGRAM_ID) ||\n pid.equals(TOKEN_2022_PROGRAM_ID));\n\nexport class TransactionInspector {\n constructor(private readonly rawTransactionBytes: Uint8Array) {}\n\n public inspectTransactionType(): TxInspectorResult {\n try {\n const message = this.normaliseMessage(this.rawTransactionBytes);\n\n for (const ixMeta of message.compiledInstructions) {\n const programId = message.allKeys[ixMeta.programIdIndex];\n\n // If we can't even read programId, we can't classify this ix.\n if (!programId) continue;\n\n // Resolve referenced keys we *do* have\n const resolvedKeys = ixMeta.accountKeyIndexes\n .map((i) => message.allKeys[i])\n .filter((key): key is PublicKey => !!key);\n\n // --- IMPORTANT FALLBACK ---\n // On Nano X (v0 + ALTs), some or all account metas can be missing here.\n // If programId shows it's Token / Token-2022 / ATA, classify as SPL even without fields.\n if (resolvedKeys.length !== ixMeta.accountKeyIndexes.length) {\n if (isSPLProgramId(programId)) {\n return { transactionType: SolanaTransactionTypes.SPL, data: {} };\n }\n continue;\n }\n\n // Normal path: we have all keys, try full decode\n const instruction = new TransactionInstruction({\n programId,\n keys: resolvedKeys.map((key) => ({\n pubkey: key,\n isSigner: false,\n isWritable: false,\n })),\n data: Buffer.from(ixMeta.data),\n });\n\n const ctx: IxContext = { programId, ixMeta, message, instruction };\n\n for (const decoder of DECODERS) {\n if (!decoder.when(ctx)) continue;\n const data = decoder.decode(ctx);\n if (data) {\n return { transactionType: SolanaTransactionTypes.SPL, data };\n }\n }\n }\n\n return { transactionType: SolanaTransactionTypes.STANDARD, data: {} };\n } catch {\n return { transactionType: SolanaTransactionTypes.STANDARD, data: {} };\n }\n }\n\n /**\n * Normalise any tx (legacy or v0) into { compiledInstructions, allKeys }.\n * If LUT accounts are provided, looked-up keys are included in allKeys.\n */\n private normaliseMessage(rawBytes: Uint8Array): NormalizedMessage {\n const versionedTX = this.tryDeserialiseVersioned(rawBytes);\n if (versionedTX) {\n const msg = versionedTX.message as VersionedMessage & {\n getAccountKeys?: (options?: {\n accountKeysFromLookups?: LoadedAddresses;\n }) => {\n staticAccountKeys: PublicKey[];\n accountKeysFromLookups?: LoadedAddresses;\n keySegments: () => PublicKey[][];\n };\n compiledInstructions: Array<{\n programIdIndex: number;\n accountKeyIndexes?: number[]; // legacy field name\n accounts?: number[]; // v0 field name\n data: Uint8Array | string | number[];\n }>;\n staticAccountKeys: PublicKey[];\n };\n\n // Build the key array in the exact order used by compiledInstructions.\n // NOTE: Without passing lookups, this returns only static keys; looked-up addresses remain unresolved.\n let allKeys: PublicKey[];\n if (typeof msg.getAccountKeys === \"function\") {\n const messageAccountKeys = msg.getAccountKeys();\n allKeys = messageAccountKeys.keySegments().flat();\n } else {\n allKeys = [...msg.staticAccountKeys];\n }\n\n const compiledInstructions: NormalizedCompiledIx[] =\n msg.compiledInstructions.map((ix) => {\n // prefer v0 `accounts`, fall back to legacy `accountKeyIndexes`\n const ixWithAccounts = ix as typeof ix & { accounts?: number[] };\n const accountKeyIndexes = Array.from(\n ixWithAccounts.accounts ?? ix.accountKeyIndexes ?? [],\n ) as number[];\n\n // normalise data\n let data: Uint8Array;\n if (ix.data instanceof Uint8Array) {\n data = ix.data;\n } else if (typeof ix.data === \"string\") {\n // v0 encodes instruction data as base64 strings\n data = Buffer.from(ix.data, \"base64\");\n } else {\n data = Uint8Array.from(ix.data ?? []);\n }\n\n return {\n programIdIndex: ix.programIdIndex,\n accountKeyIndexes,\n data,\n };\n });\n\n return { compiledInstructions, allKeys };\n }\n\n // legacy fallback\n const legacy = Transaction.from(rawBytes);\n\n const allKeyMap = new Map<string, PublicKey>();\n const add = (pubkey?: PublicKey | null) => {\n if (!pubkey) return;\n const key = pubkey.toBase58();\n if (!allKeyMap.has(key)) allKeyMap.set(key, pubkey);\n };\n\n add(legacy.feePayer ?? null);\n for (const ix of legacy.instructions) {\n add(ix.programId);\n for (const key of ix.keys) add(key.pubkey);\n }\n const allKeys = Array.from(allKeyMap.values());\n const indexByB58 = new Map(allKeys.map((pk, i) => [pk.toBase58(), i]));\n\n const compiledInstructions: NormalizedCompiledIx[] =\n legacy.instructions.map((ix) => ({\n programIdIndex: indexByB58.get(ix.programId.toBase58()) ?? -1,\n accountKeyIndexes: ix.keys.map(\n (key) => indexByB58.get(key.pubkey.toBase58()) ?? -1,\n ),\n data: ix.data,\n }));\n\n return { compiledInstructions, allKeys };\n }\n\n private tryDeserialiseVersioned(\n rawBytes: Uint8Array,\n ): VersionedTransaction | null {\n try {\n return VersionedTransaction.deserialize(rawBytes);\n } catch {\n try {\n const msg = VersionedMessage.deserialize(rawBytes);\n // wrap in a dummy VersionedTransaction-like shape just for uniform handling\n return { message: msg } as VersionedTransaction;\n } catch {\n return null;\n }\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OACE,+BAAAA,EACA,yBAAAC,EACA,oBAAAC,MACK,oBACP,OAEE,eAAAC,EACA,0BAAAC,EACA,oBAAAC,EACA,wBAAAC,MACK,kBACP,OAAS,UAAAC,MAAc,SAEvB,OACE,YAAAC,MAGK,0DAEA,IAAKC,OACVA,EAAA,SAAW,WACXA,EAAA,IAAM,MAFIA,OAAA,IAkBZ,MAAMC,EAAkBC,GACtB,CAAC,CAACA,IACDA,EAAI,OAAOX,CAA2B,GACrCW,EAAI,OAAOT,CAAgB,GAC3BS,EAAI,OAAOV,CAAqB,GAE7B,MAAMW,CAAqB,CAChC,YAA6BC,EAAiC,CAAjC,yBAAAA,CAAkC,CAExD,wBAA4C,CACjD,GAAI,CACF,MAAMC,EAAU,KAAK,iBAAiB,KAAK,mBAAmB,EAE9D,UAAWC,KAAUD,EAAQ,qBAAsB,CACjD,MAAME,EAAYF,EAAQ,QAAQC,EAAO,cAAc,EAGvD,GAAI,CAACC,EAAW,SAGhB,MAAMC,EAAeF,EAAO,kBACzB,IAAKG,GAAMJ,EAAQ,QAAQI,CAAC,CAAC,EAC7B,OAAQC,GAA0B,CAAC,CAACA,CAAG,EAK1C,GAAIF,EAAa,SAAWF,EAAO,kBAAkB,OAAQ,CAC3D,GAAIL,EAAeM,CAAS,EAC1B,MAAO,CAAE,gBAAiB,MAA4B,KAAM,CAAC,CAAE,EAEjE,QACF,CAGA,MAAMI,EAAc,IAAIhB,EAAuB,CAC7C,UAAAY,EACA,KAAMC,EAAa,IAAKE,IAAS,CAC/B,OAAQA,EACR,SAAU,GACV,WAAY,EACd,EAAE,EACF,KAAMZ,EAAO,KAAKQ,EAAO,IAAI,CAC/B,CAAC,EAEKM,EAAiB,CAAE,UAAAL,EAAW,OAAAD,EAAQ,QAAAD,EAAS,YAAAM,CAAY,EAEjE,UAAWE,KAAWd,E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G,EAAO,aAAc,CACpCE,EAAIL,EAAG,SAAS,EAChB,UAAWT,KAAOS,EAAG,KAAMK,EAAId,EAAI,MAAM,CAC3C,CACA,MAAMQ,EAAU,MAAM,KAAKK,EAAU,OAAO,CAAC,EACvCG,EAAa,IAAI,IAAIR,EAAQ,IAAI,CAACS,EAAIlB,IAAM,CAACkB,EAAG,SAAS,EAAGlB,CAAC,CAAC,CAAC,EAWrE,MAAO,CAAE,qBARPa,EAAO,aAAa,IAAKH,IAAQ,CAC/B,eAAgBO,EAAW,IAAIP,EAAG,UAAU,SAAS,CAAC,GAAK,GAC3D,kBAAmBA,EAAG,KAAK,IACxBT,GAAQgB,EAAW,IAAIhB,EAAI,OAAO,SAAS,CAAC,GAAK,EACpD,EACA,KAAMS,EAAG,IACX,EAAE,EAE2B,QAAAD,CAAQ,CACzC,CAEQ,wBACNH,EAC6B,CAC7B,GAAI,CACF,OAAOlB,EAAqB,YAAYkB,CAAQ,CAClD,MAAQ,CACN,GAAI,CAGF,MAAO,CAAE,QAFGnB,EAAiB,YAAYmB,CAAQ,CAE3B,CACxB,MAAQ,CACN,OAAO,IACT,CACF,CACF,CACF",
|
|
6
|
+
"names": ["ASSOCIATED_TOKEN_PROGRAM_ID", "TOKEN_2022_PROGRAM_ID", "TOKEN_PROGRAM_ID", "Transaction", "TransactionInstruction", "VersionedMessage", "VersionedTransaction", "Buffer", "DECODERS", "SolanaTransactionTypes", "isSPLProgramId", "pid", "TransactionInspector", "rawTransactionBytes", "message", "ixMeta", "programId", "resolvedKeys", "i", "key", "instruction", "ctx", "decoder", "data", "rawBytes", "versionedTX", "msg", "allKeys", "ix", "ixWithAccounts", "accountKeyIndexes", "legacy", "allKeyMap", "add", "pubkey", "indexByB58", "pk"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{ASSOCIATED_TOKEN_PROGRAM_ID as a,decodeBurnCheckedInstruction as k,decodeBurnInstruction as y,decodeCloseAccountInstruction as A,decodeFreezeAccountInstruction as p,decodeInitializeAccount2Instruction as l,decodeInitializeAccount3Instruction as m,decodeInitializeAccountInstruction as I,decodeInitializeImmutableOwnerInstruction as b,decodeSyncNativeInstruction as B,decodeThawAccountInstruction as T,decodeTransferCheckedInstruction as h,decodeTransferCheckedWithFeeInstruction as w,decodeTransferInstruction as x,TOKEN_2022_PROGRAM_ID as c,TOKEN_PROGRAM_ID as u}from"@solana/spl-token";const d=e=>e.equals(u)||e.equals(c),o=e=>{try{return e()}catch{return null}},P=[{when:({programId:e})=>e.equals(a),decode:({ixMeta:e,message:n})=>{const t=e.accountKeyIndexes.map(i=>n.allKeys[i]).filter(Boolean),s=t[1],r=t[3];return s&&r?{createATA:{address:s.toBase58(),mintAddress:r.toBase58()}}:null}},{when:({programId:e})=>e.equals(c),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{destination:t,mint:s}}=w(e,n);return{tokenAddress:t.pubkey.toBase58(),mintAddress:s.pubkey.toBase58()}})},{when:({programId:e})=>d(e),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{destination:t}}=x(e,n);return{tokenAddress:t.pubkey.toBase58()}})},{when:({programId:e})=>d(e),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{destination:t,mint:s}}=h(e,n);return{tokenAddress:t.pubkey.toBase58(),mintAddress:s.pubkey.toBase58()}})},{when:({programId:e})=>d(e),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{account:t,mint:s}}=I(e,n);return{createATA:{address:t.pubkey.toBase58(),mintAddress:s.pubkey.toBase58()}}})},{when:({programId:e})=>d(e),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{account:t,mint:s}}=l(e,n);return{createATA:{address:t.pubkey.toBase58(),mintAddress:s.pubkey.toBase58()}}})},{when:({programId:e})=>d(e),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{account:t,mint:s}}=m(e,n);return{createATA:{address:t.pubkey.toBase58(),mintAddress:s.pubkey.toBase58()}}})},{when:({programId:e})=>d(e),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{account:t}}=b(e,n);return{tokenAddress:t.pubkey.toBase58()}})},{when:({programId:e})=>d(e),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{account:t}}=A(e,n);return{tokenAddress:t.pubkey.toBase58()}})},{when:({programId:e})=>d(e),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{account:t}}=B(e,n);return{tokenAddress:t.pubkey.toBase58()}})},{when:({programId:e})=>d(e),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{account:t,mint:s}}=k(e,n);return{tokenAddress:t.pubkey.toBase58(),mintAddress:s.pubkey.toBase58()}})},{when:({programId:e})=>d(e),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{account:t,mint:s}}=y(e,n);return{tokenAddress:t.pubkey.toBase58(),mintAddress:s.pubkey.toBase58()}})},{when:({programId:e})=>d(e),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{account:t,mint:s}}=p(e,n);return{tokenAddress:t.pubkey.toBase58(),mintAddress:s.pubkey.toBase58()}})},{when:({programId:e})=>d(e),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{account:t,mint:s}}=T(e,n);return{tokenAddress:t.pubkey.toBase58(),mintAddress:s.pubkey.toBase58()}})},{when:({programId:e})=>e.equals(a)||e.equals(u)||e.equals(c),decode:()=>({})}];export{P as DECODERS};
|
|
2
|
+
//# sourceMappingURL=transactionDecoders.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/internal/app-binder/services/utils/transactionDecoders.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n ASSOCIATED_TOKEN_PROGRAM_ID,\n decodeBurnCheckedInstruction,\n decodeBurnInstruction,\n decodeCloseAccountInstruction,\n decodeFreezeAccountInstruction,\n decodeInitializeAccount2Instruction,\n decodeInitializeAccount3Instruction,\n decodeInitializeAccountInstruction,\n decodeInitializeImmutableOwnerInstruction,\n decodeSyncNativeInstruction,\n decodeThawAccountInstruction,\n decodeTransferCheckedInstruction,\n decodeTransferCheckedWithFeeInstruction,\n decodeTransferInstruction,\n TOKEN_2022_PROGRAM_ID,\n TOKEN_PROGRAM_ID,\n} from \"@solana/spl-token\";\nimport { type PublicKey, type TransactionInstruction } from \"@solana/web3.js\";\n\nimport {\n type NormalizedCompiledIx,\n type NormalizedMessage,\n type SolanaTransactionTypes,\n} from \"@internal/app-binder/services/TransactionInspector\";\n\nexport interface TxInspectorResult {\n transactionType: SolanaTransactionTypes;\n data: {\n tokenAddress?: string;\n mintAddress?: string;\n createATA?: { address: string; mintAddress: string };\n };\n}\n\nexport type IxContext = {\n programId: PublicKey;\n ixMeta: NormalizedCompiledIx;\n message: NormalizedMessage;\n instruction: TransactionInstruction;\n};\n\nexport type Decoder = {\n when: (ctx: IxContext) => boolean;\n decode: (ctx: IxContext) => TxInspectorResult[\"data\"] | null;\n};\n\nconst isTokenProgramId = (pid: PublicKey) =>\n pid.equals(TOKEN_PROGRAM_ID) || pid.equals(TOKEN_2022_PROGRAM_ID);\n\nconst safe = <T>(fn: () => T): T | null => {\n try {\n return fn();\n } catch {\n return null;\n }\n};\n\nexport const DECODERS: Decoder[] = [\n // ATA creation\n {\n when: ({ programId }) => programId.equals(ASSOCIATED_TOKEN_PROGRAM_ID),\n decode: ({ ixMeta, message }) => {\n const accountPks = ixMeta.accountKeyIndexes\n .map((i) => message.allKeys[i])\n .filter(Boolean) as PublicKey[];\n const ataPk = accountPks[1];\n const mintPk = accountPks[3];\n return ataPk && mintPk\n ? {\n createATA: {\n address: ataPk.toBase58(),\n mintAddress: mintPk.toBase58(),\n },\n }\n : null;\n },\n },\n\n // Token-2022 fee\u2019d transfer (CWIF)\n {\n when: ({ programId }) => programId.equals(TOKEN_2022_PROGRAM_ID),\n decode: ({ instruction, programId }) =>\n safe(() => {\n const {\n keys: { destination, mint },\n } = decodeTransferCheckedWithFeeInstruction(instruction, programId);\n return {\n tokenAddress: destination.pubkey.toBase58(),\n mintAddress: mint.pubkey.toBase58(),\n };\n }),\n },\n\n // Transfers\n {\n when: ({ programId }) => isTokenProgramId(programId),\n decode: ({ instruction, programId }) =>\n safe(() => {\n const {\n keys: { destination },\n } = decodeTransferInstruction(instruction, programId);\n return { tokenAddress: destination.pubkey.toBase58() };\n }),\n },\n {\n when: ({ programId }) => isTokenProgramId(programId),\n decode: ({ instruction, programId }) =>\n safe(() => {\n const {\n keys: { destination, mint },\n } = decodeTransferCheckedInstruction(instruction, programId);\n return {\n tokenAddress: destination.pubkey.toBase58(),\n mintAddress: mint.pubkey.toBase58(),\n };\n }),\n },\n\n // Account init\n {\n when: ({ programId }) => isTokenProgramId(programId),\n decode: ({ instruction, programId }) =>\n safe(() => {\n const {\n keys: { account, mint },\n } = decodeInitializeAccountInstruction(instruction, programId);\n return {\n createATA: {\n address: account.pubkey.toBase58(),\n mintAddress: mint.pubkey.toBase58(),\n },\n };\n }),\n },\n {\n when: ({ programId }) => isTokenProgramId(programId),\n decode: ({ instruction, programId }) =>\n safe(() => {\n const {\n keys: { account, mint },\n } = decodeInitializeAccount2Instruction(instruction, programId);\n return {\n createATA: {\n address: account.pubkey.toBase58(),\n mintAddress: mint.pubkey.toBase58(),\n },\n };\n }),\n },\n {\n when: ({ programId }) => isTokenProgramId(programId),\n decode: ({ instruction, programId }) =>\n safe(() => {\n const {\n keys: { account, mint },\n } = decodeInitializeAccount3Instruction(instruction, programId);\n return {\n createATA: {\n address: account.pubkey.toBase58(),\n mintAddress: mint.pubkey.toBase58(),\n },\n };\n }),\n },\n {\n when: ({ programId }) => isTokenProgramId(programId),\n decode: ({ instruction, programId }) =>\n safe(() => {\n const {\n keys: { account },\n } = decodeInitializeImmutableOwnerInstruction(instruction, programId);\n return { tokenAddress: account.pubkey.toBase58() };\n }),\n },\n\n // Lifecycle / WSOL\n {\n when: ({ programId }) => isTokenProgramId(programId),\n decode: ({ instruction, programId }) =>\n safe(() => {\n const {\n keys: { account },\n } = decodeCloseAccountInstruction(instruction, programId);\n return { tokenAddress: account.pubkey.toBase58() };\n }),\n },\n {\n when: ({ programId }) => isTokenProgramId(programId),\n decode: ({ instruction, programId }) =>\n safe(() => {\n const {\n keys: { account },\n } = decodeSyncNativeInstruction(instruction, programId);\n return { tokenAddress: account.pubkey.toBase58() };\n }),\n },\n\n // Mint / Burn\n {\n when: ({ programId }) => isTokenProgramId(programId),\n decode: ({ instruction, programId }) =>\n safe(() => {\n const {\n keys: { account, mint },\n } = decodeBurnCheckedInstruction(instruction, programId);\n return {\n tokenAddress: account.pubkey.toBase58(),\n mintAddress: mint.pubkey.toBase58(),\n };\n }),\n },\n {\n when: ({ programId }) => isTokenProgramId(programId),\n decode: ({ instruction, programId }) =>\n safe(() => {\n const {\n keys: { account, mint },\n } = decodeBurnInstruction(instruction, programId);\n return {\n tokenAddress: account.pubkey.toBase58(),\n mintAddress: mint.pubkey.toBase58(),\n };\n }),\n },\n\n // Freeze / Thaw\n {\n when: ({ programId }) => isTokenProgramId(programId),\n decode: ({ instruction, programId }) =>\n safe(() => {\n const {\n keys: { account, mint },\n } = decodeFreezeAccountInstruction(instruction, programId);\n return {\n tokenAddress: account.pubkey.toBase58(),\n mintAddress: mint.pubkey.toBase58(),\n };\n }),\n },\n {\n when: ({ programId }) => isTokenProgramId(programId),\n decode: ({ instruction, programId }) =>\n safe(() => {\n const {\n keys: { account, mint },\n } = decodeThawAccountInstruction(instruction, programId);\n return {\n tokenAddress: account.pubkey.toBase58(),\n mintAddress: mint.pubkey.toBase58(),\n };\n }),\n },\n\n // LAST-RESORT: tag as SPL by program id only (when decoders can't run)\n {\n when: ({ programId }) =>\n programId.equals(ASSOCIATED_TOKEN_PROGRAM_ID) ||\n programId.equals(TOKEN_PROGRAM_ID) ||\n programId.equals(TOKEN_2022_PROGRAM_ID),\n decode: () => ({}),\n },\n];\n"],
|
|
5
|
+
"mappings": "AAAA,OACE,+BAAAA,EACA,gCAAAC,EACA,yBAAAC,EACA,iCAAAC,EACA,kCAAAC,EACA,uCAAAC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C,EAClB,CACF",
|
|
6
|
+
"names": ["ASSOCIATED_TOKEN_PROGRAM_ID", "decodeBurnCheckedInstruction", "decodeBurnInstruction", "decodeCloseAccountInstruction", "decodeFreezeAccountInstruction", "decodeInitializeAccount2Instruction", "decodeInitializeAccount3Instruction", "decodeInitializeAccountInstruction", "decodeInitializeImmutableOwnerInstruction", "decodeSyncNativeInstruction", "decodeThawAccountInstruction", "decodeTransferCheckedInstruction", "decodeTransferCheckedWithFeeInstruction", "decodeTransferInstruction", "TOKEN_2022_PROGRAM_ID", "TOKEN_PROGRAM_ID", "isTokenProgramId", "pid", "safe", "fn", "DECODERS", "programId", "ixMeta", "message", "accountPks", "ataPk", "mintPk", "instruction", "destination", "mint", "account"]
|
|
7
|
+
}
|
|
@@ -5,7 +5,7 @@ import { type AppConfiguration } from "../model/AppConfiguration";
|
|
|
5
5
|
import { type Signature } from "../model/Signature";
|
|
6
6
|
import { type Transaction } from "../model/Transaction";
|
|
7
7
|
import { type SolanaAppErrorCodes } from "../../internal/app-binder/command/utils/SolanaApplicationErrors";
|
|
8
|
-
import { type TxInspectorResult } from "../../internal/app-binder/services/
|
|
8
|
+
import { type TxInspectorResult } from "../../internal/app-binder/services/utils/transactionDecoders";
|
|
9
9
|
export type SignTransactionDAOutput = Signature;
|
|
10
10
|
export type SignTransactionDAInput = {
|
|
11
11
|
readonly derivationPath: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignTransactionDeviceActionTypes.d.ts","sourceRoot":"","sources":["../../../../src/api/app-binder/SignTransactionDeviceActionTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,KAAK,qCAAqC,EAAE,MAAM,kEAAkE,CAAC;AAC9H,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,6BAA6B,EAClC,KAAK,cAAc,EACnB,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,EAC5B,KAAK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C,aAAa,EAAE,aAAa,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAC9B,cAAc,GACd,uBAAuB,CAAC,mBAAmB,CAAC,CAAC;AAEjD,KAAK,oCAAoC,GACrC,uBAAuB,GACvB,4BAA4B,CAAC;AAEjC,MAAM,MAAM,kCAAkC,GAAG;IAC/C,uBAAuB,EAAE,oCAAoC,CAAC;CAC/D,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,iBAAiB,CACpD,uBAAuB,EACvB,sBAAsB,EACtB,kCAAkC,CACnC,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,QAAQ,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAC9C,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC5C,QAAQ,CAAC,wBAAwB,EAAE,qCAAqC,GAAG,IAAI,CAAC;IAChF,QAAQ,CAAC,eAAe,EAAE,iBAAiB,GAAG,IAAI,CAAC;CACpD,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,6BAA6B,CACrE,uBAAuB,EACvB,sBAAsB,EACtB,kCAAkC,CACnC,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { type SignTransactionDAError, type SignTransactionDAInput, type SignTran
|
|
|
4
4
|
import { type AppConfiguration } from "../../../api/model/AppConfiguration";
|
|
5
5
|
import { type Signature } from "../../../api/model/Signature";
|
|
6
6
|
import { type SolanaAppErrorCodes } from "../../app-binder/command/utils/SolanaApplicationErrors";
|
|
7
|
-
import { type TxInspectorResult } from "../../app-binder/services/
|
|
7
|
+
import { type TxInspectorResult } from "../../app-binder/services/utils/transactionDecoders";
|
|
8
8
|
import { type BuildTransactionContextTaskArgs, type SolanaBuildContextResult } from "../../app-binder/task/BuildTransactionContextTask";
|
|
9
9
|
import { type SolanaContextForDevice } from "../../app-binder/task/ProvideTransactionContextTask";
|
|
10
10
|
export type MachineDependencies = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignTransactionDeviceAction.d.ts","sourceRoot":"","sources":["../../../../../src/internal/app-binder/device-action/SignTransactionDeviceAction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAE7B,KAAK,WAAW,EAMhB,kBAAkB,EACnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAQ,KAAK,KAAK,EAAS,MAAM,WAAW,CAAC;AAGpD,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,kCAAkC,EACvC,KAAK,8BAA8B,EACnC,KAAK,uBAAuB,EAC7B,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,4DAA4D,CAAC;
|
|
1
|
+
{"version":3,"file":"SignTransactionDeviceAction.d.ts","sourceRoot":"","sources":["../../../../../src/internal/app-binder/device-action/SignTransactionDeviceAction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAE7B,KAAK,WAAW,EAMhB,kBAAkB,EACnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAQ,KAAK,KAAK,EAAS,MAAM,WAAW,CAAC;AAGpD,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,kCAAkC,EACvC,KAAK,8BAA8B,EACnC,KAAK,uBAAuB,EAC7B,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBA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EAAE,WAAW,GACvB,wBAAwB,CACzB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,kCAAkC,EAClC,8BAA8B,CAC/B;IAgVD,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,mBAAmB;CA6CnE"}
|
|
@@ -1,38 +1,27 @@
|
|
|
1
1
|
import { type PublicKey } from "@solana/web3.js";
|
|
2
|
+
import { type TxInspectorResult } from "../../app-binder/services/utils/transactionDecoders";
|
|
2
3
|
export declare enum SolanaTransactionTypes {
|
|
3
4
|
STANDARD = "Standard",
|
|
4
5
|
SPL = "SPL"
|
|
5
6
|
}
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
type LoadedAddresses = {
|
|
18
|
-
writable: PublicKey[];
|
|
19
|
-
readonly: PublicKey[];
|
|
7
|
+
export type NormalizedCompiledIx = {
|
|
8
|
+
programIdIndex: number;
|
|
9
|
+
accountKeyIndexes: number[];
|
|
10
|
+
data: Uint8Array;
|
|
11
|
+
};
|
|
12
|
+
export type NormalizedMessage = {
|
|
13
|
+
compiledInstructions: NormalizedCompiledIx[];
|
|
14
|
+
allKeys: PublicKey[];
|
|
20
15
|
};
|
|
21
16
|
export declare class TransactionInspector {
|
|
22
17
|
private readonly rawTransactionBytes;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @param rawTransactionBytes - raw bytes of the transaction to inspect
|
|
26
|
-
* @param lookedUpAddresses - optional hydrated LUT keys
|
|
27
|
-
*/
|
|
28
|
-
constructor(rawTransactionBytes: Uint8Array, lookedUpAddresses?: LoadedAddresses | undefined);
|
|
18
|
+
constructor(rawTransactionBytes: Uint8Array);
|
|
29
19
|
inspectTransactionType(): TxInspectorResult;
|
|
30
20
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
21
|
+
* Normalise any tx (legacy or v0) into { compiledInstructions, allKeys }.
|
|
22
|
+
* If LUT accounts are provided, looked-up keys are included in allKeys.
|
|
33
23
|
*/
|
|
34
24
|
private normaliseMessage;
|
|
35
25
|
private tryDeserialiseVersioned;
|
|
36
26
|
}
|
|
37
|
-
export {};
|
|
38
27
|
//# sourceMappingURL=TransactionInspector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionInspector.d.ts","sourceRoot":"","sources":["../../../../../src/internal/app-binder/services/TransactionInspector.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TransactionInspector.d.ts","sourceRoot":"","sources":["../../../../../src/internal/app-binder/services/TransactionInspector.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,SAAS,EAKf,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,yDAAyD,CAAC;AAEjE,oBAAY,sBAAsB;IAChC,QAAQ,aAAa;IACrB,GAAG,QAAQ;CACZ;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,IAAI,EAAE,UAAU,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,oBAAoB,EAAE,oBAAoB,EAAE,CAAC;IAC7C,OAAO,EAAE,SAAS,EAAE,CAAC;CACtB,CAAC;AAUF,qBAAa,oBAAoB;IACnB,OAAO,CAAC,QAAQ,CAAC,mBAAmB;gBAAnB,mBAAmB,EAAE,UAAU;IAErD,sBAAsB,IAAI,iBAAiB;IAqDlD;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAyFxB,OAAO,CAAC,uBAAuB;CAehC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type PublicKey, type TransactionInstruction } from "@solana/web3.js";
|
|
2
|
+
import { type NormalizedCompiledIx, type NormalizedMessage, type SolanaTransactionTypes } from "../../../app-binder/services/TransactionInspector";
|
|
3
|
+
export interface TxInspectorResult {
|
|
4
|
+
transactionType: SolanaTransactionTypes;
|
|
5
|
+
data: {
|
|
6
|
+
tokenAddress?: string;
|
|
7
|
+
mintAddress?: string;
|
|
8
|
+
createATA?: {
|
|
9
|
+
address: string;
|
|
10
|
+
mintAddress: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export type IxContext = {
|
|
15
|
+
programId: PublicKey;
|
|
16
|
+
ixMeta: NormalizedCompiledIx;
|
|
17
|
+
message: NormalizedMessage;
|
|
18
|
+
instruction: TransactionInstruction;
|
|
19
|
+
};
|
|
20
|
+
export type Decoder = {
|
|
21
|
+
when: (ctx: IxContext) => boolean;
|
|
22
|
+
decode: (ctx: IxContext) => TxInspectorResult["data"] | null;
|
|
23
|
+
};
|
|
24
|
+
export declare const DECODERS: Decoder[];
|
|
25
|
+
//# sourceMappingURL=transactionDecoders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactionDecoders.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/app-binder/services/utils/transactionDecoders.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAE9E,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC5B,MAAM,oDAAoD,CAAC;AAE5D,MAAM,WAAW,iBAAiB;IAChC,eAAe,EAAE,sBAAsB,CAAC;IACxC,IAAI,EAAE;QACJ,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,SAAS,CAAC,EAAE;YAAE,OAAO,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,MAAM,CAAA;SAAE,CAAC;KACtD,CAAC;CACH;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,SAAS,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,oBAAoB,CAAC;IAC7B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,WAAW,EAAE,sBAAsB,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,CAAC,GAAG,EAAE,SAAS,KAAK,OAAO,CAAC;IAClC,MAAM,EAAE,CAAC,GAAG,EAAE,SAAS,KAAK,iBAAiB,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;CAC9D,CAAC;AAaF,eAAO,MAAM,QAAQ,EAAE,OAAO,EA4M7B,CAAC"}
|