@ledgerhq/context-module 0.0.0-develop-20260715002034 → 0.0.0-develop-20260716002346

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.
Files changed (73) hide show
  1. package/lib/cjs/package.json +1 -1
  2. package/lib/cjs/src/modules/solana/alt-resolution/data/HttpAltResolutionDataSource.js +1 -1
  3. package/lib/cjs/src/modules/solana/alt-resolution/data/HttpAltResolutionDataSource.js.map +1 -1
  4. package/lib/cjs/src/modules/solana/enum-variant/domain/EnumVariantContextLoader.js +1 -1
  5. package/lib/cjs/src/modules/solana/enum-variant/domain/EnumVariantContextLoader.js.map +2 -2
  6. package/lib/cjs/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.js +1 -1
  7. package/lib/cjs/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.js.map +3 -3
  8. package/lib/cjs/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.js +1 -1
  9. package/lib/cjs/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.js.map +3 -3
  10. package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoDto.js +1 -1
  11. package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoDto.js.map +3 -3
  12. package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoMapper.js +1 -1
  13. package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoMapper.js.map +3 -3
  14. package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoMapper.test.js +1 -1
  15. package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoMapper.test.js.map +2 -2
  16. package/lib/cjs/src/modules/solana/instruction-info/domain/InstructionInfoContextLoader.js +1 -1
  17. package/lib/cjs/src/modules/solana/instruction-info/domain/InstructionInfoContextLoader.js.map +2 -2
  18. package/lib/cjs/src/modules/solana/model/SolanaPayloads.js.map +1 -1
  19. package/lib/cjs/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.js +1 -1
  20. package/lib/cjs/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.js.map +1 -1
  21. package/lib/cjs/src/modules/solana/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
  22. package/lib/cjs/src/modules/solana/trusted-name/data/HttpTrustedNameDataSource.js.map +3 -3
  23. package/lib/cjs/src/modules/solana/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  24. package/lib/cjs/src/modules/solana/trusted-name/data/HttpTrustedNameDataSource.test.js.map +3 -3
  25. package/lib/cjs/src/modules/solana/trusted-name/data/TrustedNameDataSource.js +1 -1
  26. package/lib/cjs/src/modules/solana/trusted-name/data/TrustedNameDataSource.js.map +1 -1
  27. package/lib/cjs/src/modules/solana/trusted-name/domain/TrustedNameContextLoader.js +1 -1
  28. package/lib/cjs/src/modules/solana/trusted-name/domain/TrustedNameContextLoader.js.map +3 -3
  29. package/lib/cjs/src/modules/solana/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
  30. package/lib/cjs/src/modules/solana/trusted-name/domain/TrustedNameContextLoader.test.js.map +3 -3
  31. package/lib/esm/package.json +1 -1
  32. package/lib/esm/src/modules/solana/alt-resolution/data/HttpAltResolutionDataSource.js +1 -1
  33. package/lib/esm/src/modules/solana/alt-resolution/data/HttpAltResolutionDataSource.js.map +1 -1
  34. package/lib/esm/src/modules/solana/enum-variant/domain/EnumVariantContextLoader.js +1 -1
  35. package/lib/esm/src/modules/solana/enum-variant/domain/EnumVariantContextLoader.js.map +2 -2
  36. package/lib/esm/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.js +1 -1
  37. package/lib/esm/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.js.map +3 -3
  38. package/lib/esm/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.js +1 -1
  39. package/lib/esm/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.js.map +3 -3
  40. package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoDto.js +1 -1
  41. package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoDto.js.map +3 -3
  42. package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoMapper.js +1 -1
  43. package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoMapper.js.map +3 -3
  44. package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoMapper.test.js +1 -1
  45. package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoMapper.test.js.map +2 -2
  46. package/lib/esm/src/modules/solana/instruction-info/domain/InstructionInfoContextLoader.js +1 -1
  47. package/lib/esm/src/modules/solana/instruction-info/domain/InstructionInfoContextLoader.js.map +2 -2
  48. package/lib/esm/src/modules/solana/model/SolanaPayloads.js.map +1 -1
  49. package/lib/esm/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.js +1 -1
  50. package/lib/esm/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.js.map +1 -1
  51. package/lib/esm/src/modules/solana/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
  52. package/lib/esm/src/modules/solana/trusted-name/data/HttpTrustedNameDataSource.js.map +3 -3
  53. package/lib/esm/src/modules/solana/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  54. package/lib/esm/src/modules/solana/trusted-name/data/HttpTrustedNameDataSource.test.js.map +3 -3
  55. package/lib/esm/src/modules/solana/trusted-name/domain/TrustedNameContextLoader.js +1 -1
  56. package/lib/esm/src/modules/solana/trusted-name/domain/TrustedNameContextLoader.js.map +3 -3
  57. package/lib/esm/src/modules/solana/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
  58. package/lib/esm/src/modules/solana/trusted-name/domain/TrustedNameContextLoader.test.js.map +3 -3
  59. package/lib/types/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.d.ts.map +1 -1
  60. package/lib/types/src/modules/solana/instruction-info/data/InstructionInfoDto.d.ts +50 -56
  61. package/lib/types/src/modules/solana/instruction-info/data/InstructionInfoDto.d.ts.map +1 -1
  62. package/lib/types/src/modules/solana/instruction-info/data/InstructionInfoMapper.d.ts +4 -1
  63. package/lib/types/src/modules/solana/instruction-info/data/InstructionInfoMapper.d.ts.map +1 -1
  64. package/lib/types/src/modules/solana/model/SolanaPayloads.d.ts +3 -5
  65. package/lib/types/src/modules/solana/model/SolanaPayloads.d.ts.map +1 -1
  66. package/lib/types/src/modules/solana/trusted-name/data/HttpTrustedNameDataSource.d.ts +1 -1
  67. package/lib/types/src/modules/solana/trusted-name/data/HttpTrustedNameDataSource.d.ts.map +1 -1
  68. package/lib/types/src/modules/solana/trusted-name/data/TrustedNameDataSource.d.ts +0 -1
  69. package/lib/types/src/modules/solana/trusted-name/data/TrustedNameDataSource.d.ts.map +1 -1
  70. package/lib/types/src/modules/solana/trusted-name/domain/TrustedNameContextLoader.d.ts +0 -1
  71. package/lib/types/src/modules/solana/trusted-name/domain/TrustedNameContextLoader.d.ts.map +1 -1
  72. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  73. package/package.json +5 -5
@@ -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-20260715002034"
61
+ "version": "0.0.0-develop-20260716002346"
62
62
  }
