@ledgerhq/device-signer-kit-solana 0.0.0-transactionInspector-resolutionObj-20250916104735 → 0.0.0-transactionInspector-resolutionObj-20250916153045
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 +1 -1
- package/lib/cjs/internal/app-binder/services/utils/transactionDecoders.js.map +3 -3
- 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 +1 -1
- package/lib/esm/internal/app-binder/services/utils/transactionDecoders.js.map +3 -3
- 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 +3 -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 +11 -2
- package/lib/types/internal/app-binder/services/TransactionInspector.d.ts.map +1 -1
- package/lib/types/internal/app-binder/services/utils/transactionDecoders.d.ts +1 -12
- 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
|
-
import{ASSOCIATED_TOKEN_PROGRAM_ID as
|
|
1
|
+
import{ASSOCIATED_TOKEN_PROGRAM_ID as I,TOKEN_2022_PROGRAM_ID as g,TOKEN_PROGRAM_ID as K}from"@solana/spl-token";import{Connection as b,Transaction as P,TransactionInstruction as k,VersionedMessage as x,VersionedTransaction as S}from"@solana/web3.js";import{Buffer as p}from"buffer";import{DECODERS as L}from"../../app-binder/services/utils/transactionDecoders";var h=(a=>(a.STANDARD="Standard",a.SPL="SPL",a))(h||{});const D="https://api.mainnet-beta.solana.com/",R=new b(D,{commitment:"confirmed"}),A=i=>!!i&&(i.equals(I)||i.equals(K)||i.equals(g));class _{constructor(n,a,s){this.rawTransactionBytes=n;this.tokenAddress=a;this.createATA=s}async inspectTransactionType(){try{const n=await this.normaliseMessage(this.rawTransactionBytes);if(this.tokenAddress||this.createATA)return{transactionType:n.compiledInstructions.some(r=>A(n.allKeys[r.programIdIndex]))?"SPL":"Standard",data:{...this.tokenAddress?{tokenAddress:this.tokenAddress}:{},...this.createATA?{createATA:this.createATA}:{}}};let a=!1,s={};for(const o of n.compiledInstructions){const r=n.allKeys[o.programIdIndex];if(!r)continue;A(r)&&(a=!0);const d=o.accountKeyIndexes.map(e=>n.allKeys[e]).filter(e=>!!e),l=new k({programId:r,keys:d.map(e=>({pubkey:e,isSigner:!1,isWritable:!1})),data:p.from(o.data)}),u={programId:r,ixMeta:o,message:n,instruction:l};for(const e of L){if(!e.when(u))continue;const t=e.decode(u);t&&(t.createATA&&!s.createATA?s={...s,createATA:t.createATA}:t.tokenAddress&&!s.tokenAddress&&!s.createATA&&(s={...s,tokenAddress:t.tokenAddress}))}}return s.createATA?{transactionType:"SPL",data:s}:s.tokenAddress?{transactionType:"SPL",data:s}:a?{transactionType:"SPL",data:{}}:{transactionType:"Standard",data:{}}}catch{return{transactionType:"Standard",data:{}}}}async normaliseMessage(n){const a=this.tryDeserialiseVersioned(n);if(a){const e=a.message,t=await M(e);let m;return typeof e.getAccountKeys=="function"?m=e.getAccountKeys(t?{accountKeysFromLookups:t}:void 0).keySegments().flat():m=[...e.staticAccountKeys],{compiledInstructions:e.compiledInstructions.map(c=>{const f=c,T=Array.from(f.accounts??c.accountKeyIndexes??[]);let y;return c.data instanceof Uint8Array?y=c.data:typeof c.data=="string"?y=p.from(c.data,"base64"):y=Uint8Array.from(c.data??[]),{programIdIndex:c.programIdIndex,accountKeyIndexes:T,data:y}}),allKeys:m}}const s=P.from(n),o=new Map,r=e=>{if(!e)return;const t=e.toBase58();o.has(t)||o.set(t,e)};r(s.feePayer??null);for(const e of s.instructions){r(e.programId);for(const t of e.keys)r(t.pubkey)}const d=Array.from(o.values()),l=new Map(d.map((e,t)=>[e.toBase58(),t]));return{compiledInstructions:s.instructions.map(e=>({programIdIndex:l.get(e.programId.toBase58())??-1,accountKeyIndexes:e.keys.map(t=>l.get(t.pubkey.toBase58())??-1),data:e.data})),allKeys:d}}tryDeserialiseVersioned(n){try{return S.deserialize(n)}catch{try{return{message:x.deserialize(n)}}catch{return null}}}}async function M(i){const n=i.addressTableLookups??[];if(!n.length)return;const a=[],s=[];return await Promise.all(n.map(async o=>{const d=(await R.getAddressLookupTable(o.accountKey)).value;if(!d)return;const l=d.state.addresses;for(const u of o.writableIndexes??[]){const e=l[u];e&&a.push(e)}for(const u of o.readonlyIndexes??[]){const e=l[u];e&&s.push(e)}})),{writable:a,readonly:s}}export{h as SolanaTransactionTypes,_ 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 ASSOCIATED_TOKEN_PROGRAM_ID,\n TOKEN_2022_PROGRAM_ID,\n TOKEN_PROGRAM_ID,\n} from \"@solana/spl-token\";\nimport {\n Connection,\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
|
|
5
|
-
"mappings": "AAAA,OACE,+BAAAA,EACA,yBAAAC,EACA,oBAAAC,MACK,oBACP,OACE,cAAAC,EAEA,eAAAC,EACA,0BAAAC,EACA,oBAAAC,EACA,wBAAAC,MACK,kBACP,OAAS,UAAAC,MAAc,SAEvB,OACE,YAAAC,
|
|
6
|
-
"names": ["ASSOCIATED_TOKEN_PROGRAM_ID", "TOKEN_2022_PROGRAM_ID", "TOKEN_PROGRAM_ID", "Connection", "Transaction", "TransactionInstruction", "VersionedMessage", "VersionedTransaction", "Buffer", "DECODERS", "SolanaTransactionTypes", "RPC_URL", "defaultConnection", "isSPLProgramId", "pid", "TransactionInspector", "rawTransactionBytes", "tokenAddress", "createATA", "message", "
|
|
4
|
+
"sourcesContent": ["import {\n ASSOCIATED_TOKEN_PROGRAM_ID,\n TOKEN_2022_PROGRAM_ID,\n TOKEN_PROGRAM_ID,\n} from \"@solana/spl-token\";\nimport {\n Connection,\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} 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\nexport interface TxInspectorResult {\n transactionType: SolanaTransactionTypes;\n data: {\n tokenAddress?: string;\n createATA?: { address: string; mintAddress: string };\n };\n}\n\ntype LoadedAddresses = { writable: PublicKey[]; readonly: PublicKey[] };\n\nconst RPC_URL = \"https://api.mainnet-beta.solana.com/\";\n\nconst defaultConnection = new Connection(RPC_URL, { commitment: \"confirmed\" });\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(\n private readonly rawTransactionBytes: Uint8Array,\n private readonly tokenAddress?: string | null,\n private readonly createATA?: {\n address: string;\n mintAddress: string;\n } | null,\n ) {}\n\n public async inspectTransactionType(): Promise<TxInspectorResult> {\n try {\n const message = await this.normaliseMessage(this.rawTransactionBytes);\n\n // Fast path when hints are provided\n if (this.tokenAddress || this.createATA) {\n const looksSPL = message.compiledInstructions.some((ix) =>\n isSPLProgramId(message.allKeys[ix.programIdIndex]),\n );\n return {\n transactionType: looksSPL\n ? SolanaTransactionTypes.SPL\n : SolanaTransactionTypes.STANDARD,\n data: {\n ...(this.tokenAddress ? { tokenAddress: this.tokenAddress } : {}),\n ...(this.createATA ? { createATA: this.createATA } : {}),\n },\n };\n }\n\n // Accumulate best data across all instructions\n let sawSPL = false;\n let best: TxInspectorResult[\"data\"] = {};\n\n for (const ixMeta of message.compiledInstructions) {\n const programId = message.allKeys[ixMeta.programIdIndex];\n if (!programId) continue;\n\n if (isSPLProgramId(programId)) sawSPL = true;\n\n const resolvedKeys = ixMeta.accountKeyIndexes\n .map((i) => message.allKeys[i])\n .filter((k): k is PublicKey => !!k);\n\n const instruction = new TransactionInstruction({\n programId,\n keys: resolvedKeys.map((pk) => ({\n pubkey: pk,\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) continue;\n\n // Prefer createATA (needed when destination ATA doesn\u2019t exist yet)\n if (data.createATA && !best.createATA) {\n best = { ...best, createATA: data.createATA };\n } else if (\n data.tokenAddress &&\n !best.tokenAddress &&\n !best.createATA\n ) {\n best = { ...best, tokenAddress: data.tokenAddress };\n }\n }\n }\n\n if (best.createATA)\n return { transactionType: SolanaTransactionTypes.SPL, data: best };\n if (best.tokenAddress)\n return { transactionType: SolanaTransactionTypes.SPL, data: best };\n if (sawSPL)\n return { transactionType: SolanaTransactionTypes.SPL, data: {} };\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 * For v0, auto-fetch looked-up addresses from ALT(s) via the baked-in connection.\n */\n private async normaliseMessage(\n rawBytes: Uint8Array,\n ): Promise<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 const lookedUp = await resolveLookedUpAddressesFromMessage(msg);\n\n let allKeys: PublicKey[];\n if (typeof msg.getAccountKeys === \"function\") {\n const messageAccountKeys = msg.getAccountKeys(\n lookedUp ? { accountKeysFromLookups: lookedUp } : undefined,\n );\n allKeys = messageAccountKeys.keySegments().flat();\n } else {\n allKeys = [...msg.staticAccountKeys];\n }\n\n const compiledInstructions: NormalizedCompiledIx[] =\n msg.compiledInstructions.map((ix) => {\n const ixWithAccounts = ix as typeof ix & { accounts?: number[] };\n const accountKeyIndexes = Array.from(\n ixWithAccounts.accounts ?? ix.accountKeyIndexes ?? [],\n ) as number[];\n\n let data: Uint8Array;\n if (ix.data instanceof Uint8Array) {\n data = ix.data;\n } else if (typeof ix.data === \"string\") {\n data = Buffer.from(ix.data, \"base64\"); // v0 encodes instruction data as 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 (no ALTs)\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 return { message: msg } as VersionedTransaction;\n } catch {\n return null;\n }\n }\n }\n}\n\n// fetch looked-up addresses for a VersionedMessage via the baked-in connection\nasync function resolveLookedUpAddressesFromMessage(\n msg: VersionedMessage,\n): Promise<LoadedAddresses | undefined> {\n const lookups = msg.addressTableLookups ?? [];\n if (!lookups.length) return;\n\n const writable: PublicKey[] = [];\n const readonly: PublicKey[] = [];\n\n await Promise.all(\n lookups.map(async (lu) => {\n const res = await defaultConnection.getAddressLookupTable(lu.accountKey);\n const table = res.value;\n if (!table) return;\n const addrs = table.state.addresses;\n\n for (const i of lu.writableIndexes ?? []) {\n const pk = addrs[i];\n if (pk) writable.push(pk);\n }\n for (const i of lu.readonlyIndexes ?? []) {\n const pk = addrs[i];\n if (pk) readonly.push(pk);\n }\n }),\n );\n\n return { writable, readonly };\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OACE,+BAAAA,EACA,yBAAAC,EACA,oBAAAC,MACK,oBACP,OACE,cAAAC,EAEA,eAAAC,EACA,0BAAAC,EACA,oBAAAC,EACA,wBAAAC,MACK,kBACP,OAAS,UAAAC,MAAc,SAEvB,OACE,YAAAC,MAEK,0DAEA,IAAKC,OACVA,EAAA,SAAW,WACXA,EAAA,IAAM,MAFIA,OAAA,IA0BZ,MAAMC,EAAU,uCAEVC,EAAoB,IAAIT,EAAWQ,EAAS,CAAE,WAAY,WAAY,CAAC,EAEvEE,EAAkBC,GACtB,CAAC,CAACA,IACDA,EAAI,OAAOd,CAA2B,GACrCc,EAAI,OAAOZ,CAAgB,GAC3BY,EAAI,OAAOb,CAAqB,GAE7B,MAAMc,CAAqB,CAChC,YACmBC,EACAC,EACAC,EAIjB,CANiB,yBAAAF,EACA,kBAAAC,EACA,eAAAC,CAIhB,CAEH,MAAa,wBAAqD,CAChE,GAAI,CACF,MAAMC,EAAU,MAAM,KAAK,iBAAiB,KAAK,mBAAmB,EAGpE,GAAI,KAAK,cAAgB,KAAK,UAI5B,MAAO,CACL,gBAJeA,EAAQ,qBAAqB,KAAMC,GAClDP,EAAeM,EAAQ,QAAQC,EAAG,cAAc,CAAC,CACnD,EAGM,MACA,WACJ,KAAM,CACJ,GAAI,KAAK,aAAe,CAAE,aAAc,KAAK,YAAa,EAAI,CAAC,EAC/D,GAAI,KAAK,UAAY,CAAE,UAAW,KAAK,SAAU,EAAI,CAAC,CACxD,CACF,EAIF,IAAIC,EAAS,GACTC,EAAkC,CAAC,EAEvC,UAAWC,KAAUJ,EAAQ,qBAAsB,CACjD,MAAMK,EAAYL,EAAQ,QAAQI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BA,EAAG,KAAK,IACxByB,GAAQC,EAAW,IAAID,EAAI,OAAO,SAAS,CAAC,GAAK,EACpD,EACA,KAAMzB,EAAG,IACX,EAAE,EAE2B,QAAAkB,CAAQ,CACzC,CAEQ,wBACNL,EAC6B,CAC7B,GAAI,CACF,OAAO1B,EAAqB,YAAY0B,CAAQ,CAClD,MAAQ,CACN,GAAI,CAEF,MAAO,CAAE,QADG3B,EAAiB,YAAY2B,CAAQ,CAC3B,CACxB,MAAQ,CACN,OAAO,IACT,CACF,CACF,CACF,CAGA,eAAeI,EACbF,EACsC,CACtC,MAAMY,EAAUZ,EAAI,qBAAuB,CAAC,EAC5C,GAAI,CAACY,EAAQ,OAAQ,OAErB,MAAMC,EAAwB,CAAC,EACzBC,EAAwB,CAAC,EAE/B,aAAM,QAAQ,IACZF,EAAQ,IAAI,MAAOG,GAAO,CAExB,MAAMC,GADM,MAAMvC,EAAkB,sBAAsBsC,EAAG,UAAU,GACrD,MAClB,GAAI,CAACC,EAAO,OACZ,MAAMC,EAAQD,EAAM,MAAM,UAE1B,UAAWzB,KAAKwB,EAAG,iBAAmB,CAAC,EAAG,CACxC,MAAMrB,EAAKuB,EAAM1B,CAAC,EACdG,GAAImB,EAAS,KAAKnB,CAAE,CAC1B,CACA,UAAWH,KAAKwB,EAAG,iBAAmB,CAAC,EAAG,CACxC,MAAMrB,EAAKuB,EAAM1B,CAAC,EACdG,GAAIoB,EAAS,KAAKpB,CAAE,CAC1B,CACF,CAAC,CACH,EAEO,CAAE,SAAAmB,EAAU,SAAAC,CAAS,CAC9B",
|
|
6
|
+
"names": ["ASSOCIATED_TOKEN_PROGRAM_ID", "TOKEN_2022_PROGRAM_ID", "TOKEN_PROGRAM_ID", "Connection", "Transaction", "TransactionInstruction", "VersionedMessage", "VersionedTransaction", "Buffer", "DECODERS", "SolanaTransactionTypes", "RPC_URL", "defaultConnection", "isSPLProgramId", "pid", "TransactionInspector", "rawTransactionBytes", "tokenAddress", "createATA", "message", "ix", "sawSPL", "best", "ixMeta", "programId", "resolvedKeys", "i", "k", "instruction", "pk", "ctx", "decoder", "data", "rawBytes", "versionedTX", "msg", "lookedUp", "resolveLookedUpAddressesFromMessage", "allKeys", "ixWithAccounts", "accountKeyIndexes", "legacy", "allKeyMap", "add", "pubkey", "key", "indexByB58", "lookups", "writable", "readonly", "lu", "table", "addrs"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ASSOCIATED_TOKEN_PROGRAM_ID as
|
|
1
|
+
import{ASSOCIATED_TOKEN_PROGRAM_ID as a,decodeBurnCheckedInstruction as l,decodeBurnInstruction as A,decodeCloseAccountInstruction as I,decodeFreezeAccountInstruction as p,decodeInitializeAccount2Instruction as b,decodeInitializeAccount3Instruction as m,decodeInitializeAccountInstruction as h,decodeInitializeImmutableOwnerInstruction as B,decodeSyncNativeInstruction as T,decodeThawAccountInstruction as w,decodeTransferCheckedInstruction as x,decodeTransferCheckedWithFeeInstruction as C,decodeTransferInstruction as P,TOKEN_2022_PROGRAM_ID as d,TOKEN_PROGRAM_ID as i}from"@solana/spl-token";const s=e=>e.equals(i)||e.equals(d),o=e=>{try{return e()}catch{return null}},z=[{when:({programId:e})=>e.equals(a),decode:({ixMeta:e,message:n})=>{const t=y=>{const u=e.accountKeyIndexes[y];return u!==void 0?n.allKeys[u]??null:null},c=t(1),k=t(2),r=t(3);return!k||!r||!c?null:{createATA:{address:c.toBase58(),mintAddress:r.toBase58()}}}},{when:({programId:e})=>e.equals(d),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{destination:t}}=C(e,n);return{tokenAddress:t.pubkey.toBase58()}})},{when:({programId:e})=>s(e),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{destination:t}}=P(e,n);return{tokenAddress:t.pubkey.toBase58()}})},{when:({programId:e})=>s(e),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{destination:t}}=x(e,n);return{tokenAddress:t.pubkey.toBase58()}})},{when:({programId:e})=>s(e),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{account:t,mint:c}}=h(e,n);return{createATA:{address:t.pubkey.toBase58(),mintAddress:c.pubkey.toBase58()}}})},{when:({programId:e})=>s(e),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{account:t,mint:c}}=b(e,n);return{createATA:{address:t.pubkey.toBase58(),mintAddress:c.pubkey.toBase58()}}})},{when:({programId:e})=>s(e),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{account:t,mint:c}}=m(e,n);return{createATA:{address:t.pubkey.toBase58(),mintAddress:c.pubkey.toBase58()}}})},{when:({programId:e})=>s(e),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{account:t}}=B(e,n);return{tokenAddress:t.pubkey.toBase58()}})},{when:({programId:e})=>s(e),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{account:t}}=I(e,n);return{tokenAddress:t.pubkey.toBase58()}})},{when:({programId:e})=>s(e),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{account:t}}=T(e,n);return{tokenAddress:t.pubkey.toBase58()}})},{when:({programId:e})=>s(e),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{account:t}}=l(e,n);return{tokenAddress:t.pubkey.toBase58()}})},{when:({programId:e})=>s(e),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{account:t}}=A(e,n);return{tokenAddress:t.pubkey.toBase58()}})},{when:({programId:e})=>s(e),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{account:t}}=p(e,n);return{tokenAddress:t.pubkey.toBase58()}})},{when:({programId:e})=>s(e),decode:({instruction:e,programId:n})=>o(()=>{const{keys:{account:t}}=w(e,n);return{tokenAddress:t.pubkey.toBase58()}})},{when:({programId:e})=>e.equals(a)||e.equals(i)||e.equals(d),decode:()=>null}];export{z 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
|
|
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,
|
|
6
|
-
"names": ["ASSOCIATED_TOKEN_PROGRAM_ID", "decodeBurnCheckedInstruction", "decodeBurnInstruction", "decodeCloseAccountInstruction", "decodeFreezeAccountInstruction", "decodeInitializeAccount2Instruction", "decodeInitializeAccount3Instruction", "decodeInitializeAccountInstruction", "decodeInitializeImmutableOwnerInstruction", "decodeSyncNativeInstruction", "decodeThawAccountInstruction", "decodeTransferCheckedInstruction", "decodeTransferCheckedWithFeeInstruction", "decodeTransferInstruction", "
|
|
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 TxInspectorResult,\n} from \"@internal/app-binder/services/TransactionInspector\";\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 (with derivation fallback)\n {\n when: ({ programId }) => programId.equals(ASSOCIATED_TOKEN_PROGRAM_ID),\n decode: ({ ixMeta, message }) => {\n const byIdx = (n: number): PublicKey | null => {\n const i = ixMeta.accountKeyIndexes[n];\n return i !== undefined ? (message.allKeys[i] ?? null) : null;\n };\n\n const ataPk = byIdx(1);\n const ownerPk = byIdx(2);\n const mintPk = byIdx(3);\n if (!ownerPk || !mintPk || !ataPk) return null;\n\n return {\n createATA: {\n address: ataPk.toBase58(),\n mintAddress: mintPk.toBase58(),\n },\n };\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 },\n } = decodeTransferCheckedWithFeeInstruction(instruction, programId);\n return {\n tokenAddress: destination.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 },\n } = decodeTransferCheckedInstruction(instruction, programId);\n return {\n tokenAddress: destination.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 },\n } = decodeBurnCheckedInstruction(instruction, programId);\n return {\n tokenAddress: account.pubkey.toBase58(),\n };\n }),\n },\n {\n when: ({ programId }) => isTokenProgramId(programId),\n decode: ({ instruction, programId }) =>\n safe(() => {\n const {\n keys: { account },\n } = decodeBurnInstruction(instruction, programId);\n return {\n tokenAddress: account.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 },\n } = decodeFreezeAccountInstruction(instruction, programId);\n return {\n tokenAddress: account.pubkey.toBase58(),\n };\n }),\n },\n {\n when: ({ programId }) => isTokenProgramId(programId),\n decode: ({ instruction, programId }) =>\n safe(() => {\n const {\n keys: { account },\n } = decodeThawAccountInstruction(instruction, programId);\n return {\n tokenAddress: account.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: () => null,\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,oBAqBP,MAAMC,EAAoBC,GACxBA,EAAI,OAAOF,CAAgB,GAAKE,EAAI,OAAOH,CAAqB,EAE5DI,EAAWC,GAA0B,CACzC,GAAI,CACF,OAAOA,EAAG,CACZ,MAAQ,CACN,OAAO,IACT,CACF,EAEaC,EAAsB,CAEjC,CACE,KAAM,CAAC,CAAE,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xC,CACF,CAAC,CACL,EAGA,CACE,KAAM,CAAC,CAAE,UAAAX,CAAU,IAAML,EAAiBK,CAAS,EACnD,OAAQ,CAAC,CAAE,YAAAS,EAAa,UAAAT,CAAU,IAChCH,EAAK,IAAM,CACT,KAAM,CACJ,KAAM,CAAE,QAAAc,CAAQ,CAClB,EAAI5B,EAA+B0B,EAAaT,CAAS,EACzD,MAAO,CACL,aAAcW,EAAQ,OAAO,SAAS,CACxC,CACF,CAAC,CACL,EACA,CACE,KAAM,CAAC,CAAE,UAAAX,CAAU,IAAML,EAAiBK,CAAS,EACnD,OAAQ,CAAC,CAAE,YAAAS,EAAa,UAAAT,CAAU,IAChCH,EAAK,IAAM,CACT,KAAM,CACJ,KAAM,CAAE,QAAAc,CAAQ,CAClB,EAAItB,EAA6BoB,EAAaT,CAAS,EACvD,MAAO,CACL,aAAcW,EAAQ,OAAO,SAAS,CACxC,CACF,CAAC,CACL,EAGA,CACE,KAAM,CAAC,CAAE,UAAAX,CAAU,IACjBA,EAAU,OAAOrB,CAA2B,GAC5CqB,EAAU,OAAON,CAAgB,GACjCM,EAAU,OAAOP,CAAqB,EACxC,OAAQ,IAAM,IAChB,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", "byIdx", "n", "i", "ataPk", "ownerPk", "mintPk", "instruction", "destination", "account", "mint"]
|
|
7
7
|
}
|
|
@@ -6,7 +6,7 @@ import { type Signature } from "../model/Signature";
|
|
|
6
6
|
import { type Transaction } from "../model/Transaction";
|
|
7
7
|
import { type TransactionResolutionContext } from "../model/TransactionResolutionContext";
|
|
8
8
|
import { type SolanaAppErrorCodes } from "../../internal/app-binder/command/utils/SolanaApplicationErrors";
|
|
9
|
-
import { type TxInspectorResult } from "../../internal/app-binder/services/
|
|
9
|
+
import { type TxInspectorResult } from "../../internal/app-binder/services/TransactionInspector";
|
|
10
10
|
export type SignTransactionDAOutput = Signature;
|
|
11
11
|
export type SignTransactionDAInput = {
|
|
12
12
|
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,uBAAuB,EAC7B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,KAAK,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AAC5F,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,4DAA4D,CAAC;AACtG,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"SignTransactionDeviceActionTypes.d.ts","sourceRoot":"","sources":["../../../../src/api/app-binder/SignTransactionDeviceActionTypes.ts"],"names":[],"mappings":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,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"}
|
|
@@ -3,8 +3,9 @@ import { type Maybe } from "purify-ts";
|
|
|
3
3
|
import { type SignTransactionDAError, type SignTransactionDAInput, type SignTransactionDAIntermediateValue, type SignTransactionDAInternalState, type SignTransactionDAOutput } from "../../../api/app-binder/SignTransactionDeviceActionTypes";
|
|
4
4
|
import { type AppConfiguration } from "../../../api/model/AppConfiguration";
|
|
5
5
|
import { type Signature } from "../../../api/model/Signature";
|
|
6
|
+
import { type TransactionResolutionContext } from "../../../api/model/TransactionResolutionContext";
|
|
6
7
|
import { type SolanaAppErrorCodes } from "../../app-binder/command/utils/SolanaApplicationErrors";
|
|
7
|
-
import { type TxInspectorResult } from "../../app-binder/services/
|
|
8
|
+
import { type TxInspectorResult } from "../../app-binder/services/TransactionInspector";
|
|
8
9
|
import { type BuildTransactionContextTaskArgs, type SolanaBuildContextResult } from "../../app-binder/task/BuildTransactionContextTask";
|
|
9
10
|
import { type SolanaContextForDevice } from "../../app-binder/task/ProvideTransactionContextTask";
|
|
10
11
|
export type MachineDependencies = {
|
|
@@ -17,6 +18,7 @@ export type MachineDependencies = {
|
|
|
17
18
|
}) => Promise<Maybe<CommandErrorResult<SolanaAppErrorCodes>>>;
|
|
18
19
|
readonly inspectTransaction: (arg0: {
|
|
19
20
|
serializedTransaction: Uint8Array;
|
|
21
|
+
resolutionContext?: TransactionResolutionContext;
|
|
20
22
|
}) => Promise<TxInspectorResult>;
|
|
21
23
|
readonly signTransaction: (arg0: {
|
|
22
24
|
input: {
|
|
@@ -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;
|
|
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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AC,CAC3E,CAAC;CACH,CAAC;AAEF,qBAAa,2BAA4B,SAAQ,kBAAkB,CACjE,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,kCAAkC,EAClC,8BAA8B,CAC/B;IACC,gBAAgB,CACd,WAAW,EAAE,WAAW,GACvB,wBAAwB,CACzB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,kCAAkC,EAClC,8BAA8B,CAC/B;IA8VD,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,mBAAmB;CAgDnE"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type PublicKey } from "@solana/web3.js";
|
|
2
|
-
import { type TxInspectorResult } from "../../app-binder/services/utils/transactionDecoders";
|
|
3
2
|
export declare enum SolanaTransactionTypes {
|
|
4
3
|
STANDARD = "Standard",
|
|
5
4
|
SPL = "SPL"
|
|
@@ -13,6 +12,16 @@ export type NormalizedMessage = {
|
|
|
13
12
|
compiledInstructions: NormalizedCompiledIx[];
|
|
14
13
|
allKeys: PublicKey[];
|
|
15
14
|
};
|
|
15
|
+
export interface TxInspectorResult {
|
|
16
|
+
transactionType: SolanaTransactionTypes;
|
|
17
|
+
data: {
|
|
18
|
+
tokenAddress?: string;
|
|
19
|
+
createATA?: {
|
|
20
|
+
address: string;
|
|
21
|
+
mintAddress: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
}
|
|
16
25
|
export declare class TransactionInspector {
|
|
17
26
|
private readonly rawTransactionBytes;
|
|
18
27
|
private readonly tokenAddress?;
|
|
@@ -24,7 +33,7 @@ export declare class TransactionInspector {
|
|
|
24
33
|
inspectTransactionType(): Promise<TxInspectorResult>;
|
|
25
34
|
/**
|
|
26
35
|
* Normalise any tx (legacy or v0) into { compiledInstructions, allKeys }.
|
|
27
|
-
* For v0,
|
|
36
|
+
* For v0, auto-fetch looked-up addresses from ALT(s) via the baked-in connection.
|
|
28
37
|
*/
|
|
29
38
|
private normaliseMessage;
|
|
30
39
|
private tryDeserialiseVersioned;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionInspector.d.ts","sourceRoot":"","sources":["../../../../../src/internal/app-binder/services/TransactionInspector.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,SAAS,EAKf,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"TransactionInspector.d.ts","sourceRoot":"","sources":["../../../../../src/internal/app-binder/services/TransactionInspector.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,SAAS,EAKf,MAAM,iBAAiB,CAAC;AAQzB,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;AAEF,MAAM,WAAW,iBAAiB;IAChC,eAAe,EAAE,sBAAsB,CAAC;IACxC,IAAI,EAAE;QACJ,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,SAAS,CAAC,EAAE;YAAE,OAAO,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,MAAM,CAAA;SAAE,CAAC;KACtD,CAAC;CACH;AAcD,qBAAa,oBAAoB;IAE7B,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IACpC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;IAC9B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;gBAFV,mBAAmB,EAAE,UAAU,EAC/B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,YAAA,EAC5B,SAAS,CAAC,EAAE;QAC3B,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;KACrB,GAAG,IAAI,YAAA;IAGG,sBAAsB,IAAI,OAAO,CAAC,iBAAiB,CAAC;IA6EjE;;;OAGG;YACW,gBAAgB;IA0F9B,OAAO,CAAC,uBAAuB;CAchC"}
|
|
@@ -1,16 +1,5 @@
|
|
|
1
1
|
import { type PublicKey, type TransactionInstruction } from "@solana/web3.js";
|
|
2
|
-
import { type NormalizedCompiledIx, type NormalizedMessage, type
|
|
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
|
-
}
|
|
2
|
+
import { type NormalizedCompiledIx, type NormalizedMessage, type TxInspectorResult } from "../../../app-binder/services/TransactionInspector";
|
|
14
3
|
export type IxContext = {
|
|
15
4
|
programId: PublicKey;
|
|
16
5
|
ixMeta: NormalizedCompiledIx;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactionDecoders.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/app-binder/services/utils/transactionDecoders.ts"],"names":[],"mappings":"
|
|
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,iBAAiB,EACvB,MAAM,oDAAoD,CAAC;AAE5D,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,EAyM7B,CAAC"}
|