@ledgerhq/context-module 0.0.0-develop-20260812001624 → 0.0.0-develop-20260813001639
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/package.json +1 -1
- package/lib/cjs/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.js +1 -1
- package/lib/cjs/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.js.map +2 -2
- package/lib/cjs/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.js +1 -1
- package/lib/cjs/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.js.map +3 -3
- package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoDto.js +1 -1
- package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoDto.js.map +2 -2
- package/lib/cjs/src/shared/utils/deviceModelIdCodec.js +1 -1
- package/lib/cjs/src/shared/utils/deviceModelIdCodec.js.map +2 -2
- package/lib/cjs/src/shared/utils/deviceModelIdCodec.test.js +1 -1
- package/lib/cjs/src/shared/utils/deviceModelIdCodec.test.js.map +2 -2
- package/lib/esm/package.json +1 -1
- package/lib/esm/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.js +1 -1
- package/lib/esm/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.js.map +2 -2
- package/lib/esm/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.js +1 -1
- package/lib/esm/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.js.map +3 -3
- package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoDto.js +1 -1
- package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoDto.js.map +2 -2
- package/lib/esm/src/shared/utils/deviceModelIdCodec.js +1 -1
- package/lib/esm/src/shared/utils/deviceModelIdCodec.js.map +2 -2
- package/lib/esm/src/shared/utils/deviceModelIdCodec.test.js +1 -1
- package/lib/esm/src/shared/utils/deviceModelIdCodec.test.js.map +2 -2
- package/lib/types/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.d.ts.map +1 -1
- package/lib/types/src/modules/solana/instruction-info/data/InstructionInfoDto.d.ts +2 -2
- package/lib/types/src/modules/solana/instruction-info/data/InstructionInfoDto.d.ts.map +1 -1
- package/lib/types/src/shared/utils/deviceModelIdCodec.d.ts +2 -2
- package/lib/types/src/shared/utils/deviceModelIdCodec.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +4 -4
package/lib/cjs/package.json
CHANGED
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
59
59
|
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
|
|
60
60
|
},
|
|
61
|
-
"version": "0.0.0-develop-
|
|
61
|
+
"version": "0.0.0-develop-20260813001639"
|
|
62
62
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var l=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var M=(n,t)=>{for(var e in t)l(n,e,{get:t[e],enumerable:!0})},k=(n,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of S(t))!T.call(n,o)&&o!==e&&l(n,o,{get:()=>t[o],enumerable:!(i=C(t,o))||i.enumerable});return n};var b=n=>k(l({},"__esModule",{value:!0}),n),g=(n,t,e,i)=>{for(var o=i>1?void 0:i?C(t,e):t,s=n.length-1,r;s>=0;s--)(r=n[s])&&(o=(i?r(t,e,o):r(o))||o);return i&&o&&l(t,e,o),o},I=(n,t)=>(e,i)=>t(e,i,n);var P={};M(P,{HttpInstructionInfoDataSource:()=>u});module.exports=b(P);var f=require("inversify"),a=require("purify-ts"),E=require("../../../../config/di/configTypes"),m=require("../../../../modules/solana/model/SolanaTransactionScanChainId"),y=require("../../../../shared/network/di/networkTypes"),D=require("./InstructionInfoDto"),p=require("./InstructionInfoMapper");const x={"solana-mainnet":m.SolanaTransactionScanChainId.MAINNET,"solana-devnet":m.SolanaTransactionScanChainId.DEVNET,"solana-testnet":m.SolanaTransactionScanChainId.TESTNET};let u=class{constructor(t,e){this.config=t;this.http=e}async getInstructionInfo({programId:t,network:e}){const i=x[e]??m.SolanaTransactionScanChainId.MAINNET;let o;try{o=await this.http.get(`${this.config.cal.url}/solana_programs`,{params:{id:t,chain_id:i,output:"id,chain_id,instructions",ref:`branch:${this.config.cal.branch}`}})}catch(r){const d=r instanceof Error?r.message:String(r);return(0,a.Left)(new Error(`[ContextModule] HttpInstructionInfoDataSource: Failed to fetch instruction descriptors: ${d}`))}if(!Array.isArray(o)||o.length===0)return(0,a.Left)(new Error(`[ContextModule] HttpInstructionInfoDataSource: empty response for program ${t}`));const s=o.find(r=>r!=null&&typeof r=="object"&&r.id===t);return s===void 0?(0,a.Left)(new Error(`[ContextModule] HttpInstructionInfoDataSource: no descriptors for program ${t}`)):D.calInstructionProgramCodec.decode(s).caseOf({Left:r=>(0,a.Left)(new Error(`[ContextModule] HttpInstructionInfoDataSource: malformed descriptors for program ${t}: ${r}`)),Right:()=>{const r=this.config.cal.mode??"prod",d=s.instructions,h=Object.fromEntries(d.map(c=>[c.discriminator_hex,c])),w=Object.fromEntries(Object.entries(h).map(([c,N])=>[c,(0,p.toInstructionInfoPayload)(t,c,N,r)]));return(0,a.Right)({programId:t,descriptors:w,enumVariants:(0,p.toProgramEnumVariants)(h,r)})}})}};u=g([(0,f.injectable)(),I(0,(0,f.inject)(E.configTypes.Config)),I(1,(0,f.inject)(y.networkTypes.NetworkClient))],u);0&&(module.exports={HttpInstructionInfoDataSource});
|
|
1
|
+
"use strict";var l=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var M=(n,t)=>{for(var e in t)l(n,e,{get:t[e],enumerable:!0})},k=(n,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of S(t))!T.call(n,o)&&o!==e&&l(n,o,{get:()=>t[o],enumerable:!(i=C(t,o))||i.enumerable});return n};var b=n=>k(l({},"__esModule",{value:!0}),n),g=(n,t,e,i)=>{for(var o=i>1?void 0:i?C(t,e):t,s=n.length-1,r;s>=0;s--)(r=n[s])&&(o=(i?r(t,e,o):r(o))||o);return i&&o&&l(t,e,o),o},I=(n,t)=>(e,i)=>t(e,i,n);var P={};M(P,{HttpInstructionInfoDataSource:()=>u});module.exports=b(P);var f=require("inversify"),a=require("purify-ts"),E=require("../../../../config/di/configTypes"),m=require("../../../../modules/solana/model/SolanaTransactionScanChainId"),y=require("../../../../shared/network/di/networkTypes"),D=require("./InstructionInfoDto"),p=require("./InstructionInfoMapper");const x={"solana-mainnet":m.SolanaTransactionScanChainId.MAINNET,"solana-devnet":m.SolanaTransactionScanChainId.DEVNET,"solana-testnet":m.SolanaTransactionScanChainId.TESTNET};let u=class{constructor(t,e){this.config=t;this.http=e}async getInstructionInfo({programId:t,network:e}){const i=x[e]??m.SolanaTransactionScanChainId.MAINNET;let o;try{o=await this.http.get(`${this.config.cal.url}/solana_programs`,{params:{id:t,chain_id:i,output:"id,chain_id,instructions",ref:`branch:${this.config.cal.branch}`}})}catch(r){const d=r instanceof Error?r.message:String(r);return(0,a.Left)(new Error(`[ContextModule] HttpInstructionInfoDataSource: Failed to fetch instruction descriptors: ${d}`))}if(!Array.isArray(o)||o.length===0)return(0,a.Left)(new Error(`[ContextModule] HttpInstructionInfoDataSource: empty response for program ${t}`));const s=o.find(r=>r!=null&&typeof r=="object"&&r.id===t);return s===void 0?(0,a.Left)(new Error(`[ContextModule] HttpInstructionInfoDataSource: no descriptors for program ${t}`)):D.calInstructionProgramCodec.decode(s).caseOf({Left:r=>(0,a.Left)(new Error(`[ContextModule] HttpInstructionInfoDataSource: malformed descriptors for program ${t}: ${r}`)),Right:()=>{const r=this.config.cal.mode??"prod",d=s.instructions,h=Object.fromEntries(d.map(c=>[c.discriminator_hex??"",c])),w=Object.fromEntries(Object.entries(h).map(([c,N])=>[c,(0,p.toInstructionInfoPayload)(t,c,N,r)]));return(0,a.Right)({programId:t,descriptors:w,enumVariants:(0,p.toProgramEnumVariants)(h,r)})}})}};u=g([(0,f.injectable)(),I(0,(0,f.inject)(E.configTypes.Config)),I(1,(0,f.inject)(y.networkTypes.NetworkClient))],u);0&&(module.exports={HttpInstructionInfoDataSource});
|
|
2
2
|
//# sourceMappingURL=HttpInstructionInfoDataSource.js.map
|
package/lib/cjs/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.ts"],
|
|
4
|
-
"sourcesContent": ["import { DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { SolanaTransactionScanChainId } from \"@/modules/solana/model/SolanaTransactionScanChainId\";\nimport { networkTypes } from \"@/shared/network/di/networkTypes\";\n\nimport {\n GetInstructionInfoParams,\n InstructionInfoDataSource,\n InstructionInfoResult,\n} from \"./InstructionInfoDataSource\";\nimport {\n type CalInstructionDescriptorDto,\n calInstructionProgramCodec,\n type CalInstructionProgramDto,\n} from \"./InstructionInfoDto\";\nimport {\n type CalMode,\n toInstructionInfoPayload,\n toProgramEnumVariants,\n} from \"./InstructionInfoMapper\";\n\n// Maps the DMK network label to the numeric CAL `chain_id` (the extended\n// Solana network ids 900/901/902). Unknown labels fall back to mainnet.\nconst CHAIN_ID_BY_NETWORK: Record<string, SolanaTransactionScanChainId> = {\n \"solana-mainnet\": SolanaTransactionScanChainId.MAINNET,\n \"solana-devnet\": SolanaTransactionScanChainId.DEVNET,\n \"solana-testnet\": SolanaTransactionScanChainId.TESTNET,\n};\n\n@injectable()\nexport class HttpInstructionInfoDataSource\n implements InstructionInfoDataSource\n{\n constructor(\n @inject(configTypes.Config)\n private readonly config: ContextModuleServiceConfig,\n @inject(networkTypes.NetworkClient)\n private readonly http: DmkNetworkClient,\n ) {}\n\n public async getInstructionInfo({\n programId,\n network,\n }: GetInstructionInfoParams): Promise<Either<Error, InstructionInfoResult>> {\n const chainId =\n CHAIN_ID_BY_NETWORK[network] ?? SolanaTransactionScanChainId.MAINNET;\n let data: unknown;\n try {\n data = await this.http.get(`${this.config.cal.url}/solana_programs`, {\n params: {\n id: programId,\n chain_id: chainId,\n output: \"id,chain_id,instructions\",\n ref: `branch:${this.config.cal.branch}`,\n },\n });\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n return Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: Failed to fetch instruction descriptors: ${reason}`,\n ),\n );\n }\n\n if (!Array.isArray(data) || data.length === 0) {\n return Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: empty response for program ${programId}`,\n ),\n );\n }\n\n // Select the program object whose `id` matches the requested `programId`\n // (the response is an array, one object per requested id).\n const program = data.find(\n (entry): entry is { id: unknown } =>\n entry != null &&\n typeof entry === \"object\" &&\n (entry as { id?: unknown }).id === programId,\n );\n if (program === undefined) {\n return Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: no descriptors for program ${programId}`,\n ),\n );\n }\n\n // Validate the program shape so the mapper can dereference `descriptor` /\n // `enum_variants` without runtime-throwing on a malformed CAL payload. A\n // malformed program degrades to a per-program ERROR rather than rejecting\n // the batch. On success we transform each validated DTO into the core\n // payload so the loader never sees the CAL DTO shapes.\n return calInstructionProgramCodec\n .decode(program)\n .caseOf<Either<Error, InstructionInfoResult>>({\n Left: (error) =>\n Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: malformed descriptors for program ${programId}: ${error}`,\n ),\n ),\n Right: () => {\n const mode: CalMode = this.config.cal.mode ?? \"prod\";\n // The codec strips undeclared fields, so we key the original\n // (full) instruction objects by `discriminator_hex` \u2014 the cast is\n // justified now that the shape has been validated.\n const instructions = (program as CalInstructionProgramDto)\n .instructions;\n const descriptorsByDiscriminator: Record<\n string,\n CalInstructionDescriptorDto\n > = Object.fromEntries(\n instructions.map((dto) => [dto.discriminator_hex, dto]),\n );\n const mapped = Object.fromEntries(\n Object.entries(descriptorsByDiscriminator).map(\n ([discriminator, dto]) => [\n discriminator,\n toInstructionInfoPayload(programId, discriminator, dto, mode),\n ],\n ),\n );\n return Right({\n programId,\n descriptors: mapped,\n enumVariants: toProgramEnumVariants(\n descriptorsByDiscriminator,\n mode,\n ),\n });\n },\n });\n }\n}\n"],
|
|
5
|
-
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAmC,qBACnCC,EAAoC,qBAEpCC,EAA4B,mCAE5BC,EAA6C,+DAC7CC,EAA6B,4CAO7BC,EAIO,gCACPC,EAIO,mCAIP,MAAMC,EAAoE,CACxE,iBAAkB,+BAA6B,QAC/C,gBAAiB,+BAA6B,OAC9C,iBAAkB,+BAA6B,OACjD,EAGO,IAAMC,EAAN,KAEP,CACE,YAEmBC,EAEAC,EACjB,CAHiB,YAAAD,EAEA,UAAAC,CAChB,CAEH,MAAa,mBAAmB,CAC9B,UAAAC,EACA,QAAAC,CACF,EAA4E,CAC1E,MAAMC,EACJN,EAAoBK,CAAO,GAAK,+BAA6B,QAC/D,IAAIE,EACJ,GAAI,CACFA,EAAO,MAAM,KAAK,KAAK,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,mBAAoB,CACnE,OAAQ,CACN,GAAIH,EACJ,SAAUE,EACV,OAAQ,2BACR,IAAK,UAAU,KAAK,OAAO,IAAI,MAAM,EACvC,CACF,CAAC,CACH,OAASE,EAAO,CACd,MAAMC,EAASD,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,EACpE,SAAO,QACL,IAAI,MACF,2FAA2FC,CAAM,EACnG,CACF,CACF,CAEA,GAAI,CAAC,MAAM,QAAQF,CAAI,GAAKA,EAAK,SAAW,EAC1C,SAAO,QACL,IAAI,MACF,6EAA6EH,CAAS,EACxF,CACF,EAKF,MAAMM,EAAUH,EAAK,KAClBI,GACCA,GAAS,MACT,OAAOA,GAAU,UAChBA,EAA2B,KAAOP,CACvC,EACA,OAAIM,IAAY,UACP,QACL,IAAI,MACF,6EAA6EN,CAAS,EACxF,CACF,EAQK,6BACJ,OAAOM,CAAO,EACd,OAA6C,CAC5C,KAAOF,MACL,QACE,IAAI,MACF,oFAAoFJ,CAAS,KAAKI,CAAK,EACzG,CACF,EACF,MAAO,IAAM,CACX,MAAMI,EAAgB,KAAK,OAAO,IAAI,MAAQ,
|
|
4
|
+
"sourcesContent": ["import { DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { SolanaTransactionScanChainId } from \"@/modules/solana/model/SolanaTransactionScanChainId\";\nimport { networkTypes } from \"@/shared/network/di/networkTypes\";\n\nimport {\n GetInstructionInfoParams,\n InstructionInfoDataSource,\n InstructionInfoResult,\n} from \"./InstructionInfoDataSource\";\nimport {\n type CalInstructionDescriptorDto,\n calInstructionProgramCodec,\n type CalInstructionProgramDto,\n} from \"./InstructionInfoDto\";\nimport {\n type CalMode,\n toInstructionInfoPayload,\n toProgramEnumVariants,\n} from \"./InstructionInfoMapper\";\n\n// Maps the DMK network label to the numeric CAL `chain_id` (the extended\n// Solana network ids 900/901/902). Unknown labels fall back to mainnet.\nconst CHAIN_ID_BY_NETWORK: Record<string, SolanaTransactionScanChainId> = {\n \"solana-mainnet\": SolanaTransactionScanChainId.MAINNET,\n \"solana-devnet\": SolanaTransactionScanChainId.DEVNET,\n \"solana-testnet\": SolanaTransactionScanChainId.TESTNET,\n};\n\n@injectable()\nexport class HttpInstructionInfoDataSource\n implements InstructionInfoDataSource\n{\n constructor(\n @inject(configTypes.Config)\n private readonly config: ContextModuleServiceConfig,\n @inject(networkTypes.NetworkClient)\n private readonly http: DmkNetworkClient,\n ) {}\n\n public async getInstructionInfo({\n programId,\n network,\n }: GetInstructionInfoParams): Promise<Either<Error, InstructionInfoResult>> {\n const chainId =\n CHAIN_ID_BY_NETWORK[network] ?? SolanaTransactionScanChainId.MAINNET;\n let data: unknown;\n try {\n data = await this.http.get(`${this.config.cal.url}/solana_programs`, {\n params: {\n id: programId,\n chain_id: chainId,\n output: \"id,chain_id,instructions\",\n ref: `branch:${this.config.cal.branch}`,\n },\n });\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n return Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: Failed to fetch instruction descriptors: ${reason}`,\n ),\n );\n }\n\n if (!Array.isArray(data) || data.length === 0) {\n return Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: empty response for program ${programId}`,\n ),\n );\n }\n\n // Select the program object whose `id` matches the requested `programId`\n // (the response is an array, one object per requested id).\n const program = data.find(\n (entry): entry is { id: unknown } =>\n entry != null &&\n typeof entry === \"object\" &&\n (entry as { id?: unknown }).id === programId,\n );\n if (program === undefined) {\n return Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: no descriptors for program ${programId}`,\n ),\n );\n }\n\n // Validate the program shape so the mapper can dereference `descriptor` /\n // `enum_variants` without runtime-throwing on a malformed CAL payload. A\n // malformed program degrades to a per-program ERROR rather than rejecting\n // the batch. On success we transform each validated DTO into the core\n // payload so the loader never sees the CAL DTO shapes.\n return calInstructionProgramCodec\n .decode(program)\n .caseOf<Either<Error, InstructionInfoResult>>({\n Left: (error) =>\n Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: malformed descriptors for program ${programId}: ${error}`,\n ),\n ),\n Right: () => {\n const mode: CalMode = this.config.cal.mode ?? \"prod\";\n // The codec strips undeclared fields, so we key the original\n // (full) instruction objects by `discriminator_hex` \u2014 the cast is\n // justified now that the shape has been validated. A descriptor\n // without a discriminator (single-instruction programs such as SPL\n // Memo) is keyed under the empty string.\n const instructions = (program as CalInstructionProgramDto)\n .instructions;\n const descriptorsByDiscriminator: Record<\n string,\n CalInstructionDescriptorDto\n > = Object.fromEntries(\n instructions.map((dto) => [dto.discriminator_hex ?? \"\", dto]),\n );\n const mapped = Object.fromEntries(\n Object.entries(descriptorsByDiscriminator).map(\n ([discriminator, dto]) => [\n discriminator,\n toInstructionInfoPayload(programId, discriminator, dto, mode),\n ],\n ),\n );\n return Right({\n programId,\n descriptors: mapped,\n enumVariants: toProgramEnumVariants(\n descriptorsByDiscriminator,\n mode,\n ),\n });\n },\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAmC,qBACnCC,EAAoC,qBAEpCC,EAA4B,mCAE5BC,EAA6C,+DAC7CC,EAA6B,4CAO7BC,EAIO,gCACPC,EAIO,mCAIP,MAAMC,EAAoE,CACxE,iBAAkB,+BAA6B,QAC/C,gBAAiB,+BAA6B,OAC9C,iBAAkB,+BAA6B,OACjD,EAGO,IAAMC,EAAN,KAEP,CACE,YAEmBC,EAEAC,EACjB,CAHiB,YAAAD,EAEA,UAAAC,CAChB,CAEH,MAAa,mBAAmB,CAC9B,UAAAC,EACA,QAAAC,CACF,EAA4E,CAC1E,MAAMC,EACJN,EAAoBK,CAAO,GAAK,+BAA6B,QAC/D,IAAIE,EACJ,GAAI,CACFA,EAAO,MAAM,KAAK,KAAK,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,mBAAoB,CACnE,OAAQ,CACN,GAAIH,EACJ,SAAUE,EACV,OAAQ,2BACR,IAAK,UAAU,KAAK,OAAO,IAAI,MAAM,EACvC,CACF,CAAC,CACH,OAASE,EAAO,CACd,MAAMC,EAASD,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,EACpE,SAAO,QACL,IAAI,MACF,2FAA2FC,CAAM,EACnG,CACF,CACF,CAEA,GAAI,CAAC,MAAM,QAAQF,CAAI,GAAKA,EAAK,SAAW,EAC1C,SAAO,QACL,IAAI,MACF,6EAA6EH,CAAS,EACxF,CACF,EAKF,MAAMM,EAAUH,EAAK,KAClBI,GACCA,GAAS,MACT,OAAOA,GAAU,UAChBA,EAA2B,KAAOP,CACvC,EACA,OAAIM,IAAY,UACP,QACL,IAAI,MACF,6EAA6EN,CAAS,EACxF,CACF,EAQK,6BACJ,OAAOM,CAAO,EACd,OAA6C,CAC5C,KAAOF,MACL,QACE,IAAI,MACF,oFAAoFJ,CAAS,KAAKI,CAAK,EACzG,CACF,EACF,MAAO,IAAM,CACX,MAAMI,EAAgB,KAAK,OAAO,IAAI,MAAQ,OAMxCC,EAAgBH,EACnB,aACGI,EAGF,OAAO,YACTD,EAAa,IAAKE,GAAQ,CAACA,EAAI,mBAAqB,GAAIA,CAAG,CAAC,CAC9D,EACMC,EAAS,OAAO,YACpB,OAAO,QAAQF,CAA0B,EAAE,IACzC,CAAC,CAACG,EAAeF,CAAG,IAAM,CACxBE,KACA,4BAAyBb,EAAWa,EAAeF,EAAKH,CAAI,CAC9D,CACF,CACF,EACA,SAAO,SAAM,CACX,UAAAR,EACA,YAAaY,EACb,gBAAc,yBACZF,EACAF,CACF,CACF,CAAC,CACH,CACF,CAAC,CACL,CACF,EA3GaX,EAANiB,EAAA,IADN,cAAW,EAKPC,EAAA,eAAO,cAAY,MAAM,GAEzBA,EAAA,eAAO,eAAa,aAAa,IANzBlB",
|
|
6
6
|
"names": ["HttpInstructionInfoDataSource_exports", "__export", "HttpInstructionInfoDataSource", "__toCommonJS", "import_inversify", "import_purify_ts", "import_configTypes", "import_SolanaTransactionScanChainId", "import_networkTypes", "import_InstructionInfoDto", "import_InstructionInfoMapper", "CHAIN_ID_BY_NETWORK", "HttpInstructionInfoDataSource", "config", "http", "programId", "network", "chainId", "data", "error", "reason", "program", "entry", "mode", "instructions", "descriptorsByDiscriminator", "dto", "mapped", "discriminator", "__decorateClass", "__decorateParam"]
|
|
7
7
|
}
|
package/lib/cjs/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var a=require("purify-ts"),t=require("vitest"),i=require("../../../../modules/solana/model/SolanaTransactionScanChainId"),
|
|
1
|
+
"use strict";var a=require("purify-ts"),t=require("vitest"),i=require("../../../../modules/solana/model/SolanaTransactionScanChainId"),d=require("./HttpInstructionInfoDataSource");(0,t.describe)("HttpInstructionInfoDataSource",()=>{let r,o;const e="11111111111111111111111111111111",s="solana-mainnet",l={cal:{url:"https://global.api.prd.ledger.com/cal/v1",mode:"prod",branch:"main"}},c=[{id:e,chain_id:i.SolanaTransactionScanChainId.MAINNET,instructions:[{discriminator_hex:"00000000",instruction_name:"createAccount",descriptor:{data:"00010101",signatures:{prod:"prodsig",test:"testsig"}},display_fields:[],value_flow_ports:[],hide_rules:[],account_resets:[]}]}];(0,t.beforeEach)(()=>{t.vi.clearAllMocks(),o={get:t.vi.fn()},r=new d.HttpInstructionInfoDataSource(l,o)}),(0,t.it)("calls CAL /solana_programs with id, chain_id and output params",async()=>{o.get.mockResolvedValue(c),await r.getInstructionInfo({programId:e,network:s}),(0,t.expect)(o.get).toHaveBeenCalledTimes(1),(0,t.expect)(o.get).toHaveBeenCalledWith("https://global.api.prd.ledger.com/cal/v1/solana_programs",{params:{id:e,chain_id:i.SolanaTransactionScanChainId.MAINNET,output:"id,chain_id,instructions",ref:"branch:main"}})}),(0,t.it)("maps devnet/testnet networks to their numeric chain ids",async()=>{o.get.mockResolvedValue(c),await r.getInstructionInfo({programId:e,network:"solana-devnet"}),(0,t.expect)(o.get).toHaveBeenCalledWith("https://global.api.prd.ledger.com/cal/v1/solana_programs",t.expect.objectContaining({params:t.expect.objectContaining({chain_id:901})}))}),(0,t.it)("returns Right with each descriptor transformed into the core payload on success",async()=>{o.get.mockResolvedValue(c);const n=await r.getInstructionInfo({programId:e,network:s});(0,t.expect)(n).toEqual((0,a.Right)({programId:e,descriptors:{"00000000":(0,a.Right)({programId:e,discriminator:"00000000",instructionInfo:{data:"00010101",signature:"prodsig"},substructures:[],enumVariants:[],idlDescriptor:{typePool:[],rootType:0},mintAssociations:[],valueFlowPorts:[],accountResets:[],displayFields:[]})},enumVariants:[]}))}),(0,t.it)("keys a descriptor without `discriminator_hex` under the empty string",async()=>{o.get.mockResolvedValue([{id:e,chain_id:i.SolanaTransactionScanChainId.MAINNET,instructions:[{instruction_name:"addMemo",descriptor:{data:"00010101",signatures:{prod:"prodsig",test:"testsig"}}}]}]);const n=await r.getInstructionInfo({programId:e,network:s});(0,t.expect)(n.isRight()).toBe(!0);const{descriptors:u}=n.unsafeCoerce();(0,t.expect)(Object.keys(u)).toEqual([""]),(0,t.expect)(u[""].unsafeCoerce()).toEqual(t.expect.objectContaining({programId:e,discriminator:"",instructionInfo:{data:"00010101",signature:"prodsig"}}))}),(0,t.it)("returns Left when the response array is empty",async()=>{o.get.mockResolvedValue([]);const n=await r.getInstructionInfo({programId:e,network:s});(0,t.expect)(n).toEqual((0,a.Left)(new Error(`[ContextModule] HttpInstructionInfoDataSource: empty response for program ${e}`)))}),(0,t.it)("returns Left when no program object matches the requested programId",async()=>{o.get.mockResolvedValue([{id:"OtherProgram",chain_id:i.SolanaTransactionScanChainId.MAINNET,instructions:[]}]);const n=await r.getInstructionInfo({programId:e,network:s});(0,t.expect)(n).toEqual((0,a.Left)(new Error(`[ContextModule] HttpInstructionInfoDataSource: no descriptors for program ${e}`)))}),(0,t.it)("returns Left (not a throw) when an instruction descriptor is malformed",async()=>{o.get.mockResolvedValue([{id:e,chain_id:i.SolanaTransactionScanChainId.MAINNET,instructions:[{discriminator_hex:"00000000"}]}]);const n=await r.getInstructionInfo({programId:e,network:s});(0,t.expect)(n.isLeft()).toBe(!0),(0,t.expect)(n.extract().message).toMatch(new RegExp(String.raw`\[ContextModule\] HttpInstructionInfoDataSource: malformed descriptors for program ${e}:`))}),(0,t.it)("returns Left when the HTTP client throws",async()=>{o.get.mockRejectedValue(new Error("network"));const n=await r.getInstructionInfo({programId:e,network:s});(0,t.expect)(n).toEqual((0,a.Left)(new Error("[ContextModule] HttpInstructionInfoDataSource: Failed to fetch instruction descriptors: network")))})});
|
|
2
2
|
//# sourceMappingURL=HttpInstructionInfoDataSource.test.js.map
|
package/lib/cjs/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { type DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\nimport { beforeEach, describe, expect, it, vi } from \"vitest\";\n\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { SolanaTransactionScanChainId } from \"@/modules/solana/model/SolanaTransactionScanChainId\";\n\nimport { HttpInstructionInfoDataSource } from \"./HttpInstructionInfoDataSource\";\nimport { type InstructionInfoDataSource } from \"./InstructionInfoDataSource\";\nimport { type CalInstructionInfoResponseDto } from \"./InstructionInfoDto\";\n\ndescribe(\"HttpInstructionInfoDataSource\", () => {\n let datasource: InstructionInfoDataSource;\n let httpMock: { get: ReturnType<typeof vi.fn> };\n const programId = \"11111111111111111111111111111111\";\n const network = \"solana-mainnet\";\n const config: ContextModuleServiceConfig = {\n cal: {\n url: \"https://global.api.prd.ledger.com/cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n } as ContextModuleServiceConfig;\n\n const successResponse: CalInstructionInfoResponseDto = [\n {\n id: programId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: [\n {\n discriminator_hex: \"00000000\",\n instruction_name: \"createAccount\",\n descriptor: {\n data: \"00010101\",\n signatures: { prod: \"prodsig\", test: \"testsig\" },\n },\n display_fields: [],\n value_flow_ports: [],\n hide_rules: [],\n account_resets: [],\n },\n ],\n },\n ];\n\n beforeEach(() => {\n vi.clearAllMocks();\n httpMock = { get: vi.fn() };\n datasource = new HttpInstructionInfoDataSource(\n config,\n httpMock as unknown as DmkNetworkClient,\n );\n });\n\n it(\"calls CAL /solana_programs with id, chain_id and output params\", async () => {\n httpMock.get.mockResolvedValue(successResponse);\n\n await datasource.getInstructionInfo({ programId, network });\n\n expect(httpMock.get).toHaveBeenCalledTimes(1);\n expect(httpMock.get).toHaveBeenCalledWith(\n \"https://global.api.prd.ledger.com/cal/v1/solana_programs\",\n {\n params: {\n id: programId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n output: \"id,chain_id,instructions\",\n ref: \"branch:main\",\n },\n },\n );\n });\n\n it(\"maps devnet/testnet networks to their numeric chain ids\", async () => {\n httpMock.get.mockResolvedValue(successResponse);\n\n await datasource.getInstructionInfo({\n programId,\n network: \"solana-devnet\",\n });\n\n expect(httpMock.get).toHaveBeenCalledWith(\n \"https://global.api.prd.ledger.com/cal/v1/solana_programs\",\n expect.objectContaining({\n params: expect.objectContaining({ chain_id: 901 }),\n }),\n );\n });\n\n it(\"returns Right with each descriptor transformed into the core payload on success\", async () => {\n httpMock.get.mockResolvedValue(successResponse);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result).toEqual(\n Right({\n programId,\n descriptors: {\n \"00000000\": Right({\n programId,\n discriminator: \"00000000\",\n instructionInfo: { data: \"00010101\", signature: \"prodsig\" },\n substructures: [],\n enumVariants: [],\n idlDescriptor: { typePool: [], rootType: 0 },\n mintAssociations: [],\n valueFlowPorts: [],\n accountResets: [],\n displayFields: [],\n }),\n },\n enumVariants: [],\n }),\n );\n });\n\n it(\"returns Left when the response array is empty\", async () => {\n httpMock.get.mockResolvedValue([]);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result).toEqual(\n Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: empty response for program ${programId}`,\n ),\n ),\n );\n });\n\n it(\"returns Left when no program object matches the requested programId\", async () => {\n httpMock.get.mockResolvedValue([\n {\n id: \"OtherProgram\",\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: [],\n },\n ]);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result).toEqual(\n Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: no descriptors for program ${programId}`,\n ),\n ),\n );\n });\n\n it(\"returns Left (not a throw) when an instruction descriptor is malformed\", async () => {\n // `descriptor` missing on the instruction \u2014 would crash the loader if the\n // datasource handed it through unvalidated.\n httpMock.get.mockResolvedValue([\n {\n id: programId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: [{ discriminator_hex: \"00000000\" }],\n },\n ]);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result.isLeft()).toBe(true);\n expect((result.extract() as Error).message).toMatch(\n new RegExp(\n String.raw`\\[ContextModule\\] HttpInstructionInfoDataSource: malformed descriptors for program ${programId}:`,\n ),\n );\n });\n\n it(\"returns Left when the HTTP client throws\", async () => {\n httpMock.get.mockRejectedValue(new Error(\"network\"));\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpInstructionInfoDataSource: Failed to fetch instruction descriptors: network\",\n ),\n ),\n );\n });\n});\n"],
|
|
5
|
-
"mappings": "aACA,IAAAA,EAA4B,qBAC5BC,EAAqD,kBAGrDC,EAA6C,+DAE7CC,EAA8C,8CAI9C,YAAS,gCAAiC,IAAM,CAC9C,IAAIC,EACAC,EACJ,MAAMC,EAAY,mCACZC,EAAU,iBACVC,EAAqC,CACzC,IAAK,CACH,IAAK,2CACL,KAAM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AS,IAAI,kBAAkB,IAAI,MAAM,SAAS,CAAC,EAEnD,MAAMK,EAAS,MAAMN,EAAW,mBAAmB,CAAE,UAAAE,EAAW,QAAAC,CAAQ,CAAC,KAEzE,UAAOG,CAAM,EAAE,WACb,QACE,IAAI,MACF,iGACF,CACF,CACF,CACF,CAAC,CACH,CAAC",
|
|
6
|
-
"names": ["import_purify_ts", "import_vitest", "import_SolanaTransactionScanChainId", "import_HttpInstructionInfoDataSource", "datasource", "httpMock", "programId", "network", "config", "successResponse", "result"]
|
|
4
|
+
"sourcesContent": ["import { type DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\nimport { beforeEach, describe, expect, it, vi } from \"vitest\";\n\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { SolanaTransactionScanChainId } from \"@/modules/solana/model/SolanaTransactionScanChainId\";\n\nimport { HttpInstructionInfoDataSource } from \"./HttpInstructionInfoDataSource\";\nimport { type InstructionInfoDataSource } from \"./InstructionInfoDataSource\";\nimport { type CalInstructionInfoResponseDto } from \"./InstructionInfoDto\";\n\ndescribe(\"HttpInstructionInfoDataSource\", () => {\n let datasource: InstructionInfoDataSource;\n let httpMock: { get: ReturnType<typeof vi.fn> };\n const programId = \"11111111111111111111111111111111\";\n const network = \"solana-mainnet\";\n const config: ContextModuleServiceConfig = {\n cal: {\n url: \"https://global.api.prd.ledger.com/cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n } as ContextModuleServiceConfig;\n\n const successResponse: CalInstructionInfoResponseDto = [\n {\n id: programId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: [\n {\n discriminator_hex: \"00000000\",\n instruction_name: \"createAccount\",\n descriptor: {\n data: \"00010101\",\n signatures: { prod: \"prodsig\", test: \"testsig\" },\n },\n display_fields: [],\n value_flow_ports: [],\n hide_rules: [],\n account_resets: [],\n },\n ],\n },\n ];\n\n beforeEach(() => {\n vi.clearAllMocks();\n httpMock = { get: vi.fn() };\n datasource = new HttpInstructionInfoDataSource(\n config,\n httpMock as unknown as DmkNetworkClient,\n );\n });\n\n it(\"calls CAL /solana_programs with id, chain_id and output params\", async () => {\n httpMock.get.mockResolvedValue(successResponse);\n\n await datasource.getInstructionInfo({ programId, network });\n\n expect(httpMock.get).toHaveBeenCalledTimes(1);\n expect(httpMock.get).toHaveBeenCalledWith(\n \"https://global.api.prd.ledger.com/cal/v1/solana_programs\",\n {\n params: {\n id: programId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n output: \"id,chain_id,instructions\",\n ref: \"branch:main\",\n },\n },\n );\n });\n\n it(\"maps devnet/testnet networks to their numeric chain ids\", async () => {\n httpMock.get.mockResolvedValue(successResponse);\n\n await datasource.getInstructionInfo({\n programId,\n network: \"solana-devnet\",\n });\n\n expect(httpMock.get).toHaveBeenCalledWith(\n \"https://global.api.prd.ledger.com/cal/v1/solana_programs\",\n expect.objectContaining({\n params: expect.objectContaining({ chain_id: 901 }),\n }),\n );\n });\n\n it(\"returns Right with each descriptor transformed into the core payload on success\", async () => {\n httpMock.get.mockResolvedValue(successResponse);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result).toEqual(\n Right({\n programId,\n descriptors: {\n \"00000000\": Right({\n programId,\n discriminator: \"00000000\",\n instructionInfo: { data: \"00010101\", signature: \"prodsig\" },\n substructures: [],\n enumVariants: [],\n idlDescriptor: { typePool: [], rootType: 0 },\n mintAssociations: [],\n valueFlowPorts: [],\n accountResets: [],\n displayFields: [],\n }),\n },\n enumVariants: [],\n }),\n );\n });\n\n it(\"keys a descriptor without `discriminator_hex` under the empty string\", async () => {\n // Single-instruction programs (e.g. SPL Memo `addMemo`) genuinely have no\n // discriminator, so CAL omits the field.\n httpMock.get.mockResolvedValue([\n {\n id: programId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: [\n {\n instruction_name: \"addMemo\",\n descriptor: {\n data: \"00010101\",\n signatures: { prod: \"prodsig\", test: \"testsig\" },\n },\n },\n ],\n },\n ]);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result.isRight()).toBe(true);\n const { descriptors } = result.unsafeCoerce();\n expect(Object.keys(descriptors)).toEqual([\"\"]);\n expect(descriptors[\"\"]!.unsafeCoerce()).toEqual(\n expect.objectContaining({\n programId,\n discriminator: \"\",\n instructionInfo: { data: \"00010101\", signature: \"prodsig\" },\n }),\n );\n });\n\n it(\"returns Left when the response array is empty\", async () => {\n httpMock.get.mockResolvedValue([]);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result).toEqual(\n Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: empty response for program ${programId}`,\n ),\n ),\n );\n });\n\n it(\"returns Left when no program object matches the requested programId\", async () => {\n httpMock.get.mockResolvedValue([\n {\n id: \"OtherProgram\",\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: [],\n },\n ]);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result).toEqual(\n Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: no descriptors for program ${programId}`,\n ),\n ),\n );\n });\n\n it(\"returns Left (not a throw) when an instruction descriptor is malformed\", async () => {\n // `descriptor` missing on the instruction \u2014 would crash the loader if the\n // datasource handed it through unvalidated.\n httpMock.get.mockResolvedValue([\n {\n id: programId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: [{ discriminator_hex: \"00000000\" }],\n },\n ]);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result.isLeft()).toBe(true);\n expect((result.extract() as Error).message).toMatch(\n new RegExp(\n String.raw`\\[ContextModule\\] HttpInstructionInfoDataSource: malformed descriptors for program ${programId}:`,\n ),\n );\n });\n\n it(\"returns Left when the HTTP client throws\", async () => {\n httpMock.get.mockRejectedValue(new Error(\"network\"));\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpInstructionInfoDataSource: Failed to fetch inst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AEjC,MAAMK,EAAS,MAAMN,EAAW,mBAAmB,CAAE,UAAAE,EAAW,QAAAC,CAAQ,CAAC,KAEzE,UAAOG,CAAM,EAAE,WACb,QACE,IAAI,MACF,6EAA6EJ,CAAS,EACxF,CACF,CACF,CACF,CAAC,KAED,MAAG,sEAAuE,SAAY,CACpFD,EAAS,IAAI,kBAAkB,CAC7B,CACE,GAAI,eACJ,SAAU,+BAA6B,QACvC,aAAc,CAAC,CACjB,CACF,CAAC,EAED,MAAMK,EAAS,MAAMN,EAAW,mBAAmB,CAAE,UAAAE,EAAW,QAAAC,CAAQ,CAAC,KAEzE,UAAOG,CAAM,EAAE,WACb,QACE,IAAI,MACF,6EAA6EJ,CAAS,EACxF,CACF,CACF,CACF,CAAC,KAED,MAAG,yEAA0E,SAAY,CAGvFD,EAAS,IAAI,kBAAkB,CAC7B,CACE,GAAIC,EACJ,SAAU,+BAA6B,QACvC,aAAc,CAAC,CAAE,kBAAmB,UAAW,CAAC,CAClD,CACF,CAAC,EAED,MAAMI,EAAS,MAAMN,EAAW,mBAAmB,CAAE,UAAAE,EAAW,QAAAC,CAAQ,CAAC,KAEzE,UAAOG,EAAO,OAAO,CAAC,EAAE,KAAK,EAAI,KACjC,UAAQA,EAAO,QAAQ,EAAY,OAAO,EAAE,QAC1C,IAAI,OACF,OAAO,yFAAyFJ,CAAS,GAC3G,CACF,CACF,CAAC,KAED,MAAG,2CAA4C,SAAY,CACzDD,EAAS,IAAI,kBAAkB,IAAI,MAAM,SAAS,CAAC,EAEnD,MAAMK,EAAS,MAAMN,EAAW,mBAAmB,CAAE,UAAAE,EAAW,QAAAC,CAAQ,CAAC,KAEzE,UAAOG,CAAM,EAAE,WACb,QACE,IAAI,MACF,iGACF,CACF,CACF,CACF,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_purify_ts", "import_vitest", "import_SolanaTransactionScanChainId", "import_HttpInstructionInfoDataSource", "datasource", "httpMock", "programId", "network", "config", "successResponse", "result", "descriptors"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var d=(r,e)=>{for(var o in e)a(r,o,{get:e[o],enumerable:!0})},_=(r,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of l(e))!p.call(r,n)&&n!==o&&a(r,n,{get:()=>e[n],enumerable:!(s=u(e,n))||s.enumerable});return r};var C=r=>_(a({},"__esModule",{value:!0}),r);var b={};d(b,{calInstructionProgramCodec:()=>y});module.exports=C(b);var t=require("purify-ts");const D=t.Codec.interface({prod:(0,t.optional)(t.string),test:(0,t.optional)(t.string)}),c=t.Codec.interface({data:t.string,signatures:D}),g=t.Codec.interface({descriptor:c}),i=t.Codec.interface({descriptor:t.string}),m=t.Codec.interface({discriminator_hex:t.string,descriptor:c,enum_variants:(0,t.optional)((0,t.record)(t.string,(0,t.record)(t.string,g))),display_fields:(0,t.optional)((0,t.array)(i)),value_flow_ports:(0,t.optional)((0,t.array)(i)),hide_rules:(0,t.optional)((0,t.array)(i)),account_resets:(0,t.optional)((0,t.array)(i))}),y=t.Codec.interface({id:t.string,chain_id:t.number,instructions:(0,t.array)(m)});0&&(module.exports={calInstructionProgramCodec});
|
|
1
|
+
"use strict";var a=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var d=(r,e)=>{for(var o in e)a(r,o,{get:e[o],enumerable:!0})},_=(r,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of l(e))!p.call(r,n)&&n!==o&&a(r,n,{get:()=>e[n],enumerable:!(s=u(e,n))||s.enumerable});return r};var C=r=>_(a({},"__esModule",{value:!0}),r);var b={};d(b,{calInstructionProgramCodec:()=>y});module.exports=C(b);var t=require("purify-ts");const D=t.Codec.interface({prod:(0,t.optional)(t.string),test:(0,t.optional)(t.string)}),c=t.Codec.interface({data:t.string,signatures:D}),g=t.Codec.interface({descriptor:c}),i=t.Codec.interface({descriptor:t.string}),m=t.Codec.interface({discriminator_hex:(0,t.optional)(t.string),descriptor:c,enum_variants:(0,t.optional)((0,t.record)(t.string,(0,t.record)(t.string,g))),display_fields:(0,t.optional)((0,t.array)(i)),value_flow_ports:(0,t.optional)((0,t.array)(i)),hide_rules:(0,t.optional)((0,t.array)(i)),account_resets:(0,t.optional)((0,t.array)(i))}),y=t.Codec.interface({id:t.string,chain_id:t.number,instructions:(0,t.array)(m)});0&&(module.exports={calInstructionProgramCodec});
|
|
2
2
|
//# sourceMappingURL=InstructionInfoDto.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/modules/solana/instruction-info/data/InstructionInfoDto.ts"],
|
|
4
|
-
"sourcesContent": ["// DTO + codecs for the CAL instruction-descriptors response (one object per\n// `programId`, wrapped in a JSON array).\n//\n// The hand-written types describe the consumed shape (with genuinely optional\n// `?:` fields); the codecs below validate that shape at runtime so\n// `HttpInstructionInfoDataSource` can hand the loaders a payload they can\n// dereference without runtime-throwing on a malformed descriptor.\n\nimport { array, Codec, number, optional, record, string } from \"purify-ts\";\n\nexport type CalSignatures = {\n prod?: string;\n test?: string;\n};\n\nexport type CalSignedDescriptorDto = {\n data: string;\n signatures: CalSignatures;\n};\n\n// Decoded CAL JSON shapes (snake_case mirrors the CAL response) that drive\n// host-side requirement building.\n\nexport type CalValueDto = {\n source: string;\n account_index?: number;\n data?: string;\n path?: { steps: number[] };\n};\n\nexport type CalTokenValueDto = {\n kind: string;\n value?: CalValueDto;\n account_index?: number;\n};\n\nexport type CalMintAssociationDto = {\n account_index: number;\n mint_index: number;\n};\n\nexport type CalTypePoolEntryDto = {\n index: number;\n kind: string;\n refs?: number[];\n size?: number;\n encoding?: number;\n len_kind?: string;\n flag_kind?: string;\n sentinel?: string;\n disc_kind?: string;\n total_variants?: number;\n enum_id?: string;\n};\n\nexport type CalEnumVariantDto = {\n variant_name: string;\n payload_kind?: string;\n descriptor: CalSignedDescriptorDto;\n};\n\n/** A substructure CAL serves only as opaque TLV (e.g. HIDE_RULE). */\nexport type CalSubstructureDto = {\n descriptor: string;\n};\n\nexport type CalValueFlowPortDto = CalSubstructureDto & {\n account_indices: number[];\n optional_account_strategy?: string;\n token_value: CalTokenValueDto;\n};\n\nexport type CalAccountResetDto = CalSubstructureDto & {\n account_index?: number;\n require_pre_balance_zero?: boolean;\n};\n\nexport type CalDisplayFieldDto = CalSubstructureDto & {\n name?: string;\n param?: { type: string; value?: CalValueDto; token?: CalValueDto };\n};\n\nexport type CalInstructionDescriptorDto = {\n discriminator_hex
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gCAAAE,IAAA,eAAAC,EAAAH,GAQA,IAAAI,EAA+D,qBA0G/D,MAAMC,EAAqB,QAAM,UAAU,CACzC,QAAM,YAAS,QAAM,EACrB,QAAM,YAAS,QAAM,CACvB,CAAC,EAEKC,EAA2B,QAAM,UAAU,CAC/C,KAAM,SACN,WAAYD,CACd,CAAC,EAEKE,EAAsB,QAAM,UAAU,CAC1C,WAAYD,CACd,CAAC,EAEKE,EAAuB,QAAM,UAAU,CAC3C,WAAY,QACd,CAAC,EAEKC,EAAgC,QAAM,UAAU,CACpD,
|
|
4
|
+
"sourcesContent": ["// DTO + codecs for the CAL instruction-descriptors response (one object per\n// `programId`, wrapped in a JSON array).\n//\n// The hand-written types describe the consumed shape (with genuinely optional\n// `?:` fields); the codecs below validate that shape at runtime so\n// `HttpInstructionInfoDataSource` can hand the loaders a payload they can\n// dereference without runtime-throwing on a malformed descriptor.\n\nimport { array, Codec, number, optional, record, string } from \"purify-ts\";\n\nexport type CalSignatures = {\n prod?: string;\n test?: string;\n};\n\nexport type CalSignedDescriptorDto = {\n data: string;\n signatures: CalSignatures;\n};\n\n// Decoded CAL JSON shapes (snake_case mirrors the CAL response) that drive\n// host-side requirement building.\n\nexport type CalValueDto = {\n source: string;\n account_index?: number;\n data?: string;\n path?: { steps: number[] };\n};\n\nexport type CalTokenValueDto = {\n kind: string;\n value?: CalValueDto;\n account_index?: number;\n};\n\nexport type CalMintAssociationDto = {\n account_index: number;\n mint_index: number;\n};\n\nexport type CalTypePoolEntryDto = {\n index: number;\n kind: string;\n refs?: number[];\n size?: number;\n encoding?: number;\n len_kind?: string;\n flag_kind?: string;\n sentinel?: string;\n disc_kind?: string;\n total_variants?: number;\n enum_id?: string;\n};\n\nexport type CalEnumVariantDto = {\n variant_name: string;\n payload_kind?: string;\n descriptor: CalSignedDescriptorDto;\n};\n\n/** A substructure CAL serves only as opaque TLV (e.g. HIDE_RULE). */\nexport type CalSubstructureDto = {\n descriptor: string;\n};\n\nexport type CalValueFlowPortDto = CalSubstructureDto & {\n account_indices: number[];\n optional_account_strategy?: string;\n token_value: CalTokenValueDto;\n};\n\nexport type CalAccountResetDto = CalSubstructureDto & {\n account_index?: number;\n require_pre_balance_zero?: boolean;\n};\n\nexport type CalDisplayFieldDto = CalSubstructureDto & {\n name?: string;\n param?: { type: string; value?: CalValueDto; token?: CalValueDto };\n};\n\nexport type CalInstructionDescriptorDto = {\n discriminator_hex?: string;\n instruction_name?: string;\n descriptor: CalSignedDescriptorDto;\n idl_descriptor?: {\n type_pool?: CalTypePoolEntryDto[];\n root_type?: number;\n };\n mint_association?: CalMintAssociationDto;\n owner_association?: unknown;\n enum_variants?: Record<string, Record<string, CalEnumVariantDto>>;\n display_fields?: CalDisplayFieldDto[];\n value_flow_ports?: CalValueFlowPortDto[];\n hide_rules?: CalSubstructureDto[];\n account_resets?: CalAccountResetDto[];\n};\n\n// One program object of the `solana_programs` response: the program `id`, its\n// `chain_id`, and the flat `instructions` array (keyed downstream by\n// `discriminator_hex`).\nexport type CalInstructionProgramDto = {\n id: string;\n chain_id: number;\n instructions: CalInstructionDescriptorDto[];\n};\n\n// Outer shape: array of program objects (one per requested `id`).\nexport type CalInstructionInfoResponseDto = CalInstructionProgramDto[];\n\n// --- Validation codecs (runtime). Validate only the fields the loaders read;\n// `Codec.interface` ignores unknown extras so CAL can add fields freely. ---\n\nconst calSignaturesCodec = Codec.interface({\n prod: optional(string),\n test: optional(string),\n});\n\nconst calSignedDescriptorCodec = Codec.interface({\n data: string,\n signatures: calSignaturesCodec,\n});\n\nconst calEnumVariantCodec = Codec.interface({\n descriptor: calSignedDescriptorCodec,\n});\n\nconst calSubstructureCodec = Codec.interface({\n descriptor: string,\n});\n\nconst calInstructionDescriptorCodec = Codec.interface({\n discriminator_hex: optional(string),\n descriptor: calSignedDescriptorCodec,\n enum_variants: optional(record(string, record(string, calEnumVariantCodec))),\n display_fields: optional(array(calSubstructureCodec)),\n value_flow_ports: optional(array(calSubstructureCodec)),\n hide_rules: optional(array(calSubstructureCodec)),\n account_resets: optional(array(calSubstructureCodec)),\n});\n\n/**\n * Codec for one program object of the `solana_programs` response. Used by the\n * datasource to validate the CAL payload before handing it to the loaders.\n * Only loader-consumed fields are validated; unrelated CAL fields\n * (`idl_descriptor`, `mint_association`, \u2026) are ignored.\n */\nexport const calInstructionProgramCodec = Codec.interface({\n id: string,\n chain_id: number,\n instructions: array(calInstructionDescriptorCodec),\n});\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gCAAAE,IAAA,eAAAC,EAAAH,GAQA,IAAAI,EAA+D,qBA0G/D,MAAMC,EAAqB,QAAM,UAAU,CACzC,QAAM,YAAS,QAAM,EACrB,QAAM,YAAS,QAAM,CACvB,CAAC,EAEKC,EAA2B,QAAM,UAAU,CAC/C,KAAM,SACN,WAAYD,CACd,CAAC,EAEKE,EAAsB,QAAM,UAAU,CAC1C,WAAYD,CACd,CAAC,EAEKE,EAAuB,QAAM,UAAU,CAC3C,WAAY,QACd,CAAC,EAEKC,EAAgC,QAAM,UAAU,CACpD,qBAAmB,YAAS,QAAM,EAClC,WAAYH,EACZ,iBAAe,eAAS,UAAO,YAAQ,UAAO,SAAQC,CAAmB,CAAC,CAAC,EAC3E,kBAAgB,eAAS,SAAMC,CAAoB,CAAC,EACpD,oBAAkB,eAAS,SAAMA,CAAoB,CAAC,EACtD,cAAY,eAAS,SAAMA,CAAoB,CAAC,EAChD,kBAAgB,eAAS,SAAMA,CAAoB,CAAC,CACtD,CAAC,EAQYN,EAA6B,QAAM,UAAU,CACxD,GAAI,SACJ,SAAU,SACV,gBAAc,SAAMO,CAA6B,CACnD,CAAC",
|
|
6
6
|
"names": ["InstructionInfoDto_exports", "__export", "calInstructionProgramCodec", "__toCommonJS", "import_purify_ts", "calSignaturesCodec", "calSignedDescriptorCodec", "calEnumVariantCodec", "calSubstructureCodec", "calInstructionDescriptorCodec"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var i=Object.defineProperty;var
|
|
1
|
+
"use strict";var i=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var X=Object.prototype.hasOwnProperty;var f=(d,e)=>{for(var t in e)i(d,t,{get:e[t],enumerable:!0})},l=(d,e,t,m)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of N(e))!X.call(d,r)&&r!==t&&i(d,r,{get:()=>e[r],enumerable:!(m=A(e,r))||m.enumerable});return d};var p=d=>l(i({},"__esModule",{value:!0}),d);var n={};f(n,{deviceModelIdCodec:()=>O});module.exports=p(n);var c=require("@ledgerhq/device-management-kit"),o=require("purify-ts");const O=(0,o.oneOf)([(0,o.exactly)(c.DeviceModelId.NANO_X),(0,o.exactly)(c.DeviceModelId.NANO_SP),(0,o.exactly)(c.DeviceModelId.STAX),(0,o.exactly)(c.DeviceModelId.FLEX),(0,o.exactly)(c.DeviceModelId.APEX)]);0&&(module.exports={deviceModelIdCodec});
|
|
2
2
|
//# sourceMappingURL=deviceModelIdCodec.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/shared/utils/deviceModelIdCodec.ts"],
|
|
4
|
-
"sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { exactly, oneOf } from \"purify-ts\";\n\n/**\n * Set of device models supported by the clear-signing and transaction-check\n * flows. Excludes `NANO_S
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA8B,2CAC9BC,EAA+B,qBAMxB,MAAMH,KAAqB,SAAM,IACtC,WAAQ,gBAAc,MAAM,KAC5B,WAAQ,gBAAc,OAAO,KAC7B,WAAQ,gBAAc,IAAI,KAC1B,WAAQ,gBAAc,IAAI,CAC5B,CAAC",
|
|
4
|
+
"sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { exactly, oneOf } from \"purify-ts\";\n\n/**\n * Set of device models supported by the clear-signing and transaction-check\n * flows. Excludes `NANO_S`.\n */\nexport const deviceModelIdCodec = oneOf([\n exactly(DeviceModelId.NANO_X),\n exactly(DeviceModelId.NANO_SP),\n exactly(DeviceModelId.STAX),\n exactly(DeviceModelId.FLEX),\n exactly(DeviceModelId.APEX),\n]);\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA8B,2CAC9BC,EAA+B,qBAMxB,MAAMH,KAAqB,SAAM,IACtC,WAAQ,gBAAc,MAAM,KAC5B,WAAQ,gBAAc,OAAO,KAC7B,WAAQ,gBAAc,IAAI,KAC1B,WAAQ,gBAAc,IAAI,KAC1B,WAAQ,gBAAc,IAAI,CAC5B,CAAC",
|
|
6
6
|
"names": ["deviceModelIdCodec_exports", "__export", "deviceModelIdCodec", "__toCommonJS", "import_device_management_kit", "import_purify_ts"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("@ledgerhq/device-management-kit"),t=require("purify-ts"),d=require("./deviceModelIdCodec");describe("deviceModelIdCodec",()=>{it.each([e.DeviceModelId.NANO_X,e.DeviceModelId.NANO_SP,e.DeviceModelId.STAX,e.DeviceModelId.FLEX])("decodes %s as Right",o=>{expect(d.deviceModelIdCodec.decode(o)).toEqual((0,t.Right)(o))}),it("rejects NANO_S (unsupported for clear-signing)",()=>{expect(d.deviceModelIdCodec.decode(e.DeviceModelId.NANO_S).isLeft()).toBe(!0)}),it.each([null,void 0,"","ledger",42,{},[]])("rejects non-model values: %s",o=>{expect(d.deviceModelIdCodec.decode(o).isLeft()).toBe(!0)}),it("encodes a model as itself",()=>{expect(d.deviceModelIdCodec.encode(e.DeviceModelId.NANO_X)).toBe(e.DeviceModelId.NANO_X)})});
|
|
1
|
+
"use strict";var e=require("@ledgerhq/device-management-kit"),t=require("purify-ts"),d=require("./deviceModelIdCodec");describe("deviceModelIdCodec",()=>{it.each([e.DeviceModelId.NANO_X,e.DeviceModelId.NANO_SP,e.DeviceModelId.STAX,e.DeviceModelId.FLEX,e.DeviceModelId.APEX])("decodes %s as Right",o=>{expect(d.deviceModelIdCodec.decode(o)).toEqual((0,t.Right)(o))}),it("rejects NANO_S (unsupported for clear-signing)",()=>{expect(d.deviceModelIdCodec.decode(e.DeviceModelId.NANO_S).isLeft()).toBe(!0)}),it.each([null,void 0,"","ledger",42,{},[]])("rejects non-model values: %s",o=>{expect(d.deviceModelIdCodec.decode(o).isLeft()).toBe(!0)}),it("encodes a model as itself",()=>{expect(d.deviceModelIdCodec.encode(e.DeviceModelId.NANO_X)).toBe(e.DeviceModelId.NANO_X)})});
|
|
2
2
|
//# sourceMappingURL=deviceModelIdCodec.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/shared/utils/deviceModelIdCodec.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { Right } from \"purify-ts\";\n\nimport { deviceModelIdCodec } from \"./deviceModelIdCodec\";\n\ndescribe(\"deviceModelIdCodec\", () => {\n it.each([\n DeviceModelId.NANO_X,\n DeviceModelId.NANO_SP,\n DeviceModelId.STAX,\n DeviceModelId.FLEX,\n ])(\"decodes %s as Right\", (model) => {\n expect(deviceModelIdCodec.decode(model)).toEqual(Right(model));\n });\n\n it(\"rejects NANO_S (unsupported for clear-signing)\", () => {\n expect(deviceModelIdCodec.decode(DeviceModelId.NANO_S).isLeft()).toBe(true);\n });\n\n it.each([null, undefined, \"\", \"ledger\", 42, {}, []])(\n \"rejects non-model values: %s\",\n (value) => {\n expect(deviceModelIdCodec.decode(value).isLeft()).toBe(true);\n },\n );\n\n it(\"encodes a model as itself\", () => {\n expect(deviceModelIdCodec.encode(DeviceModelId.NANO_X)).toBe(\n DeviceModelId.NANO_X,\n );\n });\n});\n"],
|
|
5
|
-
"mappings": "aAAA,IAAAA,EAA8B,2CAC9BC,EAAsB,qBAEtBC,EAAmC,gCAEnC,SAAS,qBAAsB,IAAM,CACnC,GAAG,KAAK,CACN,gBAAc,OACd,gBAAc,QACd,gBAAc,KACd,gBAAc,IAChB,CAAC,EAAE,sBAAwBC,GAAU,CACnC,OAAO,qBAAmB,OAAOA,CAAK,CAAC,EAAE,WAAQ,SAAMA,CAAK,CAAC,CAC/D,CAAC,EAED,GAAG,iDAAkD,IAAM,CACzD,OAAO,qBAAmB,OAAO,gBAAc,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAI,CAC5E,CAAC,EAED,GAAG,KAAK,CAAC,KAAM,OAAW,GAAI,SAAU,GAAI,CAAC,EAAG,CAAC,CAAC,CAAC,EACjD,+BACCC,GAAU,CACT,OAAO,qBAAmB,OAAOA,CAAK,EAAE,OAAO,CAAC,EAAE,KAAK,EAAI,CAC7D,CACF,EAEA,GAAG,4BAA6B,IAAM,CACpC,OAAO,qBAAmB,OAAO,gBAAc,MAAM,CAAC,EAAE,KACtD,gBAAc,MAChB,CACF,CAAC,CACH,CAAC",
|
|
4
|
+
"sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { Right } from \"purify-ts\";\n\nimport { deviceModelIdCodec } from \"./deviceModelIdCodec\";\n\ndescribe(\"deviceModelIdCodec\", () => {\n it.each([\n DeviceModelId.NANO_X,\n DeviceModelId.NANO_SP,\n DeviceModelId.STAX,\n DeviceModelId.FLEX,\n DeviceModelId.APEX,\n ])(\"decodes %s as Right\", (model) => {\n expect(deviceModelIdCodec.decode(model)).toEqual(Right(model));\n });\n\n it(\"rejects NANO_S (unsupported for clear-signing)\", () => {\n expect(deviceModelIdCodec.decode(DeviceModelId.NANO_S).isLeft()).toBe(true);\n });\n\n it.each([null, undefined, \"\", \"ledger\", 42, {}, []])(\n \"rejects non-model values: %s\",\n (value) => {\n expect(deviceModelIdCodec.decode(value).isLeft()).toBe(true);\n },\n );\n\n it(\"encodes a model as itself\", () => {\n expect(deviceModelIdCodec.encode(DeviceModelId.NANO_X)).toBe(\n DeviceModelId.NANO_X,\n );\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAA8B,2CAC9BC,EAAsB,qBAEtBC,EAAmC,gCAEnC,SAAS,qBAAsB,IAAM,CACnC,GAAG,KAAK,CACN,gBAAc,OACd,gBAAc,QACd,gBAAc,KACd,gBAAc,KACd,gBAAc,IAChB,CAAC,EAAE,sBAAwBC,GAAU,CACnC,OAAO,qBAAmB,OAAOA,CAAK,CAAC,EAAE,WAAQ,SAAMA,CAAK,CAAC,CAC/D,CAAC,EAED,GAAG,iDAAkD,IAAM,CACzD,OAAO,qBAAmB,OAAO,gBAAc,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAI,CAC5E,CAAC,EAED,GAAG,KAAK,CAAC,KAAM,OAAW,GAAI,SAAU,GAAI,CAAC,EAAG,CAAC,CAAC,CAAC,EACjD,+BACCC,GAAU,CACT,OAAO,qBAAmB,OAAOA,CAAK,EAAE,OAAO,CAAC,EAAE,KAAK,EAAI,CAC7D,CACF,EAEA,GAAG,4BAA6B,IAAM,CACpC,OAAO,qBAAmB,OAAO,gBAAc,MAAM,CAAC,EAAE,KACtD,gBAAc,MAChB,CACF,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["import_device_management_kit", "import_purify_ts", "import_deviceModelIdCodec", "model", "value"]
|
|
7
7
|
}
|
package/lib/esm/package.json
CHANGED
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
59
59
|
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
|
|
60
60
|
},
|
|
61
|
-
"version": "0.0.0-develop-
|
|
61
|
+
"version": "0.0.0-develop-20260813001639"
|
|
62
62
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var g=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var d=(s,o,n,e)=>{for(var r=e>1?void 0:e?E(o,n):o,i=s.length-1,t;i>=0;i--)(t=s[i])&&(r=(e?t(o,n,r):t(r))||r);return e&&r&&g(o,n,r),r},l=(s,o)=>(n,e)=>o(n,e,s);import{inject as I,injectable as y}from"inversify";import{Left as c,Right as D}from"purify-ts";import{configTypes as w}from"../../../../config/di/configTypes";import{SolanaTransactionScanChainId as m}from"../../../../modules/solana/model/SolanaTransactionScanChainId";import{networkTypes as N}from"../../../../shared/network/di/networkTypes";import{calInstructionProgramCodec as S}from"./InstructionInfoDto";import{toInstructionInfoPayload as T,toProgramEnumVariants as M}from"./InstructionInfoMapper";const k={"solana-mainnet":m.MAINNET,"solana-devnet":m.DEVNET,"solana-testnet":m.TESTNET};let u=class{constructor(o,n){this.config=o;this.http=n}async getInstructionInfo({programId:o,network:n}){const e=k[n]??m.MAINNET;let r;try{r=await this.http.get(`${this.config.cal.url}/solana_programs`,{params:{id:o,chain_id:e,output:"id,chain_id,instructions",ref:`branch:${this.config.cal.branch}`}})}catch(t){const f=t instanceof Error?t.message:String(t);return c(new Error(`[ContextModule] HttpInstructionInfoDataSource: Failed to fetch instruction descriptors: ${f}`))}if(!Array.isArray(r)||r.length===0)return c(new Error(`[ContextModule] HttpInstructionInfoDataSource: empty response for program ${o}`));const i=r.find(t=>t!=null&&typeof t=="object"&&t.id===o);return i===void 0?c(new Error(`[ContextModule] HttpInstructionInfoDataSource: no descriptors for program ${o}`)):S.decode(i).caseOf({Left:t=>c(new Error(`[ContextModule] HttpInstructionInfoDataSource: malformed descriptors for program ${o}: ${t}`)),Right:()=>{const t=this.config.cal.mode??"prod",f=i.instructions,p=Object.fromEntries(f.map(a=>[a.discriminator_hex,a])),h=Object.fromEntries(Object.entries(p).map(([a,C])=>[a,T(o,a,C,t)]));return D({programId:o,descriptors:h,enumVariants:M(p,t)})}})}};u=d([y(),l(0,I(w.Config)),l(1,I(N.NetworkClient))],u);export{u as HttpInstructionInfoDataSource};
|
|
1
|
+
var g=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var d=(s,o,n,e)=>{for(var r=e>1?void 0:e?E(o,n):o,i=s.length-1,t;i>=0;i--)(t=s[i])&&(r=(e?t(o,n,r):t(r))||r);return e&&r&&g(o,n,r),r},l=(s,o)=>(n,e)=>o(n,e,s);import{inject as I,injectable as y}from"inversify";import{Left as c,Right as D}from"purify-ts";import{configTypes as w}from"../../../../config/di/configTypes";import{SolanaTransactionScanChainId as m}from"../../../../modules/solana/model/SolanaTransactionScanChainId";import{networkTypes as N}from"../../../../shared/network/di/networkTypes";import{calInstructionProgramCodec as S}from"./InstructionInfoDto";import{toInstructionInfoPayload as T,toProgramEnumVariants as M}from"./InstructionInfoMapper";const k={"solana-mainnet":m.MAINNET,"solana-devnet":m.DEVNET,"solana-testnet":m.TESTNET};let u=class{constructor(o,n){this.config=o;this.http=n}async getInstructionInfo({programId:o,network:n}){const e=k[n]??m.MAINNET;let r;try{r=await this.http.get(`${this.config.cal.url}/solana_programs`,{params:{id:o,chain_id:e,output:"id,chain_id,instructions",ref:`branch:${this.config.cal.branch}`}})}catch(t){const f=t instanceof Error?t.message:String(t);return c(new Error(`[ContextModule] HttpInstructionInfoDataSource: Failed to fetch instruction descriptors: ${f}`))}if(!Array.isArray(r)||r.length===0)return c(new Error(`[ContextModule] HttpInstructionInfoDataSource: empty response for program ${o}`));const i=r.find(t=>t!=null&&typeof t=="object"&&t.id===o);return i===void 0?c(new Error(`[ContextModule] HttpInstructionInfoDataSource: no descriptors for program ${o}`)):S.decode(i).caseOf({Left:t=>c(new Error(`[ContextModule] HttpInstructionInfoDataSource: malformed descriptors for program ${o}: ${t}`)),Right:()=>{const t=this.config.cal.mode??"prod",f=i.instructions,p=Object.fromEntries(f.map(a=>[a.discriminator_hex??"",a])),h=Object.fromEntries(Object.entries(p).map(([a,C])=>[a,T(o,a,C,t)]));return D({programId:o,descriptors:h,enumVariants:M(p,t)})}})}};u=d([y(),l(0,I(w.Config)),l(1,I(N.NetworkClient))],u);export{u as HttpInstructionInfoDataSource};
|
|
2
2
|
//# sourceMappingURL=HttpInstructionInfoDataSource.js.map
|
package/lib/esm/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.ts"],
|
|
4
|
-
"sourcesContent": ["import { DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { SolanaTransactionScanChainId } from \"@/modules/solana/model/SolanaTransactionScanChainId\";\nimport { networkTypes } from \"@/shared/network/di/networkTypes\";\n\nimport {\n GetInstructionInfoParams,\n InstructionInfoDataSource,\n InstructionInfoResult,\n} from \"./InstructionInfoDataSource\";\nimport {\n type CalInstructionDescriptorDto,\n calInstructionProgramCodec,\n type CalInstructionProgramDto,\n} from \"./InstructionInfoDto\";\nimport {\n type CalMode,\n toInstructionInfoPayload,\n toProgramEnumVariants,\n} from \"./InstructionInfoMapper\";\n\n// Maps the DMK network label to the numeric CAL `chain_id` (the extended\n// Solana network ids 900/901/902). Unknown labels fall back to mainnet.\nconst CHAIN_ID_BY_NETWORK: Record<string, SolanaTransactionScanChainId> = {\n \"solana-mainnet\": SolanaTransactionScanChainId.MAINNET,\n \"solana-devnet\": SolanaTransactionScanChainId.DEVNET,\n \"solana-testnet\": SolanaTransactionScanChainId.TESTNET,\n};\n\n@injectable()\nexport class HttpInstructionInfoDataSource\n implements InstructionInfoDataSource\n{\n constructor(\n @inject(configTypes.Config)\n private readonly config: ContextModuleServiceConfig,\n @inject(networkTypes.NetworkClient)\n private readonly http: DmkNetworkClient,\n ) {}\n\n public async getInstructionInfo({\n programId,\n network,\n }: GetInstructionInfoParams): Promise<Either<Error, InstructionInfoResult>> {\n const chainId =\n CHAIN_ID_BY_NETWORK[network] ?? SolanaTransactionScanChainId.MAINNET;\n let data: unknown;\n try {\n data = await this.http.get(`${this.config.cal.url}/solana_programs`, {\n params: {\n id: programId,\n chain_id: chainId,\n output: \"id,chain_id,instructions\",\n ref: `branch:${this.config.cal.branch}`,\n },\n });\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n return Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: Failed to fetch instruction descriptors: ${reason}`,\n ),\n );\n }\n\n if (!Array.isArray(data) || data.length === 0) {\n return Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: empty response for program ${programId}`,\n ),\n );\n }\n\n // Select the program object whose `id` matches the requested `programId`\n // (the response is an array, one object per requested id).\n const program = data.find(\n (entry): entry is { id: unknown } =>\n entry != null &&\n typeof entry === \"object\" &&\n (entry as { id?: unknown }).id === programId,\n );\n if (program === undefined) {\n return Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: no descriptors for program ${programId}`,\n ),\n );\n }\n\n // Validate the program shape so the mapper can dereference `descriptor` /\n // `enum_variants` without runtime-throwing on a malformed CAL payload. A\n // malformed program degrades to a per-program ERROR rather than rejecting\n // the batch. On success we transform each validated DTO into the core\n // payload so the loader never sees the CAL DTO shapes.\n return calInstructionProgramCodec\n .decode(program)\n .caseOf<Either<Error, InstructionInfoResult>>({\n Left: (error) =>\n Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: malformed descriptors for program ${programId}: ${error}`,\n ),\n ),\n Right: () => {\n const mode: CalMode = this.config.cal.mode ?? \"prod\";\n // The codec strips undeclared fields, so we key the original\n // (full) instruction objects by `discriminator_hex` \u2014 the cast is\n // justified now that the shape has been validated.\n const instructions = (program as CalInstructionProgramDto)\n .instructions;\n const descriptorsByDiscriminator: Record<\n string,\n CalInstructionDescriptorDto\n > = Object.fromEntries(\n instructions.map((dto) => [dto.discriminator_hex, dto]),\n );\n const mapped = Object.fromEntries(\n Object.entries(descriptorsByDiscriminator).map(\n ([discriminator, dto]) => [\n discriminator,\n toInstructionInfoPayload(programId, discriminator, dto, mode),\n ],\n ),\n );\n return Right({\n programId,\n descriptors: mapped,\n enumVariants: toProgramEnumVariants(\n descriptorsByDiscriminator,\n mode,\n ),\n });\n },\n });\n }\n}\n"],
|
|
5
|
-
"mappings": "iOACA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAE5B,OAAS,gCAAAC,MAAoC,sDAC7C,OAAS,gBAAAC,MAAoB,mCAO7B,OAEE,8BAAAC,MAEK,uBACP,OAEE,4BAAAC,EACA,yBAAAC,MACK,0BAIP,MAAMC,EAAoE,CACxE,iBAAkBC,EAA6B,QAC/C,gBAAiBA,EAA6B,OAC9C,iBAAkBA,EAA6B,OACjD,EAGO,IAAMC,EAAN,KAEP,CACE,YAEmBC,EAEAC,EACjB,CAHiB,YAAAD,EAEA,UAAAC,CAChB,CAEH,MAAa,mBAAmB,CAC9B,UAAAC,EACA,QAAAC,CACF,EAA4E,CAC1E,MAAMC,EACJP,EAAoBM,CAAO,GAAKL,EAA6B,QAC/D,IAAIO,EACJ,GAAI,CACFA,EAAO,MAAM,KAAK,KAAK,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,mBAAoB,CACnE,OAAQ,CACN,GAAIH,EACJ,SAAUE,EACV,OAAQ,2BACR,IAAK,UAAU,KAAK,OAAO,IAAI,MAAM,EACvC,CACF,CAAC,CACH,OAASE,EAAO,CACd,MAAMC,EAASD,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,EACpE,OAAOE,EACL,IAAI,MACF,2FAA2FD,CAAM,EACnG,CACF,CACF,CAEA,GAAI,CAAC,MAAM,QAAQF,CAAI,GAAKA,EAAK,SAAW,EAC1C,OAAOG,EACL,IAAI,MACF,6EAA6EN,CAAS,EACxF,CACF,EAKF,MAAMO,EAAUJ,EAAK,KAClBK,GACCA,GAAS,MACT,OAAOA,GAAU,UAChBA,EAA2B,KAAOR,CACvC,EACA,OAAIO,IAAY,OACPD,EACL,IAAI,MACF,6EAA6EN,CAAS,EACxF,CACF,EAQKS,EACJ,OAAOF,CAAO,EACd,OAA6C,CAC5C,KAAOH,GACLE,EACE,IAAI,MACF,oFAAoFN,CAAS,KAAKI,CAAK,EACzG,CACF,EACF,MAAO,IAAM,CACX,MAAMM,EAAgB,KAAK,OAAO,IAAI,MAAQ,
|
|
4
|
+
"sourcesContent": ["import { DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { SolanaTransactionScanChainId } from \"@/modules/solana/model/SolanaTransactionScanChainId\";\nimport { networkTypes } from \"@/shared/network/di/networkTypes\";\n\nimport {\n GetInstructionInfoParams,\n InstructionInfoDataSource,\n InstructionInfoResult,\n} from \"./InstructionInfoDataSource\";\nimport {\n type CalInstructionDescriptorDto,\n calInstructionProgramCodec,\n type CalInstructionProgramDto,\n} from \"./InstructionInfoDto\";\nimport {\n type CalMode,\n toInstructionInfoPayload,\n toProgramEnumVariants,\n} from \"./InstructionInfoMapper\";\n\n// Maps the DMK network label to the numeric CAL `chain_id` (the extended\n// Solana network ids 900/901/902). Unknown labels fall back to mainnet.\nconst CHAIN_ID_BY_NETWORK: Record<string, SolanaTransactionScanChainId> = {\n \"solana-mainnet\": SolanaTransactionScanChainId.MAINNET,\n \"solana-devnet\": SolanaTransactionScanChainId.DEVNET,\n \"solana-testnet\": SolanaTransactionScanChainId.TESTNET,\n};\n\n@injectable()\nexport class HttpInstructionInfoDataSource\n implements InstructionInfoDataSource\n{\n constructor(\n @inject(configTypes.Config)\n private readonly config: ContextModuleServiceConfig,\n @inject(networkTypes.NetworkClient)\n private readonly http: DmkNetworkClient,\n ) {}\n\n public async getInstructionInfo({\n programId,\n network,\n }: GetInstructionInfoParams): Promise<Either<Error, InstructionInfoResult>> {\n const chainId =\n CHAIN_ID_BY_NETWORK[network] ?? SolanaTransactionScanChainId.MAINNET;\n let data: unknown;\n try {\n data = await this.http.get(`${this.config.cal.url}/solana_programs`, {\n params: {\n id: programId,\n chain_id: chainId,\n output: \"id,chain_id,instructions\",\n ref: `branch:${this.config.cal.branch}`,\n },\n });\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n return Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: Failed to fetch instruction descriptors: ${reason}`,\n ),\n );\n }\n\n if (!Array.isArray(data) || data.length === 0) {\n return Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: empty response for program ${programId}`,\n ),\n );\n }\n\n // Select the program object whose `id` matches the requested `programId`\n // (the response is an array, one object per requested id).\n const program = data.find(\n (entry): entry is { id: unknown } =>\n entry != null &&\n typeof entry === \"object\" &&\n (entry as { id?: unknown }).id === programId,\n );\n if (program === undefined) {\n return Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: no descriptors for program ${programId}`,\n ),\n );\n }\n\n // Validate the program shape so the mapper can dereference `descriptor` /\n // `enum_variants` without runtime-throwing on a malformed CAL payload. A\n // malformed program degrades to a per-program ERROR rather than rejecting\n // the batch. On success we transform each validated DTO into the core\n // payload so the loader never sees the CAL DTO shapes.\n return calInstructionProgramCodec\n .decode(program)\n .caseOf<Either<Error, InstructionInfoResult>>({\n Left: (error) =>\n Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: malformed descriptors for program ${programId}: ${error}`,\n ),\n ),\n Right: () => {\n const mode: CalMode = this.config.cal.mode ?? \"prod\";\n // The codec strips undeclared fields, so we key the original\n // (full) instruction objects by `discriminator_hex` \u2014 the cast is\n // justified now that the shape has been validated. A descriptor\n // without a discriminator (single-instruction programs such as SPL\n // Memo) is keyed under the empty string.\n const instructions = (program as CalInstructionProgramDto)\n .instructions;\n const descriptorsByDiscriminator: Record<\n string,\n CalInstructionDescriptorDto\n > = Object.fromEntries(\n instructions.map((dto) => [dto.discriminator_hex ?? \"\", dto]),\n );\n const mapped = Object.fromEntries(\n Object.entries(descriptorsByDiscriminator).map(\n ([discriminator, dto]) => [\n discriminator,\n toInstructionInfoPayload(programId, discriminator, dto, mode),\n ],\n ),\n );\n return Right({\n programId,\n descriptors: mapped,\n enumVariants: toProgramEnumVariants(\n descriptorsByDiscriminator,\n mode,\n ),\n });\n },\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "iOACA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAE5B,OAAS,gCAAAC,MAAoC,sDAC7C,OAAS,gBAAAC,MAAoB,mCAO7B,OAEE,8BAAAC,MAEK,uBACP,OAEE,4BAAA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,OAAO,YACpB,OAAO,QAAQF,CAA0B,EAAE,IACzC,CAAC,CAACG,EAAeF,CAAG,IAAM,CACxBE,EACAC,EAAyBhB,EAAWe,EAAeF,EAAKH,CAAI,CAC9D,CACF,CACF,EACA,OAAOO,EAAM,CACX,UAAAjB,EACA,YAAac,EACb,aAAcI,EACZN,EACAF,CACF,CACF,CAAC,CACH,CACF,CAAC,CACL,CACF,EA3Gab,EAANsB,EAAA,CADNC,EAAW,EAKPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,GAEzBF,EAAA,EAAAC,EAAOE,EAAa,aAAa,IANzB3B",
|
|
6
6
|
"names": ["inject", "injectable", "Left", "Right", "configTypes", "SolanaTransactionScanChainId", "networkTypes", "calInstructionProgramCodec", "toInstructionInfoPayload", "toProgramEnumVariants", "CHAIN_ID_BY_NETWORK", "SolanaTransactionScanChainId", "HttpInstructionInfoDataSource", "config", "http", "programId", "network", "chainId", "data", "error", "reason", "Left", "program", "entry", "calInstructionProgramCodec", "mode", "instructions", "descriptorsByDiscriminator", "dto", "mapped", "discriminator", "toInstructionInfoPayload", "Right", "toProgramEnumVariants", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes", "networkTypes"]
|
|
7
7
|
}
|
package/lib/esm/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Left as u,Right as l}from"purify-ts";import{beforeEach as
|
|
1
|
+
import{Left as u,Right as l}from"purify-ts";import{beforeEach as g,describe as f,expect as e,it as s,vi as p}from"vitest";import{SolanaTransactionScanChainId as i}from"../../../../modules/solana/model/SolanaTransactionScanChainId";import{HttpInstructionInfoDataSource as h}from"./HttpInstructionInfoDataSource";f("HttpInstructionInfoDataSource",()=>{let r,o;const t="11111111111111111111111111111111",a="solana-mainnet",m={cal:{url:"https://global.api.prd.ledger.com/cal/v1",mode:"prod",branch:"main"}},c=[{id:t,chain_id:i.MAINNET,instructions:[{discriminator_hex:"00000000",instruction_name:"createAccount",descriptor:{data:"00010101",signatures:{prod:"prodsig",test:"testsig"}},display_fields:[],value_flow_ports:[],hide_rules:[],account_resets:[]}]}];g(()=>{p.clearAllMocks(),o={get:p.fn()},r=new h(m,o)}),s("calls CAL /solana_programs with id, chain_id and output params",async()=>{o.get.mockResolvedValue(c),await r.getInstructionInfo({programId:t,network:a}),e(o.get).toHaveBeenCalledTimes(1),e(o.get).toHaveBeenCalledWith("https://global.api.prd.ledger.com/cal/v1/solana_programs",{params:{id:t,chain_id:i.MAINNET,output:"id,chain_id,instructions",ref:"branch:main"}})}),s("maps devnet/testnet networks to their numeric chain ids",async()=>{o.get.mockResolvedValue(c),await r.getInstructionInfo({programId:t,network:"solana-devnet"}),e(o.get).toHaveBeenCalledWith("https://global.api.prd.ledger.com/cal/v1/solana_programs",e.objectContaining({params:e.objectContaining({chain_id:901})}))}),s("returns Right with each descriptor transformed into the core payload on success",async()=>{o.get.mockResolvedValue(c);const n=await r.getInstructionInfo({programId:t,network:a});e(n).toEqual(l({programId:t,descriptors:{"00000000":l({programId:t,discriminator:"00000000",instructionInfo:{data:"00010101",signature:"prodsig"},substructures:[],enumVariants:[],idlDescriptor:{typePool:[],rootType:0},mintAssociations:[],valueFlowPorts:[],accountResets:[],displayFields:[]})},enumVariants:[]}))}),s("keys a descriptor without `discriminator_hex` under the empty string",async()=>{o.get.mockResolvedValue([{id:t,chain_id:i.MAINNET,instructions:[{instruction_name:"addMemo",descriptor:{data:"00010101",signatures:{prod:"prodsig",test:"testsig"}}}]}]);const n=await r.getInstructionInfo({programId:t,network:a});e(n.isRight()).toBe(!0);const{descriptors:d}=n.unsafeCoerce();e(Object.keys(d)).toEqual([""]),e(d[""].unsafeCoerce()).toEqual(e.objectContaining({programId:t,discriminator:"",instructionInfo:{data:"00010101",signature:"prodsig"}}))}),s("returns Left when the response array is empty",async()=>{o.get.mockResolvedValue([]);const n=await r.getInstructionInfo({programId:t,network:a});e(n).toEqual(u(new Error(`[ContextModule] HttpInstructionInfoDataSource: empty response for program ${t}`)))}),s("returns Left when no program object matches the requested programId",async()=>{o.get.mockResolvedValue([{id:"OtherProgram",chain_id:i.MAINNET,instructions:[]}]);const n=await r.getInstructionInfo({programId:t,network:a});e(n).toEqual(u(new Error(`[ContextModule] HttpInstructionInfoDataSource: no descriptors for program ${t}`)))}),s("returns Left (not a throw) when an instruction descriptor is malformed",async()=>{o.get.mockResolvedValue([{id:t,chain_id:i.MAINNET,instructions:[{discriminator_hex:"00000000"}]}]);const n=await r.getInstructionInfo({programId:t,network:a});e(n.isLeft()).toBe(!0),e(n.extract().message).toMatch(new RegExp(String.raw`\[ContextModule\] HttpInstructionInfoDataSource: malformed descriptors for program ${t}:`))}),s("returns Left when the HTTP client throws",async()=>{o.get.mockRejectedValue(new Error("network"));const n=await r.getInstructionInfo({programId:t,network:a});e(n).toEqual(u(new Error("[ContextModule] HttpInstructionInfoDataSource: Failed to fetch instruction descriptors: network")))})});
|
|
2
2
|
//# sourceMappingURL=HttpInstructionInfoDataSource.test.js.map
|
package/lib/esm/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { type DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\nimport { beforeEach, describe, expect, it, vi } from \"vitest\";\n\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { SolanaTransactionScanChainId } from \"@/modules/solana/model/SolanaTransactionScanChainId\";\n\nimport { HttpInstructionInfoDataSource } from \"./HttpInstructionInfoDataSource\";\nimport { type InstructionInfoDataSource } from \"./InstructionInfoDataSource\";\nimport { type CalInstructionInfoResponseDto } from \"./InstructionInfoDto\";\n\ndescribe(\"HttpInstructionInfoDataSource\", () => {\n let datasource: InstructionInfoDataSource;\n let httpMock: { get: ReturnType<typeof vi.fn> };\n const programId = \"11111111111111111111111111111111\";\n const network = \"solana-mainnet\";\n const config: ContextModuleServiceConfig = {\n cal: {\n url: \"https://global.api.prd.ledger.com/cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n } as ContextModuleServiceConfig;\n\n const successResponse: CalInstructionInfoResponseDto = [\n {\n id: programId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: [\n {\n discriminator_hex: \"00000000\",\n instruction_name: \"createAccount\",\n descriptor: {\n data: \"00010101\",\n signatures: { prod: \"prodsig\", test: \"testsig\" },\n },\n display_fields: [],\n value_flow_ports: [],\n hide_rules: [],\n account_resets: [],\n },\n ],\n },\n ];\n\n beforeEach(() => {\n vi.clearAllMocks();\n httpMock = { get: vi.fn() };\n datasource = new HttpInstructionInfoDataSource(\n config,\n httpMock as unknown as DmkNetworkClient,\n );\n });\n\n it(\"calls CAL /solana_programs with id, chain_id and output params\", async () => {\n httpMock.get.mockResolvedValue(successResponse);\n\n await datasource.getInstructionInfo({ programId, network });\n\n expect(httpMock.get).toHaveBeenCalledTimes(1);\n expect(httpMock.get).toHaveBeenCalledWith(\n \"https://global.api.prd.ledger.com/cal/v1/solana_programs\",\n {\n params: {\n id: programId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n output: \"id,chain_id,instructions\",\n ref: \"branch:main\",\n },\n },\n );\n });\n\n it(\"maps devnet/testnet networks to their numeric chain ids\", async () => {\n httpMock.get.mockResolvedValue(successResponse);\n\n await datasource.getInstructionInfo({\n programId,\n network: \"solana-devnet\",\n });\n\n expect(httpMock.get).toHaveBeenCalledWith(\n \"https://global.api.prd.ledger.com/cal/v1/solana_programs\",\n expect.objectContaining({\n params: expect.objectContaining({ chain_id: 901 }),\n }),\n );\n });\n\n it(\"returns Right with each descriptor transformed into the core payload on success\", async () => {\n httpMock.get.mockResolvedValue(successResponse);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result).toEqual(\n Right({\n programId,\n descriptors: {\n \"00000000\": Right({\n programId,\n discriminator: \"00000000\",\n instructionInfo: { data: \"00010101\", signature: \"prodsig\" },\n substructures: [],\n enumVariants: [],\n idlDescriptor: { typePool: [], rootType: 0 },\n mintAssociations: [],\n valueFlowPorts: [],\n accountResets: [],\n displayFields: [],\n }),\n },\n enumVariants: [],\n }),\n );\n });\n\n it(\"returns Left when the response array is empty\", async () => {\n httpMock.get.mockResolvedValue([]);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result).toEqual(\n Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: empty response for program ${programId}`,\n ),\n ),\n );\n });\n\n it(\"returns Left when no program object matches the requested programId\", async () => {\n httpMock.get.mockResolvedValue([\n {\n id: \"OtherProgram\",\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: [],\n },\n ]);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result).toEqual(\n Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: no descriptors for program ${programId}`,\n ),\n ),\n );\n });\n\n it(\"returns Left (not a throw) when an instruction descriptor is malformed\", async () => {\n // `descriptor` missing on the instruction \u2014 would crash the loader if the\n // datasource handed it through unvalidated.\n httpMock.get.mockResolvedValue([\n {\n id: programId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: [{ discriminator_hex: \"00000000\" }],\n },\n ]);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result.isLeft()).toBe(true);\n expect((result.extract() as Error).message).toMatch(\n new RegExp(\n String.raw`\\[ContextModule\\] HttpInstructionInfoDataSource: malformed descriptors for program ${programId}:`,\n ),\n );\n });\n\n it(\"returns Left when the HTTP client throws\", async () => {\n httpMock.get.mockRejectedValue(new Error(\"network\"));\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpInstructionInfoDataSource: Failed to fetch instruction descriptors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IAAI,kBAAkB,CAC7B,CACE,GAAIC,EACJ,SAAUJ,EAA6B,QACvC,aAAc,CAAC,CAAE,kBAAmB,UAAW,CAAC,CAClD,CACF,CAAC,EAED,MAAMQ,EAAS,MAAMN,EAAW,mBAAmB,CAAE,UAAAE,EAAW,QAAAC,CAAQ,CAAC,EAEzER,EAAOW,EAAO,OAAO,CAAC,EAAE,KAAK,EAAI,EACjCX,EAAQW,EAAO,QAAQ,EAAY,OAAO,EAAE,QAC1C,IAAI,OACF,OAAO,yFAAyFJ,CAAS,GAC3G,CACF,CACF,CAAC,EAEDN,EAAG,2CAA4C,SAAY,CACzDK,EAAS,IAAI,kBAAkB,IAAI,MAAM,SAAS,CAAC,EAEnD,MAAMK,EAAS,MAAMN,EAAW,mBAAmB,CAAE,UAAAE,EAAW,QAAAC,CAAQ,CAAC,EAEzER,EAAOW,CAAM,EAAE,QACbf,EACE,IAAI,MACF,iGACF,CACF,CACF,CACF,CAAC,CACH,CAAC",
|
|
6
|
-
"names": ["Left", "Right", "beforeEach", "describe", "expect", "it", "vi", "SolanaTransactionScanChainId", "HttpInstructionInfoDataSource", "datasource", "httpMock", "programId", "network", "config", "successResponse", "result"]
|
|
4
|
+
"sourcesContent": ["import { type DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\nimport { beforeEach, describe, expect, it, vi } from \"vitest\";\n\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { SolanaTransactionScanChainId } from \"@/modules/solana/model/SolanaTransactionScanChainId\";\n\nimport { HttpInstructionInfoDataSource } from \"./HttpInstructionInfoDataSource\";\nimport { type InstructionInfoDataSource } from \"./InstructionInfoDataSource\";\nimport { type CalInstructionInfoResponseDto } from \"./InstructionInfoDto\";\n\ndescribe(\"HttpInstructionInfoDataSource\", () => {\n let datasource: InstructionInfoDataSource;\n let httpMock: { get: ReturnType<typeof vi.fn> };\n const programId = \"11111111111111111111111111111111\";\n const network = \"solana-mainnet\";\n const config: ContextModuleServiceConfig = {\n cal: {\n url: \"https://global.api.prd.ledger.com/cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n } as ContextModuleServiceConfig;\n\n const successResponse: CalInstructionInfoResponseDto = [\n {\n id: programId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: [\n {\n discriminator_hex: \"00000000\",\n instruction_name: \"createAccount\",\n descriptor: {\n data: \"00010101\",\n signatures: { prod: \"prodsig\", test: \"testsig\" },\n },\n display_fields: [],\n value_flow_ports: [],\n hide_rules: [],\n account_resets: [],\n },\n ],\n },\n ];\n\n beforeEach(() => {\n vi.clearAllMocks();\n httpMock = { get: vi.fn() };\n datasource = new HttpInstructionInfoDataSource(\n config,\n httpMock as unknown as DmkNetworkClient,\n );\n });\n\n it(\"calls CAL /solana_programs with id, chain_id and output params\", async () => {\n httpMock.get.mockResolvedValue(successResponse);\n\n await datasource.getInstructionInfo({ programId, network });\n\n expect(httpMock.get).toHaveBeenCalledTimes(1);\n expect(httpMock.get).toHaveBeenCalledWith(\n \"https://global.api.prd.ledger.com/cal/v1/solana_programs\",\n {\n params: {\n id: programId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n output: \"id,chain_id,instructions\",\n ref: \"branch:main\",\n },\n },\n );\n });\n\n it(\"maps devnet/testnet networks to their numeric chain ids\", async () => {\n httpMock.get.mockResolvedValue(successResponse);\n\n await datasource.getInstructionInfo({\n programId,\n network: \"solana-devnet\",\n });\n\n expect(httpMock.get).toHaveBeenCalledWith(\n \"https://global.api.prd.ledger.com/cal/v1/solana_programs\",\n expect.objectContaining({\n params: expect.objectContaining({ chain_id: 901 }),\n }),\n );\n });\n\n it(\"returns Right with each descriptor transformed into the core payload on success\", async () => {\n httpMock.get.mockResolvedValue(successResponse);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result).toEqual(\n Right({\n programId,\n descriptors: {\n \"00000000\": Right({\n programId,\n discriminator: \"00000000\",\n instructionInfo: { data: \"00010101\", signature: \"prodsig\" },\n substructures: [],\n enumVariants: [],\n idlDescriptor: { typePool: [], rootType: 0 },\n mintAssociations: [],\n valueFlowPorts: [],\n accountResets: [],\n displayFields: [],\n }),\n },\n enumVariants: [],\n }),\n );\n });\n\n it(\"keys a descriptor without `discriminator_hex` under the empty string\", async () => {\n // Single-instruction programs (e.g. SPL Memo `addMemo`) genuinely have no\n // discriminator, so CAL omits the field.\n httpMock.get.mockResolvedValue([\n {\n id: programId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: [\n {\n instruction_name: \"addMemo\",\n descriptor: {\n data: \"00010101\",\n signatures: { prod: \"prodsig\", test: \"testsig\" },\n },\n },\n ],\n },\n ]);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result.isRight()).toBe(true);\n const { descriptors } = result.unsafeCoerce();\n expect(Object.keys(descriptors)).toEqual([\"\"]);\n expect(descriptors[\"\"]!.unsafeCoerce()).toEqual(\n expect.objectContaining({\n programId,\n discriminator: \"\",\n instructionInfo: { data: \"00010101\", signature: \"prodsig\" },\n }),\n );\n });\n\n it(\"returns Left when the response array is empty\", async () => {\n httpMock.get.mockResolvedValue([]);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result).toEqual(\n Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: empty response for program ${programId}`,\n ),\n ),\n );\n });\n\n it(\"returns Left when no program object matches the requested programId\", async () => {\n httpMock.get.mockResolvedValue([\n {\n id: \"OtherProgram\",\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: [],\n },\n ]);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result).toEqual(\n Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: no descriptors for program ${programId}`,\n ),\n ),\n );\n });\n\n it(\"returns Left (not a throw) when an instruction descriptor is malformed\", async () => {\n // `descriptor` missing on the instruction \u2014 would crash the loader if the\n // datasource handed it through unvalidated.\n httpMock.get.mockResolvedValue([\n {\n id: programId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: [{ discriminator_hex: \"00000000\" }],\n },\n ]);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result.isLeft()).toBe(true);\n expect((result.extract() as Error).message).toMatch(\n new RegExp(\n String.raw`\\[ContextModule\\] HttpInstructionInfoDataSource: malformed descriptors for program ${programId}:`,\n ),\n );\n });\n\n it(\"returns Left when the HTTP client throws\", async () => {\n httpMock.get.mockRejectedValue(new Error(\"network\"));\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpInstructionInfoDataSource: Failed to fetch instruction descriptors: network\",\n ),\n ),\n );\n });\n});\n"],
|
|
5
|
+
"mappings": "AACA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAC5B,OAAS,cAAAC,EAAY,YAAAC,EAAU,UAAAC,EAAQ,MAAAC,EAAI,MAAAC,MAAU,SAGrD,OAAS,gCAAAC,MAAoC,sDAE7C,OAAS,iCAAAC,MAAqC,kCAI9CL,EAAS,gCAAiC,IAAM,CAC9C,IAAIM,EACAC,EACJ,MAAMC,EAAY,mCACZC,EAAU,iBACVC,EAAqC,CACzC,IAAK,CACH,IAAK,2CACL,KAAM,OACN,OAAQ,MACV,CACF,EAEMC,EAAiD,CACrD,CACE,GAAIH,EACJ,SAAUJ,EAA6B,QACvC,aAAc,CACZ,CACE,kBAAmB,WACnB,iBAAkB,gBAClB,WAAY,CACV,KAAM,WACN,WAAY,CAAE,KAAM,UAAW,KAAM,SAAU,CACjD,EACA,eAAgB,CAAC,EACjB,iBAAkB,CAAC,EACnB,WAAY,CAAC,EACb,eAAgB,CAAC,CACnB,CACF,CACF,CACF,EAEAL,EAAW,IAAM,CACfI,EAAG,cAAc,EACjBI,EAAW,CAAE,IAAKJ,EAAG,GAAG,CAAE,EAC1BG,EAAa,IAAID,EACfK,EACAH,CACF,CACF,CAAC,EAEDL,EAAG,iEAAkE,SAAY,CAC/EK,EA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E,EAAW,QAAAC,CAAQ,CAAC,EAEzER,EAAOW,EAAO,OAAO,CAAC,EAAE,KAAK,EAAI,EACjCX,EAAQW,EAAO,QAAQ,EAAY,OAAO,EAAE,QAC1C,IAAI,OACF,OAAO,yFAAyFJ,CAAS,GAC3G,CACF,CACF,CAAC,EAEDN,EAAG,2CAA4C,SAAY,CACzDK,EAAS,IAAI,kBAAkB,IAAI,MAAM,SAAS,CAAC,EAEnD,MAAMK,EAAS,MAAMN,EAAW,mBAAmB,CAAE,UAAAE,EAAW,QAAAC,CAAQ,CAAC,EAEzER,EAAOW,CAAM,EAAE,QACbf,EACE,IAAI,MACF,iGACF,CACF,CACF,CACF,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["Left", "Right", "beforeEach", "describe", "expect", "it", "vi", "SolanaTransactionScanChainId", "HttpInstructionInfoDataSource", "datasource", "httpMock", "programId", "network", "config", "successResponse", "result", "descriptors"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{array as n,Codec as r,number as s,optional as
|
|
1
|
+
import{array as n,Codec as r,number as s,optional as t,record as i,string as e}from"purify-ts";const c=r.interface({prod:t(e),test:t(e)}),a=r.interface({data:e,signatures:c}),u=r.interface({descriptor:a}),o=r.interface({descriptor:e}),l=r.interface({discriminator_hex:t(e),descriptor:a,enum_variants:t(i(e,i(e,u))),display_fields:t(n(o)),value_flow_ports:t(n(o)),hide_rules:t(n(o)),account_resets:t(n(o))}),d=r.interface({id:e,chain_id:s,instructions:n(l)});export{d as calInstructionProgramCodec};
|
|
2
2
|
//# sourceMappingURL=InstructionInfoDto.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/modules/solana/instruction-info/data/InstructionInfoDto.ts"],
|
|
4
|
-
"sourcesContent": ["// DTO + codecs for the CAL instruction-descriptors response (one object per\n// `programId`, wrapped in a JSON array).\n//\n// The hand-written types describe the consumed shape (with genuinely optional\n// `?:` fields); the codecs below validate that shape at runtime so\n// `HttpInstructionInfoDataSource` can hand the loaders a payload they can\n// dereference without runtime-throwing on a malformed descriptor.\n\nimport { array, Codec, number, optional, record, string } from \"purify-ts\";\n\nexport type CalSignatures = {\n prod?: string;\n test?: string;\n};\n\nexport type CalSignedDescriptorDto = {\n data: string;\n signatures: CalSignatures;\n};\n\n// Decoded CAL JSON shapes (snake_case mirrors the CAL response) that drive\n// host-side requirement building.\n\nexport type CalValueDto = {\n source: string;\n account_index?: number;\n data?: string;\n path?: { steps: number[] };\n};\n\nexport type CalTokenValueDto = {\n kind: string;\n value?: CalValueDto;\n account_index?: number;\n};\n\nexport type CalMintAssociationDto = {\n account_index: number;\n mint_index: number;\n};\n\nexport type CalTypePoolEntryDto = {\n index: number;\n kind: string;\n refs?: number[];\n size?: number;\n encoding?: number;\n len_kind?: string;\n flag_kind?: string;\n sentinel?: string;\n disc_kind?: string;\n total_variants?: number;\n enum_id?: string;\n};\n\nexport type CalEnumVariantDto = {\n variant_name: string;\n payload_kind?: string;\n descriptor: CalSignedDescriptorDto;\n};\n\n/** A substructure CAL serves only as opaque TLV (e.g. HIDE_RULE). */\nexport type CalSubstructureDto = {\n descriptor: string;\n};\n\nexport type CalValueFlowPortDto = CalSubstructureDto & {\n account_indices: number[];\n optional_account_strategy?: string;\n token_value: CalTokenValueDto;\n};\n\nexport type CalAccountResetDto = CalSubstructureDto & {\n account_index?: number;\n require_pre_balance_zero?: boolean;\n};\n\nexport type CalDisplayFieldDto = CalSubstructureDto & {\n name?: string;\n param?: { type: string; value?: CalValueDto; token?: CalValueDto };\n};\n\nexport type CalInstructionDescriptorDto = {\n discriminator_hex
|
|
5
|
-
"mappings": "AAQA,OAAS,SAAAA,EAAO,SAAAC,EAAO,UAAAC,EAAQ,YAAAC,EAAU,UAAAC,EAAQ,UAAAC,MAAc,YA0G/D,MAAMC,EAAqBL,EAAM,UAAU,CACzC,KAAME,EAASE,CAAM,EACrB,KAAMF,EAASE,CAAM,CACvB,CAAC,EAEKE,EAA2BN,EAAM,UAAU,CAC/C,KAAMI,EACN,WAAYC,CACd,CAAC,EAEKE,EAAsBP,EAAM,UAAU,CAC1C,WAAYM,CACd,CAAC,EAEKE,EAAuBR,EAAM,UAAU,CAC3C,WAAYI,CACd,CAAC,EAEKK,EAAgCT,EAAM,UAAU,CACpD,
|
|
4
|
+
"sourcesContent": ["// DTO + codecs for the CAL instruction-descriptors response (one object per\n// `programId`, wrapped in a JSON array).\n//\n// The hand-written types describe the consumed shape (with genuinely optional\n// `?:` fields); the codecs below validate that shape at runtime so\n// `HttpInstructionInfoDataSource` can hand the loaders a payload they can\n// dereference without runtime-throwing on a malformed descriptor.\n\nimport { array, Codec, number, optional, record, string } from \"purify-ts\";\n\nexport type CalSignatures = {\n prod?: string;\n test?: string;\n};\n\nexport type CalSignedDescriptorDto = {\n data: string;\n signatures: CalSignatures;\n};\n\n// Decoded CAL JSON shapes (snake_case mirrors the CAL response) that drive\n// host-side requirement building.\n\nexport type CalValueDto = {\n source: string;\n account_index?: number;\n data?: string;\n path?: { steps: number[] };\n};\n\nexport type CalTokenValueDto = {\n kind: string;\n value?: CalValueDto;\n account_index?: number;\n};\n\nexport type CalMintAssociationDto = {\n account_index: number;\n mint_index: number;\n};\n\nexport type CalTypePoolEntryDto = {\n index: number;\n kind: string;\n refs?: number[];\n size?: number;\n encoding?: number;\n len_kind?: string;\n flag_kind?: string;\n sentinel?: string;\n disc_kind?: string;\n total_variants?: number;\n enum_id?: string;\n};\n\nexport type CalEnumVariantDto = {\n variant_name: string;\n payload_kind?: string;\n descriptor: CalSignedDescriptorDto;\n};\n\n/** A substructure CAL serves only as opaque TLV (e.g. HIDE_RULE). */\nexport type CalSubstructureDto = {\n descriptor: string;\n};\n\nexport type CalValueFlowPortDto = CalSubstructureDto & {\n account_indices: number[];\n optional_account_strategy?: string;\n token_value: CalTokenValueDto;\n};\n\nexport type CalAccountResetDto = CalSubstructureDto & {\n account_index?: number;\n require_pre_balance_zero?: boolean;\n};\n\nexport type CalDisplayFieldDto = CalSubstructureDto & {\n name?: string;\n param?: { type: string; value?: CalValueDto; token?: CalValueDto };\n};\n\nexport type CalInstructionDescriptorDto = {\n discriminator_hex?: string;\n instruction_name?: string;\n descriptor: CalSignedDescriptorDto;\n idl_descriptor?: {\n type_pool?: CalTypePoolEntryDto[];\n root_type?: number;\n };\n mint_association?: CalMintAssociationDto;\n owner_association?: unknown;\n enum_variants?: Record<string, Record<string, CalEnumVariantDto>>;\n display_fields?: CalDisplayFieldDto[];\n value_flow_ports?: CalValueFlowPortDto[];\n hide_rules?: CalSubstructureDto[];\n account_resets?: CalAccountResetDto[];\n};\n\n// One program object of the `solana_programs` response: the program `id`, its\n// `chain_id`, and the flat `instructions` array (keyed downstream by\n// `discriminator_hex`).\nexport type CalInstructionProgramDto = {\n id: string;\n chain_id: number;\n instructions: CalInstructionDescriptorDto[];\n};\n\n// Outer shape: array of program objects (one per requested `id`).\nexport type CalInstructionInfoResponseDto = CalInstructionProgramDto[];\n\n// --- Validation codecs (runtime). Validate only the fields the loaders read;\n// `Codec.interface` ignores unknown extras so CAL can add fields freely. ---\n\nconst calSignaturesCodec = Codec.interface({\n prod: optional(string),\n test: optional(string),\n});\n\nconst calSignedDescriptorCodec = Codec.interface({\n data: string,\n signatures: calSignaturesCodec,\n});\n\nconst calEnumVariantCodec = Codec.interface({\n descriptor: calSignedDescriptorCodec,\n});\n\nconst calSubstructureCodec = Codec.interface({\n descriptor: string,\n});\n\nconst calInstructionDescriptorCodec = Codec.interface({\n discriminator_hex: optional(string),\n descriptor: calSignedDescriptorCodec,\n enum_variants: optional(record(string, record(string, calEnumVariantCodec))),\n display_fields: optional(array(calSubstructureCodec)),\n value_flow_ports: optional(array(calSubstructureCodec)),\n hide_rules: optional(array(calSubstructureCodec)),\n account_resets: optional(array(calSubstructureCodec)),\n});\n\n/**\n * Codec for one program object of the `solana_programs` response. Used by the\n * datasource to validate the CAL payload before handing it to the loaders.\n * Only loader-consumed fields are validated; unrelated CAL fields\n * (`idl_descriptor`, `mint_association`, \u2026) are ignored.\n */\nexport const calInstructionProgramCodec = Codec.interface({\n id: string,\n chain_id: number,\n instructions: array(calInstructionDescriptorCodec),\n});\n"],
|
|
5
|
+
"mappings": "AAQA,OAAS,SAAAA,EAAO,SAAAC,EAAO,UAAAC,EAAQ,YAAAC,EAAU,UAAAC,EAAQ,UAAAC,MAAc,YA0G/D,MAAMC,EAAqBL,EAAM,UAAU,CACzC,KAAME,EAASE,CAAM,EACrB,KAAMF,EAASE,CAAM,CACvB,CAAC,EAEKE,EAA2BN,EAAM,UAAU,CAC/C,KAAMI,EACN,WAAYC,CACd,CAAC,EAEKE,EAAsBP,EAAM,UAAU,CAC1C,WAAYM,CACd,CAAC,EAEKE,EAAuBR,EAAM,UAAU,CAC3C,WAAYI,CACd,CAAC,EAEKK,EAAgCT,EAAM,UAAU,CACpD,kBAAmBE,EAASE,CAAM,EAClC,WAAYE,EACZ,cAAeJ,EAASC,EAAOC,EAAQD,EAAOC,EAAQG,CAAmB,CAAC,CAAC,EAC3E,eAAgBL,EAASH,EAAMS,CAAoB,CAAC,EACpD,iBAAkBN,EAASH,EAAMS,CAAoB,CAAC,EACtD,WAAYN,EAASH,EAAMS,CAAoB,CAAC,EAChD,eAAgBN,EAASH,EAAMS,CAAoB,CAAC,CACtD,CAAC,EAQYE,EAA6BV,EAAM,UAAU,CACxD,GAAII,EACJ,SAAUH,EACV,aAAcF,EAAMU,CAA6B,CACnD,CAAC",
|
|
6
6
|
"names": ["array", "Codec", "number", "optional", "record", "string", "calSignaturesCodec", "calSignedDescriptorCodec", "calEnumVariantCodec", "calSubstructureCodec", "calInstructionDescriptorCodec", "calInstructionProgramCodec"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{DeviceModelId as e}from"@ledgerhq/device-management-kit";import{exactly as o,oneOf as d}from"purify-ts";const t=d([o(e.NANO_X),o(e.NANO_SP),o(e.STAX),o(e.FLEX)]);export{t as deviceModelIdCodec};
|
|
1
|
+
import{DeviceModelId as e}from"@ledgerhq/device-management-kit";import{exactly as o,oneOf as d}from"purify-ts";const t=d([o(e.NANO_X),o(e.NANO_SP),o(e.STAX),o(e.FLEX),o(e.APEX)]);export{t as deviceModelIdCodec};
|
|
2
2
|
//# sourceMappingURL=deviceModelIdCodec.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/shared/utils/deviceModelIdCodec.ts"],
|
|
4
|
-
"sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { exactly, oneOf } from \"purify-ts\";\n\n/**\n * Set of device models supported by the clear-signing and transaction-check\n * flows. Excludes `NANO_S
|
|
5
|
-
"mappings": "AAAA,OAAS,iBAAAA,MAAqB,kCAC9B,OAAS,WAAAC,EAAS,SAAAC,MAAa,YAMxB,MAAMC,EAAqBD,EAAM,CACtCD,EAAQD,EAAc,MAAM,EAC5BC,EAAQD,EAAc,OAAO,EAC7BC,EAAQD,EAAc,IAAI,EAC1BC,EAAQD,EAAc,IAAI,CAC5B,CAAC",
|
|
4
|
+
"sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { exactly, oneOf } from \"purify-ts\";\n\n/**\n * Set of device models supported by the clear-signing and transaction-check\n * flows. Excludes `NANO_S`.\n */\nexport const deviceModelIdCodec = oneOf([\n exactly(DeviceModelId.NANO_X),\n exactly(DeviceModelId.NANO_SP),\n exactly(DeviceModelId.STAX),\n exactly(DeviceModelId.FLEX),\n exactly(DeviceModelId.APEX),\n]);\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,iBAAAA,MAAqB,kCAC9B,OAAS,WAAAC,EAAS,SAAAC,MAAa,YAMxB,MAAMC,EAAqBD,EAAM,CACtCD,EAAQD,EAAc,MAAM,EAC5BC,EAAQD,EAAc,OAAO,EAC7BC,EAAQD,EAAc,IAAI,EAC1BC,EAAQD,EAAc,IAAI,EAC1BC,EAAQD,EAAc,IAAI,CAC5B,CAAC",
|
|
6
6
|
"names": ["DeviceModelId", "exactly", "oneOf", "deviceModelIdCodec"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{DeviceModelId as e}from"@ledgerhq/device-management-kit";import{Right as t}from"purify-ts";import{deviceModelIdCodec as o}from"./deviceModelIdCodec";describe("deviceModelIdCodec",()=>{it.each([e.NANO_X,e.NANO_SP,e.STAX,e.FLEX])("decodes %s as Right",d=>{expect(o.decode(d)).toEqual(t(d))}),it("rejects NANO_S (unsupported for clear-signing)",()=>{expect(o.decode(e.NANO_S).isLeft()).toBe(!0)}),it.each([null,void 0,"","ledger",42,{},[]])("rejects non-model values: %s",d=>{expect(o.decode(d).isLeft()).toBe(!0)}),it("encodes a model as itself",()=>{expect(o.encode(e.NANO_X)).toBe(e.NANO_X)})});
|
|
1
|
+
import{DeviceModelId as e}from"@ledgerhq/device-management-kit";import{Right as t}from"purify-ts";import{deviceModelIdCodec as o}from"./deviceModelIdCodec";describe("deviceModelIdCodec",()=>{it.each([e.NANO_X,e.NANO_SP,e.STAX,e.FLEX,e.APEX])("decodes %s as Right",d=>{expect(o.decode(d)).toEqual(t(d))}),it("rejects NANO_S (unsupported for clear-signing)",()=>{expect(o.decode(e.NANO_S).isLeft()).toBe(!0)}),it.each([null,void 0,"","ledger",42,{},[]])("rejects non-model values: %s",d=>{expect(o.decode(d).isLeft()).toBe(!0)}),it("encodes a model as itself",()=>{expect(o.encode(e.NANO_X)).toBe(e.NANO_X)})});
|
|
2
2
|
//# sourceMappingURL=deviceModelIdCodec.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/shared/utils/deviceModelIdCodec.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { Right } from \"purify-ts\";\n\nimport { deviceModelIdCodec } from \"./deviceModelIdCodec\";\n\ndescribe(\"deviceModelIdCodec\", () => {\n it.each([\n DeviceModelId.NANO_X,\n DeviceModelId.NANO_SP,\n DeviceModelId.STAX,\n DeviceModelId.FLEX,\n ])(\"decodes %s as Right\", (model) => {\n expect(deviceModelIdCodec.decode(model)).toEqual(Right(model));\n });\n\n it(\"rejects NANO_S (unsupported for clear-signing)\", () => {\n expect(deviceModelIdCodec.decode(DeviceModelId.NANO_S).isLeft()).toBe(true);\n });\n\n it.each([null, undefined, \"\", \"ledger\", 42, {}, []])(\n \"rejects non-model values: %s\",\n (value) => {\n expect(deviceModelIdCodec.decode(value).isLeft()).toBe(true);\n },\n );\n\n it(\"encodes a model as itself\", () => {\n expect(deviceModelIdCodec.encode(DeviceModelId.NANO_X)).toBe(\n DeviceModelId.NANO_X,\n );\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OAAS,iBAAAA,MAAqB,kCAC9B,OAAS,SAAAC,MAAa,YAEtB,OAAS,sBAAAC,MAA0B,uBAEnC,SAAS,qBAAsB,IAAM,CACnC,GAAG,KAAK,CACNF,EAAc,OACdA,EAAc,QACdA,EAAc,KACdA,EAAc,IAChB,CAAC,EAAE,sBAAwBG,GAAU,CACnC,OAAOD,EAAmB,OAAOC,CAAK,CAAC,EAAE,QAAQF,EAAME,CAAK,CAAC,CAC/D,CAAC,EAED,GAAG,iDAAkD,IAAM,CACzD,OAAOD,EAAmB,OAAOF,EAAc,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAI,CAC5E,CAAC,EAED,GAAG,KAAK,CAAC,KAAM,OAAW,GAAI,SAAU,GAAI,CAAC,EAAG,CAAC,CAAC,CAAC,EACjD,+BACCI,GAAU,CACT,OAAOF,EAAmB,OAAOE,CAAK,EAAE,OAAO,CAAC,EAAE,KAAK,EAAI,CAC7D,CACF,EAEA,GAAG,4BAA6B,IAAM,CACpC,OAAOF,EAAmB,OAAOF,EAAc,MAAM,CAAC,EAAE,KACtDA,EAAc,MAChB,CACF,CAAC,CACH,CAAC",
|
|
4
|
+
"sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { Right } from \"purify-ts\";\n\nimport { deviceModelIdCodec } from \"./deviceModelIdCodec\";\n\ndescribe(\"deviceModelIdCodec\", () => {\n it.each([\n DeviceModelId.NANO_X,\n DeviceModelId.NANO_SP,\n DeviceModelId.STAX,\n DeviceModelId.FLEX,\n DeviceModelId.APEX,\n ])(\"decodes %s as Right\", (model) => {\n expect(deviceModelIdCodec.decode(model)).toEqual(Right(model));\n });\n\n it(\"rejects NANO_S (unsupported for clear-signing)\", () => {\n expect(deviceModelIdCodec.decode(DeviceModelId.NANO_S).isLeft()).toBe(true);\n });\n\n it.each([null, undefined, \"\", \"ledger\", 42, {}, []])(\n \"rejects non-model values: %s\",\n (value) => {\n expect(deviceModelIdCodec.decode(value).isLeft()).toBe(true);\n },\n );\n\n it(\"encodes a model as itself\", () => {\n expect(deviceModelIdCodec.encode(DeviceModelId.NANO_X)).toBe(\n DeviceModelId.NANO_X,\n );\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,iBAAAA,MAAqB,kCAC9B,OAAS,SAAAC,MAAa,YAEtB,OAAS,sBAAAC,MAA0B,uBAEnC,SAAS,qBAAsB,IAAM,CACnC,GAAG,KAAK,CACNF,EAAc,OACdA,EAAc,QACdA,EAAc,KACdA,EAAc,KACdA,EAAc,IAChB,CAAC,EAAE,sBAAwBG,GAAU,CACnC,OAAOD,EAAmB,OAAOC,CAAK,CAAC,EAAE,QAAQF,EAAME,CAAK,CAAC,CAC/D,CAAC,EAED,GAAG,iDAAkD,IAAM,CACzD,OAAOD,EAAmB,OAAOF,EAAc,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAI,CAC5E,CAAC,EAED,GAAG,KAAK,CAAC,KAAM,OAAW,GAAI,SAAU,GAAI,CAAC,EAAG,CAAC,CAAC,CAAC,EACjD,+BACCI,GAAU,CACT,OAAOF,EAAmB,OAAOE,CAAK,EAAE,OAAO,CAAC,EAAE,KAAK,EAAI,CAC7D,CACF,EAEA,GAAG,4BAA6B,IAAM,CACpC,OAAOF,EAAmB,OAAOF,EAAc,MAAM,CAAC,EAAE,KACtDA,EAAc,MAChB,CACF,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["DeviceModelId", "Right", "deviceModelIdCodec", "model", "value"]
|
|
7
7
|
}
|
package/lib/types/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpInstructionInfoDataSource.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,EAAE,MAAM,EAAe,MAAM,WAAW,CAAC;AAGhD,OAAO,EAAE,KAAK,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAIrF,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACtB,MAAM,6BAA6B,CAAC;AAoBrC,qBACa,6BACX,YAAW,yBAAyB;IAIlC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAEvB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAFJ,MAAM,EAAE,0BAA0B,EAElC,IAAI,EAAE,gBAAgB;IAG5B,kBAAkB,CAAC,EAC9B,SAAS,EACT,OAAO,GACR,EAAE,wBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,qBAAqB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"HttpInstructionInfoDataSource.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,EAAE,MAAM,EAAe,MAAM,WAAW,CAAC;AAGhD,OAAO,EAAE,KAAK,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAIrF,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACtB,MAAM,6BAA6B,CAAC;AAoBrC,qBACa,6BACX,YAAW,yBAAyB;IAIlC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAEvB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAFJ,MAAM,EAAE,0BAA0B,EAElC,IAAI,EAAE,gBAAgB;IAG5B,kBAAkB,CAAC,EAC9B,SAAS,EACT,OAAO,GACR,EAAE,wBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,qBAAqB,CAAC,CAAC;CA8F5E"}
|
|
@@ -64,7 +64,7 @@ export type CalDisplayFieldDto = CalSubstructureDto & {
|
|
|
64
64
|
};
|
|
65
65
|
};
|
|
66
66
|
export type CalInstructionDescriptorDto = {
|
|
67
|
-
discriminator_hex
|
|
67
|
+
discriminator_hex?: string;
|
|
68
68
|
instruction_name?: string;
|
|
69
69
|
descriptor: CalSignedDescriptorDto;
|
|
70
70
|
idl_descriptor?: {
|
|
@@ -95,7 +95,7 @@ export declare const calInstructionProgramCodec: Codec<{
|
|
|
95
95
|
id: string;
|
|
96
96
|
chain_id: number;
|
|
97
97
|
instructions: {
|
|
98
|
-
discriminator_hex: string;
|
|
98
|
+
discriminator_hex: string | undefined;
|
|
99
99
|
descriptor: {
|
|
100
100
|
data: string;
|
|
101
101
|
signatures: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstructionInfoDto.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/solana/instruction-info/data/InstructionInfoDto.ts"],"names":[],"mappings":"AAQA,OAAO,EAAS,KAAK,EAAoC,MAAM,WAAW,CAAC;AAE3E,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAA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AAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,GAAG;IACrD,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,WAAW,EAAE,gBAAgB,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,kBAAkB,GAAG;IACpD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,kBAAkB,GAAG;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,WAAW,CAAC;QAAC,KAAK,CAAC,EAAE,WAAW,CAAA;KAAE,CAAC;CACpE,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,iBAAiB,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"InstructionInfoDto.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/solana/instruction-info/data/InstructionInfoDto.ts"],"names":[],"mappings":"AAQA,OAAO,EAAS,KAAK,EAAoC,MAAM,WAAW,CAAC;AAE3E,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,aAAa,CAAC;CAC3B,CAAC;AAKF,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;CAC5B,CAAC;AAE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/**
|
|
3
3
|
* Set of device models supported by the clear-signing and transaction-check
|
|
4
|
-
* flows. Excludes `NANO_S
|
|
4
|
+
* flows. Excludes `NANO_S`.
|
|
5
5
|
*/
|
|
6
|
-
export declare const deviceModelIdCodec: import("purify-ts").Codec<DeviceModelId.NANO_SP | DeviceModelId.NANO_X | DeviceModelId.STAX | DeviceModelId.FLEX>;
|
|
6
|
+
export declare const deviceModelIdCodec: import("purify-ts").Codec<DeviceModelId.NANO_SP | DeviceModelId.NANO_X | DeviceModelId.STAX | DeviceModelId.FLEX | DeviceModelId.APEX>;
|
|
7
7
|
//# sourceMappingURL=deviceModelIdCodec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceModelIdCodec.d.ts","sourceRoot":"","sources":["../../../../../src/shared/utils/deviceModelIdCodec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAGhE;;;GAGG;AACH,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"deviceModelIdCodec.d.ts","sourceRoot":"","sources":["../../../../../src/shared/utils/deviceModelIdCodec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAGhE;;;GAGG;AACH,eAAO,MAAM,kBAAkB,wIAM7B,CAAC"}
|