@@ -1,2 +1,2 @@
1
- "use strict";var c=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var A=(r,e)=>{for(var t in e)c(r,t,{get:e[t],enumerable:!0})},E=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of k(e))!$.call(r,o)&&o!==t&&c(r,o,{get:()=>e[o],enumerable:!(s=g(e,o))||s.enumerable});return r};var w=r=>E(c({},"__esModule",{value:!0}),r),f=(r,e,t,s)=>{for(var o=s>1?void 0:s?g(e,t):e,l=r.length-1,i;l>=0;l--)(i=r[l])&&(o=(s?i(e,t,o):i(o))||o);return s&&o&&c(e,t,o),o},m=(r,e)=>(t,s)=>e(t,s,r);var x={};A(x,{HttpAltResolutionDataSource:()=>a});module.exports=w(x);var p=require("inversify"),n=require("purify-ts"),d=require("../../../../config/di/configTypes"),R=require("../../../../shared/network/di/networkTypes"),y=require("../../../../shared/utils/HexStringUtils"),D=require("../../../../shared/utils/signedDescriptorDto"),h=require("../../../../shared/utils/uIntCodec");let a=class{constructor(e,t){this.config=e;this.http=t}async getAltResolution({altAddress:e,entryIndex:t,challenge:s}){const o=h.u8Codec.decode(t);if(o.isLeft())return(0,n.Left)(new Error(`[ContextModule] HttpAltResolutionDataSource: invalid entryIndex (got ${t}): ${o.leftOrDefault("")}`));let l;try{l=await this.http.get(`${this.config.metadataServiceDomain.url}/v2/solana/alt-resolution/${e}/${t}`,{params:{challenge:s}})}catch(i){const u=i instanceof Error?i.message:String(i);return(0,n.Left)(new Error(`[ContextModule] HttpAltResolutionDataSource: Failed to fetch ALT resolution: ${u}`))}return D.signedDescriptorDtoCodec.decode(l).caseOf({Left:i=>(0,n.Left)(new Error(`[ContextModule] HttpAltResolutionDataSource: malformed response for (${e}, ${t}): ${i}`)),Right:i=>{let u;try{u=y.HexStringUtils.hexToBytes(i.signedDescriptor)}catch(C){return(0,n.Left)(new Error(`[ContextModule] HttpAltResolutionDataSource: invalid hex in signedDescriptor for (${e}, ${t}): ${C.message}`))}return(0,n.Right)({altAddress:e,entryIndex:t,descriptor:u,keyId:i.keyId,keyUsage:i.keyUsage})}})}};a=f([(0,p.injectable)(),m(0,(0,p.inject)(d.configTypes.Config)),m(1,(0,p.inject)(R.networkTypes.NetworkClient))],a);0&&(module.exports={HttpAltResolutionDataSource});
1
+ "use strict";var c=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var $=(r,e)=>{for(var t in e)c(r,t,{get:e[t],enumerable:!0})},E=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of A(e))!k.call(r,o)&&o!==t&&c(r,o,{get:()=>e[o],enumerable:!(s=f(e,o))||s.enumerable});return r};var w=r=>E(c({},"__esModule",{value:!0}),r),g=(r,e,t,s)=>{for(var o=s>1?void 0:s?f(e,t):e,l=r.length-1,i;l>=0;l--)(i=r[l])&&(o=(s?i(e,t,o):i(o))||o);return s&&o&&c(e,t,o),o},m=(r,e)=>(t,s)=>e(t,s,r);var x={};$(x,{HttpAltResolutionDataSource:()=>a});module.exports=w(x);var u=require("inversify"),n=require("purify-ts"),d=require("../../../../config/di/configTypes"),R=require("../../../../shared/network/di/networkTypes"),y=require("../../../../shared/utils/HexStringUtils"),D=require("../../../../shared/utils/signedDescriptorDto"),h=require("../../../../shared/utils/uIntCodec");let a=class{constructor(e,t){this.config=e;this.http=t}async getAltResolution({altAddress:e,entryIndex:t,challenge:s}){const o=h.u8Codec.decode(t);if(o.isLeft())return(0,n.Left)(new Error(`[ContextModule] HttpAltResolutionDataSource: invalid entryIndex (got ${t}): ${o.leftOrDefault("")}`));let l;try{l=await this.http.get(`${this.config.metadataServiceDomain.url}/v2/solana/alt-resolution/${e}/${t}`,{params:{challenge:s}})}catch(i){const p=i instanceof Error?i.message:String(i);return(0,n.Left)(new Error(`[ContextModule] HttpAltResolutionDataSource: Failed to fetch ALT resolution: ${p}`))}return D.signedDescriptorDtoCodec.decode(l).caseOf({Left:i=>(0,n.Left)(new Error(`[ContextModule] HttpAltResolutionDataSource: malformed response for (${e}, ${t}): ${i}`)),Right:i=>{let p;try{p=y.HexStringUtils.hexToBytes(i.signedDescriptor)}catch(C){return(0,n.Left)(new Error(`[ContextModule] HttpAltResolutionDataSource: invalid hex in signedDescriptor for (${e}, ${t}): ${C.message}`))}return(0,n.Right)({altAddress:e,entryIndex:t,descriptor:p,keyId:i.keyId,keyUsage:i.keyUsage})}})}};a=g([(0,u.injectable)(),m(0,(0,u.inject)(d.configTypes.Config)),m(1,(0,u.inject)(R.networkTypes.NetworkClient))],a);0&&(module.exports={HttpAltResolutionDataSource});
2
2
  //# sourceMappingURL=HttpAltResolutionDataSource.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/modules/solana/alt-resolution/data/HttpAltResolutionDataSource.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 { networkTypes } from \"@/shared/network/di/networkTypes\";\nimport { HexStringUtils } from \"@/shared/utils/HexStringUtils\";\nimport { signedDescriptorDtoCodec } from \"@/shared/utils/signedDescriptorDto\";\nimport { u8Codec } from \"@/shared/utils/uIntCodec\";\n\nimport {\n type AltResolutionDataSource,\n type AltResolutionResult,\n type GetAltResolutionParams,\n} from \"./AltResolutionDataSource\";\n\ntype AltResolutionResponseDto = {\n descriptorType?: string;\n descriptorVersion?: string;\n alt_address?: string;\n entry_index?: number;\n resolved_address?: string;\n signedDescriptor: string;\n keyId: string;\n keyUsage: string;\n};\n\n@injectable()\nexport class HttpAltResolutionDataSource implements AltResolutionDataSource {\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 getAltResolution({\n altAddress,\n entryIndex,\n challenge,\n }: GetAltResolutionParams): Promise<Either<Error, AltResolutionResult>> {\n const entryIndexResult = u8Codec.decode(entryIndex);\n if (entryIndexResult.isLeft()) {\n return Left(\n new Error(\n `[ContextModule] HttpAltResolutionDataSource: invalid entryIndex (got ${entryIndex}): ${entryIndexResult.leftOrDefault(\"\")}`,\n ),\n );\n }\n\n let dto: AltResolutionResponseDto;\n try {\n dto = (await this.http.get(\n `${this.config.metadataServiceDomain.url}/v2/solana/alt-resolution/${altAddress}/${entryIndex}`,\n { params: { challenge } },\n )) as AltResolutionResponseDto;\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n return Left(\n new Error(\n `[ContextModule] HttpAltResolutionDataSource: Failed to fetch ALT resolution: ${reason}`,\n ),\n );\n }\n\n return signedDescriptorDtoCodec\n .decode(dto)\n .caseOf<Either<Error, AltResolutionResult>>({\n Left: (error) =>\n Left(\n new Error(\n `[ContextModule] HttpAltResolutionDataSource: malformed response for (${altAddress}, ${entryIndex}): ${error}`,\n ),\n ),\n Right: (validated) => {\n let descriptor: Uint8Array;\n try {\n descriptor = HexStringUtils.hexToBytes(validated.signedDescriptor);\n } catch (error) {\n return Left(\n new Error(\n `[ContextModule] HttpAltResolutionDataSource: invalid hex in signedDescriptor for (${altAddress}, ${entryIndex}): ${(error as Error).message}`,\n ),\n );\n }\n\n return Right({\n altAddress,\n entryIndex,\n descriptor,\n keyId: validated.keyId,\n keyUsage: validated.keyUsage,\n });\n },\n });\n }\n}\n"],
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 { networkTypes } from \"@/shared/network/di/networkTypes\";\nimport { HexStringUtils } from \"@/shared/utils/HexStringUtils\";\nimport { signedDescriptorDtoCodec } from \"@/shared/utils/signedDescriptorDto\";\nimport { u8Codec } from \"@/shared/utils/uIntCodec\";\n\nimport {\n type AltResolutionDataSource,\n type AltResolutionResult,\n type GetAltResolutionParams,\n} from \"./AltResolutionDataSource\";\n\ntype AltResolutionResponseDto = {\n descriptorType?: string;\n descriptorVersion?: number;\n altAddress?: string;\n entryIndex?: number;\n resolvedAddress?: string;\n signedDescriptor: string;\n keyId: string;\n keyUsage: string;\n};\n\n@injectable()\nexport class HttpAltResolutionDataSource implements AltResolutionDataSource {\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 getAltResolution({\n altAddress,\n entryIndex,\n challenge,\n }: GetAltResolutionParams): Promise<Either<Error, AltResolutionResult>> {\n const entryIndexResult = u8Codec.decode(entryIndex);\n if (entryIndexResult.isLeft()) {\n return Left(\n new Error(\n `[ContextModule] HttpAltResolutionDataSource: invalid entryIndex (got ${entryIndex}): ${entryIndexResult.leftOrDefault(\"\")}`,\n ),\n );\n }\n\n let dto: AltResolutionResponseDto;\n try {\n dto = (await this.http.get(\n `${this.config.metadataServiceDomain.url}/v2/solana/alt-resolution/${altAddress}/${entryIndex}`,\n { params: { challenge } },\n )) as AltResolutionResponseDto;\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n return Left(\n new Error(\n `[ContextModule] HttpAltResolutionDataSource: Failed to fetch ALT resolution: ${reason}`,\n ),\n );\n }\n\n return signedDescriptorDtoCodec\n .decode(dto)\n .caseOf<Either<Error, AltResolutionResult>>({\n Left: (error) =>\n Left(\n new Error(\n `[ContextModule] HttpAltResolutionDataSource: malformed response for (${altAddress}, ${entryIndex}): ${error}`,\n ),\n ),\n Right: (validated) => {\n let descriptor: Uint8Array;\n try {\n descriptor = HexStringUtils.hexToBytes(validated.signedDescriptor);\n } catch (error) {\n return Left(\n new Error(\n `[ContextModule] HttpAltResolutionDataSource: invalid hex in signedDescriptor for (${altAddress}, ${entryIndex}): ${(error as Error).message}`,\n ),\n );\n }\n\n return Right({\n altAddress,\n entryIndex,\n descriptor,\n keyId: validated.keyId,\n keyUsage: validated.keyUsage,\n });\n },\n });\n }\n}\n"],
5
5
  "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAmC,qBACnCC,EAAoC,qBAEpCC,EAA4B,mCAE5BC,EAA6B,4CAC7BC,EAA+B,yCAC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pAltResolutionDataSource_exports", "__export", "HttpAltResolutionDataSource", "__toCommonJS", "import_inversify", "import_purify_ts", "import_configTypes", "import_networkTypes", "import_HexStringUtils", "import_signedDescriptorDto", "import_uIntCodec", "HttpAltResolutionDataSource", "config", "http", "altAddress", "entryIndex", "challenge", "entryIndexResult", "dto", "error", "reason", "validated", "descriptor", "__decorateClass", "__decorateParam"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var l=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var U=(o,e)=>{for(var n in e)l(o,n,{get:e[n],enumerable:!0})},_=(o,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of k(e))!O.call(o,a)&&a!==n&&l(o,a,{get:()=>e[a],enumerable:!(t=x(e,a))||t.enumerable});return o};var b=o=>_(l({},"__esModule",{value:!0}),o),S=(o,e,n,t)=>{for(var a=t>1?void 0:t?x(e,n):e,s=o.length-1,d;s>=0;s--)(d=o[s])&&(a=(t?d(e,n,a):d(a))||a);return t&&a&&l(e,n,a),a},g=(o,e)=>(n,t)=>e(n,t,o);var j={};U(j,{EnumVariantContextLoader:()=>I});module.exports=b(j);var p=require("inversify"),i=require("purify-ts"),y=require("../../../../config/di/configTypes"),E=require("../../../../modules/multichain/pki/di/pkiTypes"),R=require("../../../../modules/multichain/pki/model/KeyId"),h=require("../../../../modules/multichain/pki/model/KeyUsage"),V=require("../../../../modules/solana/instruction-info/di/instructionInfoTypes"),m=require("../../../../shared/model/ClearSignContext"),A=require("../../../../shared/utils/certificateResult"),M=require("../../../../shared/utils/deviceModelIdCodec"),L=require("../../../../shared/utils/uIntCodec");const D=[m.ClearSignContextType.SOLANA_ENUM_VARIANT],$="solana-mainnet",K=i.Codec.interface({programId:i.string,enumId:i.string,variantIndex:L.u16Codec}),F=i.Codec.interface({deviceModelId:M.deviceModelIdCodec,selections:(0,i.array)(K),network:(0,i.optional)(i.string)});let I=class{constructor(e,n,t,a){this.dataSource=e;this.config=n;this.certificateLoader=t;this.logger=a("EnumVariantContextLoader")}logger;canHandle(e,n){return D.every(t=>n.includes(t))?F.decode(e).caseOf({Left:()=>!1,Right:({selections:t})=>t.length>0&&t.every(a=>a.programId.length>0&&a.enumId.length>0)}):!1}async load(e){const n=e.network||$,t=Array.from(new Set(e.selections.map(r=>r.programId)));this.logger.debug("[load] Fetching enum variants",{data:{network:n,programCount:t.length,selectionCount:e.selections.length}});const a=(0,A.loadCertificateResult)(this.certificateLoader,{keyId:R.KeyId.TokenMetadataKey,keyUsage:h.KeyUsage.CoinMeta,targetDevice:e.deviceModelId}),s=Promise.all(t.map(r=>this.dataSource.getInstructionInfo({programId:r,network:n}))),[d,T]=await Promise.all([a,s]);if(!d.ok||!d.value){const r=d.ok?new Error("[ContextModule] EnumVariantContextLoader: certificate is missing"):d.error;return this.logger.warn("[load] ENUM_VARIANT certificate unavailable",{data:{error:r.message}}),e.selections.map(()=>({type:m.ClearSignContextType.ERROR,error:r}))}const w=d.value,N=new Map(t.map((r,c)=>[r,T[c]])),v=this.config.cal.mode??"prod";return e.selections.map(r=>{const c=N.get(r.programId);if(!c){const u=new Error(`[ContextModule] EnumVariantContextLoader: no CAL response for program ${r.programId}`);return this.logger.warn("[load] ENUM_VARIANT fetch failed",{data:{programId:r.programId,enumId:r.enumId,variantIndex:r.variantIndex,error:u.message}}),{type:m.ClearSignContextType.ERROR,error:u}}return c.caseOf({Left:u=>(this.logger.warn("[load] ENUM_VARIANT fetch failed",{data:{programId:r.programId,enumId:r.enumId,variantIndex:r.variantIndex,error:u.message}}),{type:m.ClearSignContextType.ERROR,error:u}),Right:u=>{const f=this.lookupVariant(u,r);if(!f){const C=new Error(`[ContextModule] EnumVariantContextLoader: CAL has no enum variant for (${r.programId}, ${r.enumId}, ${r.variantIndex})`);return this.logger.warn("[load] ENUM_VARIANT not found in CAL response",{data:{programId:r.programId,enumId:r.enumId,variantIndex:r.variantIndex}}),{type:m.ClearSignContextType.ERROR,error:C}}if(!f.descriptor.signature){const C=new Error(`[ContextModule] EnumVariantContextLoader: missing '${v}' signature for (${r.programId}, ${r.enumId}, ${r.variantIndex})`);return this.logger.warn("[load] ENUM_VARIANT missing signature",{data:{programId:r.programId,enumId:r.enumId,variantIndex:r.variantIndex,mode:v}}),{type:m.ClearSignContextType.ERROR,error:C}}const P={programId:r.programId,enumId:r.enumId,variantIndex:r.variantIndex,descriptor:f.descriptor};return{type:m.ClearSignContextType.SOLANA_ENUM_VARIANT,payload:P,certificate:w}}})})}lookupVariant(e,n){return e.enumVariants.find(t=>t.enumId===n.enumId&&t.variantIndex===n.variantIndex)}};I=S([(0,p.injectable)(),g(0,(0,p.inject)(V.instructionInfoTypes.InstructionInfoDataSource)),g(1,(0,p.inject)(y.configTypes.Config)),g(2,(0,p.inject)(E.pkiTypes.PkiCertificateLoader)),g(3,(0,p.inject)(y.configTypes.ContextModuleLoggerFactory))],I);0&&(module.exports={EnumVariantContextLoader});
1
+ "use strict";var c=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var U=(o,e)=>{for(var n in e)c(o,n,{get:e[n],enumerable:!0})},_=(o,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of k(e))!O.call(o,a)&&a!==n&&c(o,a,{get:()=>e[a],enumerable:!(t=x(e,a))||t.enumerable});return o};var b=o=>_(c({},"__esModule",{value:!0}),o),S=(o,e,n,t)=>{for(var a=t>1?void 0:t?x(e,n):e,s=o.length-1,d;s>=0;s--)(d=o[s])&&(a=(t?d(e,n,a):d(a))||a);return t&&a&&c(e,n,a),a},g=(o,e)=>(n,t)=>e(n,t,o);var j={};U(j,{EnumVariantContextLoader:()=>I});module.exports=b(j);var p=require("inversify"),i=require("purify-ts"),y=require("../../../../config/di/configTypes"),E=require("../../../../modules/multichain/pki/di/pkiTypes"),R=require("../../../../modules/multichain/pki/model/KeyId"),h=require("../../../../modules/multichain/pki/model/KeyUsage"),V=require("../../../../modules/solana/instruction-info/di/instructionInfoTypes"),m=require("../../../../shared/model/ClearSignContext"),A=require("../../../../shared/utils/certificateResult"),L=require("../../../../shared/utils/deviceModelIdCodec"),M=require("../../../../shared/utils/uIntCodec");const D=[m.ClearSignContextType.SOLANA_ENUM_VARIANT],$="solana-mainnet",K=i.Codec.interface({programId:i.string,enumId:i.string,variantIndex:M.u16Codec}),F=i.Codec.interface({deviceModelId:L.deviceModelIdCodec,selections:(0,i.array)(K),network:(0,i.optional)(i.string)});let I=class{constructor(e,n,t,a){this.dataSource=e;this.config=n;this.certificateLoader=t;this.logger=a("EnumVariantContextLoader")}logger;canHandle(e,n){return D.every(t=>n.includes(t))?F.decode(e).caseOf({Left:()=>!1,Right:({selections:t})=>t.length>0&&t.every(a=>a.programId.length>0&&a.enumId.length>0)}):!1}async load(e){const n=e.network||$,t=Array.from(new Set(e.selections.map(r=>r.programId)));this.logger.debug("[load] Fetching enum variants",{data:{network:n,programCount:t.length,selectionCount:e.selections.length}});const a=(0,A.loadCertificateResult)(this.certificateLoader,{keyId:R.KeyId.CalCalldataKey,keyUsage:h.KeyUsage.Calldata,targetDevice:e.deviceModelId}),s=Promise.all(t.map(r=>this.dataSource.getInstructionInfo({programId:r,network:n}))),[d,T]=await Promise.all([a,s]);if(!d.ok||!d.value){const r=d.ok?new Error("[ContextModule] EnumVariantContextLoader: certificate is missing"):d.error;return this.logger.warn("[load] ENUM_VARIANT certificate unavailable",{data:{error:r.message}}),e.selections.map(()=>({type:m.ClearSignContextType.ERROR,error:r}))}const w=d.value,N=new Map(t.map((r,l)=>[r,T[l]])),v=this.config.cal.mode??"prod";return e.selections.map(r=>{const l=N.get(r.programId);if(!l){const u=new Error(`[ContextModule] EnumVariantContextLoader: no CAL response for program ${r.programId}`);return this.logger.warn("[load] ENUM_VARIANT fetch failed",{data:{programId:r.programId,enumId:r.enumId,variantIndex:r.variantIndex,error:u.message}}),{type:m.ClearSignContextType.ERROR,error:u}}return l.caseOf({Left:u=>(this.logger.warn("[load] ENUM_VARIANT fetch failed",{data:{programId:r.programId,enumId:r.enumId,variantIndex:r.variantIndex,error:u.message}}),{type:m.ClearSignContextType.ERROR,error:u}),Right:u=>{const f=this.lookupVariant(u,r);if(!f){const C=new Error(`[ContextModule] EnumVariantContextLoader: CAL has no enum variant for (${r.programId}, ${r.enumId}, ${r.variantIndex})`);return this.logger.warn("[load] ENUM_VARIANT not found in CAL response",{data:{programId:r.programId,enumId:r.enumId,variantIndex:r.variantIndex}}),{type:m.ClearSignContextType.ERROR,error:C}}if(!f.descriptor.signature){const C=new Error(`[ContextModule] EnumVariantContextLoader: missing '${v}' signature for (${r.programId}, ${r.enumId}, ${r.variantIndex})`);return this.logger.warn("[load] ENUM_VARIANT missing signature",{data:{programId:r.programId,enumId:r.enumId,variantIndex:r.variantIndex,mode:v}}),{type:m.ClearSignContextType.ERROR,error:C}}const P={programId:r.programId,enumId:r.enumId,variantIndex:r.variantIndex,descriptor:f.descriptor};return{type:m.ClearSignContextType.SOLANA_ENUM_VARIANT,payload:P,certificate:w}}})})}lookupVariant(e,n){return e.enumVariants.find(t=>t.enumId===n.enumId&&t.variantIndex===n.variantIndex)}};I=S([(0,p.injectable)(),g(0,(0,p.inject)(V.instructionInfoTypes.InstructionInfoDataSource)),g(1,(0,p.inject)(y.configTypes.Config)),g(2,(0,p.inject)(E.pkiTypes.PkiCertificateLoader)),g(3,(0,p.inject)(y.configTypes.ContextModuleLoggerFactory))],I);0&&(module.exports={EnumVariantContextLoader});
2
2
  //# sourceMappingURL=EnumVariantContextLoader.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/modules/solana/enum-variant/domain/EnumVariantContextLoader.ts"],
