@ledgerhq/device-signer-kit-solana 0.0.0-patch-transactionInspector-20250910142959 → 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/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 +1 -1
- package/lib/cjs/internal/app-binder/services/utils/transactionDecoders.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 +1 -1
- package/lib/esm/internal/app-binder/services/utils/transactionDecoders.js.map +3 -3
- package/lib/types/internal/app-binder/services/TransactionInspector.d.ts.map +1 -1
- package/lib/types/internal/app-binder/services/utils/transactionDecoders.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +7 -7
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var I=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var S=(s,e)=>{for(var t in e)I(s,t,{get:e[t],enumerable:!0})},D=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of x(e))!P.call(s,a)&&a!==t&&I(s,a,{get:()=>e[a],enumerable:!(r=b(e,a))||r.enumerable});return s};var M=s=>D(I({},"__esModule",{value:!0}),s);var h={};S(h,{SolanaTransactionTypes:()=>g,TransactionInspector:()=>R});module.exports=M(h);var u=require("@solana/spl-token"),d=require("@solana/web3.js"),f=require("buffer"),K=require("../../app-binder/services/utils/transactionDecoders"),g=(t=>(t.STANDARD="Standard",t.SPL="SPL",t))(g||{});const N=s=>!!s&&(s.equals(u.ASSOCIATED_TOKEN_PROGRAM_ID)||s.equals(u.TOKEN_PROGRAM_ID)||s.equals(u.TOKEN_2022_PROGRAM_ID));class R{constructor(e){this.rawTransactionBytes=e}inspectTransactionType(){try{const e=this.normaliseMessage(this.rawTransactionBytes);for(const t of e.compiledInstructions){const r=e.allKeys[t.programIdIndex];if(!r)continue;const a=t.accountKeyIndexes.map(c=>e.allKeys[c]).filter(c=>!!c);if(a.length!==t.accountKeyIndexes.length){if(N(r))return{transactionType:"SPL",data:{}};continue}const l=new d.TransactionInstruction({programId:r,keys:a.map(c=>({pubkey:c,isSigner:!1,isWritable:!1})),data:f.Buffer.from(t.data)}),y={programId:r,ixMeta:t,message:e,instruction:l};for(const c of K.DECODERS){if(!c.when(y))continue;const p=c.decode(y);if(p)return{transactionType:"SPL",data:p}}}return{transactionType:"Standard",data:{}}}catch{return{transactionType:"Standard",data:{}}}}normaliseMessage(e){const t=this.tryDeserialiseVersioned(e);if(t){const n=t.message;let o;return typeof n.getAccountKeys=="function"?o=n.getAccountKeys().keySegments().flat():o=[...n.staticAccountKeys],{compiledInstructions:n.compiledInstructions.map(i=>{const A=i,T=Array.from(A.accounts??i.accountKeyIndexes??[]);let m;return i.data instanceof Uint8Array?m=i.data:typeof i.data=="string"?m=f.Buffer.from(i.data,"base64"):m=Uint8Array.from(i.data??[]),{programIdIndex:i.programIdIndex,accountKeyIndexes:T,data:m}}),allKeys:o}}const r=d.Transaction.from(e),a=new Map,l=n=>{if(!n)return;const o=n.toBase58();a.has(o)||a.set(o,n)};l(r.feePayer??null);for(const n of r.instructions){l(n.programId);for(const o of n.keys)l(o.pubkey)}const y=Array.from(a.values()),c=new Map(y.map((n,o)=>[n.toBase58(),o]));return{compiledInstructions:r.instructions.map(n=>({programIdIndex:c.get(n.programId.toBase58())??-1,accountKeyIndexes:n.keys.map(o=>c.get(o.pubkey.toBase58())??-1),data:n.data})),allKeys:y}}tryDeserialiseVersioned(e){try{return d.VersionedTransaction.deserialize(e)}catch{try{return{message:d.VersionedMessage.deserialize(e)}}catch{return null}}}}0&&(module.exports={SolanaTransactionTypes,TransactionInspector});
|
|
2
2
|
//# sourceMappingURL=TransactionInspector.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/services/TransactionInspector.ts"],
|
|
4
|
-
"sourcesContent": ["import {\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\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 if (!programId) continue;\n\n //
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,EAAA,yBAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAMO,2BACPC,EAAuB,kBAEvBC,EAIO,
|
|
6
|
-
"names": ["TransactionInspector_exports", "__export", "SolanaTransactionTypes", "TransactionInspector", "__toCommonJS", "import_web3", "import_buffer", "import_transactionDecoders", "rawTransactionBytes", "message", "ixMeta", "programId", "resolvedKeys", "i", "key", "instruction", "ctx", "decoder", "data", "rawBytes", "versionedTX", "msg", "allKeys", "ix", "ixWithAccounts", "accountKeyIndexes", "legacy", "allKeyMap", "add", "pubkey", "indexByB58", "pk"]
|
|
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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,EAAA,yBAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK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,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,OAAO,uBAAqB,YAAYA,CAAQ,CAClD,MAAQ,CACN,GAAI,CAGF,MAAO,CAAE,QAFG,mBAAiB,YAAYA,CAAQ,CAE3B,CACxB,MAAQ,CACN,OAAO,IACT,CACF,CACF,CACF",
|
|
6
|
+
"names": ["TransactionInspector_exports", "__export", "SolanaTransactionTypes", "TransactionInspector", "__toCommonJS", "import_spl_token", "import_web3", "import_buffer", "import_transactionDecoders", "isSPLProgramId", "pid", "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
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var A=(e,t)=>{for(var s in t)a(e,s,{get:t[s],enumerable:!0})},p=(e,t,s,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of k(t))!y.call(e,r)&&r!==s&&a(e,r,{get:()=>t[r],enumerable:!(o=i(t,r))||o.enumerable});return e};var l=e=>p(a({},"__esModule",{value:!0}),e);var I={};A(I,{DECODERS:()=>m});module.exports=l(I);var n=require("@solana/spl-token");const c=e=>e.equals(n.TOKEN_PROGRAM_ID)||e.equals(n.TOKEN_2022_PROGRAM_ID),d=e=>{try{return e()}catch{return null}},m=[{when:({programId:e})=>e.equals(n.ASSOCIATED_TOKEN_PROGRAM_ID),decode:({ixMeta:e,message:t})=>{const s=e.accountKeyIndexes.map(u=>t.allKeys[u]).filter(Boolean),o=s[1],r=s[3];return o&&r?{createATA:{address:o.toBase58(),mintAddress:r.toBase58()}}:null}},{when:({programId:e})=>e.equals(n.TOKEN_2022_PROGRAM_ID),decode:({instruction:e,programId:t})=>d(()=>{const{keys:{destination:s,mint:o}}=(0,n.decodeTransferCheckedWithFeeInstruction)(e,t);return{tokenAddress:s.pubkey.toBase58(),mintAddress:o.pubkey.toBase58()}})},{when:({programId:e})=>c(e),decode:({instruction:e,programId:t})=>d(()=>{const{keys:{destination:s}}=(0,n.decodeTransferInstruction)(e,t);return{tokenAddress:s.pubkey.toBase58()}})},{when:({programId:e})=>c(e),decode:({instruction:e,programId:t})=>d(()=>{const{keys:{destination:s,mint:o}}=(0,n.decodeTransferCheckedInstruction)(e,t);return{tokenAddress:s.pubkey.toBase58(),mintAddress:o.pubkey.toBase58()}})},{when:({programId:e})=>c(e),decode:({instruction:e,programId:t})=>d(()=>{const{keys:{account:s,mint:o}}=(0,n.decodeInitializeAccountInstruction)(e,t);return{createATA:{address:s.pubkey.toBase58(),mintAddress:o.pubkey.toBase58()}}})},{when:({programId:e})=>c(e),decode:({instruction:e,programId:t})=>d(()=>{const{keys:{account:s,mint:o}}=(0,n.decodeInitializeAccount2Instruction)(e,t);return{createATA:{address:s.pubkey.toBase58(),mintAddress:o.pubkey.toBase58()}}})},{when:({programId:e})=>c(e),decode:({instruction:e,programId:t})=>d(()=>{const{keys:{account:s,mint:o}}=(0,n.decodeInitializeAccount3Instruction)(e,t);return{createATA:{address:s.pubkey.toBase58(),mintAddress:o.pubkey.toBase58()}}})},{when:({programId:e})=>c(e),decode:({instruction:e,programId:t})=>d(()=>{const{keys:{account:s}}=(0,n.decodeInitializeImmutableOwnerInstruction)(e,t);return{tokenAddress:s.pubkey.toBase58()}})},{when:({programId:e})=>c(e),decode:({instruction:e,programId:t})=>d(()=>{const{keys:{account:s}}=(0,n.decodeCloseAccountInstruction)(e,t);return{tokenAddress:s.pubkey.toBase58()}})},{when:({programId:e})=>c(e),decode:({instruction:e,programId:t})=>d(()=>{const{keys:{account:s}}=(0,n.decodeSyncNativeInstruction)(e,t);return{tokenAddress:s.pubkey.toBase58()}})},{when:({programId:e})=>c(e),decode:({instruction:e,programId:t})=>d(()=>{const{keys:{account:s,mint:o}}=(0,n.decodeBurnCheckedInstruction)(e,t);return{tokenAddress:s.pubkey.toBase58(),mintAddress:o.pubkey.toBase58()}})},{when:({programId:e})=>c(e),decode:({instruction:e,programId:t})=>d(()=>{const{keys:{account:s,mint:o}}=(0,n.decodeBurnInstruction)(e,t);return{tokenAddress:s.pubkey.toBase58(),mintAddress:o.pubkey.toBase58()}})},{when:({programId:e})=>c(e),decode:({instruction:e,programId:t})=>d(()=>{const{keys:{account:s,mint:o}}=(0,n.decodeFreezeAccountInstruction)(e,t);return{tokenAddress:s.pubkey.toBase58(),mintAddress:o.pubkey.toBase58()}})},{when:({programId:e})=>c(e),decode:({instruction:e,programId:t})=>d(()=>{const{keys:{account:s,mint:o}}=(0,n.decodeThawAccountInstruction)(e,t);return{tokenAddress:s.pubkey.toBase58(),mintAddress:o.pubkey.toBase58()}})},{when:({programId:e})=>e.equals(n.ASSOCIATED_TOKEN_PROGRAM_ID)||e.equals(n.TOKEN_PROGRAM_ID)||e.equals(n.TOKEN_2022_PROGRAM_ID),decode:()=>({})}];0&&(module.exports={DECODERS});
|
|
2
2
|
//# sourceMappingURL=transactionDecoders.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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?: {
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAiBO,
|
|
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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAiBO,6BA8BP,MAAMC,EAAoBC,GACxBA,EAAI,OAAO,kBAAgB,GAAKA,EAAI,OAAO,uBAAqB,EAE5DC,EAAWC,GAA0B,CACzC,GAAI,CACF,OAAOA,EAAG,CACZ,MAAQ,CACN,OAAO,IACT,CACF,EAEaN,EAAsB,CAEjC,CACE,KAAM,CAAC,CAAE,UAAAO,CAAU,IAAMA,EAAU,OAAO,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AAO,SAAS,EACtC,YAAaD,EAAK,OAAO,SAAS,CACpC,CACF,CAAC,CACL,EAGA,CACE,KAAM,CAAC,CAAE,UAAAT,CAAU,IAAMJ,EAAiBI,CAAS,EACnD,OAAQ,CAAC,CAAE,YAAAO,EAAa,UAAAP,CAAU,IAChCF,EAAK,IAAM,CACT,KAAM,CACJ,KAAM,CAAE,QAAAY,EAAS,KAAAD,CAAK,CACxB,KAAI,kCAA+BF,EAAaP,CAAS,EACzD,MAAO,CACL,aAAcU,EAAQ,OAAO,SAAS,EACtC,YAAaD,EAAK,OAAO,SAAS,CACpC,CACF,CAAC,CACL,EACA,CACE,KAAM,CAAC,CAAE,UAAAT,CAAU,IAAMJ,EAAiBI,CAAS,EACnD,OAAQ,CAAC,CAAE,YAAAO,EAAa,UAAAP,CAAU,IAChCF,EAAK,IAAM,CACT,KAAM,CACJ,KAAM,CAAE,QAAAY,EAAS,KAAAD,CAAK,CACxB,KAAI,gCAA6BF,EAAaP,CAAS,EACvD,MAAO,CACL,aAAcU,EAAQ,OAAO,SAAS,EACtC,YAAaD,EAAK,OAAO,SAAS,CACpC,CACF,CAAC,CACL,EAGA,CACE,KAAM,CAAC,CAAE,UAAAT,CAAU,IACjBA,EAAU,OAAO,6BAA2B,GAC5CA,EAAU,OAAO,kBAAgB,GACjCA,EAAU,OAAO,uBAAqB,EACxC,OAAQ,KAAO,CAAC,EAClB,CACF",
|
|
6
6
|
"names": ["transactionDecoders_exports", "__export", "DECODERS", "__toCommonJS", "import_spl_token", "isTokenProgramId", "pid", "safe", "fn", "programId", "ixMeta", "message", "accountPks", "i", "ataPk", "mintPk", "instruction", "destination", "mint", "account"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Transaction as
|
|
1
|
+
import{ASSOCIATED_TOKEN_PROGRAM_ID as f,TOKEN_2022_PROGRAM_ID as K,TOKEN_PROGRAM_ID as g}from"@solana/spl-token";import{Transaction as A,TransactionInstruction as T,VersionedMessage as b,VersionedTransaction as x}from"@solana/web3.js";import{Buffer as m}from"buffer";import{DECODERS as P}from"../../app-binder/services/utils/transactionDecoders";var S=(t=>(t.STANDARD="Standard",t.SPL="SPL",t))(S||{});const D=i=>!!i&&(i.equals(f)||i.equals(g)||i.equals(K));class L{constructor(s){this.rawTransactionBytes=s}inspectTransactionType(){try{const s=this.normaliseMessage(this.rawTransactionBytes);for(const t of s.compiledInstructions){const r=s.allKeys[t.programIdIndex];if(!r)continue;const c=t.accountKeyIndexes.map(a=>s.allKeys[a]).filter(a=>!!a);if(c.length!==t.accountKeyIndexes.length){if(D(r))return{transactionType:"SPL",data:{}};continue}const d=new T({programId:r,keys:c.map(a=>({pubkey:a,isSigner:!1,isWritable:!1})),data:m.from(t.data)}),u={programId:r,ixMeta:t,message:s,instruction:d};for(const a of P){if(!a.when(u))continue;const y=a.decode(u);if(y)return{transactionType:"SPL",data:y}}}return{transactionType:"Standard",data:{}}}catch{return{transactionType:"Standard",data:{}}}}normaliseMessage(s){const t=this.tryDeserialiseVersioned(s);if(t){const e=t.message;let n;return typeof e.getAccountKeys=="function"?n=e.getAccountKeys().keySegments().flat():n=[...e.staticAccountKeys],{compiledInstructions:e.compiledInstructions.map(o=>{const p=o,I=Array.from(p.accounts??o.accountKeyIndexes??[]);let l;return o.data instanceof Uint8Array?l=o.data:typeof o.data=="string"?l=m.from(o.data,"base64"):l=Uint8Array.from(o.data??[]),{programIdIndex:o.programIdIndex,accountKeyIndexes:I,data:l}}),allKeys:n}}const r=A.from(s),c=new Map,d=e=>{if(!e)return;const n=e.toBase58();c.has(n)||c.set(n,e)};d(r.feePayer??null);for(const e of r.instructions){d(e.programId);for(const n of e.keys)d(n.pubkey)}const u=Array.from(c.values()),a=new Map(u.map((e,n)=>[e.toBase58(),n]));return{compiledInstructions:r.instructions.map(e=>({programIdIndex:a.get(e.programId.toBase58())??-1,accountKeyIndexes:e.keys.map(n=>a.get(n.pubkey.toBase58())??-1),data:e.data})),allKeys:u}}tryDeserialiseVersioned(s){try{return x.deserialize(s)}catch{try{return{message:b.deserialize(s)}}catch{return null}}}}export{S as SolanaTransactionTypes,L as TransactionInspector};
|
|
2
2
|
//# sourceMappingURL=TransactionInspector.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/services/TransactionInspector.ts"],
|
|
4
|
-
"sourcesContent": ["import {\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\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 if (!programId) continue;\n\n //
|
|
5
|
-
"mappings": "AAAA,OAEE,
|
|
6
|
-
"names": ["Transaction", "TransactionInstruction", "VersionedMessage", "VersionedTransaction", "Buffer", "DECODERS", "SolanaTransactionTypes", "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"]
|
|
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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ARPa,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
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ASSOCIATED_TOKEN_PROGRAM_ID as
|
|
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
2
|
//# sourceMappingURL=transactionDecoders.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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?: {
|
|
5
|
-
"mappings": "AAAA,OACE,+BAAAA,EACA,gCAAAC,EACA,yBAAAC,EACA,iCAAAC,EACA,kCAAAC,EACA,uCAAAC,EACA,uCAAAC,EACA,sCAAAC,EACA,6CAAAC,EACA,+BAAAC,EACA,gCAAAC,EACA,oCAAAC,EACA,2CAAAC,EACA,6BAAAC,EACA,yBAAAC,EACA,oBAAAC,MACK,
|
|
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", "
|
|
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,EACA,uCAAAC,EACA,sCAAAC,EACA,6CAAAC,EACA,+BAAAC,EACA,gCAAAC,EACA,oCAAAC,EACA,2CAAAC,EACA,6BAAAC,EACA,yBAAAC,EACA,oBAAAC,MACK,oBA8BP,MAAMC,EAAoBC,GACxBA,EAAI,OAAOF,CAAgB,GAAKE,EAAI,OA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YAAAM,EAAa,UAAAN,CAAU,IAChCH,EAAK,IAAM,CACT,KAAM,CACJ,KAAM,CAAE,QAAAY,EAAS,KAAAD,CAAK,CACxB,EAAI3B,EAAsByB,EAAaN,CAAS,EAChD,MAAO,CACL,aAAcS,EAAQ,OAAO,SAAS,EACtC,YAAaD,EAAK,OAAO,SAAS,CACpC,CACF,CAAC,CACL,EAGA,CACE,KAAM,CAAC,CAAE,UAAAR,CAAU,IAAML,EAAiBK,CAAS,EACnD,OAAQ,CAAC,CAAE,YAAAM,EAAa,UAAAN,CAAU,IAChCH,EAAK,IAAM,CACT,KAAM,CACJ,KAAM,CAAE,QAAAY,EAAS,KAAAD,CAAK,CACxB,EAAIzB,EAA+BuB,EAAaN,CAAS,EACzD,MAAO,CACL,aAAcS,EAAQ,OAAO,SAAS,EACtC,YAAaD,EAAK,OAAO,SAAS,CACpC,CACF,CAAC,CACL,EACA,CACE,KAAM,CAAC,CAAE,UAAAR,CAAU,IAAML,EAAiBK,CAAS,EACnD,OAAQ,CAAC,CAAE,YAAAM,EAAa,UAAAN,CAAU,IAChCH,EAAK,IAAM,CACT,KAAM,CACJ,KAAM,CAAE,QAAAY,EAAS,KAAAD,CAAK,CACxB,EAAInB,EAA6BiB,EAAaN,CAAS,EACvD,MAAO,CACL,aAAcS,EAAQ,OAAO,SAAS,EACtC,YAAaD,EAAK,OAAO,SAAS,CACpC,CACF,CAAC,CACL,EAGA,CACE,KAAM,CAAC,CAAE,UAAAR,CAAU,IACjBA,EAAU,OAAOrB,CAA2B,GAC5CqB,EAAU,OAAON,CAAgB,GACjCM,EAAU,OAAOP,CAAqB,EACxC,OAAQ,KAAO,CAAC,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
7
|
}
|
|
@@ -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"}
|
|
@@ -1 +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;
|
|
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"}
|