4
- "sourcesContent": ["import {\n type DeviceModelId,\n type LoggerPublisherService,\n} from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { array, Codec, optional, string } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { pkiTypes } from \"@/modules/multichain/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/modules/multichain/pki/domain/PkiCertificateLoader\";\nimport { KeyId } from \"@/modules/multichain/pki/model/KeyId\";\nimport { KeyUsage } from \"@/modules/multichain/pki/model/KeyUsage\";\nimport {\n type InstructionInfoDataSource,\n type InstructionInfoResult,\n} from \"@/modules/solana/instruction-info/data/InstructionInfoDataSource\";\nimport { instructionInfoTypes } from \"@/modules/solana/instruction-info/di/instructionInfoTypes\";\nimport {\n type SolanaEnumVariantPayload,\n type SolanaInstructionEnumVariant,\n} from \"@/modules/solana/model/SolanaPayloads\";\nimport { type ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { loadCertificateResult } from \"@/shared/utils/certificateResult\";\nimport { deviceModelIdCodec } from \"@/shared/utils/deviceModelIdCodec\";\nimport { u16Codec } from \"@/shared/utils/uIntCodec\";\n\nconst SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.SOLANA_ENUM_VARIANT,\n];\n\nconst NETWORK_DEFAULT = \"solana-mainnet\";\n\n/**\n * One enum-variant selection the caller wants resolved. `variantIndex` is\n * constrained to a u16 (0..=65535).\n */\nexport type SolanaEnumVariantSelection = {\n programId: string;\n enumId: string;\n variantIndex: number;\n};\n\nexport type SolanaEnumVariantContextInput = {\n deviceModelId: DeviceModelId;\n selections: SolanaEnumVariantSelection[];\n network?: string;\n};\n\nconst enumVariantSelectionCodec = Codec.interface({\n programId: string,\n enumId: string,\n variantIndex: u16Codec,\n});\n\nconst solanaEnumVariantInputCodec = Codec.interface({\n deviceModelId: deviceModelIdCodec,\n selections: array(enumVariantSelectionCodec),\n network: optional(string),\n});\n\n/**\n * Emits one SOLANA_ENUM_VARIANT context per `(programId, enumId,\n * variantIndex)` selection: fetches the CAL response for each distinct\n * program, looks up the matching variant, and emits only the selected ones.\n *\n * Shares {@link InstructionInfoDataSource} with\n * {@link InstructionInfoContextLoader}.\n */\n@injectable()\nexport class EnumVariantContextLoader\n implements ContextLoader<SolanaEnumVariantContextInput>\n{\n private readonly logger: LoggerPublisherService;\n\n constructor(\n @inject(instructionInfoTypes.InstructionInfoDataSource)\n private readonly dataSource: InstructionInfoDataSource,\n @inject(configTypes.Config)\n private readonly config: ContextModuleServiceConfig,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly certificateLoader: PkiCertificateLoader,\n @inject(configTypes.ContextModuleLoggerFactory)\n loggerFactory: (tag: string) => LoggerPublisherService,\n ) {\n this.logger = loggerFactory(\"EnumVariantContextLoader\");\n }\n\n public canHandle(\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ): input is SolanaEnumVariantContextInput {\n if (!SUPPORTED_TYPES.every((t) => expectedTypes.includes(t))) return false;\n return solanaEnumVariantInputCodec.decode(input).caseOf({\n Left: () => false,\n Right: ({ selections }) =>\n selections.length > 0 &&\n selections.every((s) => s.programId.length > 0 && s.enumId.length > 0),\n });\n }\n\n public async load(\n input: SolanaEnumVariantContextInput,\n ): Promise<ClearSignContext[]> {\n const network = input.network || NETWORK_DEFAULT;\n const distinctProgramIds = Array.from(\n new Set(input.selections.map((s) => s.programId)),\n );\n\n this.logger.debug(\"[load] Fetching enum variants\", {\n data: {\n network,\n programCount: distinctProgramIds.length,\n selectionCount: input.selections.length,\n },\n });\n\n // Cert load and CAL fetches are independent \u2014 run them in parallel. A\n // PKI failure still degrades each selection to ERROR.\n const certPromise = loadCertificateResult(this.certificateLoader, {\n keyId: KeyId.TokenMetadataKey,\n keyUsage: KeyUsage.CoinMeta,\n targetDevice: input.deviceModelId,\n });\n\n const dataPromise = Promise.all(\n distinctProgramIds.map((programId) =>\n this.dataSource.getInstructionInfo({ programId, network }),\n ),\n );\n\n const [certResult, results] = await Promise.all([certPromise, dataPromise]);\n\n if (!certResult.ok || !certResult.value) {\n const error = certResult.ok\n ? new Error(\n \"[ContextModule] EnumVariantContextLoader: certificate is missing\",\n )\n : certResult.error;\n this.logger.warn(\"[load] ENUM_VARIANT certificate unavailable\", {\n data: { error: error.message },\n });\n return input.selections.map(() => ({\n type: ClearSignContextType.ERROR,\n error,\n }));\n }\n const certificate = certResult.value;\n\n const programToEither = new Map(\n distinctProgramIds.map((programId, i) => [programId, results[i]!]),\n );\n\n const mode = this.config.cal.mode ?? \"prod\";\n\n return input.selections.map((selection) => {\n const either = programToEither.get(selection.programId);\n if (!either) {\n const error = new Error(\n `[ContextModule] EnumVariantContextLoader: no CAL response for program ${selection.programId}`,\n );\n this.logger.warn(\"[load] ENUM_VARIANT fetch failed\", {\n data: {\n programId: selection.programId,\n enumId: selection.enumId,\n variantIndex: selection.variantIndex,\n error: error.message,\n },\n });\n return { type: ClearSignContextType.ERROR, error };\n }\n\n return either.caseOf<ClearSignContext>({\n Left: (err) => {\n this.logger.warn(\"[load] ENUM_VARIANT fetch failed\", {\n data: {\n programId: selection.programId,\n enumId: selection.enumId,\n variantIndex: selection.variantIndex,\n error: err.message,\n },\n });\n return { type: ClearSignContextType.ERROR, error: err };\n },\n Right: (value) => {\n const variant = this.lookupVariant(value, selection);\n if (!variant) {\n const error = new Error(\n `[ContextModule] EnumVariantContextLoader: CAL has no enum variant for (${selection.programId}, ${selection.enumId}, ${selection.variantIndex})`,\n );\n this.logger.warn(\"[load] ENUM_VARIANT not found in CAL response\", {\n data: {\n programId: selection.programId,\n enumId: selection.enumId,\n variantIndex: selection.variantIndex,\n },\n });\n return { type: ClearSignContextType.ERROR, error };\n }\n\n // The mapper already picked the signature for the configured mode (or\n // left it empty when CAL has none for that mode).\n if (!variant.descriptor.signature) {\n const error = new Error(\n `[ContextModule] EnumVariantContextLoader: missing '${mode}' signature for (${selection.programId}, ${selection.enumId}, ${selection.variantIndex})`,\n );\n this.logger.warn(\"[load] ENUM_VARIANT missing signature\", {\n data: {\n programId: selection.programId,\n enumId: selection.enumId,\n variantIndex: selection.variantIndex,\n mode,\n },\n });\n return { type: ClearSignContextType.ERROR, error };\n }\n\n const payload: SolanaEnumVariantPayload = {\n programId: selection.programId,\n enumId: selection.enumId,\n variantIndex: selection.variantIndex,\n descriptor: variant.descriptor,\n };\n return {\n type: ClearSignContextType.SOLANA_ENUM_VARIANT,\n payload,\n certificate,\n };\n },\n });\n });\n }\n\n /**\n * Find the decoded enum variant for a selection. The data source flattens\n * `enum_variants` across all of the program's descriptors into a single list\n * (malformed `u16` keys already dropped), and CAL guarantees `(enumId,\n * variantIndex)` is unique across a program's instructions.\n */\n private lookupVariant(\n result: InstructionInfoResult,\n selection: SolanaEnumVariantSelection,\n ): SolanaInstructionEnumVariant | undefined {\n return result.enumVariants.find(\n (variant) =>\n variant.enumId === selection.enumId &&\n variant.variantIndex === selection.variantIndex,\n );\n }\n}\n"],
5
- "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAIA,IAAAI,EAAmC,qBACnCC,EAA+C,qBAE/CC,EAA4B,mCAE5BC,EAAyB,gDAEzBC,EAAsB,gDACtBC,EAAyB,mDAKzBC,EAAqC,qEAMrCC,EAGO,2CACPC,EAAsC,4CACtCC,EAAmC,6CACnCC,EAAyB,oCAEzB,MAAMC,EAA0C,CAC9C,uBAAqB,mBACvB,EAEMC,EAAkB,iBAkBlBC,EAA4B,QAAM,UAAU,CAChD,UAAW,SACX,OAAQ,SACR,aAAc,UAChB,CAAC,EAEKC,EAA8B,QAAM,UAAU,CAClD,cAAe,qBACf,cAAY,SAAMD,CAAyB,EAC3C,WAAS,YAAS,QAAM,CAC1B,CAAC,EAWM,IAAME,EAAN,KAEP,CAGE,YAEmBC,EAEAC,EAEAC,EAEjBC,EACA,CAPiB,gBAAAH,EAEA,YAAAC,EAEA,uBAAAC,EAIjB,KAAK,OAASC,EAAc,0BAA0B,CACxD,CAbiB,OAeV,UACLC,EACAC,EACwC,CAC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QA,EAAU,OAClB,aAAcA,EAAU,aACxB,KAAAD,CACF,CACF,CAAC,EACM,CAAE,KAAM,uBAAqB,MAAO,MAAAJ,CAAM,CACnD,CAEA,MAAMU,EAAoC,CACxC,UAAWL,EAAU,UACrB,OAAQA,EAAU,OAClB,aAAcA,EAAU,aACxB,WAAYI,EAAQ,UACtB,EACA,MAAO,CACL,KAAM,uBAAqB,oBAC3B,QAAAC,EACA,YAAAT,CACF,CACF,CACF,CAAC,CACH,CAAC,CACH,CAQQ,cACNU,EACAN,EAC0C,CAC1C,OAAOM,EAAO,aAAa,KACxBF,GACCA,EAAQ,SAAWJ,EAAU,QAC7BI,EAAQ,eAAiBJ,EAAU,YACvC,CACF,CACF,EAnLarB,EAAN4B,EAAA,IADN,cAAW,EAOPC,EAAA,eAAO,uBAAqB,yBAAyB,GAErDA,EAAA,eAAO,cAAY,MAAM,GAEzBA,EAAA,eAAO,WAAS,oBAAoB,GAEpCA,EAAA,eAAO,cAAY,0BAA0B,IAZrC7B",
4
+ "sourcesContent": ["import {\n type DeviceModelId,\n type LoggerPublisherService,\n} from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { array, Codec, optional, string } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { pkiTypes } from \"@/modules/multichain/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/modules/multichain/pki/domain/PkiCertificateLoader\";\nimport { KeyId } from \"@/modules/multichain/pki/model/KeyId\";\nimport { KeyUsage } from \"@/modules/multichain/pki/model/KeyUsage\";\nimport {\n type InstructionInfoDataSource,\n type InstructionInfoResult,\n} from \"@/modules/solana/instruction-info/data/InstructionInfoDataSource\";\nimport { instructionInfoTypes } from \"@/modules/solana/instruction-info/di/instructionInfoTypes\";\nimport {\n type SolanaEnumVariantPayload,\n type SolanaInstructionEnumVariant,\n} from \"@/modules/solana/model/SolanaPayloads\";\nimport { type ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { loadCertificateResult } from \"@/shared/utils/certificateResult\";\nimport { deviceModelIdCodec } from \"@/shared/utils/deviceModelIdCodec\";\nimport { u16Codec } from \"@/shared/utils/uIntCodec\";\n\nconst SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.SOLANA_ENUM_VARIANT,\n];\n\nconst NETWORK_DEFAULT = \"solana-mainnet\";\n\n/**\n * One enum-variant selection the caller wants resolved. `variantIndex` is\n * constrained to a u16 (0..=65535).\n */\nexport type SolanaEnumVariantSelection = {\n programId: string;\n enumId: string;\n variantIndex: number;\n};\n\nexport type SolanaEnumVariantContextInput = {\n deviceModelId: DeviceModelId;\n selections: SolanaEnumVariantSelection[];\n network?: string;\n};\n\nconst enumVariantSelectionCodec = Codec.interface({\n programId: string,\n enumId: string,\n variantIndex: u16Codec,\n});\n\nconst solanaEnumVariantInputCodec = Codec.interface({\n deviceModelId: deviceModelIdCodec,\n selections: array(enumVariantSelectionCodec),\n network: optional(string),\n});\n\n/**\n * Emits one SOLANA_ENUM_VARIANT context per `(programId, enumId,\n * variantIndex)` selection: fetches the CAL response for each distinct\n * program, looks up the matching variant, and emits only the selected ones.\n *\n * Shares {@link InstructionInfoDataSource} with\n * {@link InstructionInfoContextLoader}.\n */\n@injectable()\nexport class EnumVariantContextLoader\n implements ContextLoader<SolanaEnumVariantContextInput>\n{\n private readonly logger: LoggerPublisherService;\n\n constructor(\n @inject(instructionInfoTypes.InstructionInfoDataSource)\n private readonly dataSource: InstructionInfoDataSource,\n @inject(configTypes.Config)\n private readonly config: ContextModuleServiceConfig,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly certificateLoader: PkiCertificateLoader,\n @inject(configTypes.ContextModuleLoggerFactory)\n loggerFactory: (tag: string) => LoggerPublisherService,\n ) {\n this.logger = loggerFactory(\"EnumVariantContextLoader\");\n }\n\n public canHandle(\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ): input is SolanaEnumVariantContextInput {\n if (!SUPPORTED_TYPES.every((t) => expectedTypes.includes(t))) return false;\n return solanaEnumVariantInputCodec.decode(input).caseOf({\n Left: () => false,\n Right: ({ selections }) =>\n selections.length > 0 &&\n selections.every((s) => s.programId.length > 0 && s.enumId.length > 0),\n });\n }\n\n public async load(\n input: SolanaEnumVariantContextInput,\n ): Promise<ClearSignContext[]> {\n const network = input.network || NETWORK_DEFAULT;\n const distinctProgramIds = Array.from(\n new Set(input.selections.map((s) => s.programId)),\n );\n\n this.logger.debug(\"[load] Fetching enum variants\", {\n data: {\n network,\n programCount: distinctProgramIds.length,\n selectionCount: input.selections.length,\n },\n });\n\n // Cert load and CAL fetches are independent \u2014 run them in parallel. A\n // PKI failure still degrades each selection to ERROR.\n const certPromise = loadCertificateResult(this.certificateLoader, {\n keyId: KeyId.CalCalldataKey,\n keyUsage: KeyUsage.Calldata,\n targetDevice: input.deviceModelId,\n });\n\n const dataPromise = Promise.all(\n distinctProgramIds.map((programId) =>\n this.dataSource.getInstructionInfo({ programId, network }),\n ),\n );\n\n const [certResult, results] = await Promise.all([certPromise, dataPromise]);\n\n if (!certResult.ok || !certResult.value) {\n const error = certResult.ok\n ? new Error(\n \"[ContextModule] EnumVariantContextLoader: certificate is missing\",\n )\n : certResult.error;\n this.logger.warn(\"[load] ENUM_VARIANT certificate unavailable\", {\n data: { error: error.message },\n });\n return input.selections.map(() => ({\n type: ClearSignContextType.ERROR,\n error,\n }));\n }\n const certificate = certResult.value;\n\n const programToEither = new Map(\n distinctProgramIds.map((programId, i) => [programId, results[i]!]),\n );\n\n const mode = this.config.cal.mode ?? \"prod\";\n\n return input.selections.map((selection) => {\n const either = programToEither.get(selection.programId);\n if (!either) {\n const error = new Error(\n `[ContextModule] EnumVariantContextLoader: no CAL response for program ${selection.programId}`,\n );\n this.logger.warn(\"[load] ENUM_VARIANT fetch failed\", {\n data: {\n programId: selection.programId,\n enumId: selection.enumId,\n variantIndex: selection.variantIndex,\n error: error.message,\n },\n });\n return { type: ClearSignContextType.ERROR, error };\n }\n\n return either.caseOf<ClearSignContext>({\n Left: (err) => {\n this.logger.warn(\"[load] ENUM_VARIANT fetch failed\", {\n data: {\n programId: selection.programId,\n enumId: selection.enumId,\n variantIndex: selection.variantIndex,\n error: err.message,\n },\n });\n return { type: ClearSignContextType.ERROR, error: err };\n },\n Right: (value) => {\n const variant = this.lookupVariant(value, selection);\n if (!variant) {\n const error = new Error(\n `[ContextModule] EnumVariantContextLoader: CAL has no enum variant for (${selection.programId}, ${selection.enumId}, ${selection.variantIndex})`,\n );\n this.logger.warn(\"[load] ENUM_VARIANT not found in CAL response\", {\n data: {\n programId: selection.programId,\n enumId: selection.enumId,\n variantIndex: selection.variantIndex,\n },\n });\n return { type: ClearSignContextType.ERROR, error };\n }\n\n // The mapper already picked the signature for the configured mode (or\n // left it empty when CAL has none for that mode).\n if (!variant.descriptor.signature) {\n const error = new Error(\n `[ContextModule] EnumVariantContextLoader: missing '${mode}' signature for (${selection.programId}, ${selection.enumId}, ${selection.variantIndex})`,\n );\n this.logger.warn(\"[load] ENUM_VARIANT missing signature\", {\n data: {\n programId: selection.programId,\n enumId: selection.enumId,\n variantIndex: selection.variantIndex,\n mode,\n },\n });\n return { type: ClearSignContextType.ERROR, error };\n }\n\n const payload: SolanaEnumVariantPayload = {\n programId: selection.programId,\n enumId: selection.enumId,\n variantIndex: selection.variantIndex,\n descriptor: variant.descriptor,\n };\n return {\n type: ClearSignContextType.SOLANA_ENUM_VARIANT,\n payload,\n certificate,\n };\n },\n });\n });\n }\n\n /**\n * Find the decoded enum variant for a selection. The data source flattens\n * `enum_variants` across all of the program's descriptors into a single list\n * (malformed `u16` keys already dropped), and CAL guarantees `(enumId,\n * variantIndex)` is unique across a program's instructions.\n */\n private lookupVariant(\n result: InstructionInfoResult,\n selection: SolanaEnumVariantSelection,\n ): SolanaInstructionEnumVariant | undefined {\n return result.enumVariants.find(\n (variant) =>\n variant.enumId === selection.enumId &&\n variant.variantIndex === selection.variantIndex,\n );\n }\n}\n"],
5
+ "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAIA,IAAAI,EAAmC,qBACnCC,EAA+C,qBAE/CC,EAA4B,mCAE5BC,EAAyB,gDAEzBC,EAAsB,gDACtBC,EAAyB,mDAKzBC,EAAqC,qEAMrCC,EAGO,2CACPC,EAAsC,4CACtCC,EAAmC,6CACnCC,EAAyB,oCAEzB,MAAMC,EAA0C,CAC9C,uBAAqB,mBACvB,EAEMC,EAAkB,iBAkBlBC,EAA4B,QAAM,UAAU,CAChD,UAAW,SACX,OAAQ,SACR,aAAc,UAChB,CAAC,EAEKC,EAA8B,QAAM,UAAU,CAClD,cAAe,qBACf,cAAY,SAAMD,CAAyB,EAC3C,WAAS,YAAS,QAAM,CAC1B,CAAC,EAWM,IAAME,EAAN,KAEP,CAGE,YAEmBC,EAEAC,EAEAC,EAEjBC,EACA,CAPiB,gBAAAH,EAEA,YAAAC,EAEA,uBAAAC,EAIjB,KAAK,OAASC,EAAc,0BAA0B,CACxD,CAbiB,OAeV,UACLC,EACAC,EACwC,CACxC,OAAKV,EAAgB,MAAO,GAAMU,EAAc,SAAS,CAAC,CAAC,EACpDP,EAA4B,OAAOM,CAAK,EAAE,OAAO,CACtD,KAAM,IAAM,GACZ,MAAO,CAAC,CAAE,WAAAE,CAAW,IACnBA,EAAW,OAAS,GACpBA,EAAW,MAAOC,GAAMA,EAAE,UAAU,OAAS,GAAKA,EAAE,OAAO,OAAS,CAAC,CACzE,CAAC,EANoE,EAOvE,CAEA,MAAa,KACXH,EAC6B,CAC7B,MAAMI,EAAUJ,EAAM,SAAWR,EAC3Ba,EAAqB,MAAM,KAC/B,IAAI,IAAIL,EAAM,WAAW,IAAKG,GAAMA,EAAE,SAAS,CAAC,CAClD,EAEA,KAAK,OAAO,MAAM,gCAAiC,CACjD,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ADN,cAAW,EAOPC,EAAA,eAAO,uBAAqB,yBAAyB,GAErDA,EAAA,eAAO,cAAY,MAAM,GAEzBA,EAAA,eAAO,WAAS,oBAAoB,GAEpCA,EAAA,eAAO,cAAY,0BAA0B,IAZrC7B",
6
6
  "names": ["EnumVariantContextLoader_exports", "__export", "EnumVariantContextLoader", "__toCommonJS", "import_inversify", "import_purify_ts", "import_configTypes", "import_pkiTypes", "import_KeyId", "import_KeyUsage", "import_instructionInfoTypes", "import_ClearSignContext", "import_certificateResult", "import_deviceModelIdCodec", "import_uIntCodec", "SUPPORTED_TYPES", "NETWORK_DEFAULT", "enumVariantSelectionCodec", "solanaEnumVariantInputCodec", "EnumVariantContextLoader", "dataSource", "config", "certificateLoader", "loggerFactory", "input", "expectedTypes", "selections", "s", "network", "distinctProgramIds", "certPromise", "dataPromise", "programId", "certResult", "results", "error", "certificate", "programToEither", "i", "mode", "selection", "either", "err", "value", "variant", "payload", "result", "__decorateClass", "__decorateParam"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var f=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var M=(n,t)=>{for(var i in t)f(n,i,{get:t[i],enumerable:!0})},$=(n,t,i,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of D(t))!k.call(n,r)&&r!==i&&f(n,r,{get:()=>t[r],enumerable:!(e=I(t,r))||e.enumerable});return n};var x=n=>$(f({},"__esModule",{value:!0}),n),C=(n,t,i,e)=>{for(var r=e>1?void 0:e?I(t,i):t,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(e?c(t,i,r):c(r))||r);return e&&r&&f(t,i,r),r},l=(n,t)=>(i,e)=>t(i,e,n);var b={};M(b,{HttpInstructionInfoDataSource:()=>a});module.exports=x(b);var u=require("inversify"),o=require("purify-ts"),g=require("../../../../config/di/configTypes"),h=require("../../../../shared/network/di/networkTypes"),E=require("./InstructionInfoDto"),p=require("./InstructionInfoMapper");const R=o.Codec.interface({descriptors_instruction:(0,o.record)(o.string,o.unknown)});let a=class{constructor(t,i){this.config=t;this.http=i}async getInstructionInfo({programId:t,network:i}){let e;try{e=await this.http.get(`${this.config.cal.url}/solana`,{params:{output:"descriptors_instruction",network:i,program:t,ref:`branch:${this.config.cal.branch}`}})}catch(r){const s=r instanceof Error?r.message:String(r);return(0,o.Left)(new Error(`[ContextModule] HttpInstructionInfoDataSource: Failed to fetch instruction descriptors: ${s}`))}return!Array.isArray(e)||e.length===0?(0,o.Left)(new Error(`[ContextModule] HttpInstructionInfoDataSource: empty response for program ${t}`)):R.decode(e[0]).caseOf({Left:r=>(0,o.Left)(new Error(`[ContextModule] HttpInstructionInfoDataSource: malformed response for program ${t}: ${r}`)),Right:r=>{const s=r.descriptors_instruction[t];return s==null||typeof s!="object"?(0,o.Left)(new Error(`[ContextModule] HttpInstructionInfoDataSource: no descriptors for program ${t}`)):E.calInstructionDescriptorsCodec.decode(s).caseOf({Left:c=>(0,o.Left)(new Error(`[ContextModule] HttpInstructionInfoDataSource: malformed descriptors for program ${t}: ${c}`)),Right:()=>{const c=this.config.cal.mode??"prod",m=s,y=Object.fromEntries(Object.entries(m).map(([d,w])=>[d,(0,p.toInstructionInfoPayload)(d,w,c)]));return(0,o.Right)({programId:t,descriptors:y,enumVariants:(0,p.toProgramEnumVariants)(m,c)})}})}})}};a=C([(0,u.injectable)(),l(0,(0,u.inject)(g.configTypes.Config)),l(1,(0,u.inject)(h.networkTypes.NetworkClient))],a);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
@@ -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 {\n Codec,\n Either,\n Left,\n record,\n Right,\n string,\n unknown as unknownCodec,\n} from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { networkTypes } from \"@/shared/network/di/networkTypes\";\n\nimport {\n GetInstructionInfoParams,\n InstructionInfoDataSource,\n InstructionInfoResult,\n} from \"./InstructionInfoDataSource\";\nimport {\n type CalInstructionDescriptorDto,\n calInstructionDescriptorsCodec,\n} from \"./InstructionInfoDto\";\nimport {\n type CalMode,\n toInstructionInfoPayload,\n toProgramEnumVariants,\n} from \"./InstructionInfoMapper\";\n\n// Validates the outer envelope shape only. Per-discriminator descriptor\n// content is validated downstream by the loader before being consumed.\nconst calInstructionInfoEnvelopeCodec = Codec.interface({\n descriptors_instruction: record(string, unknownCodec),\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 let data: unknown;\n try {\n data = await this.http.get(`${this.config.cal.url}/solana`, {\n params: {\n output: \"descriptors_instruction\",\n network,\n program: programId,\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 return calInstructionInfoEnvelopeCodec\n .decode(data[0])\n .caseOf<Either<Error, InstructionInfoResult>>({\n Left: (error) =>\n Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: malformed response for program ${programId}: ${error}`,\n ),\n ),\n Right: (envelope) => {\n const descriptors = envelope.descriptors_instruction[programId];\n if (descriptors == null || typeof descriptors !== \"object\") {\n return Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: no descriptors for program ${programId}`,\n ),\n );\n }\n\n // Validate the inner descriptor shape so the mapper can dereference\n // `instruction_info.descriptor` / `enum_variants` without\n // runtime-throwing on a malformed CAL payload. A malformed descriptor\n // degrades the whole program to a per-program ERROR rather than\n // rejecting the batch. On success we transform each validated DTO into\n // the core payload so the loader never sees the CAL DTO shapes.\n return calInstructionDescriptorsCodec\n .decode(descriptors)\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 // The codec only validates the consumed shape and strips\n // undeclared fields, so we transform the original (full) object \u2014\n // the cast is justified now that the shape has been validated.\n Right: () => {\n const mode: CalMode = this.config.cal.mode ?? \"prod\";\n const validatedDescriptors = descriptors as Record<\n string,\n CalInstructionDescriptorDto\n >;\n const mapped = Object.fromEntries(\n Object.entries(validatedDescriptors).map(\n ([discriminator, dto]) => [\n discriminator,\n toInstructionInfoPayload(discriminator, dto, mode),\n ],\n ),\n );\n return Right({\n programId,\n descriptors: mapped,\n enumVariants: to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,CAC5C,KAAOH,MACL,QACE,IAAI,MACF,oFAAoFH,CAAS,KAAKG,CAAK,EACzG,CACF,EAIF,MAAO,IAAM,CACX,MAAMI,EAAgB,KAAK,OAAO,IAAI,MAAQ,OACxCC,EAAuBF,EAIvBG,EAAS,OAAO,YACpB,OAAO,QAAQD,CAAoB,EAAE,IACnC,CAAC,CAACE,EAAeC,CAAG,IAAM,CACxBD,KACA,4BAAyBA,EAAeC,EAAKJ,CAAI,CACnD,CACF,CACF,EACA,SAAO,SAAM,CACX,UAAAP,EACA,YAAaS,EACb,gBAAc,yBACZD,EACAD,CACF,CACF,CAAC,CACH,CACF,CAAC,CACL,CACF,CAAC,CACL,CACF,EAzGaV,EAANe,EAAA,IADN,cAAW,EAKPC,EAAA,eAAO,cAAY,MAAM,GAEzBA,EAAA,eAAO,eAAa,aAAa,IANzBhB",
6
- "names": ["HttpInstructionInfoDataSource_exports", "__export", "HttpInstructionInfoDataSource", "__toCommonJS", "import_inversify", "import_purify_ts", "import_configTypes", "import_networkTypes", "import_InstructionInfoDto", "import_InstructionInfoMapper", "calInstructionInfoEnvelopeCodec", "unknownCodec", "HttpInstructionInfoDataSource", "config", "http", "programId", "network", "data", "error", "reason", "envelope", "descriptors", "mode", "validatedDescriptors", "mapped", "discriminator", "dto", "__decorateClass", "__decorateParam"]
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,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AAO,cAAY,MAAM,GAEzBA,EAAA,eAAO,eAAa,aAAa,IANzBlB",
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
  }
@@ -1,2 +1,2 @@
1
- "use strict";var a=require("purify-ts"),t=require("vitest"),c=require("./HttpInstructionInfoDataSource");(0,t.describe)("HttpInstructionInfoDataSource",()=>{let n,r;const e="11111111111111111111111111111111",s="solana-mainnet",u={cal:{url:"https://crypto-assets-service.api.ledger.com/v1",mode:"prod",branch:"main"}},i=[{descriptors_instruction:{[e]:{"00000000":{type:"instruction",network:"solana-mainnet",version:"v1",instruction_info:{version:1,program_id:e,discriminator:"00000000",hash:"deadbeef",descriptor:{data:"00010101",signatures:{prod:"prodsig",test:"testsig"}}},display_fields:[],value_flow_ports:[],hide_rules:[],account_resets:[]}}}}];(0,t.beforeEach)(()=>{t.vi.clearAllMocks(),r={get:t.vi.fn()},n=new c.HttpInstructionInfoDataSource(u,r)}),(0,t.it)("calls CAL with singular program= and ref=branch:<branch>",async()=>{r.get.mockResolvedValue(i),await n.getInstructionInfo({programId:e,network:s}),(0,t.expect)(r.get).toHaveBeenCalledTimes(1),(0,t.expect)(r.get).toHaveBeenCalledWith("https://crypto-assets-service.api.ledger.com/v1/solana",{params:{output:"descriptors_instruction",network:s,program:e,ref:"branch:main"}})}),(0,t.it)("returns Right with each descriptor transformed into the core payload on success",async()=>{r.get.mockResolvedValue(i);const o=await n.getInstructionInfo({programId:e,network:s});(0,t.expect)(o).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)("returns Left when the response array is empty",async()=>{r.get.mockResolvedValue([]);const o=await n.getInstructionInfo({programId:e,network:s});(0,t.expect)(o).toEqual((0,a.Left)(new Error(`[ContextModule] HttpInstructionInfoDataSource: empty response for program ${e}`)))}),(0,t.it)("returns Left when the envelope is malformed",async()=>{r.get.mockResolvedValue([{foo:"bar"}]);const o=await n.getInstructionInfo({programId:e,network:s});(0,t.expect)(o.isLeft()).toBe(!0),(0,t.expect)(o.extract().message).toMatch(new RegExp(String.raw`\[ContextModule\] HttpInstructionInfoDataSource: malformed response for program ${e}:`))}),(0,t.it)("returns Left when the response doesn't contain the requested programId",async()=>{r.get.mockResolvedValue([{descriptors_instruction:{OtherProgram:{}}}]);const o=await n.getInstructionInfo({programId:e,network:s});(0,t.expect)(o).toEqual((0,a.Left)(new Error(`[ContextModule] HttpInstructionInfoDataSource: no descriptors for program ${e}`)))}),(0,t.it)("returns Left (not a throw) when an inner descriptor is malformed",async()=>{r.get.mockResolvedValue([{descriptors_instruction:{[e]:{"00000000":{type:"instruction",instruction_info:{}}}}}]);const o=await n.getInstructionInfo({programId:e,network:s});(0,t.expect)(o.isLeft()).toBe(!0),(0,t.expect)(o.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()=>{r.get.mockRejectedValue(new Error("network"));const o=await n.getInstructionInfo({programId:e,network:s});(0,t.expect)(o).toEqual((0,a.Left)(new Error("[ContextModule] HttpInstructionInfoDataSource: Failed to fetch instruction descriptors: network")))})});
1
+ "use strict";var s=require("purify-ts"),t=require("vitest"),i=require("../../../../modules/solana/model/SolanaTransactionScanChainId"),u=require("./HttpInstructionInfoDataSource");(0,t.describe)("HttpInstructionInfoDataSource",()=>{let n,o;const e="11111111111111111111111111111111",a="solana-mainnet",l={cal:{url:"https://crypto-assets-service.api.ledger.com/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()},n=new u.HttpInstructionInfoDataSource(l,o)}),(0,t.it)("calls CAL /solana_programs with id, chain_id and output params",async()=>{o.get.mockResolvedValue(c),await n.getInstructionInfo({programId:e,network:a}),(0,t.expect)(o.get).toHaveBeenCalledTimes(1),(0,t.expect)(o.get).toHaveBeenCalledWith("https://crypto-assets-service.api.ledger.com/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 n.getInstructionInfo({programId:e,network:"solana-devnet"}),(0,t.expect)(o.get).toHaveBeenCalledWith("https://crypto-assets-service.api.ledger.com/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 r=await n.getInstructionInfo({programId:e,network:a});(0,t.expect)(r).toEqual((0,s.Right)({programId:e,descriptors:{"00000000":(0,s.Right)({programId:e,discriminator:"00000000",instructionInfo:{data:"00010101",signature:"prodsig"},substructures:[],enumVariants:[],idlDescriptor:{typePool:[],rootType:0},mintAssociations:[],valueFlowPorts:[],accountResets:[],displayFields:[]})},enumVariants:[]}))}),(0,t.it)("returns Left when the response array is empty",async()=>{o.get.mockResolvedValue([]);const r=await n.getInstructionInfo({programId:e,network:a});(0,t.expect)(r).toEqual((0,s.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 r=await n.getInstructionInfo({programId:e,network:a});(0,t.expect)(r).toEqual((0,s.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 r=await n.getInstructionInfo({programId:e,network:a});(0,t.expect)(r.isLeft()).toBe(!0),(0,t.expect)(r.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 r=await n.getInstructionInfo({programId:e,network:a});(0,t.expect)(r).toEqual((0,s.Left)(new Error("[ContextModule] HttpInstructionInfoDataSource: Failed to fetch instruction descriptors: network")))})});
2
2
  //# sourceMappingURL=HttpInstructionInfoDataSource.test.js.map
@@ -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\";\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://crypto-assets-service.api.ledger.com/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n } as ContextModuleServiceConfig;\n\n const successResponse: CalInstructionInfoResponseDto = [\n {\n descriptors_instruction: {\n [programId]: {\n \"00000000\": {\n type: \"instruction\",\n network: \"solana-mainnet\",\n version: \"v1\",\n instruction_info: {\n version: 1,\n program_id: programId,\n discriminator: \"00000000\",\n hash: \"deadbeef\",\n descriptor: {\n data: \"00010101\",\n signatures: { prod: \"prodsig\", test: \"testsig\" },\n },\n },\n display_fields: [],\n value_flow_ports: [],\n hide_rules: [],\n account_resets: [],\n },\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 with singular program= and ref=branch:<branch>\", 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://crypto-assets-service.api.ledger.com/v1/solana\",\n {\n params: {\n output: \"descriptors_instruction\",\n network,\n program: programId,\n ref: \"branch:main\",\n },\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 the envelope is malformed\", async () => {\n httpMock.get.mockResolvedValue([{ foo: \"bar\" }]);\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 response for program ${programId}:`,\n ),\n );\n });\n\n it(\"returns Left when the response doesn't contain the requested programId\", async () => {\n httpMock.get.mockResolvedValue([\n { descriptors_instruction: { OtherProgram: {} } },\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 inner descriptor is malformed\", async () => {\n // `instruction_info.descriptor` missing \u2014 would crash the loader if the\n // datasource handed it through unvalidated.\n httpMock.get.mockResolvedValue([\n {\n descriptors_instruction: {\n [programId]: {\n \"00000000\": { type: \"instruction\", instruction_info: {} },\n },\n },\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,q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E,CAC1D,CACF,CACF,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_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://crypto-assets-service.api.ledger.com/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://crypto-assets-service.api.ledger.com/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://crypto-assets-service.api.ledger.com/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,kDACL,K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,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"]
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=(e,r)=>{for(var o in r)a(e,o,{get:r[o],enumerable:!0})},g=(e,r,o,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of l(r))!p.call(e,n)&&n!==o&&a(e,n,{get:()=>r[n],enumerable:!(s=u(r,n))||s.enumerable});return e};var _=e=>g(a({},"__esModule",{value:!0}),e);var x={};d(x,{calInstructionDescriptorsCodec:()=>b});module.exports=_(x);var t=require("purify-ts");const c=t.Codec.interface({prod:(0,t.optional)(t.string),test:(0,t.optional)(t.string)}),C=t.Codec.interface({data:t.string,signatures:c}),D=t.Codec.interface({program_id:t.string,descriptor:C}),m=t.Codec.interface({data:t.string,signatures:c}),i=t.Codec.interface({descriptor:t.string}),y=t.Codec.interface({instruction_info:D,enum_variants:(0,t.optional)((0,t.record)(t.string,(0,t.record)(t.string,m))),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))}),b=(0,t.record)(t.string,y);0&&(module.exports={calInstructionDescriptorsCodec});
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});
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, 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 CalInstructionInfoDto = {\n version: number;\n program_id: string;\n discriminator: string;\n hash: string;\n operation_type?: string;\n program_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};\n\nexport type CalEnumVariantDto = {\n variant_name: string;\n payload_kind?: string;\n data: string;\n signatures: CalSignatures;\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 account_index?: 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 type: string;\n source?: string;\n network?: string;\n version?: string;\n instruction_info: CalInstructionInfoDto;\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// Outer shape: array containing one envelope object keyed by program_id\n// then by discriminator hex.\nexport type CalInstructionInfoResponseDto = Array<{\n descriptors_instruction: Record<\n string,\n Record<string, CalInstructionDescriptorDto>\n >;\n}>;\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 calInstructionInfoCodec = Codec.interface({\n program_id: string,\n descriptor: calSignedDescriptorCodec,\n});\n\nconst calEnumVariantCodec = Codec.interface({\n data: string,\n signatures: calSignaturesCodec,\n});\n\nconst calSubstructureCodec = Codec.interface({\n descriptor: string,\n});\n\nconst calInstructionDescriptorCodec = Codec.interface({\n instruction_info: calInstructionInfoCodec,\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 the per-program descriptor map (keyed by discriminator hex).\n * Used by the datasource to validate the inner CAL payload before handing\n * it to the loaders. Only loader-consumed fields are validated; unrelated\n * CAL fields (`idl_descriptor`, `mint_association`, \u2026) are ignored.\n */\nexport const calInstructionDescriptorsCodec = record(\n string,\n calInstructionDescriptorCodec,\n);\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oCAAAE,IAAA,eAAAC,EAAAH,GAQA,IAAAI,EAAuD,qBAqHvD,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,EAA0B,QAAM,UAAU,CAC9C,WAAY,SACZ,WAAYD,CACd,CAAC,EAEKE,EAAsB,QAAM,UAAU,CAC1C,KAAM,SACN,WAAYH,CACd,CAAC,EAEKI,EAAuB,QAAM,UAAU,CAC3C,WAAY,QACd,CAAC,EAEKC,EAAgC,QAAM,UAAU,CACpD,iBAAkBH,EAClB,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,EAQYP,KAAiC,UAC5C,SACAQ,CACF",
6
- "names": ["InstructionInfoDto_exports", "__export", "calInstructionDescriptorsCodec", "__toCommonJS", "import_purify_ts", "calSignaturesCodec", "calSignedDescriptorCodec", "calInstructionInfoCodec", "calEnumVariantCodec", "calSubstructureCodec", "calInstructionDescriptorCodec"]
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: 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,kBAAmB,SACnB,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
+ "names": ["InstructionInfoDto_exports", "__export", "calInstructionProgramCodec", "__toCommonJS", "import_purify_ts", "calSignaturesCodec", "calSignedDescriptorCodec", "calEnumVariantCodec", "calSubstructureCodec", "calInstructionDescriptorCodec"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var s=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var S=(n,t)=>{for(var a in t)s(n,a,{get:t[a],enumerable:!0})},g=(n,t,a,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of I(t))!D.call(n,r)&&r!==a&&s(n,r,{get:()=>t[r],enumerable:!(o=C(t,r))||o.enumerable});return n};var E=n=>g(s({},"__esModule",{value:!0}),n);var P={};S(P,{toAccountResets:()=>_,toDisplayFields:()=>f,toInstructionInfoPayload:()=>V,toProgramEnumVariants:()=>F,toValueFlowPorts:()=>d});module.exports=E(P);var i=require("purify-ts"),e=require("../../../../modules/solana/model/SolanaPayloads"),l=require("../../../../shared/utils/uIntCodec");function p(n,t){return n[t]}function d(n=[]){return n.map(t=>({account_indices:t.account_indices,account_index:t.account_index,optional_account_strategy:t.optional_account_strategy,token_value:t.token_value}))}function _(n=[]){return n.flatMap(t=>t.account_index===void 0?[]:[{account_index:t.account_index,require_pre_balance_zero:t.require_pre_balance_zero}])}function f(n=[]){return n.map(t=>({name:t.name,param:t.param??{type:""}}))}function x(n){return[...(n.display_fields??[]).map(t=>({kind:e.SolanaInstructionSubstructureKind.DISPLAY_FIELD,data:t.descriptor})),...(n.value_flow_ports??[]).map(t=>({kind:e.SolanaInstructionSubstructureKind.VALUE_FLOW_PORT,data:t.descriptor})),...(n.hide_rules??[]).map(t=>({kind:e.SolanaInstructionSubstructureKind.HIDE_RULE,data:t.descriptor})),...(n.account_resets??[]).map(t=>({kind:e.SolanaInstructionSubstructureKind.ACCOUNT_RESET,data:t.descriptor}))]}function m(n,t){const a=[];for(const[o,r]of Object.entries(n.enum_variants??{}))for(const[y,u]of Object.entries(r)){const c=Number(y);l.u16Codec.decode(c).isLeft()||a.push({enumId:o,variantIndex:c,descriptor:{data:u.data,signature:p(u.signatures,t)??""}})}return a}function F(n,t){return Object.values(n).flatMap(a=>m(a,t))}function V(n,t,a){const o=t.instruction_info,r=p(o.descriptor.signatures,a);return r?(0,i.Right)({programId:o.program_id,discriminator:n,instructionInfo:{data:o.descriptor.data,signature:r},substructures:x(t),enumVariants:m(t,a),idlDescriptor:{typePool:o.idl_descriptor?.type_pool??[],rootType:o.idl_descriptor?.root_type??0},mintAssociations:o.mint_association?[o.mint_association]:[],valueFlowPorts:d(t.value_flow_ports),accountResets:_(t.account_resets),displayFields:f(t.display_fields)}):(0,i.Left)(new Error(`[ContextModule] InstructionInfoDataSource: missing '${a}' signature for (${o.program_id}, ${n})`))}0&&(module.exports={toAccountResets,toDisplayFields,toInstructionInfoPayload,toProgramEnumVariants,toValueFlowPorts});
1
+ "use strict";var s=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var S=(n,t)=>{for(var a in t)s(n,a,{get:t[a],enumerable:!0})},g=(n,t,a,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of D(t))!I.call(n,o)&&o!==a&&s(n,o,{get:()=>t[o],enumerable:!(r=C(t,o))||r.enumerable});return n};var E=n=>g(s({},"__esModule",{value:!0}),n);var P={};S(P,{toAccountResets:()=>_,toDisplayFields:()=>f,toInstructionInfoPayload:()=>x,toProgramEnumVariants:()=>V,toValueFlowPorts:()=>d});module.exports=E(P);var i=require("purify-ts"),e=require("../../../../modules/solana/model/SolanaPayloads"),l=require("../../../../shared/utils/uIntCodec");function p(n,t){return n[t]}function d(n=[]){return n.map(t=>({account_indices:t.account_indices,optional_account_strategy:t.optional_account_strategy,token_value:t.token_value}))}function _(n=[]){return n.flatMap(t=>t.account_index===void 0?[]:[{account_index:t.account_index,require_pre_balance_zero:t.require_pre_balance_zero}])}function f(n=[]){return n.map(t=>({name:t.name,param:t.param??{type:""}}))}function F(n){return[...(n.display_fields??[]).map(t=>({kind:e.SolanaInstructionSubstructureKind.DISPLAY_FIELD,data:t.descriptor})),...(n.value_flow_ports??[]).map(t=>({kind:e.SolanaInstructionSubstructureKind.VALUE_FLOW_PORT,data:t.descriptor})),...(n.hide_rules??[]).map(t=>({kind:e.SolanaInstructionSubstructureKind.HIDE_RULE,data:t.descriptor})),...(n.account_resets??[]).map(t=>({kind:e.SolanaInstructionSubstructureKind.ACCOUNT_RESET,data:t.descriptor}))]}function y(n,t){const a=[];for(const[r,o]of Object.entries(n.enum_variants??{}))for(const[m,u]of Object.entries(o)){const c=Number(m);l.u16Codec.decode(c).isLeft()||a.push({enumId:r,variantIndex:c,descriptor:{data:u.descriptor.data,signature:p(u.descriptor.signatures,t)??""}})}return a}function V(n,t){return Object.values(n).flatMap(a=>y(a,t))}function x(n,t,a,r){const o=p(a.descriptor.signatures,r);return o?(0,i.Right)({programId:n,discriminator:t,instructionInfo:{data:a.descriptor.data,signature:o},substructures:F(a),enumVariants:y(a,r),idlDescriptor:{typePool:a.idl_descriptor?.type_pool??[],rootType:a.idl_descriptor?.root_type??0},mintAssociations:a.mint_association?[a.mint_association]:[],valueFlowPorts:d(a.value_flow_ports),accountResets:_(a.account_resets),displayFields:f(a.display_fields)}):(0,i.Left)(new Error(`[ContextModule] InstructionInfoDataSource: missing '${r}' signature for (${n}, ${t})`))}0&&(module.exports={toAccountResets,toDisplayFields,toInstructionInfoPayload,toProgramEnumVariants,toValueFlowPorts});
2
2
  //# sourceMappingURL=InstructionInfoMapper.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/modules/solana/instruction-info/data/InstructionInfoMapper.ts"],
4
- "sourcesContent": ["// Maps the validated CAL instruction-descriptor DTOs into the core\n// `SolanaInstructionInfoPayload` model. Keeping this in the data layer means\n// the domain `InstructionInfoContextLoader` never has to know the CAL DTO\n// shapes \u2014 it consumes core models only.\n\nimport { type Either, Left, Right } from \"purify-ts\";\n\nimport {\n type SolanaCalAccountReset,\n type SolanaCalDisplayField,\n type SolanaCalValueFlowPort,\n type SolanaInstructionEnumVariant,\n type SolanaInstructionInfoPayload,\n type SolanaInstructionSubstructure,\n SolanaInstructionSubstructureKind,\n} from \"@/modules/solana/model/SolanaPayloads\";\nimport { u16Codec } from \"@/shared/utils/uIntCodec\";\n\nimport {\n type CalAccountResetDto,\n type CalDisplayFieldDto,\n type CalInstructionDescriptorDto,\n type CalSignatures,\n type CalValueFlowPortDto,\n} from \"./InstructionInfoDto\";\n\nexport type CalMode = \"prod\" | \"test\";\n\nfunction pickSignature(\n signatures: CalSignatures,\n mode: CalMode,\n): string | undefined {\n return signatures[mode];\n}\n\n// --- DTO \u2192 decoded-payload projections. Pick only the fields the host-side\n// requirement builder reads, dropping the signed-TLV `descriptor` carried by\n// the DTO. ---\n\nexport function toValueFlowPorts(\n dtos: CalValueFlowPortDto[] = [],\n): SolanaCalValueFlowPort[] {\n return dtos.map((port) => ({\n account_indices: port.account_indices,\n account_index: port.account_index,\n optional_account_strategy: port.optional_account_strategy,\n token_value: port.token_value,\n }));\n}\n\nexport function toAccountResets(\n dtos: CalAccountResetDto[] = [],\n): SolanaCalAccountReset[] {\n // Drop malformed resets (missing account_index) rather than defaulting to\n // slot 0, which would create an unintended TOKEN_ACCOUNT_STATE requirement.\n return dtos.flatMap((reset) =>\n reset.account_index === undefined\n ? []\n : [\n {\n account_index: reset.account_index,\n require_pre_balance_zero: reset.require_pre_balance_zero,\n },\n ],\n );\n}\n\nexport function toDisplayFields(\n dtos: CalDisplayFieldDto[] = [],\n): SolanaCalDisplayField[] {\n return dtos.map((field) => ({\n name: field.name,\n param: field.param ?? { type: \"\" },\n }));\n}\n\nfunction toSubstructures(\n dto: CalInstructionDescriptorDto,\n): SolanaInstructionSubstructure[] {\n return [\n ...(dto.display_fields ?? []).map((s) => ({\n kind: SolanaInstructionSubstructureKind.DISPLAY_FIELD,\n data: s.descriptor,\n })),\n ...(dto.value_flow_ports ?? []).map((s) => ({\n kind: SolanaInstructionSubstructureKind.VALUE_FLOW_PORT,\n data: s.descriptor,\n })),\n ...(dto.hide_rules ?? []).map((s) => ({\n kind: SolanaInstructionSubstructureKind.HIDE_RULE,\n data: s.descriptor,\n })),\n ...(dto.account_resets ?? []).map((s) => ({\n kind: SolanaInstructionSubstructureKind.ACCOUNT_RESET,\n data: s.descriptor,\n })),\n ];\n}\n\n/**\n * Flatten the CAL-bundled enum variants (keyed enumId \u2192 variantIndex). Keys\n * that don't validate as a u16 are skipped rather than leaking NaN/out-of-range\n * indices into the payload.\n */\nfunction toEnumVariants(\n dto: CalInstructionDescriptorDto,\n mode: CalMode,\n): SolanaInstructionEnumVariant[] {\n const enumVariants: SolanaInstructionEnumVariant[] = [];\n for (const [enumId, variants] of Object.entries(dto.enum_variants ?? {})) {\n for (const [variantIndex, variant] of Object.entries(variants)) {\n const index = Number(variantIndex);\n if (u16Codec.decode(index).isLeft()) {\n continue;\n }\n enumVariants.push({\n enumId,\n variantIndex: index,\n descriptor: {\n data: variant.data,\n signature: pickSignature(variant.signatures, mode) ?? \"\",\n },\n });\n }\n }\n return enumVariants;\n}\n\n/**\n * Flatten the enum variants of every descriptor in a program into a single\n * list. CAL nests `enum_variants` inside each instruction descriptor but\n * guarantees `(enumId, variantIndex)` is unique across a program, so the enum\n * loader resolves a selection against this program-level list \u2014 independently\n * of whether any individual instruction descriptor carried a usable signature.\n */\nexport function toProgramEnumVariants(\n descriptors: Record<string, CalInstructionDescriptorDto>,\n mode: CalMode,\n): SolanaInstructionEnumVariant[] {\n return Object.values(descriptors).flatMap((dto) => toEnumVariants(dto, mode));\n}\n\n/**\n * Transform one validated CAL descriptor DTO into the core\n * {@link SolanaInstructionInfoPayload}. Returns a `Left` when the descriptor is\n * unusable (no signature for the configured `mode`), so the caller can surface\n * a per-descriptor ERROR rather than emitting an empty signature.\n */\nexport function toInstructionInfoPayload(\n discriminator: string,\n dto: CalInstructionDescriptorDto,\n mode: CalMode,\n): Either<Error, SolanaInstructionInfoPayload> {\n const info = dto.instruction_info;\n const signature = pickSignature(info.descriptor.signatures, mode);\n if (!signature) {\n return Left(\n new Error(\n `[ContextModule] InstructionInfoDataSource: missing '${mode}' signature for (${info.program_id}, ${discriminator})`,\n ),\n );\n }\n\n return Right({\n programId: info.program_id,\n discriminator,\n instructionInfo: {\n data: info.descriptor.data,\n signature,\n },\n substructures: toSubstructures(dto),\n enumVariants: toEnumVariants(dto, mode),\n idlDescriptor: {\n typePool: info.idl_descriptor?.type_pool ?? [],\n rootType: info.idl_descriptor?.root_type ?? 0,\n },\n mintAssociations: info.mint_association ? [info.mint_association] : [],\n valueFlowPorts: toValueFlowPorts(dto.value_flow_ports),\n accountResets: toAccountResets(dto.account_resets),\n displayFields: toDisplayFields(dto.display_fields),\n });\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,EAAA,oBAAAC,EAAA,6BAAAC,EAAA,0BAAAC,EAAA,qBAAAC,IAAA,eAAAC,EAAAP,GAKA,IAAAQ,EAAyC,qBAEzCC,EAQO,iDACPC,EAAyB,oCAYzB,SAASC,EACPC,EACAC,EACoB,CACpB,OAAOD,EAAWC,CAAI,CACxB,CAMO,SAASP,EACdQ,EAA8B,CAAC,EACL,CAC1B,OAAOA,EAAK,IAAKC,IAAU,CACzB,gBAAiBA,EAAK,gBACtB,cAAeA,EAAK,cACpB,0BAA2BA,EAAK,0BAChC,YAAaA,EAAK,WACpB,EAAE,CACJ,CAEO,SAASb,EACdY,EAA6B,CAAC,EACL,CAGzB,OAAOA,EAAK,QAASE,GACnBA,EAAM,gBAAkB,OACpB,CAAC,EACD,CACE,CACE,cAAeA,EAAM,cACrB,yBAA0BA,EAAM,wBAClC,CACF,CACN,CACF,CAEO,SAASb,EACdW,EAA6B,CAAC,EACL,CACzB,OAAOA,EAAK,IAAKG,IAAW,CAC1B,KAAMA,EAAM,KACZ,MAAOA,EAAM,OAAS,CAAE,KAAM,EAAG,CACnC,EAAE,CACJ,CAEA,SAASC,EACPC,EACiC,CACjC,MAAO,C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AAeF,EAAKN,CAAI,EACtC,cAAe,CACb,SAAUiB,EAAK,gBAAgB,WAAa,CAAC,EAC7C,SAAUA,EAAK,gBAAgB,WAAa,CAC9C,EACA,iBAAkBA,EAAK,iBAAmB,CAACA,EAAK,gBAAgB,EAAI,CAAC,EACrE,eAAgBxB,EAAiBa,EAAI,gBAAgB,EACrD,cAAejB,EAAgBiB,EAAI,cAAc,EACjD,cAAehB,EAAgBgB,EAAI,cAAc,CACnD,CAAC,KAxBQ,QACL,IAAI,MACF,uDAAuDN,CAAI,oBAAoBiB,EAAK,UAAU,KAAKD,CAAa,GAClH,CACF,CAqBJ",
6
- "names": ["InstructionInfoMapper_exports", "__export", "toAccountResets", "toDisplayFields", "toInstructionInfoPayload", "toProgramEnumVariants", "toValueFlowPorts", "__toCommonJS", "import_purify_ts", "import_SolanaPayloads", "import_uIntCodec", "pickSignature", "signatures", "mode", "dtos", "port", "reset", "field", "toSubstructures", "dto", "s", "toEnumVariants", "enumVariants", "enumId", "variants", "variantIndex", "variant", "index", "descriptors", "discriminator", "info", "signature"]
4
+ "sourcesContent": ["// Maps the validated CAL instruction-descriptor DTOs into the core\n// `SolanaInstructionInfoPayload` model. Keeping this in the data layer means\n// the domain `InstructionInfoContextLoader` never has to know the CAL DTO\n// shapes \u2014 it consumes core models only.\n\nimport { type Either, Left, Right } from \"purify-ts\";\n\nimport {\n type SolanaCalAccountReset,\n type SolanaCalDisplayField,\n type SolanaCalValueFlowPort,\n type SolanaInstructionEnumVariant,\n type SolanaInstructionInfoPayload,\n type SolanaInstructionSubstructure,\n SolanaInstructionSubstructureKind,\n} from \"@/modules/solana/model/SolanaPayloads\";\nimport { u16Codec } from \"@/shared/utils/uIntCodec\";\n\nimport {\n type CalAccountResetDto,\n type CalDisplayFieldDto,\n type CalInstructionDescriptorDto,\n type CalSignatures,\n type CalValueFlowPortDto,\n} from \"./InstructionInfoDto\";\n\nexport type CalMode = \"prod\" | \"test\";\n\nfunction pickSignature(\n signatures: CalSignatures,\n mode: CalMode,\n): string | undefined {\n return signatures[mode];\n}\n\n// --- DTO \u2192 decoded-payload projections. Pick only the fields the host-side\n// requirement builder reads, dropping the signed-TLV `descriptor` carried by\n// the DTO. ---\n\nexport function toValueFlowPorts(\n dtos: CalValueFlowPortDto[] = [],\n): SolanaCalValueFlowPort[] {\n return dtos.map((port) => ({\n account_indices: port.account_indices,\n optional_account_strategy: port.optional_account_strategy,\n token_value: port.token_value,\n }));\n}\n\nexport function toAccountResets(\n dtos: CalAccountResetDto[] = [],\n): SolanaCalAccountReset[] {\n // Drop malformed resets (missing account_index) rather than defaulting to\n // slot 0, which would create an unintended TOKEN_ACCOUNT_STATE requirement.\n return dtos.flatMap((reset) =>\n reset.account_index === undefined\n ? []\n : [\n {\n account_index: reset.account_index,\n require_pre_balance_zero: reset.require_pre_balance_zero,\n },\n ],\n );\n}\n\nexport function toDisplayFields(\n dtos: CalDisplayFieldDto[] = [],\n): SolanaCalDisplayField[] {\n return dtos.map((field) => ({\n name: field.name,\n param: field.param ?? { type: \"\" },\n }));\n}\n\nfunction toSubstructures(\n dto: CalInstructionDescriptorDto,\n): SolanaInstructionSubstructure[] {\n return [\n ...(dto.display_fields ?? []).map((s) => ({\n kind: SolanaInstructionSubstructureKind.DISPLAY_FIELD,\n data: s.descriptor,\n })),\n ...(dto.value_flow_ports ?? []).map((s) => ({\n kind: SolanaInstructionSubstructureKind.VALUE_FLOW_PORT,\n data: s.descriptor,\n })),\n ...(dto.hide_rules ?? []).map((s) => ({\n kind: SolanaInstructionSubstructureKind.HIDE_RULE,\n data: s.descriptor,\n })),\n ...(dto.account_resets ?? []).map((s) => ({\n kind: SolanaInstructionSubstructureKind.ACCOUNT_RESET,\n data: s.descriptor,\n })),\n ];\n}\n\n/**\n * Flatten the CAL-bundled enum variants (keyed enumId \u2192 variantIndex). Keys\n * that don't validate as a u16 are skipped rather than leaking NaN/out-of-range\n * indices into the payload.\n */\nfunction toEnumVariants(\n dto: CalInstructionDescriptorDto,\n mode: CalMode,\n): SolanaInstructionEnumVariant[] {\n const enumVariants: SolanaInstructionEnumVariant[] = [];\n for (const [enumId, variants] of Object.entries(dto.enum_variants ?? {})) {\n for (const [variantIndex, variant] of Object.entries(variants)) {\n const index = Number(variantIndex);\n if (u16Codec.decode(index).isLeft()) {\n continue;\n }\n enumVariants.push({\n enumId,\n variantIndex: index,\n descriptor: {\n data: variant.descriptor.data,\n signature: pickSignature(variant.descriptor.signatures, mode) ?? \"\",\n },\n });\n }\n }\n return enumVariants;\n}\n\n/**\n * Flatten the enum variants of every descriptor in a program into a single\n * list. CAL nests `enum_variants` inside each instruction descriptor but\n * guarantees `(enumId, variantIndex)` is unique across a program, so the enum\n * loader resolves a selection against this program-level list \u2014 independently\n * of whether any individual instruction descriptor carried a usable signature.\n */\nexport function toProgramEnumVariants(\n descriptors: Record<string, CalInstructionDescriptorDto>,\n mode: CalMode,\n): SolanaInstructionEnumVariant[] {\n return Object.values(descriptors).flatMap((dto) => toEnumVariants(dto, mode));\n}\n\n/**\n * Transform one validated CAL descriptor DTO into the core\n * {@link SolanaInstructionInfoPayload}. Returns a `Left` when the descriptor is\n * unusable (no signature for the configured `mode`), so the caller can surface\n * a per-descriptor ERROR rather than emitting an empty signature.\n *\n * `programId` comes from the enclosing `solana_programs` envelope `id`;\n * `discriminator` from the instruction's `discriminator_hex`.\n */\nexport function toInstructionInfoPayload(\n programId: string,\n discriminator: string,\n dto: CalInstructionDescriptorDto,\n mode: CalMode,\n): Either<Error, SolanaInstructionInfoPayload> {\n const signature = pickSignature(dto.descriptor.signatures, mode);\n if (!signature) {\n return Left(\n new Error(\n `[ContextModule] InstructionInfoDataSource: missing '${mode}' signature for (${programId}, ${discriminator})`,\n ),\n );\n }\n\n return Right({\n programId,\n discriminator,\n instructionInfo: {\n data: dto.descriptor.data,\n signature,\n },\n substructures: toSubstructures(dto),\n enumVariants: toEnumVariants(dto, mode),\n idlDescriptor: {\n typePool: dto.idl_descriptor?.type_pool ?? [],\n rootType: dto.idl_descriptor?.root_type ?? 0,\n },\n mintAssociations: dto.mint_association ? [dto.mint_association] : [],\n valueFlowPorts: toValueFlowPorts(dto.value_flow_ports),\n accountResets: toAccountResets(dto.account_resets),\n displayFields: toDisplayFields(dto.display_fields),\n });\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,EAAA,oBAAAC,EAAA,6BAAAC,EAAA,0BAAAC,EAAA,qBAAAC,IAAA,eAAAC,EAAAP,GAKA,IAAAQ,EAAyC,qBAEzCC,EAQO,iDACPC,EAAyB,oCAYzB,SAASC,EACPC,EACAC,EACoB,CACpB,OAAOD,EAAWC,CAAI,CACxB,CAMO,SAASP,EACdQ,EAA8B,CAAC,EACL,CAC1B,OAAOA,EAAK,IAAKC,IAAU,CACzB,gBAAiBA,EAAK,gBACtB,0BAA2BA,EAAK,0BAChC,YAAaA,EAAK,WACpB,EAAE,CACJ,CAEO,SAASb,EACdY,EAA6B,CAAC,EACL,CAGzB,OAAOA,EAAK,QAASE,GACnBA,EAAM,gBAAkB,OACpB,CAAC,EACD,CACE,CACE,cAAeA,EAAM,cACrB,yBAA0BA,EAAM,wBAClC,CACF,CACN,CACF,CAEO,SAASb,EACdW,EAA6B,CAAC,EACL,CACzB,OAAOA,EAAK,IAAKG,IAAW,CAC1B,KAAMA,EAAM,KACZ,MAAOA,EAAM,OAAS,CAAE,KAAM,EAAG,CACnC,EAAE,CACJ,CAEA,SAASC,EACPC,EACiC,CACjC,MAAO,CACL,IAAIA,EAAI,gBAAkB,CAAC,GAAG,IAAKC,IAAO,CACxC,KAAM,oCAAkC,cACxC,KAAMA,EAAE,UACV,EAAE,EACF,IAAID,EAAI,kBAAoB,CAAC,GAAG,IAAKC,IAAO,CAC1C,KAAM,oCAAkC,gBACxC,KAAMA,EAAE,UACV,EAAE,EACF,IAAID,EAAI,YAAc,CAAC,GAAG,IAAKC,IAAO,CACpC,KAAM,oCAAkC,UACxC,KAAMA,EAAE,UACV,EAA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I,MACF,uDAAuDN,CAAI,oBAAoBgB,CAAS,KAAKC,CAAa,GAC5G,CACF,CAqBJ",
6
+ "names": ["InstructionInfoMapper_exports", "__export", "toAccountResets", "toDisplayFields", "toInstructionInfoPayload", "toProgramEnumVariants", "toValueFlowPorts", "__toCommonJS", "import_purify_ts", "import_SolanaPayloads", "import_uIntCodec", "pickSignature", "signatures", "mode", "dtos", "port", "reset", "field", "toSubstructures", "dto", "s", "toEnumVariants", "enumVariants", "enumId", "variants", "variantIndex", "variant", "index", "descriptors", "programId", "discriminator", "signature"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("vitest"),e=require("./InstructionInfoMapper");const o="11111111111111111111111111111111";function r(a={}){return{type:"instruction",instruction_info:{version:1,program_id:o,discriminator:"00000000",hash:"feedface",descriptor:{data:"0001sys_data",signatures:{prod:"prodsig",test:"testsig"}}},...a}}(0,t.describe)("InstructionInfoMapper",()=>{(0,t.describe)("toValueFlowPorts",()=>{(0,t.it)("returns an empty list for undefined input",()=>{(0,t.expect)((0,e.toValueFlowPorts)()).toEqual([])}),(0,t.it)("picks only the decoded fields, dropping the signed-TLV descriptor",()=>{(0,t.expect)((0,e.toValueFlowPorts)([{descriptor:"vfp1",account_indices:[0,1],account_index:0,optional_account_strategy:"OMITTED",token_value:{kind:"NATIVE"}}])).toEqual([{account_indices:[0,1],account_index:0,optional_account_strategy:"OMITTED",token_value:{kind:"NATIVE"}}])}),(0,t.it)("leaves absent optional fields as undefined",()=>{(0,t.expect)((0,e.toValueFlowPorts)([{descriptor:"vfp1"}])).toEqual([{account_indices:void 0,account_index:void 0,optional_account_strategy:void 0,token_value:void 0}])})}),(0,t.describe)("toAccountResets",()=>{(0,t.it)("returns an empty list for undefined input",()=>{(0,t.expect)((0,e.toAccountResets)()).toEqual([])}),(0,t.it)("maps the decoded fields, dropping the signed-TLV descriptor",()=>{(0,t.expect)((0,e.toAccountResets)([{descriptor:"ar1",account_index:2,require_pre_balance_zero:!0}])).toEqual([{account_index:2,require_pre_balance_zero:!0}])}),(0,t.it)("drops entries missing account_index instead of defaulting to slot 0",()=>{(0,t.expect)((0,e.toAccountResets)([{descriptor:"ar0",account_index:0},{descriptor:"arBad"},{descriptor:"ar1",account_index:1}])).toEqual([{account_index:0,require_pre_balance_zero:void 0},{account_index:1,require_pre_balance_zero:void 0}])})}),(0,t.describe)("toDisplayFields",()=>{(0,t.it)("returns an empty list for undefined input",()=>{(0,t.expect)((0,e.toDisplayFields)()).toEqual([])}),(0,t.it)("picks name and param, dropping the signed-TLV descriptor",()=>{(0,t.expect)((0,e.toDisplayFields)([{descriptor:"df1",name:"New Account",param:{type:"ACCOUNT",value:{source:"ACCOUNT_PATH",account_index:1}}}])).toEqual([{name:"New Account",param:{type:"ACCOUNT",value:{source:"ACCOUNT_PATH",account_index:1}}}])}),(0,t.it)("falls back to an empty-type param when param is absent",()=>{(0,t.expect)((0,e.toDisplayFields)([{descriptor:"df1"}])).toEqual([{name:void 0,param:{type:""}}])})}),(0,t.describe)("toInstructionInfoPayload",()=>{(0,t.it)("surfaces CAL's decoded JSON (type pool, mint assoc, ports, resets, fields) and ordered substructures",()=>{const a=r({instruction_info:{version:1,program_id:o,discriminator:"00000000",hash:"feedface",descriptor:{data:"0001sys_data",signatures:{prod:"prodsig",test:"testsig"}},idl_descriptor:{root_type:3,type_pool:[{index:0,kind:"STRUCT",refs:[1]},{index:1,kind:"U64"}]},mint_association:{account_index:1,mint_index:3}},display_fields:[{descriptor:"df1",name:"New Account",param:{type:"ACCOUNT",value:{source:"ACCOUNT_PATH",account_index:1}}}],value_flow_ports:[{descriptor:"vfp1",account_indices:[0],token_value:{kind:"NATIVE"}}],hide_rules:[{descriptor:"hr1"}],account_resets:[{descriptor:"ar1",account_index:1,require_pre_balance_zero:!0}]}),n=(0,e.toInstructionInfoPayload)("00000000",a,"prod").unsafeCoerce();(0,t.expect)(n).toMatchObject({programId:o,discriminator:"00000000",instructionInfo:{data:"0001sys_data",signature:"prodsig"},idlDescriptor:{rootType:3,typePool:[{index:0,kind:"STRUCT",refs:[1]},{index:1,kind:"U64"}]},mintAssociations:[{account_index:1,mint_index:3}],valueFlowPorts:[{account_indices:[0],optional_account_strategy:void 0,token_value:{kind:"NATIVE"}}],accountResets:[{account_index:1,require_pre_balance_zero:!0}],displayFields:[{name:"New Account",param:{type:"ACCOUNT",value:{source:"ACCOUNT_PATH",account_index:1}}}]}),(0,t.expect)(n.substructures).toEqual([{kind:0,data:"df1"},{kind:1,data:"vfp1"},{kind:2,data:"hr1"},{kind:3,data:"ar1"}])}),(0,t.it)("defaults idlDescriptor when CAL omits it",()=>{const a=(0,e.toInstructionInfoPayload)("00000000",r(),"prod").unsafeCoerce();(0,t.expect)(a.idlDescriptor).toEqual({typePool:[],rootType:0}),(0,t.expect)(a.mintAssociations).toEqual([])}),(0,t.it)("bundles CAL enum_variants into the payload with the mode signature",()=>{const a=r({enum_variants:{swap:{46:{variant_name:"raydiumCP",data:"01_raydium_tlv",signatures:{prod:"prodsig_v46",test:"testsig_v46"}}}}}),n=(0,e.toInstructionInfoPayload)("00000000",a,"prod").unsafeCoerce();(0,t.expect)(n.enumVariants).toEqual([{enumId:"swap",variantIndex:46,descriptor:{data:"01_raydium_tlv",signature:"prodsig_v46"}}])}),(0,t.it)("skips enum_variants keyed by a non-u16 index instead of leaking NaN",()=>{const a=r({enum_variants:{swap:{46:{variant_name:"raydiumCP",data:"01_raydium_tlv",signatures:{prod:"prodsig_v46",test:"testsig_v46"}},"7abc":{variant_name:"junk",data:"junk_tlv",signatures:{prod:"x",test:"x"}},7e4:{variant_name:"overflow",data:"overflow_tlv",signatures:{prod:"x",test:"x"}}}}}),n=(0,e.toInstructionInfoPayload)("00000000",a,"prod").unsafeCoerce();(0,t.expect)(n.enumVariants).toEqual([{enumId:"swap",variantIndex:46,descriptor:{data:"01_raydium_tlv",signature:"prodsig_v46"}}])}),(0,t.it)("selects the signature for the configured mode",()=>{const a=(0,e.toInstructionInfoPayload)("00000000",r(),"test").unsafeCoerce();(0,t.expect)(a.instructionInfo.signature).toBe("testsig")}),(0,t.it)("returns Left when the configured mode signature is missing",()=>{const a=r();delete a.instruction_info.descriptor.signatures.test;const n=(0,e.toInstructionInfoPayload)("00000000",a,"test");(0,t.expect)(n.isLeft()).toBe(!0),(0,t.expect)(n.swap().unsafeCoerce().message).toMatch(/missing 'test' signature/)})}),(0,t.describe)("toProgramEnumVariants",()=>{(0,t.it)("flattens enum variants across all descriptors, dropping malformed keys",()=>{const a={"00000000":r({enum_variants:{swap:{46:{variant_name:"raydiumCP",data:"01_raydium_tlv",signatures:{prod:"prodsig_v46",test:"testsig_v46"}},bad:{variant_name:"junk",data:"junk_tlv",signatures:{prod:"x",test:"x"}}}}}),"00000001":r({enum_variants:{route:{12:{variant_name:"orca",data:"02_orca_tlv",signatures:{prod:"prodsig_v12",test:"testsig_v12"}}}}})};(0,t.expect)((0,e.toProgramEnumVariants)(a,"prod")).toEqual([{enumId:"swap",variantIndex:46,descriptor:{data:"01_raydium_tlv",signature:"prodsig_v46"}},{enumId:"route",variantIndex:12,descriptor:{data:"02_orca_tlv",signature:"prodsig_v12"}}])}),(0,t.it)("leaves the signature empty when CAL has none for the configured mode",()=>{const a=r({enum_variants:{swap:{46:{variant_name:"raydiumCP",data:"01_raydium_tlv",signatures:{prod:"prodsig_v46"}}}}});(0,t.expect)((0,e.toProgramEnumVariants)({"00000000":a},"test")).toEqual([{enumId:"swap",variantIndex:46,descriptor:{data:"01_raydium_tlv",signature:""}}])})})});
1
+ "use strict";var t=require("vitest"),e=require("./InstructionInfoMapper");const o="11111111111111111111111111111111";function n(a={}){return{discriminator_hex:"00000000",instruction_name:"createAccount",descriptor:{data:"0001sys_data",signatures:{prod:"prodsig",test:"testsig"}},...a}}(0,t.describe)("InstructionInfoMapper",()=>{(0,t.describe)("toValueFlowPorts",()=>{(0,t.it)("returns an empty list for undefined input",()=>{(0,t.expect)((0,e.toValueFlowPorts)()).toEqual([])}),(0,t.it)("picks only the decoded fields, dropping the signed-TLV descriptor",()=>{(0,t.expect)((0,e.toValueFlowPorts)([{descriptor:"vfp1",account_indices:[0,1],optional_account_strategy:"OMITTED",token_value:{kind:"NATIVE"}}])).toEqual([{account_indices:[0,1],optional_account_strategy:"OMITTED",token_value:{kind:"NATIVE"}}])}),(0,t.it)("leaves the absent optional strategy as undefined",()=>{(0,t.expect)((0,e.toValueFlowPorts)([{descriptor:"vfp1",account_indices:[0],token_value:{kind:"NATIVE"}}])).toEqual([{account_indices:[0],optional_account_strategy:void 0,token_value:{kind:"NATIVE"}}])})}),(0,t.describe)("toAccountResets",()=>{(0,t.it)("returns an empty list for undefined input",()=>{(0,t.expect)((0,e.toAccountResets)()).toEqual([])}),(0,t.it)("maps the decoded fields, dropping the signed-TLV descriptor",()=>{(0,t.expect)((0,e.toAccountResets)([{descriptor:"ar1",account_index:2,require_pre_balance_zero:!0}])).toEqual([{account_index:2,require_pre_balance_zero:!0}])}),(0,t.it)("drops entries missing account_index instead of defaulting to slot 0",()=>{(0,t.expect)((0,e.toAccountResets)([{descriptor:"ar0",account_index:0},{descriptor:"arBad"},{descriptor:"ar1",account_index:1}])).toEqual([{account_index:0,require_pre_balance_zero:void 0},{account_index:1,require_pre_balance_zero:void 0}])})}),(0,t.describe)("toDisplayFields",()=>{(0,t.it)("returns an empty list for undefined input",()=>{(0,t.expect)((0,e.toDisplayFields)()).toEqual([])}),(0,t.it)("picks name and param, dropping the signed-TLV descriptor",()=>{(0,t.expect)((0,e.toDisplayFields)([{descriptor:"df1",name:"New Account",param:{type:"ACCOUNT",value:{source:"ACCOUNT_PATH",account_index:1}}}])).toEqual([{name:"New Account",param:{type:"ACCOUNT",value:{source:"ACCOUNT_PATH",account_index:1}}}])}),(0,t.it)("falls back to an empty-type param when param is absent",()=>{(0,t.expect)((0,e.toDisplayFields)([{descriptor:"df1"}])).toEqual([{name:void 0,param:{type:""}}])})}),(0,t.describe)("toInstructionInfoPayload",()=>{(0,t.it)("surfaces CAL's decoded JSON (type pool, mint assoc, ports, resets, fields) and ordered substructures",()=>{const a=n({idl_descriptor:{root_type:3,type_pool:[{index:0,kind:"STRUCT",refs:[1]},{index:1,kind:"U64"}]},mint_association:{account_index:1,mint_index:3},display_fields:[{descriptor:"df1",name:"New Account",param:{type:"ACCOUNT",value:{source:"ACCOUNT_PATH",account_index:1}}}],value_flow_ports:[{descriptor:"vfp1",account_indices:[0],token_value:{kind:"NATIVE"}}],hide_rules:[{descriptor:"hr1"}],account_resets:[{descriptor:"ar1",account_index:1,require_pre_balance_zero:!0}]}),r=(0,e.toInstructionInfoPayload)(o,"00000000",a,"prod").unsafeCoerce();(0,t.expect)(r).toMatchObject({programId:o,discriminator:"00000000",instructionInfo:{data:"0001sys_data",signature:"prodsig"},idlDescriptor:{rootType:3,typePool:[{index:0,kind:"STRUCT",refs:[1]},{index:1,kind:"U64"}]},mintAssociations:[{account_index:1,mint_index:3}],valueFlowPorts:[{account_indices:[0],optional_account_strategy:void 0,token_value:{kind:"NATIVE"}}],accountResets:[{account_index:1,require_pre_balance_zero:!0}],displayFields:[{name:"New Account",param:{type:"ACCOUNT",value:{source:"ACCOUNT_PATH",account_index:1}}}]}),(0,t.expect)(r.substructures).toEqual([{kind:0,data:"df1"},{kind:1,data:"vfp1"},{kind:2,data:"hr1"},{kind:3,data:"ar1"}])}),(0,t.it)("defaults idlDescriptor when CAL omits it",()=>{const a=(0,e.toInstructionInfoPayload)(o,"00000000",n(),"prod").unsafeCoerce();(0,t.expect)(a.idlDescriptor).toEqual({typePool:[],rootType:0}),(0,t.expect)(a.mintAssociations).toEqual([])}),(0,t.it)("bundles CAL enum_variants into the payload with the mode signature",()=>{const a=n({enum_variants:{swap:{46:{variant_name:"raydiumCP",descriptor:{data:"01_raydium_tlv",signatures:{prod:"prodsig_v46",test:"testsig_v46"}}}}}}),r=(0,e.toInstructionInfoPayload)(o,"00000000",a,"prod").unsafeCoerce();(0,t.expect)(r.enumVariants).toEqual([{enumId:"swap",variantIndex:46,descriptor:{data:"01_raydium_tlv",signature:"prodsig_v46"}}])}),(0,t.it)("skips enum_variants keyed by a non-u16 index instead of leaking NaN",()=>{const a=n({enum_variants:{swap:{46:{variant_name:"raydiumCP",descriptor:{data:"01_raydium_tlv",signatures:{prod:"prodsig_v46",test:"testsig_v46"}}},"7abc":{variant_name:"junk",descriptor:{data:"junk_tlv",signatures:{prod:"x",test:"x"}}},7e4:{variant_name:"overflow",descriptor:{data:"overflow_tlv",signatures:{prod:"x",test:"x"}}}}}}),r=(0,e.toInstructionInfoPayload)(o,"00000000",a,"prod").unsafeCoerce();(0,t.expect)(r.enumVariants).toEqual([{enumId:"swap",variantIndex:46,descriptor:{data:"01_raydium_tlv",signature:"prodsig_v46"}}])}),(0,t.it)("selects the signature for the configured mode",()=>{const a=(0,e.toInstructionInfoPayload)(o,"00000000",n(),"test").unsafeCoerce();(0,t.expect)(a.instructionInfo.signature).toBe("testsig")}),(0,t.it)("returns Left when the configured mode signature is missing",()=>{const a=n();delete a.descriptor.signatures.test;const r=(0,e.toInstructionInfoPayload)(o,"00000000",a,"test");(0,t.expect)(r.isLeft()).toBe(!0),(0,t.expect)(r.swap().unsafeCoerce().message).toMatch(/missing 'test' signature/)})}),(0,t.describe)("toProgramEnumVariants",()=>{(0,t.it)("flattens enum variants across all descriptors, dropping malformed keys",()=>{const a={"00000000":n({enum_variants:{swap:{46:{variant_name:"raydiumCP",descriptor:{data:"01_raydium_tlv",signatures:{prod:"prodsig_v46",test:"testsig_v46"}}},bad:{variant_name:"junk",descriptor:{data:"junk_tlv",signatures:{prod:"x",test:"x"}}}}}}),"00000001":n({enum_variants:{route:{12:{variant_name:"orca",descriptor:{data:"02_orca_tlv",signatures:{prod:"prodsig_v12",test:"testsig_v12"}}}}}})};(0,t.expect)((0,e.toProgramEnumVariants)(a,"prod")).toEqual([{enumId:"swap",variantIndex:46,descriptor:{data:"01_raydium_tlv",signature:"prodsig_v46"}},{enumId:"route",variantIndex:12,descriptor:{data:"02_orca_tlv",signature:"prodsig_v12"}}])}),(0,t.it)("leaves the signature empty when CAL has none for the configured mode",()=>{const a=n({enum_variants:{swap:{46:{variant_name:"raydiumCP",descriptor:{data:"01_raydium_tlv",signatures:{prod:"prodsig_v46"}}}}}});(0,t.expect)((0,e.toProgramEnumVariants)({"00000000":a},"test")).toEqual([{enumId:"swap",variantIndex:46,descriptor:{data:"01_raydium_tlv",signature:""}}])})})});
2
2
  //# sourceMappingURL=InstructionInfoMapper.test.js.map