@ledgerhq/context-module 2.7.0 → 2.8.0

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 (100) hide show
  1. package/lib/cjs/package.json +1 -1
  2. package/lib/cjs/src/DefaultContextModule.js +1 -1
  3. package/lib/cjs/src/DefaultContextModule.js.map +2 -2
  4. package/lib/cjs/src/DefaultContextModule.test.js +1 -1
  5. package/lib/cjs/src/DefaultContextModule.test.js.map +3 -3
  6. package/lib/cjs/src/index.js +1 -1
  7. package/lib/cjs/src/index.js.map +2 -2
  8. package/lib/cjs/src/modules/solana/enum-variant/domain/EnumVariantContextLoader.test.js +1 -1
  9. package/lib/cjs/src/modules/solana/enum-variant/domain/EnumVariantContextLoader.test.js.map +2 -2
  10. package/lib/cjs/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.js +1 -1
  11. package/lib/cjs/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.js.map +3 -3
  12. package/lib/cjs/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.js +1 -1
  13. package/lib/cjs/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.js.map +3 -3
  14. package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoDataSource.js +1 -1
  15. package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoDataSource.js.map +3 -3
  16. package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoDto.js +1 -1
  17. package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoDto.js.map +3 -3
  18. package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoMapper.js +1 -1
  19. package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoMapper.js.map +3 -3
  20. package/lib/cjs/src/modules/solana/instruction-info/di/instructionInfoModuleFactory.js +1 -1
  21. package/lib/cjs/src/modules/solana/instruction-info/di/instructionInfoModuleFactory.js.map +3 -3
  22. package/lib/cjs/src/modules/solana/instruction-info/di/instructionInfoModuleFactory.test.js +2 -0
  23. package/lib/cjs/src/modules/solana/instruction-info/di/instructionInfoModuleFactory.test.js.map +7 -0
  24. package/lib/cjs/src/modules/solana/instruction-info/di/instructionInfoTypes.js +1 -1
  25. package/lib/cjs/src/modules/solana/instruction-info/di/instructionInfoTypes.js.map +2 -2
  26. package/lib/cjs/src/modules/solana/instruction-info/domain/InstructionInfoContextLoader.test.js +1 -1
  27. package/lib/cjs/src/modules/solana/instruction-info/domain/InstructionInfoContextLoader.test.js.map +2 -2
  28. package/lib/cjs/src/modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader.js +2 -0
  29. package/lib/cjs/src/modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader.js.map +7 -0
  30. package/lib/cjs/src/modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader.test.js +2 -0
  31. package/lib/cjs/src/modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader.test.js.map +7 -0
  32. package/lib/cjs/src/modules/solana/model/SolanaClearSignContext.js +1 -1
  33. package/lib/cjs/src/modules/solana/model/SolanaClearSignContext.js.map +2 -2
  34. package/lib/cjs/src/modules/solana/model/SolanaContextTypes.js +1 -1
  35. package/lib/cjs/src/modules/solana/model/SolanaContextTypes.js.map +1 -1
  36. package/lib/cjs/src/shared/model/ClearSignContext.js +1 -1
  37. package/lib/cjs/src/shared/model/ClearSignContext.js.map +2 -2
  38. package/lib/esm/package.json +1 -1
  39. package/lib/esm/src/DefaultContextModule.js +1 -1
  40. package/lib/esm/src/DefaultContextModule.js.map +2 -2
  41. package/lib/esm/src/DefaultContextModule.test.js +1 -1
  42. package/lib/esm/src/DefaultContextModule.test.js.map +3 -3
  43. package/lib/esm/src/index.js +1 -1
  44. package/lib/esm/src/index.js.map +2 -2
  45. package/lib/esm/src/modules/solana/enum-variant/domain/EnumVariantContextLoader.test.js +1 -1
  46. package/lib/esm/src/modules/solana/enum-variant/domain/EnumVariantContextLoader.test.js.map +2 -2
  47. package/lib/esm/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.js +1 -1
  48. package/lib/esm/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.js.map +3 -3
  49. package/lib/esm/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.js +1 -1
  50. package/lib/esm/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.js.map +3 -3
  51. package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoDataSource.js +1 -0
  52. package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoDataSource.js.map +4 -4
  53. package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoDto.js +1 -1
  54. package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoDto.js.map +3 -3
  55. package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoMapper.js +1 -1
  56. package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoMapper.js.map +3 -3
  57. package/lib/esm/src/modules/solana/instruction-info/di/instructionInfoModuleFactory.js +1 -1
  58. package/lib/esm/src/modules/solana/instruction-info/di/instructionInfoModuleFactory.js.map +3 -3
  59. package/lib/esm/src/modules/solana/instruction-info/di/instructionInfoModuleFactory.test.js +2 -0
  60. package/lib/esm/src/modules/solana/instruction-info/di/instructionInfoModuleFactory.test.js.map +7 -0
  61. package/lib/esm/src/modules/solana/instruction-info/di/instructionInfoTypes.js +1 -1
  62. package/lib/esm/src/modules/solana/instruction-info/di/instructionInfoTypes.js.map +2 -2
  63. package/lib/esm/src/modules/solana/instruction-info/domain/InstructionInfoContextLoader.test.js +1 -1
  64. package/lib/esm/src/modules/solana/instruction-info/domain/InstructionInfoContextLoader.test.js.map +2 -2
  65. package/lib/esm/src/modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader.js +2 -0
  66. package/lib/esm/src/modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader.js.map +7 -0
  67. package/lib/esm/src/modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader.test.js +2 -0
  68. package/lib/esm/src/modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader.test.js.map +7 -0
  69. package/lib/esm/src/modules/solana/model/SolanaClearSignContext.js +1 -1
  70. package/lib/esm/src/modules/solana/model/SolanaClearSignContext.js.map +2 -2
  71. package/lib/esm/src/shared/model/ClearSignContext.js +1 -1
  72. package/lib/esm/src/shared/model/ClearSignContext.js.map +2 -2
  73. package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
  74. package/lib/types/src/index.d.ts +1 -0
  75. package/lib/types/src/index.d.ts.map +1 -1
  76. package/lib/types/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.d.ts +3 -0
  77. package/lib/types/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.d.ts.map +1 -1
  78. package/lib/types/src/modules/solana/instruction-info/data/InstructionInfoDataSource.d.ts +20 -0
  79. package/lib/types/src/modules/solana/instruction-info/data/InstructionInfoDataSource.d.ts.map +1 -1
  80. package/lib/types/src/modules/solana/instruction-info/data/InstructionInfoDto.d.ts +26 -0
  81. package/lib/types/src/modules/solana/instruction-info/data/InstructionInfoDto.d.ts.map +1 -1
  82. package/lib/types/src/modules/solana/instruction-info/data/InstructionInfoMapper.d.ts +9 -0
  83. package/lib/types/src/modules/solana/instruction-info/data/InstructionInfoMapper.d.ts.map +1 -1
  84. package/lib/types/src/modules/solana/instruction-info/di/instructionInfoModuleFactory.d.ts.map +1 -1
  85. package/lib/types/src/modules/solana/instruction-info/di/instructionInfoModuleFactory.test.d.ts +2 -0
  86. package/lib/types/src/modules/solana/instruction-info/di/instructionInfoModuleFactory.test.d.ts.map +1 -0
  87. package/lib/types/src/modules/solana/instruction-info/di/instructionInfoTypes.d.ts +1 -0
  88. package/lib/types/src/modules/solana/instruction-info/di/instructionInfoTypes.d.ts.map +1 -1
  89. package/lib/types/src/modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader.d.ts +31 -0
  90. package/lib/types/src/modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader.d.ts.map +1 -0
  91. package/lib/types/src/modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader.test.d.ts +2 -0
  92. package/lib/types/src/modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader.test.d.ts.map +1 -0
  93. package/lib/types/src/modules/solana/model/SolanaClearSignContext.d.ts +4 -0
  94. package/lib/types/src/modules/solana/model/SolanaClearSignContext.d.ts.map +1 -1
  95. package/lib/types/src/modules/solana/model/SolanaContextTypes.d.ts +20 -0
  96. package/lib/types/src/modules/solana/model/SolanaContextTypes.d.ts.map +1 -1
  97. package/lib/types/src/shared/model/ClearSignContext.d.ts +1 -0
  98. package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -1
  99. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  100. package/package.json +2 -2
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/modules/solana/enum-variant/domain/EnumVariantContextLoader.test.ts"],
4
- "sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { DeviceModelId } 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 { type PkiCertificateLoader } from \"@/modules/multichain/pki/domain/PkiCertificateLoader\";\nimport {\n type InstructionInfoDataSource,\n type InstructionInfoResult,\n} from \"@/modules/solana/instruction-info/data/InstructionInfoDataSource\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\n\nimport { EnumVariantContextLoader } from \"./EnumVariantContextLoader\";\n\nconst mockLoggerFactory = () => ({\n debug: vi.fn(),\n info: vi.fn(),\n warn: vi.fn(),\n error: vi.fn(),\n subscribers: [],\n});\n\nconst mockCertificate = {\n keyUsageNumber: 8,\n payload: new Uint8Array([0x42]),\n};\n\nconst mockConfig = {\n cal: {\n url: \"https://global.api.prd.ledger.com/cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n} as ContextModuleServiceConfig;\n\nconst JUPITER_PROGRAM = \"JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4\";\nconst OTHER_PROGRAM = \"OtherProgram111111111111111111111111111111\";\n\n// The data source flattens enum variants into core models, with the signature\n// already picked for the configured mode.\nfunction makeJupiterWithVariants(): InstructionInfoResult {\n return {\n programId: JUPITER_PROGRAM,\n descriptors: {},\n enumVariants: [\n {\n enumId: \"swap\",\n variantIndex: 46,\n descriptor: { data: \"01_raydium_tlv\", signature: \"prodsig_v46\" },\n },\n {\n enumId: \"swap\",\n variantIndex: 12,\n descriptor: { data: \"01_orca_tlv\", signature: \"prodsig_v12\" },\n },\n ],\n };\n}\n\ndescribe(\"EnumVariantContextLoader\", () => {\n let dataSource: InstructionInfoDataSource;\n let certificateLoader: PkiCertificateLoader;\n\n beforeEach(() => {\n vi.restoreAllMocks();\n dataSource = {\n getInstructionInfo: vi.fn(),\n };\n certificateLoader = {\n loadCertificate: vi.fn().mockResolvedValue(mockCertificate),\n };\n });\n\n const makeLoader = (config = mockConfig) =>\n new EnumVariantContextLoader(\n dataSource,\n config,\n certificateLoader,\n mockLoggerFactory,\n );\n\n describe(\"canHandle\", () => {\n it(\"returns true when SOLANA_ENUM_VARIANT is requested and selections are valid\", () => {\n expect(\n makeLoader().canHandle(\n {\n deviceModelId: DeviceModelId.NANO_X,\n selections: [\n {\n programId: JUPITER_PROGRAM,\n enumId: \"swap\",\n variantIndex: 46,\n },\n ],\n },\n [ClearSignContextType.SOLANA_ENUM_VARIANT],\n ),\n ).toBe(true);\n });\n\n it(\"returns false when SOLANA_ENUM_VARIANT is not requested\", () => {\n expect(\n makeLoader().canHandle(\n {\n deviceModelId: DeviceModelId.NANO_X,\n selections: [\n { programId: JUPITER_PROGRAM, enumId: \"swap\", variantIndex: 46 },\n ],\n },\n [ClearSignContextType.SOLANA_INSTRUCTION_INFO],\n ),\n ).toBe(false);\n });\n\n it.each([-1, 65536, 1.5, \"46\", null])(\n \"rejects non-u16 variantIndex: %s\",\n (badIndex) => {\n const loader = makeLoader();\n expect(\n loader.canHandle(\n {\n deviceModelId: DeviceModelId.NANO_X,\n selections: [\n {\n programId: JUPITER_PROGRAM,\n enumId: \"swap\",\n variantIndex: badIndex,\n },\n ],\n } as any,\n [ClearSignContextType.SOLANA_ENUM_VARIANT],\n ),\n ).toBe(false);\n },\n );\n\n it(\"rejects empty programId / enumId / selections\", () => {\n const loader = makeLoader();\n const types = [ClearSignContextType.SOLANA_ENUM_VARIANT];\n expect(loader.canHandle({ selections: [] } as any, types)).toBe(false);\n expect(\n loader.canHandle(\n {\n selections: [{ programId: \"\", enumId: \"swap\", variantIndex: 1 }],\n } as any,\n types,\n ),\n ).toBe(false);\n expect(\n loader.canHandle(\n {\n selections: [\n { programId: JUPITER_PROGRAM, enumId: \"\", variantIndex: 1 },\n ],\n } as any,\n types,\n ),\n ).toBe(false);\n });\n });\n\n describe(\"load\", () => {\n it(\"emits one SOLANA_ENUM_VARIANT per selection with certificate\", async () => {\n vi.spyOn(dataSource, \"getInstructionInfo\").mockResolvedValue(\n Right(makeJupiterWithVariants()),\n );\n\n const result = await makeLoader().load({\n deviceModelId: DeviceModelId.NANO_X,\n selections: [\n { programId: JUPITER_PROGRAM, enumId: \"swap\", variantIndex: 46 },\n { programId: JUPITER_PROGRAM, enumId: \"swap\", variantIndex: 12 },\n ],\n });\n\n expect(result).toHaveLength(2);\n expect(result[0]).toMatchObject({\n type: ClearSignContextType.SOLANA_ENUM_VARIANT,\n payload: {\n programId: JUPITER_PROGRAM,\n enumId: \"swap\",\n variantIndex: 46,\n descriptor: { data: \"01_raydium_tlv\", signature: \"prodsig_v46\" },\n },\n certificate: mockCertificate,\n });\n expect(result[1]).toMatchObject({\n payload: {\n variantIndex: 12,\n descriptor: { data: \"01_orca_tlv\", signature: \"prodsig_v12\" },\n },\n });\n });\n\n it(\"dedups CAL fetches across selections that share a programId\", async () => {\n const spy = vi\n .spyOn(dataSource, \"getInstructionInfo\")\n .mockResolvedValue(Right(makeJupiterWithVariants()));\n\n await makeLoader().load({\n deviceModelId: DeviceModelId.NANO_X,\n selections: [\n { programId: JUPITER_PROGRAM, enumId: \"swap\", variantIndex: 46 },\n { programId: JUPITER_PROGRAM, enumId: \"swap\", variantIndex: 12 },\n ],\n });\n\n expect(spy).toHaveBeenCalledTimes(1);\n });\n\n it(\"resolves a variant index > 255 (u16, disc_kind U16 enums)\", async () => {\n const result: InstructionInfoResult = {\n programId: JUPITER_PROGRAM,\n descriptors: {},\n enumVariants: [\n {\n enumId: \"swap\",\n variantIndex: 300,\n descriptor: { data: \"01_big_tlv\", signature: \"prodsig_v300\" },\n },\n ],\n };\n vi.spyOn(dataSource, \"getInstructionInfo\").mockResolvedValue(\n Right(result),\n );\n\n const out = await makeLoader().load({\n deviceModelId: DeviceModelId.NANO_X,\n selections: [\n { programId: JUPITER_PROGRAM, enumId: \"swap\", variantIndex: 300 },\n ],\n });\n\n expect(out).toHaveLength(1);\n expect(out[0]?.type).toBe(ClearSignContextType.SOLANA_ENUM_VARIANT);\n expect((out[0] as any).payload).toMatchObject({\n variantIndex: 300,\n descriptor: { data: \"01_big_tlv\", signature: \"prodsig_v300\" },\n });\n });\n\n it(\"emits ERROR when CAL has no matching variant for a selection\", async () => {\n vi.spyOn(dataSource, \"getInstructionInfo\").mockResolvedValue(\n Right(makeJupiterWithVariants()),\n );\n\n const result = await makeLoader().load({\n deviceModelId: DeviceModelId.NANO_X,\n selections: [\n { programId: JUPITER_PROGRAM, enumId: \"swap\", variantIndex: 99 },\n ],\n });\n\n expect(result).toHaveLength(1);\n expect(result[0]?.type).toBe(ClearSignContextType.ERROR);\n expect((result[0] as any).error.message).toMatch(/no enum variant/);\n });\n\n it(\"emits ERROR when CAL fetch fails\", async () => {\n vi.spyOn(dataSource, \"getInstructionInfo\").mockResolvedValue(\n Left(new Error(\"upstream-500\")),\n );\n\n const result = await makeLoader().load({\n deviceModelId: DeviceModelId.NANO_X,\n selections: [\n { programId: OTHER_PROGRAM, enumId: \"x\", variantIndex: 0 },\n ],\n });\n\n expect(result[0]?.type).toBe(ClearSignContextType.ERROR);\n expect((result[0] as any).error.message).toBe(\"upstream-500\");\n });\n\n it(\"emits ERROR when configured signature mode is missing\", async () => {\n // The mapper leaves the signature empty when CAL has none for the mode.\n const result: InstructionInfoResult = {\n programId: JUPITER_PROGRAM,\n descriptors: {},\n enumVariants: [\n {\n enumId: \"swap\",\n variantIndex: 46,\n descriptor: { data: \"01_raydium_tlv\", signature: \"\" },\n },\n ],\n };\n vi.spyOn(dataSource, \"getInstructionInfo\").mockResolvedValue(\n Right(result),\n );\n\n const loader = makeLoader({\n ...mockConfig,\n cal: { ...mockConfig.cal, mode: \"test\" },\n } as any);\n\n const out = await loader.load({\n deviceModelId: DeviceModelId.NANO_X,\n selections: [\n { programId: JUPITER_PROGRAM, enumId: \"swap\", variantIndex: 46 },\n ],\n });\n\n expect(out[0]?.type).toBe(ClearSignContextType.ERROR);\n expect((out[0] as any).error.message).toMatch(/missing 'test' signature/);\n });\n\n it(\"degrades every selection to ERROR when certificate loading fails\", async () => {\n vi.spyOn(certificateLoader, \"loadCertificate\").mockRejectedValue(\n new Error(\"pki-down\"),\n );\n // Data fetches run in parallel with cert load; resolve so awaits settle.\n vi.spyOn(dataSource, \"getInstructionInfo\").mockResolvedValue(\n Right(makeJupiterWithVariants()),\n );\n\n const out = await makeLoader().load({\n deviceModelId: DeviceModelId.NANO_X,\n selections: [\n { programId: JUPITER_PROGRAM, enumId: \"swap\", variantIndex: 46 },\n { programId: JUPITER_PROGRAM, enumId: \"swap\", variantIndex: 12 },\n ],\n });\n\n expect(out).toHaveLength(2);\n expect(out.every((c) => c.type === ClearSignContextType.ERROR)).toBe(\n true,\n );\n });\n\n it(\"falls back to default network when input.network is empty / missing\", async () => {\n const spy = vi\n .spyOn(dataSource, \"getInstructionInfo\")\n .mockResolvedValue(Right(makeJupiterWithVariants()));\n\n await makeLoader().load({\n deviceModelId: DeviceModelId.NANO_X,\n selections: [\n { programId: JUPITER_PROGRAM, enumId: \"swap\", variantIndex: 46 },\n ],\n network: \"\",\n });\n\n expect(spy).toHaveBeenCalledWith({\n programId: JUPITER_PROGRAM,\n network: \"solana-mainnet\",\n });\n });\n });\n});\n"],
5
- "mappings": "aACA,IAAAA,EAA8B,2CAC9BC,EAA4B,qBAC5BC,EAAqD,kBAQrDC,EAAqC,2CAErCC,EAAyC,sCAEzC,MAAMC,EAAoB,KAAO,CAC/B,MAAO,KAAG,GAAG,EACb,KAAM,KAAG,GAAG,EACZ,KAAM,KAAG,GAAG,EACZ,MAAO,KAAG,GAAG,EACb,YAAa,CAAC,CAChB,GAEMC,EAAkB,CACtB,eAAgB,EAChB,QAAS,IAAI,WAAW,CAAC,EAAI,CAAC,CAChC,EAEMC,EAAa,CACjB,IAAK,CACH,IAAK,2CACL,KAAM,OACN,OAAQ,MACV,CACF,EAEMC,EAAkB,8CAClBC,EAAgB,6CAItB,SAASC,GAAiD,CACxD,MAAO,CACL,UAAWF,EACX,YAAa,CAAC,EACd,aAAc,CACZ,CACE,OAAQ,OACR,aAAc,GACd,WAAY,CAAE,KAAM,iBAAkB,UAAW,aAAc,CACjE,EACA,CACE,OAAQ,OACR,aAAc,GACd,WAAY,CAAE,KAAM,cAAe,UAAW,aAAc,CAC9D,CACF,CACF,CACF,IAEA,YAAS,2BAA4B,IAAM,CACzC,IAAIG,EACAC,KAEJ,cAAW,IAAM,CACf,KAAG,gBAAgB,EACnBD,EAAa,CACX,mBAAoB,KAAG,GAAG,CAC5B,EACAC,EAAoB,CAClB,gBAAiB,KAAG,GAAG,EAAE,kBAAkBN,CAAe,CAC5D,CACF,CAAC,EAED,MAAMO,EAAa,CAACC,EAASP,IAC3B,IAAI,2BACFI,EACAG,EACAF,EACAP,CACF,KAEF,YAAS,YAAa,IAAM,IAC1B,MAAG,8EAA+E,IAAM,IACtF,UACEQ,EAAW,EAAE,U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CAAC,KAED,UAAOW,CAAG,EAAE,qBAAqB,CAC/B,UAAWX,EACX,QAAS,gBACX,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
4
+ "sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { DeviceModelId } 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 { type PkiCertificateLoader } from \"@/modules/multichain/pki/domain/PkiCertificateLoader\";\nimport {\n type InstructionInfoDataSource,\n type InstructionInfoResult,\n} from \"@/modules/solana/instruction-info/data/InstructionInfoDataSource\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\n\nimport { EnumVariantContextLoader } from \"./EnumVariantContextLoader\";\n\nconst mockLoggerFactory = () => ({\n debug: vi.fn(),\n info: vi.fn(),\n warn: vi.fn(),\n error: vi.fn(),\n subscribers: [],\n});\n\nconst mockCertificate = {\n keyUsageNumber: 8,\n payload: new Uint8Array([0x42]),\n};\n\nconst mockConfig = {\n cal: {\n url: \"https://global.api.prd.ledger.com/cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n} as ContextModuleServiceConfig;\n\nconst JUPITER_PROGRAM = \"JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4\";\nconst OTHER_PROGRAM = \"OtherProgram111111111111111111111111111111\";\n\n// The data source flattens enum variants into core models, with the signature\n// already picked for the configured mode.\nfunction makeJupiterWithVariants(): InstructionInfoResult {\n return {\n programId: JUPITER_PROGRAM,\n descriptors: {},\n basicFlowTags: [],\n enumVariants: [\n {\n enumId: \"swap\",\n variantIndex: 46,\n descriptor: { data: \"01_raydium_tlv\", signature: \"prodsig_v46\" },\n },\n {\n enumId: \"swap\",\n variantIndex: 12,\n descriptor: { data: \"01_orca_tlv\", signature: \"prodsig_v12\" },\n },\n ],\n };\n}\n\ndescribe(\"EnumVariantContextLoader\", () => {\n let dataSource: InstructionInfoDataSource;\n let certificateLoader: PkiCertificateLoader;\n\n beforeEach(() => {\n vi.restoreAllMocks();\n dataSource = {\n getInstructionInfo: vi.fn(),\n };\n certificateLoader = {\n loadCertificate: vi.fn().mockResolvedValue(mockCertificate),\n };\n });\n\n const makeLoader = (config = mockConfig) =>\n new EnumVariantContextLoader(\n dataSource,\n config,\n certificateLoader,\n mockLoggerFactory,\n );\n\n describe(\"canHandle\", () => {\n it(\"returns true when SOLANA_ENUM_VARIANT is requested and selections are valid\", () => {\n expect(\n makeLoader().canHandle(\n {\n deviceModelId: DeviceModelId.NANO_X,\n selections: [\n {\n programId: JUPITER_PROGRAM,\n enumId: \"swap\",\n variantIndex: 46,\n },\n ],\n },\n [ClearSignContextType.SOLANA_ENUM_VARIANT],\n ),\n ).toBe(true);\n });\n\n it(\"returns false when SOLANA_ENUM_VARIANT is not requested\", () => {\n expect(\n makeLoader().canHandle(\n {\n deviceModelId: DeviceModelId.NANO_X,\n selections: [\n { programId: JUPITER_PROGRAM, enumId: \"swap\", variantIndex: 46 },\n ],\n },\n [ClearSignContextType.SOLANA_INSTRUCTION_INFO],\n ),\n ).toBe(false);\n });\n\n it.each([-1, 65536, 1.5, \"46\", null])(\n \"rejects non-u16 variantIndex: %s\",\n (badIndex) => {\n const loader = makeLoader();\n expect(\n loader.canHandle(\n {\n deviceModelId: DeviceModelId.NANO_X,\n selections: [\n {\n programId: JUPITER_PROGRAM,\n enumId: \"swap\",\n variantIndex: badIndex,\n },\n ],\n } as any,\n [ClearSignContextType.SOLANA_ENUM_VARIANT],\n ),\n ).toBe(false);\n },\n );\n\n it(\"rejects empty programId / enumId / selections\", () => {\n const loader = makeLoader();\n const types = [ClearSignContextType.SOLANA_ENUM_VARIANT];\n expect(loader.canHandle({ selections: [] } as any, types)).toBe(false);\n expect(\n loader.canHandle(\n {\n selections: [{ programId: \"\", enumId: \"swap\", variantIndex: 1 }],\n } as any,\n types,\n ),\n ).toBe(false);\n expect(\n loader.canHandle(\n {\n selections: [\n { programId: JUPITER_PROGRAM, enumId: \"\", variantIndex: 1 },\n ],\n } as any,\n types,\n ),\n ).toBe(false);\n });\n });\n\n describe(\"load\", () => {\n it(\"emits one SOLANA_ENUM_VARIANT per selection with certificate\", async () => {\n vi.spyOn(dataSource, \"getInstructionInfo\").mockResolvedValue(\n Right(makeJupiterWithVariants()),\n );\n\n const result = await makeLoader().load({\n deviceModelId: DeviceModelId.NANO_X,\n selections: [\n { programId: JUPITER_PROGRAM, enumId: \"swap\", variantIndex: 46 },\n { programId: JUPITER_PROGRAM, enumId: \"swap\", variantIndex: 12 },\n ],\n });\n\n expect(result).toHaveLength(2);\n expect(result[0]).toMatchObject({\n type: ClearSignContextType.SOLANA_ENUM_VARIANT,\n payload: {\n programId: JUPITER_PROGRAM,\n enumId: \"swap\",\n variantIndex: 46,\n descriptor: { data: \"01_raydium_tlv\", signature: \"prodsig_v46\" },\n },\n certificate: mockCertificate,\n });\n expect(result[1]).toMatchObject({\n payload: {\n variantIndex: 12,\n descriptor: { data: \"01_orca_tlv\", signature: \"prodsig_v12\" },\n },\n });\n });\n\n it(\"dedups CAL fetches across selections that share a programId\", async () => {\n const spy = vi\n .spyOn(dataSource, \"getInstructionInfo\")\n .mockResolvedValue(Right(makeJupiterWithVariants()));\n\n await makeLoader().load({\n deviceModelId: DeviceModelId.NANO_X,\n selections: [\n { programId: JUPITER_PROGRAM, enumId: \"swap\", variantIndex: 46 },\n { programId: JUPITER_PROGRAM, enumId: \"swap\", variantIndex: 12 },\n ],\n });\n\n expect(spy).toHaveBeenCalledTimes(1);\n });\n\n it(\"resolves a variant index > 255 (u16, disc_kind U16 enums)\", async () => {\n const result: InstructionInfoResult = {\n programId: JUPITER_PROGRAM,\n descriptors: {},\n basicFlowTags: [],\n enumVariants: [\n {\n enumId: \"swap\",\n variantIndex: 300,\n descriptor: { data: \"01_big_tlv\", signature: \"prodsig_v300\" },\n },\n ],\n };\n vi.spyOn(dataSource, \"getInstructionInfo\").mockResolvedValue(\n Right(result),\n );\n\n const out = await makeLoader().load({\n deviceModelId: DeviceModelId.NANO_X,\n selections: [\n { programId: JUPITER_PROGRAM, enumId: \"swap\", variantIndex: 300 },\n ],\n });\n\n expect(out).toHaveLength(1);\n expect(out[0]?.type).toBe(ClearSignContextType.SOLANA_ENUM_VARIANT);\n expect((out[0] as any).payload).toMatchObject({\n variantIndex: 300,\n descriptor: { data: \"01_big_tlv\", signature: \"prodsig_v300\" },\n });\n });\n\n it(\"emits ERROR when CAL has no matching variant for a selection\", async () => {\n vi.spyOn(dataSource, \"getInstructionInfo\").mockResolvedValue(\n Right(makeJupiterWithVariants()),\n );\n\n const result = await makeLoader().load({\n deviceModelId: DeviceModelId.NANO_X,\n selections: [\n { programId: JUPITER_PROGRAM, enumId: \"swap\", variantIndex: 99 },\n ],\n });\n\n expect(result).toHaveLength(1);\n expect(result[0]?.type).toBe(ClearSignContextType.ERROR);\n expect((result[0] as any).error.message).toMatch(/no enum variant/);\n });\n\n it(\"emits ERROR when CAL fetch fails\", async () => {\n vi.spyOn(dataSource, \"getInstructionInfo\").mockResolvedValue(\n Left(new Error(\"upstream-500\")),\n );\n\n const result = await makeLoader().load({\n deviceModelId: DeviceModelId.NANO_X,\n selections: [\n { programId: OTHER_PROGRAM, enumId: \"x\", variantIndex: 0 },\n ],\n });\n\n expect(result[0]?.type).toBe(ClearSignContextType.ERROR);\n expect((result[0] as any).error.message).toBe(\"upstream-500\");\n });\n\n it(\"emits ERROR when configured signature mode is missing\", async () => {\n // The mapper leaves the signature empty when CAL has none for the mode.\n const result: InstructionInfoResult = {\n programId: JUPITER_PROGRAM,\n descriptors: {},\n basicFlowTags: [],\n enumVariants: [\n {\n enumId: \"swap\",\n variantIndex: 46,\n descriptor: { data: \"01_raydium_tlv\", signature: \"\" },\n },\n ],\n };\n vi.spyOn(dataSource, \"getInstructionInfo\").mockResolvedValue(\n Right(result),\n );\n\n const loader = makeLoader({\n ...mockConfig,\n cal: { ...mockConfig.cal, mode: \"test\" },\n } as any);\n\n const out = await loader.load({\n deviceModelId: DeviceModelId.NANO_X,\n selections: [\n { programId: JUPITER_PROGRAM, enumId: \"swap\", variantIndex: 46 },\n ],\n });\n\n expect(out[0]?.type).toBe(ClearSignContextType.ERROR);\n expect((out[0] as any).error.message).toMatch(/missing 'test' signature/);\n });\n\n it(\"degrades every selection to ERROR when certificate loading fails\", async () => {\n vi.spyOn(certificateLoader, \"loadCertificate\").mockRejectedValue(\n new Error(\"pki-down\"),\n );\n // Data fetches run in parallel with cert load; resolve so awaits settle.\n vi.spyOn(dataSource, \"getInstructionInfo\").mockResolvedValue(\n Right(makeJupiterWithVariants()),\n );\n\n const out = await makeLoader().load({\n deviceModelId: DeviceModelId.NANO_X,\n selections: [\n { programId: JUPITER_PROGRAM, enumId: \"swap\", variantIndex: 46 },\n { programId: JUPITER_PROGRAM, enumId: \"swap\", variantIndex: 12 },\n ],\n });\n\n expect(out).toHaveLength(2);\n expect(out.every((c) => c.type === ClearSignContextType.ERROR)).toBe(\n true,\n );\n });\n\n it(\"falls back to default network when input.network is empty / missing\", async () => {\n const spy = vi\n .spyOn(dataSource, \"getInstructionInfo\")\n .mockResolvedValue(Right(makeJupiterWithVariants()));\n\n await makeLoader().load({\n deviceModelId: DeviceModelId.NANO_X,\n selections: [\n { programId: JUPITER_PROGRAM, enumId: \"swap\", variantIndex: 46 },\n ],\n network: \"\",\n });\n\n expect(spy).toHaveBeenCalledWith({\n programId: JUPITER_PROGRAM,\n network: \"solana-mainnet\",\n });\n });\n });\n});\n"],
5
+ "mappings": "aACA,IAAAA,EAA8B,2CAC9BC,EAA4B,qBAC5BC,EAAqD,kBAQrDC,EAAqC,2CAErCC,EAAyC,sCAEzC,MAAMC,EAAoB,KAAO,CAC/B,MAAO,KAAG,GAAG,EACb,KAAM,KAAG,GAAG,EACZ,KAAM,KAAG,GAAG,EACZ,MAAO,KAAG,GAAG,EACb,YAAa,CAAC,CAChB,GAEMC,EA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QA,EAAI,CAAC,EAAU,MAAM,OAAO,EAAE,QAAQ,0BAA0B,CAC1E,CAAC,KAED,MAAG,mEAAoE,SAAY,CACjF,KAAG,MAAMR,EAAmB,iBAAiB,EAAE,kBAC7C,IAAI,MAAM,UAAU,CACtB,EAEA,KAAG,MAAMD,EAAY,oBAAoB,EAAE,qBACzC,SAAMD,EAAwB,CAAC,CACjC,EAEA,MAAMU,EAAM,MAAMP,EAAW,EAAE,KAAK,CAClC,cAAe,gBAAc,OAC7B,WAAY,CACV,CAAE,UAAWL,EAAiB,OAAQ,OAAQ,aAAc,EAAG,EAC/D,CAAE,UAAWA,EAAiB,OAAQ,OAAQ,aAAc,EAAG,CACjE,CACF,CAAC,KAED,UAAOY,CAAG,EAAE,aAAa,CAAC,KAC1B,UAAOA,EAAI,MAAOC,GAAMA,EAAE,OAAS,uBAAqB,KAAK,CAAC,EAAE,KAC9D,EACF,CACF,CAAC,KAED,MAAG,sEAAuE,SAAY,CACpF,MAAMF,EAAM,KACT,MAAMR,EAAY,oBAAoB,EACtC,qBAAkB,SAAMD,EAAwB,CAAC,CAAC,EAErD,MAAMG,EAAW,EAAE,KAAK,CACtB,cAAe,gBAAc,OAC7B,WAAY,CACV,CAAE,UAAWL,EAAiB,OAAQ,OAAQ,aAAc,EAAG,CACjE,EACA,QAAS,EACX,CAAC,KAED,UAAOW,CAAG,EAAE,qBAAqB,CAC/B,UAAWX,EACX,QAAS,gBACX,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
6
  "names": ["import_device_management_kit", "import_purify_ts", "import_vitest", "import_ClearSignContext", "import_EnumVariantContextLoader", "mockLoggerFactory", "mockCertificate", "mockConfig", "JUPITER_PROGRAM", "OTHER_PROGRAM", "makeJupiterWithVariants", "dataSource", "certificateLoader", "makeLoader", "config", "badIndex", "loader", "types", "result", "spy", "out", "c"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var l=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var M=(n,t)=>{for(var e in t)l(n,e,{get:t[e],enumerable:!0})},k=(n,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of S(t))!T.call(n,o)&&o!==e&&l(n,o,{get:()=>t[o],enumerable:!(i=C(t,o))||i.enumerable});return n};var b=n=>k(l({},"__esModule",{value:!0}),n),g=(n,t,e,i)=>{for(var o=i>1?void 0:i?C(t,e):t,s=n.length-1,r;s>=0;s--)(r=n[s])&&(o=(i?r(t,e,o):r(o))||o);return i&&o&&l(t,e,o),o},I=(n,t)=>(e,i)=>t(e,i,n);var P={};M(P,{HttpInstructionInfoDataSource:()=>u});module.exports=b(P);var f=require("inversify"),a=require("purify-ts"),E=require("../../../../config/di/configTypes"),m=require("../../../../modules/solana/model/SolanaTransactionScanChainId"),y=require("../../../../shared/network/di/networkTypes"),D=require("./InstructionInfoDto"),p=require("./InstructionInfoMapper");const x={"solana-mainnet":m.SolanaTransactionScanChainId.MAINNET,"solana-devnet":m.SolanaTransactionScanChainId.DEVNET,"solana-testnet":m.SolanaTransactionScanChainId.TESTNET};let u=class{constructor(t,e){this.config=t;this.http=e}async getInstructionInfo({programId:t,network:e}){const i=x[e]??m.SolanaTransactionScanChainId.MAINNET;let o;try{o=await this.http.get(`${this.config.cal.url}/solana_programs`,{params:{id:t,chain_id:i,output:"id,chain_id,instructions",ref:`branch:${this.config.cal.branch}`}})}catch(r){const d=r instanceof Error?r.message:String(r);return(0,a.Left)(new Error(`[ContextModule] HttpInstructionInfoDataSource: Failed to fetch instruction descriptors: ${d}`))}if(!Array.isArray(o)||o.length===0)return(0,a.Left)(new Error(`[ContextModule] HttpInstructionInfoDataSource: empty response for program ${t}`));const s=o.find(r=>r!=null&&typeof r=="object"&&r.id===t);return s===void 0?(0,a.Left)(new Error(`[ContextModule] HttpInstructionInfoDataSource: no descriptors for program ${t}`)):D.calInstructionProgramCodec.decode(s).caseOf({Left:r=>(0,a.Left)(new Error(`[ContextModule] HttpInstructionInfoDataSource: malformed descriptors for program ${t}: ${r}`)),Right:()=>{const r=this.config.cal.mode??"prod",d=s.instructions,h=Object.fromEntries(d.map(c=>[c.discriminator_hex??"",c])),w=Object.fromEntries(Object.entries(h).map(([c,N])=>[c,(0,p.toInstructionInfoPayload)(t,c,N,r)]));return(0,a.Right)({programId:t,descriptors:w,enumVariants:(0,p.toProgramEnumVariants)(h,r)})}})}};u=g([(0,f.injectable)(),I(0,(0,f.inject)(E.configTypes.Config)),I(1,(0,f.inject)(y.networkTypes.NetworkClient))],u);0&&(module.exports={HttpInstructionInfoDataSource});
1
+ "use strict";var d=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var x=(i,t)=>{for(var o in t)d(i,o,{get:t[o],enumerable:!0})},M=(i,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of D(t))!v.call(i,n)&&n!==o&&d(i,n,{get:()=>t[n],enumerable:!(r=g(t,n))||r.enumerable});return i};var N=i=>M(d({},"__esModule",{value:!0}),i),y=(i,t,o,r)=>{for(var n=r>1?void 0:r?g(t,o):t,e=i.length-1,s;e>=0;e--)(s=i[e])&&(n=(r?s(t,o,n):s(n))||n);return r&&n&&d(t,o,n),n},C=(i,t)=>(o,r)=>t(o,r,i);var _={};x(_,{HttpInstructionInfoDataSource:()=>h});module.exports=N(_);var p=require("inversify"),a=require("purify-ts"),w=require("../../../../config/di/configTypes"),m=require("../../../../modules/solana/model/SolanaTransactionScanChainId"),S=require("../../../../shared/network/di/networkTypes"),I=require("./InstructionInfoDataSource"),T=require("./InstructionInfoDto"),l=require("./InstructionInfoMapper");const R={"solana-mainnet":m.SolanaTransactionScanChainId.MAINNET,"solana-devnet":m.SolanaTransactionScanChainId.DEVNET,"solana-testnet":m.SolanaTransactionScanChainId.TESTNET},b=3e4,P=64;let h=class{constructor(t,o){this.config=t;this.http=o}cache=new Map;getInstructionInfo({programId:t,network:o}){const r=R[o]??m.SolanaTransactionScanChainId.MAINNET,n=`${r}:${t}`,e=Date.now(),s=this.cache.get(n);if(s!==void 0&&s.expiresAt>e)return s.result;const c=this.fetchInstructionInfo(t,r);if(this.cache.delete(n),this.cache.size>=P){const u=this.cache.keys().next();u.done||this.cache.delete(u.value)}return this.cache.set(n,{expiresAt:e+b,result:c}),c.then(u=>{u.caseOf({Left:E=>E instanceof I.SolanaProgramNotFoundError,Right:()=>!0})||this.evict(n,c)},()=>this.evict(n,c)),c}evict(t,o){this.cache.get(t)?.result===o&&this.cache.delete(t)}async fetchInstructionInfo(t,o){let r;try{r=await this.http.get(`${this.config.cal.url}/solana_programs`,{params:{id:t,chain_id:o,output:"id,chain_id,instructions",ref:`branch:${this.config.cal.branch}`}})}catch(e){const s=e instanceof Error?e.message:String(e);return(0,a.Left)(new Error(`[ContextModule] HttpInstructionInfoDataSource: Failed to fetch instruction descriptors: ${s}`))}if(!Array.isArray(r))return(0,a.Left)(new Error(`[ContextModule] HttpInstructionInfoDataSource: unexpected response for program ${t}`));if(r.length===0)return(0,a.Left)(new I.SolanaProgramNotFoundError(t,`[ContextModule] HttpInstructionInfoDataSource: empty response for program ${t}`));const n=r.find(e=>e!=null&&typeof e=="object"&&e.id===t);return n===void 0?(0,a.Left)(new I.SolanaProgramNotFoundError(t,`[ContextModule] HttpInstructionInfoDataSource: no descriptors for program ${t}`)):T.calInstructionProgramCodec.decode(n).caseOf({Left:e=>(0,a.Left)(new Error(`[ContextModule] HttpInstructionInfoDataSource: malformed descriptors for program ${t}: ${e}`)),Right:()=>{const e=this.config.cal.mode??"prod",s=n.instructions,c=Object.fromEntries(s.map(f=>[f.discriminator_hex??"",f])),u=Object.fromEntries(Object.entries(c).map(([f,E])=>[f,(0,l.toInstructionInfoPayload)(t,f,E,e)]));return(0,a.Right)({programId:t,descriptors:u,enumVariants:(0,l.toProgramEnumVariants)(c,e),basicFlowTags:(0,l.toBasicFlowTags)(c)})}})}};h=y([(0,p.injectable)(),C(0,(0,p.inject)(w.configTypes.Config)),C(1,(0,p.inject)(S.networkTypes.NetworkClient))],h);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 { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { SolanaTransactionScanChainId } from \"@/modules/solana/model/SolanaTransactionScanChainId\";\nimport { networkTypes } from \"@/shared/network/di/networkTypes\";\n\nimport {\n GetInstructionInfoParams,\n InstructionInfoDataSource,\n InstructionInfoResult,\n} from \"./InstructionInfoDataSource\";\nimport {\n type CalInstructionDescriptorDto,\n calInstructionProgramCodec,\n type CalInstructionProgramDto,\n} from \"./InstructionInfoDto\";\nimport {\n type CalMode,\n toInstructionInfoPayload,\n toProgramEnumVariants,\n} from \"./InstructionInfoMapper\";\n\n// Maps the DMK network label to the numeric CAL `chain_id` (the extended\n// Solana network ids 900/901/902). Unknown labels fall back to mainnet.\nconst CHAIN_ID_BY_NETWORK: Record<string, SolanaTransactionScanChainId> = {\n \"solana-mainnet\": SolanaTransactionScanChainId.MAINNET,\n \"solana-devnet\": SolanaTransactionScanChainId.DEVNET,\n \"solana-testnet\": SolanaTransactionScanChainId.TESTNET,\n};\n\n@injectable()\nexport class HttpInstructionInfoDataSource\n implements InstructionInfoDataSource\n{\n constructor(\n @inject(configTypes.Config)\n private readonly config: ContextModuleServiceConfig,\n @inject(networkTypes.NetworkClient)\n private readonly http: DmkNetworkClient,\n ) {}\n\n public async getInstructionInfo({\n programId,\n network,\n }: GetInstructionInfoParams): Promise<Either<Error, InstructionInfoResult>> {\n const chainId =\n CHAIN_ID_BY_NETWORK[network] ?? SolanaTransactionScanChainId.MAINNET;\n let data: unknown;\n try {\n data = await this.http.get(`${this.config.cal.url}/solana_programs`, {\n params: {\n id: programId,\n chain_id: chainId,\n output: \"id,chain_id,instructions\",\n ref: `branch:${this.config.cal.branch}`,\n },\n });\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n return Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: Failed to fetch instruction descriptors: ${reason}`,\n ),\n );\n }\n\n if (!Array.isArray(data) || data.length === 0) {\n return Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: empty response for program ${programId}`,\n ),\n );\n }\n\n // Select the program object whose `id` matches the requested `programId`\n // (the response is an array, one object per requested id).\n const program = data.find(\n (entry): entry is { id: unknown } =>\n entry != null &&\n typeof entry === \"object\" &&\n (entry as { id?: unknown }).id === programId,\n );\n if (program === undefined) {\n return Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: no descriptors for program ${programId}`,\n ),\n );\n }\n\n // Validate the program shape so the mapper can dereference `descriptor` /\n // `enum_variants` without runtime-throwing on a malformed CAL payload. A\n // malformed program degrades to a per-program ERROR rather than rejecting\n // the batch. On success we transform each validated DTO into the core\n // payload so the loader never sees the CAL DTO shapes.\n return calInstructionProgramCodec\n .decode(program)\n .caseOf<Either<Error, InstructionInfoResult>>({\n Left: (error) =>\n Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: malformed descriptors for program ${programId}: ${error}`,\n ),\n ),\n Right: () => {\n const mode: CalMode = this.config.cal.mode ?? \"prod\";\n // The codec strips undeclared fields, so we key the original\n // (full) instruction objects by `discriminator_hex` \u2014 the cast is\n // justified now that the shape has been validated. A descriptor\n // without a discriminator (single-instruction programs such as SPL\n // Memo) is keyed under the empty string.\n const instructions = (program as CalInstructionProgramDto)\n .instructions;\n const descriptorsByDiscriminator: Record<\n string,\n CalInstructionDescriptorDto\n > = Object.fromEntries(\n instructions.map((dto) => [dto.discriminator_hex ?? \"\", dto]),\n );\n const mapped = Object.fromEntries(\n Object.entries(descriptorsByDiscriminator).map(\n ([discriminator, dto]) => [\n discriminator,\n toInstructionInfoPayload(programId, discriminator, dto, mode),\n ],\n ),\n );\n return Right({\n programId,\n descriptors: mapped,\n enumVariants: toProgramEnumVariants(\n descriptorsByDiscriminator,\n mode,\n ),\n });\n },\n });\n }\n}\n"],
5
- "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAmC,qBACnCC,EAAoC,qBAEpCC,EAA4B,mCAE5BC,EAA6C,+DAC7CC,EAA6B,4CAO7BC,EAIO,gCACPC,EAIO,mCAIP,MAAMC,EAAoE,CACxE,iBAAkB,+BAA6B,QAC/C,gBAAiB,+BAA6B,OAC9C,iBAAkB,+BAA6B,OACjD,EAGO,IAAMC,EAAN,KAEP,CACE,YAEmBC,EAEAC,EACjB,CAHiB,YAAAD,EAEA,UAAAC,CAChB,CAEH,MAAa,mBAAmB,CAC9B,UAAAC,EACA,QAAAC,CACF,EAA4E,CAC1E,MAAMC,EACJN,EAAoBK,CAAO,GAAK,+BAA6B,QAC/D,IAAIE,EACJ,GAAI,CACFA,EAAO,MAAM,KAAK,KAAK,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,mBAAoB,CACnE,OAAQ,CACN,GAAIH,EACJ,SAAUE,EACV,OAAQ,2BACR,IAAK,UAAU,KAAK,OAAO,IAAI,MAAM,EACvC,CACF,CAAC,CACH,OAASE,EAAO,CACd,MAAMC,EAASD,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,EACpE,SAAO,QACL,IAAI,MACF,2FAA2FC,CAAM,EACnG,CACF,CACF,CAEA,GAAI,CAAC,MAAM,QAAQF,CAAI,GAAKA,EAAK,SAAW,EAC1C,SAAO,QACL,IAAI,MACF,6EAA6EH,CAAS,EACxF,CACF,EAKF,MAAMM,EAAUH,EAAK,KAClBI,GACCA,GAAS,MACT,OAAOA,GAAU,UAChBA,EAA2B,KAAOP,CACvC,EACA,OAAIM,IAAY,UACP,QACL,IAAI,MACF,6EAA6EN,CAAS,EACxF,CACF,EAQK,6BACJ,OAAOM,CAAO,EACd,OAA6C,CAC5C,KAAOF,MACL,QACE,IAAI,MACF,oFAAoFJ,CAAS,KAAKI,CAAK,EACzG,CACF,EACF,MAAO,IAAM,CACX,MAAMI,EAAgB,KAAK,OAAO,IAAI,MAAQ,OAMxCC,EAAgBH,EACnB,aACGI,EAGF,OAAO,YACTD,EAAa,IAAKE,GAAQ,CAACA,EAAI,mBAAqB,GAAIA,CAAG,CAAC,CAC9D,EACMC,EAAS,OAAO,YACpB,OAAO,QAAQF,CAA0B,EAAE,IACzC,CAAC,CAACG,EAAeF,CAAG,IAAM,CACxBE,KACA,4BAAyBb,EAAWa,EAAeF,EAAKH,CAAI,CAC9D,CACF,CACF,EACA,SAAO,SAAM,CACX,UAAAR,EACA,YAAaY,EACb,gBAAc,yBACZF,EACAF,CACF,CACF,CAAC,CACH,CACF,CAAC,CACL,CACF,EA3GaX,EAANiB,EAAA,IADN,cAAW,EAKPC,EAAA,eAAO,cAAY,MAAM,GAEzBA,EAAA,eAAO,eAAa,aAAa,IANzBlB",
6
- "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"]
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 SolanaProgramNotFoundError,\n} from \"./InstructionInfoDataSource\";\nimport {\n type CalInstructionDescriptorDto,\n calInstructionProgramCodec,\n type CalInstructionProgramDto,\n} from \"./InstructionInfoDto\";\nimport {\n type CalMode,\n toBasicFlowTags,\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// One sign looks up the same programs several times (signing-route lookup,\n// instruction-info and enum-variant loaders), so results are memoized for a\n// short time. The TTL only has to cover one sign; the size cap bounds memory.\nconst CACHE_TTL_MS = 30_000;\nconst CACHE_MAX_ENTRIES = 64;\n\ntype InstructionInfoCacheEntry = {\n expiresAt: number;\n result: Promise<Either<Error, InstructionInfoResult>>;\n};\n\n@injectable()\nexport class HttpInstructionInfoDataSource\n implements InstructionInfoDataSource\n{\n // Keyed by `${chainId}:${programId}`. The in-flight promise is stored, so\n // concurrent callers share one HTTP call.\n private readonly cache = new Map<string, InstructionInfoCacheEntry>();\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 getInstructionInfo({\n programId,\n network,\n }: GetInstructionInfoParams): Promise<Either<Error, InstructionInfoResult>> {\n const chainId =\n CHAIN_ID_BY_NETWORK[network] ?? SolanaTransactionScanChainId.MAINNET;\n const key = `${chainId}:${programId}`;\n const now = Date.now();\n\n const cached = this.cache.get(key);\n if (cached !== undefined && cached.expiresAt > now) {\n return cached.result;\n }\n\n const result = this.fetchInstructionInfo(programId, chainId);\n this.cache.delete(key);\n if (this.cache.size >= CACHE_MAX_ENTRIES) {\n // Map iterates in insertion order: evict the oldest entry.\n const oldest = this.cache.keys().next();\n if (!oldest.done) this.cache.delete(oldest.value);\n }\n this.cache.set(key, { expiresAt: now + CACHE_TTL_MS, result });\n\n // Failures are not cached so the next caller retries. \"Program not found\"\n // is a valid CAL answer and stays cached.\n void result.then(\n (either) => {\n const cacheable = either.caseOf({\n Left: (error) => error instanceof SolanaProgramNotFoundError,\n Right: () => true,\n });\n if (!cacheable) this.evict(key, result);\n },\n () => this.evict(key, result),\n );\n\n return result;\n }\n\n private evict(\n key: string,\n result: Promise<Either<Error, InstructionInfoResult>>,\n ): void {\n // Only drop our own entry, not a newer one stored under the same key.\n if (this.cache.get(key)?.result === result) {\n this.cache.delete(key);\n }\n }\n\n private async fetchInstructionInfo(\n programId: string,\n chainId: SolanaTransactionScanChainId,\n ): Promise<Either<Error, InstructionInfoResult>> {\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)) {\n return Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: unexpected response for program ${programId}`,\n ),\n );\n }\n\n // CAL answers with an empty array for a program it doesn't know.\n if (data.length === 0) {\n return Left(\n new SolanaProgramNotFoundError(\n programId,\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 SolanaProgramNotFoundError(\n programId,\n `[ContextModule] HttpInstructionInfoDataSource: no descriptors for program ${programId}`,\n ),\n );\n }\n\n // Validate the program shape so the mapper can dereference `descriptor` /\n // `enum_variants` without runtime-throwing on a malformed CAL payload. A\n // malformed program degrades to a per-program ERROR rather than rejecting\n // the batch. On success we transform each validated DTO into the core\n // payload so the loader never sees the CAL DTO shapes.\n return calInstructionProgramCodec\n .decode(program)\n .caseOf<Either<Error, InstructionInfoResult>>({\n Left: (error) =>\n Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: malformed descriptors for program ${programId}: ${error}`,\n ),\n ),\n Right: () => {\n const mode: CalMode = this.config.cal.mode ?? \"prod\";\n // The codec strips undeclared fields, so we key the original\n // (full) instruction objects by `discriminator_hex` \u2014 the cast is\n // justified now that the shape has been validated. A descriptor\n // without a discriminator (single-instruction programs such as SPL\n // Memo) is keyed under the empty string.\n const instructions = (program as CalInstructionProgramDto)\n .instructions;\n const descriptorsByDiscriminator: Record<\n string,\n CalInstructionDescriptorDto\n > = Object.fromEntries(\n instructions.map((dto) => [dto.discriminator_hex ?? \"\", dto]),\n );\n const mapped = Object.fromEntries(\n Object.entries(descriptorsByDiscriminator).map(\n ([discriminator, dto]) => [\n discriminator,\n toInstructionInfoPayload(programId, discriminator, dto, mode),\n ],\n ),\n );\n return Right({\n programId,\n descriptors: mapped,\n enumVariants: toProgramEnumVariants(\n descriptorsByDiscriminator,\n mode,\n ),\n basicFlowTags: toBasicFlowTags(descriptorsByDiscriminator),\n });\n },\n });\n }\n}\n"],
5
+ "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAmC,qBACnC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,CAA0B,CAC3D,CAAC,CACH,CACF,CAAC,CACL,CACF,EA1KanB,EAANuB,EAAA,IADN,cAAW,EASPC,EAAA,eAAO,cAAY,MAAM,GAEzBA,EAAA,eAAO,eAAa,aAAa,IAVzBxB",
6
+ "names": ["HttpInstructionInfoDataSource_exports", "__export", "HttpInstructionInfoDataSource", "__toCommonJS", "import_inversify", "import_purify_ts", "import_configTypes", "import_SolanaTransactionScanChainId", "import_networkTypes", "import_InstructionInfoDataSource", "import_InstructionInfoDto", "import_InstructionInfoMapper", "CHAIN_ID_BY_NETWORK", "CACHE_TTL_MS", "CACHE_MAX_ENTRIES", "HttpInstructionInfoDataSource", "config", "http", "programId", "network", "chainId", "key", "now", "cached", "result", "oldest", "either", "error", "data", "reason", "program", "entry", "mode", "instructions", "descriptorsByDiscriminator", "dto", "mapped", "discriminator", "__decorateClass", "__decorateParam"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var i=require("purify-ts"),t=require("vitest"),a=require("../../../../modules/solana/model/SolanaTransactionScanChainId"),d=require("./HttpInstructionInfoDataSource");(0,t.describe)("HttpInstructionInfoDataSource",()=>{let r,n;const e="11111111111111111111111111111111",s="solana-mainnet",l={cal:{url:"https://global.api.prd.ledger.com/cal/v1",mode:"prod",branch:"main"}},u=[{id:e,chain_id:a.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(),n={get:t.vi.fn()},r=new d.HttpInstructionInfoDataSource(l,n)}),(0,t.it)("calls CAL /solana_programs with id, chain_id and output params",async()=>{n.get.mockResolvedValue(u),await r.getInstructionInfo({programId:e,network:s}),(0,t.expect)(n.get).toHaveBeenCalledTimes(1),(0,t.expect)(n.get).toHaveBeenCalledWith("https://global.api.prd.ledger.com/cal/v1/solana_programs",{params:{id:e,chain_id:a.SolanaTransactionScanChainId.MAINNET,output:"id,chain_id,instructions",ref:"branch:main"}})}),(0,t.it)("maps devnet/testnet networks to their numeric chain ids",async()=>{n.get.mockResolvedValue(u),await r.getInstructionInfo({programId:e,network:"solana-devnet"}),(0,t.expect)(n.get).toHaveBeenCalledWith("https://global.api.prd.ledger.com/cal/v1/solana_programs",t.expect.objectContaining({params:t.expect.objectContaining({chain_id:901})}))}),(0,t.it)("returns Right with each descriptor transformed into the core payload on success",async()=>{n.get.mockResolvedValue(u);const o=await r.getInstructionInfo({programId:e,network:s});(0,t.expect)(o).toEqual((0,i.Right)({programId:e,descriptors:{"00000000":(0,i.Right)({programId:e,discriminator:"00000000",instructionName:"createAccount",instructionInfo:{data:"00010101",signature:"prodsig"},substructures:[],enumVariants:[],idlDescriptor:{typePool:[],rootType:0},mintAssociations:[],ownerAssociations:[],valueFlowPorts:[],accountResets:[],displayFields:[],hideRules:[]})},enumVariants:[]}))}),(0,t.it)("keys a descriptor without `discriminator_hex` under the empty string",async()=>{n.get.mockResolvedValue([{id:e,chain_id:a.SolanaTransactionScanChainId.MAINNET,instructions:[{instruction_name:"addMemo",descriptor:{data:"00010101",signatures:{prod:"prodsig",test:"testsig"}}}]}]);const o=await r.getInstructionInfo({programId:e,network:s});(0,t.expect)(o.isRight()).toBe(!0);const{descriptors:c}=o.unsafeCoerce();(0,t.expect)(Object.keys(c)).toEqual([""]),(0,t.expect)(c[""].unsafeCoerce()).toEqual(t.expect.objectContaining({programId:e,discriminator:"",instructionInfo:{data:"00010101",signature:"prodsig"}}))}),(0,t.it)("returns Left when the response array is empty",async()=>{n.get.mockResolvedValue([]);const o=await r.getInstructionInfo({programId:e,network:s});(0,t.expect)(o).toEqual((0,i.Left)(new Error(`[ContextModule] HttpInstructionInfoDataSource: empty response for program ${e}`)))}),(0,t.it)("returns Left when no program object matches the requested programId",async()=>{n.get.mockResolvedValue([{id:"OtherProgram",chain_id:a.SolanaTransactionScanChainId.MAINNET,instructions:[]}]);const o=await r.getInstructionInfo({programId:e,network:s});(0,t.expect)(o).toEqual((0,i.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()=>{n.get.mockResolvedValue([{id:e,chain_id:a.SolanaTransactionScanChainId.MAINNET,instructions:[{discriminator_hex:"00000000"}]}]);const o=await r.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 (not a throw) when account_schema.slots is not an array",async()=>{n.get.mockResolvedValue([{id:e,chain_id:a.SolanaTransactionScanChainId.MAINNET,instructions:[{discriminator_hex:"00000000",descriptor:{data:"00010101",signatures:{prod:"prodsig",test:"testsig"}},account_schema:{slots:{}}}]}]);const o=await r.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 Right with accountSchema mapped through when it is well-formed",async()=>{n.get.mockResolvedValue([{id:e,chain_id:a.SolanaTransactionScanChainId.MAINNET,instructions:[{discriminator_hex:"00000000",descriptor:{data:"00010101",signatures:{prod:"prodsig",test:"testsig"}},account_schema:{count_min:2,count_max:2,slots:[{signer:"REQUIRED",writable:"EITHER"}]}}]}]);const o=await r.getInstructionInfo({programId:e,network:s});(0,t.expect)(o.isRight()).toBe(!0);const{descriptors:c}=o.unsafeCoerce();(0,t.expect)(c["00000000"].unsafeCoerce()).toEqual(t.expect.objectContaining({accountSchema:{count_min:2,count_max:2,remaining_policy:{signer:"EITHER",writable:"EITHER"},slots:[{signer:"REQUIRED",writable:"EITHER"}]}}))}),(0,t.it)("returns Left when the HTTP client throws",async()=>{n.get.mockRejectedValue(new Error("network"));const o=await r.getInstructionInfo({programId:e,network:s});(0,t.expect)(o).toEqual((0,i.Left)(new Error("[ContextModule] HttpInstructionInfoDataSource: Failed to fetch instruction descriptors: network")))})});
1
+ "use strict";var m=require("purify-ts"),e=require("vitest"),l=require("../../../../modules/solana/model/SolanaTransactionScanChainId"),w=require("./HttpInstructionInfoDataSource"),g=require("./InstructionInfoDataSource");(0,e.describe)("HttpInstructionInfoDataSource",()=>{let r,n;const t="11111111111111111111111111111111",a="solana-mainnet",h={cal:{url:"https://global.api.prd.ledger.com/cal/v1",mode:"prod",branch:"main"}},u=[{id:t,chain_id:l.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,e.beforeEach)(()=>{e.vi.clearAllMocks(),n={get:e.vi.fn()},r=new w.HttpInstructionInfoDataSource(h,n)}),(0,e.it)("calls CAL /solana_programs with id, chain_id and output params",async()=>{n.get.mockResolvedValue(u),await r.getInstructionInfo({programId:t,network:a}),(0,e.expect)(n.get).toHaveBeenCalledTimes(1),(0,e.expect)(n.get).toHaveBeenCalledWith("https://global.api.prd.ledger.com/cal/v1/solana_programs",{params:{id:t,chain_id:l.SolanaTransactionScanChainId.MAINNET,output:"id,chain_id,instructions",ref:"branch:main"}})}),(0,e.it)("maps devnet/testnet networks to their numeric chain ids",async()=>{n.get.mockResolvedValue(u),await r.getInstructionInfo({programId:t,network:"solana-devnet"}),(0,e.expect)(n.get).toHaveBeenCalledWith("https://global.api.prd.ledger.com/cal/v1/solana_programs",e.expect.objectContaining({params:e.expect.objectContaining({chain_id:901})}))}),(0,e.it)("returns Right with each descriptor transformed into the core payload on success",async()=>{n.get.mockResolvedValue(u);const o=await r.getInstructionInfo({programId:t,network:a});(0,e.expect)(o).toEqual((0,m.Right)({programId:t,descriptors:{"00000000":(0,m.Right)({programId:t,discriminator:"00000000",instructionName:"createAccount",instructionInfo:{data:"00010101",signature:"prodsig"},substructures:[],enumVariants:[],idlDescriptor:{typePool:[],rootType:0},mintAssociations:[],ownerAssociations:[],valueFlowPorts:[],accountResets:[],displayFields:[],hideRules:[]})},enumVariants:[],basicFlowTags:[]}))}),(0,e.it)("keys a descriptor without `discriminator_hex` under the empty string",async()=>{n.get.mockResolvedValue([{id:t,chain_id:l.SolanaTransactionScanChainId.MAINNET,instructions:[{instruction_name:"addMemo",descriptor:{data:"00010101",signatures:{prod:"prodsig",test:"testsig"}}}]}]);const o=await r.getInstructionInfo({programId:t,network:a});(0,e.expect)(o.isRight()).toBe(!0);const{descriptors:s}=o.unsafeCoerce();(0,e.expect)(Object.keys(s)).toEqual([""]),(0,e.expect)(s[""].unsafeCoerce()).toEqual(e.expect.objectContaining({programId:t,discriminator:"",instructionInfo:{data:"00010101",signature:"prodsig"}}))}),(0,e.it)("returns a SolanaProgramNotFoundError when the response array is empty",async()=>{n.get.mockResolvedValue([]);const o=await r.getInstructionInfo({programId:t,network:a});(0,e.expect)(o).toEqual((0,m.Left)(new g.SolanaProgramNotFoundError(t,`[ContextModule] HttpInstructionInfoDataSource: empty response for program ${t}`))),(0,e.expect)(o.extract()).toBeInstanceOf(g.SolanaProgramNotFoundError)}),(0,e.it)("returns a plain Error, not a not-found, when the response is not an array",async()=>{n.get.mockResolvedValue({unexpected:!0});const o=await r.getInstructionInfo({programId:t,network:a});(0,e.expect)(o.isLeft()).toBe(!0),(0,e.expect)(o.extract()).not.toBeInstanceOf(g.SolanaProgramNotFoundError),(0,e.expect)(o.extract().message).toBe(`[ContextModule] HttpInstructionInfoDataSource: unexpected response for program ${t}`)}),(0,e.it)("returns a SolanaProgramNotFoundError when no program object matches the requested programId",async()=>{n.get.mockResolvedValue([{id:"OtherProgram",chain_id:l.SolanaTransactionScanChainId.MAINNET,instructions:[]}]);const o=await r.getInstructionInfo({programId:t,network:a});(0,e.expect)(o).toEqual((0,m.Left)(new g.SolanaProgramNotFoundError(t,`[ContextModule] HttpInstructionInfoDataSource: no descriptors for program ${t}`)))}),(0,e.it)("returns Left (not a throw) when an instruction descriptor is malformed",async()=>{n.get.mockResolvedValue([{id:t,chain_id:l.SolanaTransactionScanChainId.MAINNET,instructions:[{discriminator_hex:"00000000"}]}]);const o=await r.getInstructionInfo({programId:t,network:a});(0,e.expect)(o.isLeft()).toBe(!0),(0,e.expect)(o.extract().message).toMatch(new RegExp(String.raw`\[ContextModule\] HttpInstructionInfoDataSource: malformed descriptors for program ${t}:`))}),(0,e.it)("returns Left (not a throw) when account_schema.slots is not an array",async()=>{n.get.mockResolvedValue([{id:t,chain_id:l.SolanaTransactionScanChainId.MAINNET,instructions:[{discriminator_hex:"00000000",descriptor:{data:"00010101",signatures:{prod:"prodsig",test:"testsig"}},account_schema:{slots:{}}}]}]);const o=await r.getInstructionInfo({programId:t,network:a});(0,e.expect)(o.isLeft()).toBe(!0),(0,e.expect)(o.extract().message).toMatch(new RegExp(String.raw`\[ContextModule\] HttpInstructionInfoDataSource: malformed descriptors for program ${t}:`))}),(0,e.it)("returns Right with accountSchema mapped through when it is well-formed",async()=>{n.get.mockResolvedValue([{id:t,chain_id:l.SolanaTransactionScanChainId.MAINNET,instructions:[{discriminator_hex:"00000000",descriptor:{data:"00010101",signatures:{prod:"prodsig",test:"testsig"}},account_schema:{count_min:2,count_max:2,slots:[{signer:"REQUIRED",writable:"EITHER"}]}}]}]);const o=await r.getInstructionInfo({programId:t,network:a});(0,e.expect)(o.isRight()).toBe(!0);const{descriptors:s}=o.unsafeCoerce();(0,e.expect)(s["00000000"].unsafeCoerce()).toEqual(e.expect.objectContaining({accountSchema:{count_min:2,count_max:2,remaining_policy:{signer:"EITHER",writable:"EITHER"},slots:[{signer:"REQUIRED",writable:"EITHER"}]}}))}),(0,e.it)("returns Left when the HTTP client throws",async()=>{n.get.mockRejectedValue(new Error("network"));const o=await r.getInstructionInfo({programId:t,network:a});(0,e.expect)(o).toEqual((0,m.Left)(new Error("[ContextModule] HttpInstructionInfoDataSource: Failed to fetch instruction descriptors: network"))),(0,e.expect)(o.extract()).not.toBeInstanceOf(g.SolanaProgramNotFoundError)}),(0,e.describe)("signing_route",()=>{const o="Stake11111111111111111111111111111111111111",s={data:"00010101",signatures:{prod:"prodsig",test:"testsig"}},i=c=>[{id:o,chain_id:l.SolanaTransactionScanChainId.MAINNET,instructions:Object.entries(c).map(([f,p])=>({discriminator_hex:f,descriptor:s,...p===void 0?{}:{signing_route:p}}))}],d=()=>r.getInstructionInfo({programId:o,network:a});(0,e.it)("maps basic_flow tags to one entry per (discriminator, rule, role)",async()=>{n.get.mockResolvedValue(i({"00000000":{basic_flow:[{rule:"native-staking",role:"allowed"}]},"02000000":{basic_flow:[{rule:"native-staking",role:"required"},{rule:"other-rule",role:"allowed"}]}}));const c=await d();(0,e.expect)(c.unsafeCoerce().basicFlowTags).toEqual([{discriminator:"00000000",rule:"native-staking",role:"allowed"},{discriminator:"02000000",rule:"native-staking",role:"required"},{discriminator:"02000000",rule:"other-rule",role:"allowed"}])}),(0,e.it)("returns no tags when CAL doesn't serve signing_route (today's CAL)",async()=>{n.get.mockResolvedValue(i({"00000000":void 0,"02000000":void 0}));const c=await d();(0,e.expect)(c.unsafeCoerce().basicFlowTags).toEqual([])}),(0,e.it)("drops unknown roles, empty rule ids and unknown keys",async()=>{n.get.mockResolvedValue(i({"02000000":{basic_flow:[{rule:"native-staking",role:"forbidden"},{rule:"",role:"required"},{rule:"native-staking",role:"required",extra:1}],other_flow:[{rule:"x",role:"required"}]}}));const c=await d();(0,e.expect)(c.unsafeCoerce().basicFlowTags).toEqual([{discriminator:"02000000",rule:"native-staking",role:"required"}])}),e.it.each([["a string","native-staking"],["basic_flow not an array",{basic_flow:{rule:"a"}}],["an entry without role",{basic_flow:[{rule:"native-staking"}]}],["a non-string rule",{basic_flow:[{rule:1,role:"required"}]}]])("drops a malformed signing_route (%s) but keeps the descriptors",async(c,f)=>{n.get.mockResolvedValue(i({"00000000":{basic_flow:[{rule:"native-staking",role:"allowed"}]},"02000000":f}));const p=await d();(0,e.expect)(p.isRight()).toBe(!0);const{descriptors:I,basicFlowTags:k}=p.unsafeCoerce();(0,e.expect)(Object.keys(I)).toEqual(["00000000","02000000"]),(0,e.expect)(I["02000000"].isRight()).toBe(!0),(0,e.expect)(k).toEqual([{discriminator:"00000000",rule:"native-staking",role:"allowed"}])}),(0,e.it)("ignores tags on an instruction without discriminator_hex",async()=>{n.get.mockResolvedValue([{id:o,chain_id:l.SolanaTransactionScanChainId.MAINNET,instructions:[{descriptor:s,signing_route:{basic_flow:[{rule:"native-staking",role:"required"}]}}]}]);const c=await d();(0,e.expect)(c.unsafeCoerce().basicFlowTags).toEqual([])})}),(0,e.describe)("cache",()=>{(0,e.beforeEach)(()=>{e.vi.useFakeTimers()}),(0,e.afterEach)(()=>{e.vi.useRealTimers()}),(0,e.it)("serves a second call for the same program and network from the cache",async()=>{n.get.mockResolvedValue(u);const o=await r.getInstructionInfo({programId:t,network:a}),s=await r.getInstructionInfo({programId:t,network:a});(0,e.expect)(n.get).toHaveBeenCalledTimes(1),(0,e.expect)(s).toBe(o)}),(0,e.it)("shares one HTTP call between concurrent callers",async()=>{n.get.mockResolvedValue(u),await Promise.all([r.getInstructionInfo({programId:t,network:a}),r.getInstructionInfo({programId:t,network:a})]),(0,e.expect)(n.get).toHaveBeenCalledTimes(1)}),(0,e.it)("keys the cache by chain id",async()=>{n.get.mockResolvedValue(u),await r.getInstructionInfo({programId:t,network:a}),await r.getInstructionInfo({programId:t,network:"solana-devnet"}),await r.getInstructionInfo({programId:t,network:"unknown"}),(0,e.expect)(n.get).toHaveBeenCalledTimes(2)}),(0,e.it)("fetches again once the entry has expired",async()=>{n.get.mockResolvedValue(u),await r.getInstructionInfo({programId:t,network:a}),e.vi.advanceTimersByTime(30001),await r.getInstructionInfo({programId:t,network:a}),(0,e.expect)(n.get).toHaveBeenCalledTimes(2)}),(0,e.it)("evicts the oldest entry beyond the size cap",async()=>{n.get.mockImplementation((s,{params:i})=>Promise.resolve([{...u[0],id:i.id}]));const o=Array.from({length:65},(s,i)=>`program-${i}`);for(const s of o)await r.getInstructionInfo({programId:s,network:a});await r.getInstructionInfo({programId:o[64],network:a}),(0,e.expect)(n.get).toHaveBeenCalledTimes(65),await r.getInstructionInfo({programId:o[0],network:a}),(0,e.expect)(n.get).toHaveBeenCalledTimes(66)}),e.it.each([["the HTTP client throws",()=>Promise.reject(new Error("network"))],["the program is malformed",()=>Promise.resolve([{id:t,chain_id:900,instructions:[{}]}])]])("does not cache a failure (%s)",async(o,s)=>{n.get.mockImplementationOnce(s).mockResolvedValue(u);const i=await r.getInstructionInfo({programId:t,network:a}),d=await r.getInstructionInfo({programId:t,network:a});(0,e.expect)(i.isLeft()).toBe(!0),(0,e.expect)(d.isRight()).toBe(!0),(0,e.expect)(n.get).toHaveBeenCalledTimes(2)}),(0,e.it)("caches a program-not-found answer",async()=>{n.get.mockResolvedValue([]),await r.getInstructionInfo({programId:t,network:a});const o=await r.getInstructionInfo({programId:t,network:a});(0,e.expect)(o.extract()).toBeInstanceOf(g.SolanaProgramNotFoundError),(0,e.expect)(n.get).toHaveBeenCalledTimes(1)})})});
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\";\nimport { SolanaTransactionScanChainId } from \"@/modules/solana/model/SolanaTransactionScanChainId\";\n\nimport { HttpInstructionInfoDataSource } from \"./HttpInstructionInfoDataSource\";\nimport { type InstructionInfoDataSource } from \"./InstructionInfoDataSource\";\nimport { type CalInstructionInfoResponseDto } from \"./InstructionInfoDto\";\n\ndescribe(\"HttpInstructionInfoDataSource\", () => {\n let datasource: InstructionInfoDataSource;\n let httpMock: { get: ReturnType<typeof vi.fn> };\n const programId = \"11111111111111111111111111111111\";\n const network = \"solana-mainnet\";\n const config: ContextModuleServiceConfig = {\n cal: {\n url: \"https://global.api.prd.ledger.com/cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n } as ContextModuleServiceConfig;\n\n const successResponse: CalInstructionInfoResponseDto = [\n {\n id: programId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: [\n {\n discriminator_hex: \"00000000\",\n instruction_name: \"createAccount\",\n descriptor: {\n data: \"00010101\",\n signatures: { prod: \"prodsig\", test: \"testsig\" },\n },\n display_fields: [],\n value_flow_ports: [],\n hide_rules: [],\n account_resets: [],\n },\n ],\n },\n ];\n\n beforeEach(() => {\n vi.clearAllMocks();\n httpMock = { get: vi.fn() };\n datasource = new HttpInstructionInfoDataSource(\n config,\n httpMock as unknown as DmkNetworkClient,\n );\n });\n\n it(\"calls CAL /solana_programs with id, chain_id and output params\", async () => {\n httpMock.get.mockResolvedValue(successResponse);\n\n await datasource.getInstructionInfo({ programId, network });\n\n expect(httpMock.get).toHaveBeenCalledTimes(1);\n expect(httpMock.get).toHaveBeenCalledWith(\n \"https://global.api.prd.ledger.com/cal/v1/solana_programs\",\n {\n params: {\n id: programId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n output: \"id,chain_id,instructions\",\n ref: \"branch:main\",\n },\n },\n );\n });\n\n it(\"maps devnet/testnet networks to their numeric chain ids\", async () => {\n httpMock.get.mockResolvedValue(successResponse);\n\n await datasource.getInstructionInfo({\n programId,\n network: \"solana-devnet\",\n });\n\n expect(httpMock.get).toHaveBeenCalledWith(\n \"https://global.api.prd.ledger.com/cal/v1/solana_programs\",\n expect.objectContaining({\n params: expect.objectContaining({ chain_id: 901 }),\n }),\n );\n });\n\n it(\"returns Right with each descriptor transformed into the core payload on success\", async () => {\n httpMock.get.mockResolvedValue(successResponse);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result).toEqual(\n Right({\n programId,\n descriptors: {\n \"00000000\": Right({\n programId,\n discriminator: \"00000000\",\n instructionName: \"createAccount\",\n instructionInfo: { data: \"00010101\", signature: \"prodsig\" },\n substructures: [],\n enumVariants: [],\n idlDescriptor: { typePool: [], rootType: 0 },\n mintAssociations: [],\n ownerAssociations: [],\n valueFlowPorts: [],\n accountResets: [],\n displayFields: [],\n hideRules: [],\n }),\n },\n enumVariants: [],\n }),\n );\n });\n\n it(\"keys a descriptor without `discriminator_hex` under the empty string\", async () => {\n // Single-instruction programs (e.g. SPL Memo `addMemo`) genuinely have no\n // discriminator, so CAL omits the field.\n httpMock.get.mockResolvedValue([\n {\n id: programId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: [\n {\n instruction_name: \"addMemo\",\n descriptor: {\n data: \"00010101\",\n signatures: { prod: \"prodsig\", test: \"testsig\" },\n },\n },\n ],\n },\n ]);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result.isRight()).toBe(true);\n const { descriptors } = result.unsafeCoerce();\n expect(Object.keys(descriptors)).toEqual([\"\"]);\n expect(descriptors[\"\"]!.unsafeCoerce()).toEqual(\n expect.objectContaining({\n programId,\n discriminator: \"\",\n instructionInfo: { data: \"00010101\", signature: \"prodsig\" },\n }),\n );\n });\n\n it(\"returns Left when the response array is empty\", async () => {\n httpMock.get.mockResolvedValue([]);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result).toEqual(\n Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: empty response for program ${programId}`,\n ),\n ),\n );\n });\n\n it(\"returns Left when no program object matches the requested programId\", async () => {\n httpMock.get.mockResolvedValue([\n {\n id: \"OtherProgram\",\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: [],\n },\n ]);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result).toEqual(\n Left(\n new Error(\n `[ContextModule] HttpInstructionInfoDataSource: no descriptors for program ${programId}`,\n ),\n ),\n );\n });\n\n it(\"returns Left (not a throw) when an instruction descriptor is malformed\", async () => {\n // `descriptor` missing on the instruction \u2014 would crash the loader if the\n // datasource handed it through unvalidated.\n httpMock.get.mockResolvedValue([\n {\n id: programId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: [{ discriminator_hex: \"00000000\" }],\n },\n ]);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result.isLeft()).toBe(true);\n expect((result.extract() as Error).message).toMatch(\n new RegExp(\n String.raw`\\[ContextModule\\] HttpInstructionInfoDataSource: malformed descriptors for program ${programId}:`,\n ),\n );\n });\n\n it(\"returns Left (not a throw) when account_schema.slots is not an array\", async () => {\n // Regression: account_schema was not codec-validated, so a malformed\n // shape (e.g. `slots` as an object instead of an array) bypassed\n // validation here and crashed later in the mapper's `.map()` call instead\n // of degrading gracefully to a per-program error.\n httpMock.get.mockResolvedValue([\n {\n id: programId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: [\n {\n discriminator_hex: \"00000000\",\n descriptor: {\n data: \"00010101\",\n signatures: { prod: \"prodsig\", test: \"testsig\" },\n },\n account_schema: { slots: {} },\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 Right with accountSchema mapped through when it is well-formed\", async () => {\n httpMock.get.mockResolvedValue([\n {\n id: programId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: [\n {\n discriminator_hex: \"00000000\",\n descriptor: {\n data: \"00010101\",\n signatures: { prod: \"prodsig\", test: \"testsig\" },\n },\n account_schema: {\n count_min: 2,\n count_max: 2,\n slots: [{ signer: \"REQUIRED\", writable: \"EITHER\" }],\n },\n },\n ],\n },\n ]);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result.isRight()).toBe(true);\n const { descriptors } = result.unsafeCoerce();\n expect(descriptors[\"00000000\"]!.unsafeCoerce()).toEqual(\n expect.objectContaining({\n accountSchema: {\n count_min: 2,\n count_max: 2,\n remaining_policy: { signer: \"EITHER\", writable: \"EITHER\" },\n slots: [{ signer: \"REQUIRED\", writable: \"EITHER\" }],\n },\n }),\n );\n });\n\n it(\"returns Left when the HTTP client throws\", async () => {\n httpMock.get.mockRejectedValue(new Error(\"network\"));\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpInstructionInfoDataSource: Failed to fetch instruction descriptors: network\",\n ),\n ),\n );\n });\n});\n"],
5
- "mappings": "aACA,IAAAA,EAA4B,qBAC5BC,EAAqD,kBAGrDC,EAA6C,+DAE7CC,EAA8C,8CAI9C,YAAS,gCAAiC,IAAM,CAC9C,IAAIC,EACAC,EACJ,MAAMC,EAAY,mCACZC,EAAU,iBACVC,EAAqC,CACzC,IAAK,CACH,IAAK,2CACL,KAAM,OACN,OAAQ,MACV,CACF,EAEMC,EAAiD,CACrD,CACE,GAAIH,EACJ,SAAU,+BAA6B,QACvC,aAAc,CACZ,CACE,kBAAmB,WACnB,iBAAkB,gBAClB,WAAY,CACV,KAAM,WACN,WAAY,CAAE,KAAM,UAAW,KAAM,SAAU,CACjD,EACA,eAAgB,CAAC,EACjB,iBAAkB,CAAC,EACnB,WAAY,CAAC,EACb,eAAgB,CAAC,CACnB,CACF,CACF,CACF,KAEA,cAAW,IAAM,CACf,KAAG,cAAc,EACjBD,EAAW,CAAE,IAAK,KAAG,GAAG,CAAE,EAC1BD,EAAa,IAAI,gCACfI,EACAH,CACF,CACF,CAAC,KAED,MAAG,iEAAkE,SAAY,CAC/EA,EAAS,IAAI,kBAAkBI,CAAe,EAE9C,MAAML,EAAW,mBAAmB,CAAE,UAAAE,EAAW,QAAAC,CAAQ,CAAC,KAE1D,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,SAAU,QAAS,EACzD,MAAO,CAAC,CAAE,OAAQ,WAAY,SAAU,QAAS,CAAC,CACpD,CACF,CAAC,CACH,CACF,CAAC,KAED,MAAG,2CAA4C,SAAY,CACzDN,EAAS,IAAI,kBAAkB,IAAI,MAAM,SAAS,CAAC,EAEnD,MAAMK,EAAS,MAAMN,EAAW,mBAAmB,CAAE,UAAAE,EAAW,QAAAC,CAAQ,CAAC,KAEzE,UAAOG,CAAM,EAAE,WACb,QACE,IAAI,MACF,iGACF,CACF,CACF,CACF,CAAC,CACH,CAAC",
6
- "names": ["import_purify_ts", "import_vitest", "import_SolanaTransactionScanChainId", "import_HttpInstructionInfoDataSource", "datasource", "httpMock", "programId", "network", "config", "successResponse", "result", "descriptors"]
4
+ "sourcesContent": ["import { type DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\nimport { afterEach, 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 {\n type InstructionInfoDataSource,\n SolanaProgramNotFoundError,\n} from \"./InstructionInfoDataSource\";\nimport { type CalInstructionInfoResponseDto } from \"./InstructionInfoDto\";\n\ndescribe(\"HttpInstructionInfoDataSource\", () => {\n let datasource: InstructionInfoDataSource;\n let httpMock: { get: ReturnType<typeof vi.fn> };\n const programId = \"11111111111111111111111111111111\";\n const network = \"solana-mainnet\";\n const config: ContextModuleServiceConfig = {\n cal: {\n url: \"https://global.api.prd.ledger.com/cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n } as ContextModuleServiceConfig;\n\n const successResponse: CalInstructionInfoResponseDto = [\n {\n id: programId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: [\n {\n discriminator_hex: \"00000000\",\n instruction_name: \"createAccount\",\n descriptor: {\n data: \"00010101\",\n signatures: { prod: \"prodsig\", test: \"testsig\" },\n },\n display_fields: [],\n value_flow_ports: [],\n hide_rules: [],\n account_resets: [],\n },\n ],\n },\n ];\n\n beforeEach(() => {\n vi.clearAllMocks();\n httpMock = { get: vi.fn() };\n datasource = new HttpInstructionInfoDataSource(\n config,\n httpMock as unknown as DmkNetworkClient,\n );\n });\n\n it(\"calls CAL /solana_programs with id, chain_id and output params\", async () => {\n httpMock.get.mockResolvedValue(successResponse);\n\n await datasource.getInstructionInfo({ programId, network });\n\n expect(httpMock.get).toHaveBeenCalledTimes(1);\n expect(httpMock.get).toHaveBeenCalledWith(\n \"https://global.api.prd.ledger.com/cal/v1/solana_programs\",\n {\n params: {\n id: programId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n output: \"id,chain_id,instructions\",\n ref: \"branch:main\",\n },\n },\n );\n });\n\n it(\"maps devnet/testnet networks to their numeric chain ids\", async () => {\n httpMock.get.mockResolvedValue(successResponse);\n\n await datasource.getInstructionInfo({\n programId,\n network: \"solana-devnet\",\n });\n\n expect(httpMock.get).toHaveBeenCalledWith(\n \"https://global.api.prd.ledger.com/cal/v1/solana_programs\",\n expect.objectContaining({\n params: expect.objectContaining({ chain_id: 901 }),\n }),\n );\n });\n\n it(\"returns Right with each descriptor transformed into the core payload on success\", async () => {\n httpMock.get.mockResolvedValue(successResponse);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result).toEqual(\n Right({\n programId,\n descriptors: {\n \"00000000\": Right({\n programId,\n discriminator: \"00000000\",\n instructionName: \"createAccount\",\n instructionInfo: { data: \"00010101\", signature: \"prodsig\" },\n substructures: [],\n enumVariants: [],\n idlDescriptor: { typePool: [], rootType: 0 },\n mintAssociations: [],\n ownerAssociations: [],\n valueFlowPorts: [],\n accountResets: [],\n displayFields: [],\n hideRules: [],\n }),\n },\n enumVariants: [],\n basicFlowTags: [],\n }),\n );\n });\n\n it(\"keys a descriptor without `discriminator_hex` under the empty string\", async () => {\n // Single-instruction programs (e.g. SPL Memo `addMemo`) genuinely have no\n // discriminator, so CAL omits the field.\n httpMock.get.mockResolvedValue([\n {\n id: programId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: [\n {\n instruction_name: \"addMemo\",\n descriptor: {\n data: \"00010101\",\n signatures: { prod: \"prodsig\", test: \"testsig\" },\n },\n },\n ],\n },\n ]);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result.isRight()).toBe(true);\n const { descriptors } = result.unsafeCoerce();\n expect(Object.keys(descriptors)).toEqual([\"\"]);\n expect(descriptors[\"\"]!.unsafeCoerce()).toEqual(\n expect.objectContaining({\n programId,\n discriminator: \"\",\n instructionInfo: { data: \"00010101\", signature: \"prodsig\" },\n }),\n );\n });\n\n it(\"returns a SolanaProgramNotFoundError 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 SolanaProgramNotFoundError(\n programId,\n `[ContextModule] HttpInstructionInfoDataSource: empty response for program ${programId}`,\n ),\n ),\n );\n expect(result.extract()).toBeInstanceOf(SolanaProgramNotFoundError);\n });\n\n it(\"returns a plain Error, not a not-found, when the response is not an array\", async () => {\n httpMock.get.mockResolvedValue({ unexpected: true });\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result.isLeft()).toBe(true);\n expect(result.extract()).not.toBeInstanceOf(SolanaProgramNotFoundError);\n expect((result.extract() as Error).message).toBe(\n `[ContextModule] HttpInstructionInfoDataSource: unexpected response for program ${programId}`,\n );\n });\n\n it(\"returns a SolanaProgramNotFoundError 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 SolanaProgramNotFoundError(\n programId,\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 (not a throw) when account_schema.slots is not an array\", async () => {\n // Regression: account_schema was not codec-validated, so a malformed\n // shape (e.g. `slots` as an object instead of an array) bypassed\n // validation here and crashed later in the mapper's `.map()` call instead\n // of degrading gracefully to a per-program error.\n httpMock.get.mockResolvedValue([\n {\n id: programId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: [\n {\n discriminator_hex: \"00000000\",\n descriptor: {\n data: \"00010101\",\n signatures: { prod: \"prodsig\", test: \"testsig\" },\n },\n account_schema: { slots: {} },\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 Right with accountSchema mapped through when it is well-formed\", async () => {\n httpMock.get.mockResolvedValue([\n {\n id: programId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: [\n {\n discriminator_hex: \"00000000\",\n descriptor: {\n data: \"00010101\",\n signatures: { prod: \"prodsig\", test: \"testsig\" },\n },\n account_schema: {\n count_min: 2,\n count_max: 2,\n slots: [{ signer: \"REQUIRED\", writable: \"EITHER\" }],\n },\n },\n ],\n },\n ]);\n\n const result = await datasource.getInstructionInfo({ programId, network });\n\n expect(result.isRight()).toBe(true);\n const { descriptors } = result.unsafeCoerce();\n expect(descriptors[\"00000000\"]!.unsafeCoerce()).toEqual(\n expect.objectContaining({\n accountSchema: {\n count_min: 2,\n count_max: 2,\n remaining_policy: { signer: \"EITHER\", writable: \"EITHER\" },\n slots: [{ signer: \"REQUIRED\", writable: \"EITHER\" }],\n },\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 expect(result.extract()).not.toBeInstanceOf(SolanaProgramNotFoundError);\n });\n\n describe(\"signing_route\", () => {\n const stakeProgramId = \"Stake11111111111111111111111111111111111111\";\n const signedDescriptor = {\n data: \"00010101\",\n signatures: { prod: \"prodsig\", test: \"testsig\" },\n };\n\n // Agreed CAL contract: `signing_route` sits on each instruction object,\n // outside the signed `descriptor`.\n const stakeResponse = (\n signingRoutes: Record<string, unknown>,\n ): CalInstructionInfoResponseDto =>\n [\n {\n id: stakeProgramId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: Object.entries(signingRoutes).map(\n ([discriminator_hex, signing_route]) => ({\n discriminator_hex,\n descriptor: signedDescriptor,\n ...(signing_route === undefined ? {} : { signing_route }),\n }),\n ),\n },\n ] as CalInstructionInfoResponseDto;\n\n const getStakeInfo = () =>\n datasource.getInstructionInfo({ programId: stakeProgramId, network });\n\n it(\"maps basic_flow tags to one entry per (discriminator, rule, role)\", async () => {\n httpMock.get.mockResolvedValue(\n stakeResponse({\n \"00000000\": {\n basic_flow: [{ rule: \"native-staking\", role: \"allowed\" }],\n },\n \"02000000\": {\n basic_flow: [\n { rule: \"native-staking\", role: \"required\" },\n { rule: \"other-rule\", role: \"allowed\" },\n ],\n },\n }),\n );\n\n const result = await getStakeInfo();\n\n expect(result.unsafeCoerce().basicFlowTags).toEqual([\n { discriminator: \"00000000\", rule: \"native-staking\", role: \"allowed\" },\n {\n discriminator: \"02000000\",\n rule: \"native-staking\",\n role: \"required\",\n },\n { discriminator: \"02000000\", rule: \"other-rule\", role: \"allowed\" },\n ]);\n });\n\n it(\"returns no tags when CAL doesn't serve signing_route (today's CAL)\", async () => {\n httpMock.get.mockResolvedValue(\n stakeResponse({ \"00000000\": undefined, \"02000000\": undefined }),\n );\n\n const result = await getStakeInfo();\n\n expect(result.unsafeCoerce().basicFlowTags).toEqual([]);\n });\n\n it(\"drops unknown roles, empty rule ids and unknown keys\", async () => {\n httpMock.get.mockResolvedValue(\n stakeResponse({\n \"02000000\": {\n basic_flow: [\n { rule: \"native-staking\", role: \"forbidden\" },\n { rule: \"\", role: \"required\" },\n { rule: \"native-staking\", role: \"required\", extra: 1 },\n ],\n other_flow: [{ rule: \"x\", role: \"required\" }],\n },\n }),\n );\n\n const result = await getStakeInfo();\n\n expect(result.unsafeCoerce().basicFlowTags).toEqual([\n {\n discriminator: \"02000000\",\n rule: \"native-staking\",\n role: \"required\",\n },\n ]);\n });\n\n it.each([\n [\"a string\", \"native-staking\"],\n [\"basic_flow not an array\", { basic_flow: { rule: \"a\" } }],\n [\"an entry without role\", { basic_flow: [{ rule: \"native-staking\" }] }],\n [\"a non-string rule\", { basic_flow: [{ rule: 1, role: \"required\" }] }],\n ])(\n \"drops a malformed signing_route (%s) but keeps the descriptors\",\n async (_, signingRoute) => {\n httpMock.get.mockResolvedValue(\n stakeResponse({\n \"00000000\": {\n basic_flow: [{ rule: \"native-staking\", role: \"allowed\" }],\n },\n \"02000000\": signingRoute,\n }),\n );\n\n const result = await getStakeInfo();\n\n expect(result.isRight()).toBe(true);\n const { descriptors, basicFlowTags } = result.unsafeCoerce();\n expect(Object.keys(descriptors)).toEqual([\"00000000\", \"02000000\"]);\n expect(descriptors[\"02000000\"]!.isRight()).toBe(true);\n expect(basicFlowTags).toEqual([\n {\n discriminator: \"00000000\",\n rule: \"native-staking\",\n role: \"allowed\",\n },\n ]);\n },\n );\n\n it(\"ignores tags on an instruction without discriminator_hex\", async () => {\n httpMock.get.mockResolvedValue([\n {\n id: stakeProgramId,\n chain_id: SolanaTransactionScanChainId.MAINNET,\n instructions: [\n {\n descriptor: signedDescriptor,\n signing_route: {\n basic_flow: [{ rule: \"native-staking\", role: \"required\" }],\n },\n },\n ],\n },\n ]);\n\n const result = await getStakeInfo();\n\n expect(result.unsafeCoerce().basicFlowTags).toEqual([]);\n });\n });\n\n describe(\"cache\", () => {\n beforeEach(() => {\n vi.useFakeTimers();\n });\n\n afterEach(() => {\n vi.useRealTimers();\n });\n\n it(\"serves a second call for the same program and network from the cache\", async () => {\n httpMock.get.mockResolvedValue(successResponse);\n\n const first = await datasource.getInstructionInfo({ programId, network });\n const second = await datasource.getInstructionInfo({\n programId,\n network,\n });\n\n expect(httpMock.get).toHaveBeenCalledTimes(1);\n expect(second).toBe(first);\n });\n\n it(\"shares one HTTP call between concurrent callers\", async () => {\n httpMock.get.mockResolvedValue(successResponse);\n\n await Promise.all([\n datasource.getInstructionInfo({ programId, network }),\n datasource.getInstructionInfo({ programId, network }),\n ]);\n\n expect(httpMock.get).toHaveBeenCalledTimes(1);\n });\n\n it(\"keys the cache by chain id\", async () => {\n httpMock.get.mockResolvedValue(successResponse);\n\n await datasource.getInstructionInfo({ programId, network });\n await datasource.getInstructionInfo({\n programId,\n network: \"solana-devnet\",\n });\n // Unknown labels fall back to mainnet, so they share its entry.\n await datasource.getInstructionInfo({ programId, network: \"unknown\" });\n\n expect(httpMock.get).toHaveBeenCalledTimes(2);\n });\n\n it(\"fetches again once the entry has expired\", async () => {\n httpMock.get.mockResolvedValue(successResponse);\n\n await datasource.getInstructionInfo({ programId, network });\n vi.advanceTimersByTime(30_001);\n await datasource.getInstructionInfo({ programId, network });\n\n expect(httpMock.get).toHaveBeenCalledTimes(2);\n });\n\n it(\"evicts the oldest entry beyond the size cap\", async () => {\n httpMock.get.mockImplementation(\n (_url: string, { params }: { params: { id: string } }) =>\n Promise.resolve([\n { ...successResponse[0]!, id: params.id },\n ] as CalInstructionInfoResponseDto),\n );\n const ids = Array.from({ length: 65 }, (_, i) => `program-${i}`);\n\n for (const id of ids) {\n await datasource.getInstructionInfo({ programId: id, network });\n }\n // The most recent entry is still cached, the oldest was evicted.\n await datasource.getInstructionInfo({ programId: ids[64]!, network });\n expect(httpMock.get).toHaveBeenCalledTimes(65);\n await datasource.getInstructionInfo({ programId: ids[0]!, network });\n expect(httpMock.get).toHaveBeenCalledTimes(66);\n });\n\n it.each([\n [\"the HTTP client throws\", () => Promise.reject(new Error(\"network\"))],\n [\n \"the program is malformed\",\n () =>\n Promise.resolve([\n { id: programId, chain_id: 900, instructions: [{}] },\n ]),\n ],\n ])(\"does not cache a failure (%s)\", async (_, failingGet) => {\n httpMock.get\n .mockImplementationOnce(failingGet)\n .mockResolvedValue(successResponse);\n\n const first = await datasource.getInstructionInfo({ programId, network });\n const second = await datasource.getInstructionInfo({\n programId,\n network,\n });\n\n expect(first.isLeft()).toBe(true);\n expect(second.isRight()).toBe(true);\n expect(httpMock.get).toHaveBeenCalledTimes(2);\n });\n\n it(\"caches a program-not-found answer\", async () => {\n httpMock.get.mockResolvedValue([]);\n\n await datasource.getInstructionInfo({ programId, network });\n const second = await datasource.getInstructionInfo({\n programId,\n network,\n });\n\n expect(second.extract()).toBeInstanceOf(SolanaProgramNotFoundError);\n expect(httpMock.get).toHaveBeenCalledTimes(1);\n });\n });\n});\n"],
5
+ "mappings": "aACA,IAAAA,EAA4B,qBAC5BC,EAAgE,kBAGhEC,EAA6C,+DAE7CC,EAA8C,2CAC9CC,EAGO,0CAGP,YAAS,gCAAiC,IAAM,CAC9C,IAAIC,EACAC,EACJ,MAAMC,EAAY,mCACZC,EAAU,iBACVC,EAAqC,CACzC,IAAK,CACH,IAAK,2CACL,KAAM,OACN,OAAQ,MACV,CACF,EAEMC,EAAiD,CACrD,C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ACE,QAAQ,QAAQ,CACd,CAAE,GAAIC,EAAW,SAAU,IAAK,aAAc,CAAC,CAAC,CAAC,CAAE,CACrD,CAAC,CACL,CACF,CAAC,EAAE,gCAAiC,MAAOa,EAAGS,IAAe,CAC3DvB,EAAS,IACN,uBAAuBuB,CAAU,EACjC,kBAAkBnB,CAAe,EAEpC,MAAMa,EAAQ,MAAMlB,EAAW,mBAAmB,CAAE,UAAAE,EAAW,QAAAC,CAAQ,CAAC,EAClEgB,EAAS,MAAMnB,EAAW,mBAAmB,CACjD,UAAAE,EACA,QAAAC,CACF,CAAC,KAED,UAAOe,EAAM,OAAO,CAAC,EAAE,KAAK,EAAI,KAChC,UAAOC,EAAO,QAAQ,CAAC,EAAE,KAAK,EAAI,KAClC,UAAOlB,EAAS,GAAG,EAAE,sBAAsB,CAAC,CAC9C,CAAC,KAED,MAAG,oCAAqC,SAAY,CAClDA,EAAS,IAAI,kBAAkB,CAAC,CAAC,EAEjC,MAAMD,EAAW,mBAAmB,CAAE,UAAAE,EAAW,QAAAC,CAAQ,CAAC,EAC1D,MAAMgB,EAAS,MAAMnB,EAAW,mBAAmB,CACjD,UAAAE,EACA,QAAAC,CACF,CAAC,KAED,UAAOgB,EAAO,QAAQ,CAAC,EAAE,eAAe,4BAA0B,KAClE,UAAOlB,EAAS,GAAG,EAAE,sBAAsB,CAAC,CAC9C,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_purify_ts", "import_vitest", "import_SolanaTransactionScanChainId", "import_HttpInstructionInfoDataSource", "import_InstructionInfoDataSource", "datasource", "httpMock", "programId", "network", "config", "successResponse", "result", "descriptors", "stakeProgramId", "signedDescriptor", "stakeResponse", "signingRoutes", "discriminator_hex", "signing_route", "getStakeInfo", "_", "signingRoute", "basicFlowTags", "first", "second", "_url", "params", "ids", "id", "failingGet"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var a=Object.defineProperty;var e=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var u=(r,t,i,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of s(t))!I.call(r,n)&&n!==i&&a(r,n,{get:()=>t[n],enumerable:!(o=e(t,n))||o.enumerable});return r};var c=r=>u(a({},"__esModule",{value:!0}),r);var p={};module.exports=c(p);
1
+ "use strict";var a=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var e=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var I=(o,r)=>{for(var t in r)a(o,t,{get:r[t],enumerable:!0})},c=(o,r,t,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of e(r))!u.call(o,n)&&n!==t&&a(o,n,{get:()=>r[n],enumerable:!(s=i(r,n))||s.enumerable});return o};var l=o=>c(a({},"__esModule",{value:!0}),o);var g={};I(g,{SolanaProgramNotFoundError:()=>p});module.exports=l(g);class p extends Error{programId;constructor(r,t){super(t),this.name="SolanaProgramNotFoundError",this.programId=r}}0&&(module.exports={SolanaProgramNotFoundError});
2
2
  //# sourceMappingURL=InstructionInfoDataSource.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/modules/solana/instruction-info/data/InstructionInfoDataSource.ts"],
4
- "sourcesContent": ["import { type Either } from \"purify-ts\";\n\nimport {\n type SolanaInstructionEnumVariant,\n type SolanaInstructionInfoPayload,\n} from \"@/modules/solana/model/SolanaPayloads\";\n\nexport type GetInstructionInfoParams = {\n programId: string;\n network: string;\n};\n\n/**\n * Result of one CAL call for a single `programId`, fully transformed into core\n * models so consumers never see the CAL DTO shapes.\n *\n * - `descriptors` is indexed by discriminator hex (multiple entries when a\n * program defines several instructions). Each is the decoded\n * {@link SolanaInstructionInfoPayload}, or a `Left` when that descriptor could\n * not be decoded (e.g. no signature for the configured CAL mode) so the\n * consumer can surface a per-descriptor error.\n * - `enumVariants` is the program-wide flat list of decoded enum variants,\n * resolved independently of per-descriptor signature validity.\n */\nexport type InstructionInfoResult = {\n programId: string;\n descriptors: Record<string, Either<Error, SolanaInstructionInfoPayload>>;\n enumVariants: SolanaInstructionEnumVariant[];\n};\n\nexport interface InstructionInfoDataSource {\n /**\n * Fetch all instruction descriptors for one Solana program from CAL.\n * One HTTP call per `programId`; consumers fan out across multiple\n * `programId`s in parallel.\n */\n getInstructionInfo(\n params: GetInstructionInfoParams,\n ): Promise<Either<Error, InstructionInfoResult>>;\n}\n"],
5
- "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
- "names": ["InstructionInfoDataSource_exports", "__toCommonJS"]
4
+ "sourcesContent": ["import { type Either } from \"purify-ts\";\n\nimport {\n type SolanaInstructionEnumVariant,\n type SolanaInstructionInfoPayload,\n} from \"@/modules/solana/model/SolanaPayloads\";\n\nexport type GetInstructionInfoParams = {\n programId: string;\n network: string;\n};\n\n/**\n * Result of one CAL call for a single `programId`, fully transformed into core\n * models so consumers never see the CAL DTO shapes.\n *\n * - `descriptors` is indexed by discriminator hex (multiple entries when a\n * program defines several instructions). Each is the decoded\n * {@link SolanaInstructionInfoPayload}, or a `Left` when that descriptor could\n * not be decoded (e.g. no signature for the configured CAL mode) so the\n * consumer can surface a per-descriptor error.\n * - `enumVariants` is the program-wide flat list of decoded enum variants,\n * resolved independently of per-descriptor signature validity.\n * - `basicFlowTags` lists the instructions' `signing_route.basic_flow`\n * tags, one entry per (discriminator, rule, role).\n */\nexport type InstructionInfoResult = {\n programId: string;\n descriptors: Record<string, Either<Error, SolanaInstructionInfoPayload>>;\n enumVariants: SolanaInstructionEnumVariant[];\n basicFlowTags: SolanaBasicFlowTag[];\n};\n\n/**\n * Tags one instruction (by discriminator hex) as part of a basic-flow rule.\n * Only instructions with a discriminator carry tags.\n */\nexport type SolanaBasicFlowTag = {\n discriminator: string;\n rule: string;\n role: \"required\" | \"allowed\";\n};\n\n/**\n * Returned when CAL answers but has no entry for the program, as opposed to a\n * transport, HTTP or validation failure.\n */\nexport class SolanaProgramNotFoundError extends Error {\n readonly programId: string;\n\n constructor(programId: string, message: string) {\n super(message);\n this.name = \"SolanaProgramNotFoundError\";\n this.programId = programId;\n }\n}\n\nexport interface InstructionInfoDataSource {\n /**\n * Fetch all instruction descriptors for one Solana program from CAL.\n * One HTTP call per `programId`; consumers fan out across multiple\n * `programId`s in parallel.\n */\n getInstructionInfo(\n params: GetInstructionInfoParams,\n ): Promise<Either<Error, InstructionInfoResult>>;\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gCAAAE,IAAA,eAAAC,EAAAH,GA+CO,MAAME,UAAmC,KAAM,CAC3C,UAET,YAAYE,EAAmBC,EAAiB,CAC9C,MAAMA,CAAO,EACb,KAAK,KAAO,6BACZ,KAAK,UAAYD,CACnB,CACF",
6
+ "names": ["InstructionInfoDataSource_exports", "__export", "SolanaProgramNotFoundError", "__toCommonJS", "programId", "message"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var i=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var C=(n,e)=>{for(var r in e)i(n,r,{get:e[r],enumerable:!0})},_=(n,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of p(e))!d.call(n,o)&&o!==r&&i(n,o,{get:()=>e[o],enumerable:!(s=u(e,o))||s.enumerable});return n};var D=n=>_(i({},"__esModule",{value:!0}),n);var S={};C(S,{calInstructionProgramCodec:()=>x});module.exports=D(S);var t=require("purify-ts");const g=t.Codec.interface({prod:(0,t.optional)(t.string),test:(0,t.optional)(t.string)}),l=t.Codec.interface({data:t.string,signatures:g}),m=t.Codec.interface({descriptor:l}),a=t.Codec.interface({descriptor:t.string}),c=t.Codec.interface({signer:t.string,writable:t.string}),y=t.Codec.interface({count_min:(0,t.optional)(t.number),count_max:(0,t.optional)(t.number),remaining_policy:(0,t.optional)(c),slots:(0,t.optional)((0,t.array)(c))}),b=t.Codec.interface({discriminator_hex:(0,t.optional)(t.string),descriptor:l,enum_variants:(0,t.optional)((0,t.record)(t.string,(0,t.record)(t.string,m))),display_fields:(0,t.optional)((0,t.array)(a)),value_flow_ports:(0,t.optional)((0,t.array)(a)),hide_rules:(0,t.optional)((0,t.array)(a)),account_resets:(0,t.optional)((0,t.array)(a)),account_schema:(0,t.optional)(y)}),x=t.Codec.interface({id:t.string,chain_id:t.number,instructions:(0,t.array)(b)});0&&(module.exports={calInstructionProgramCodec});
1
+ "use strict";var a=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var g=(n,e)=>{for(var r in e)a(n,r,{get:e[r],enumerable:!0})},C=(n,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of p(e))!d.call(n,o)&&o!==r&&a(n,o,{get:()=>e[o],enumerable:!(s=u(e,o))||s.enumerable});return n};var _=n=>C(a({},"__esModule",{value:!0}),n);var f={};g(f,{calInstructionProgramCodec:()=>S,calSigningRouteCodec:()=>x});module.exports=_(f);var t=require("purify-ts");const D=t.Codec.interface({prod:(0,t.optional)(t.string),test:(0,t.optional)(t.string)}),l=t.Codec.interface({data:t.string,signatures:D}),m=t.Codec.interface({descriptor:l}),i=t.Codec.interface({descriptor:t.string}),c=t.Codec.interface({signer:t.string,writable:t.string}),y=t.Codec.interface({count_min:(0,t.optional)(t.number),count_max:(0,t.optional)(t.number),remaining_policy:(0,t.optional)(c),slots:(0,t.optional)((0,t.array)(c))}),b=t.Codec.interface({discriminator_hex:(0,t.optional)(t.string),descriptor:l,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)),account_schema:(0,t.optional)(y)}),x=t.Codec.interface({basic_flow:(0,t.optional)((0,t.array)(t.Codec.interface({rule:t.string,role:t.string})))}),S=t.Codec.interface({id:t.string,chain_id:t.number,instructions:(0,t.array)(b)});0&&(module.exports={calInstructionProgramCodec,calSigningRouteCodec});
2
2
  //# sourceMappingURL=InstructionInfoDto.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/modules/solana/instruction-info/data/InstructionInfoDto.ts"],
4
- "sourcesContent": ["// DTO + codecs for the CAL instruction-descriptors response (one object per\n// `programId`, wrapped in a JSON array).\n//\n// The hand-written types describe the consumed shape (with genuinely optional\n// `?:` fields); the codecs below validate that shape at runtime so\n// `HttpInstructionInfoDataSource` can hand the loaders a payload they can\n// dereference without runtime-throwing on a malformed descriptor.\n\nimport { array, Codec, number, optional, record, string } from \"purify-ts\";\n\nexport type CalSignatures = {\n prod?: string;\n test?: string;\n};\n\nexport type CalSignedDescriptorDto = {\n data: string;\n signatures: CalSignatures;\n};\n\n// Decoded CAL JSON shapes (snake_case mirrors the CAL response) that drive\n// host-side requirement building.\n\nexport type CalValueDto = {\n source: string;\n account_index?: number;\n data?: string;\n path?: { steps: number[] };\n};\n\nexport type CalTokenValueDto = {\n kind: string;\n value?: CalValueDto;\n account_index?: number;\n /** `RESOLVE` only: account index whose address is the mint of last resort. */\n fallback_account?: number;\n};\n\nexport type CalMintAssociationDto = {\n account_index: number;\n mint_index: number;\n};\n\n// Neither half is codec-validated, and the spec requires both or neither, so\n// both are optional here and the mapper drops a half-declared pair.\nexport type CalOwnerAssociationDto = {\n account_index?: number;\n owner?: CalValueDto;\n};\n\n/** One `ACTIVE_WHEN` predicate: a bare name, or `MINT_PREDICATE` + its mint. */\nexport type CalActiveWhenPredicateDto =\n | string\n | { kind: string; mint?: string };\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 active_when?: CalActiveWhenPredicateDto[];\n};\n\nexport type CalHideRuleDto = CalSubstructureDto & {\n rule_set_index?: number;\n target?: CalValueDto;\n condition?: string;\n};\n\nexport type CalAccountResetDto = CalSubstructureDto & {\n account_index?: number;\n require_pre_balance_zero?: boolean;\n value_kind?: string;\n token?: CalTokenValueDto;\n require_native_pre_balance_zero?: boolean;\n};\n\nexport type CalSlotConstraintDto = {\n signer: string;\n writable: string;\n};\n\nexport type CalAccountSchemaDto = {\n count_min?: number;\n count_max?: number;\n remaining_policy?: CalSlotConstraintDto;\n slots?: CalSlotConstraintDto[];\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?: CalOwnerAssociationDto;\n enum_variants?: Record<string, Record<string, CalEnumVariantDto>>;\n display_fields?: CalDisplayFieldDto[];\n value_flow_ports?: CalValueFlowPortDto[];\n hide_rules?: CalHideRuleDto[];\n account_resets?: CalAccountResetDto[];\n /** Absent means \"no ACCOUNT_SCHEMA check\". */\n account_schema?: CalAccountSchemaDto;\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 calSlotConstraintCodec = Codec.interface({\n signer: string,\n writable: string,\n});\n\nconst calAccountSchemaCodec = Codec.interface({\n count_min: optional(number),\n count_max: optional(number),\n remaining_policy: optional(calSlotConstraintCodec),\n slots: optional(array(calSlotConstraintCodec)),\n});\n\nconst calInstructionDescriptorCodec = Codec.interface({\n discriminator_hex: optional(string),\n descriptor: calSignedDescriptorCodec,\n enum_variants: optional(record(string, record(string, calEnumVariantCodec))),\n display_fields: optional(array(calSubstructureCodec)),\n value_flow_ports: optional(array(calSubstructureCodec)),\n hide_rules: optional(array(calSubstructureCodec)),\n account_resets: optional(array(calSubstructureCodec)),\n account_schema: optional(calAccountSchemaCodec),\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,qBAgJ/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,EAAyB,QAAM,UAAU,CAC7C,OAAQ,SACR,SAAU,QACZ,CAAC,EAEKC,EAAwB,QAAM,UAAU,CAC5C,aAAW,YAAS,QAAM,EAC1B,aAAW,YAAS,QAAM,EAC1B,oBAAkB,YAASD,CAAsB,EACjD,SAAO,eAAS,SAAMA,CAAsB,CAAC,CAC/C,CAAC,EAEKE,EAAgC,QAAM,UAAU,CACpD,qBAAmB,YAAS,QAAM,EAClC,WAAYL,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,EACpD,kBAAgB,YAASE,CAAqB,CAChD,CAAC,EAQYR,EAA6B,QAAM,UAAU,CACxD,GAAI,SACJ,SAAU,SACV,gBAAc,SAAMS,CAA6B,CACnD,CAAC",
6
- "names": ["InstructionInfoDto_exports", "__export", "calInstructionProgramCodec", "__toCommonJS", "import_purify_ts", "calSignaturesCodec", "calSignedDescriptorCodec", "calEnumVariantCodec", "calSubstructureCodec", "calSlotConstraintCodec", "calAccountSchemaCodec", "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 /** `RESOLVE` only: account index whose address is the mint of last resort. */\n fallback_account?: number;\n};\n\nexport type CalMintAssociationDto = {\n account_index: number;\n mint_index: number;\n};\n\n// Neither half is codec-validated, and the spec requires both or neither, so\n// both are optional here and the mapper drops a half-declared pair.\nexport type CalOwnerAssociationDto = {\n account_index?: number;\n owner?: CalValueDto;\n};\n\n/** One `ACTIVE_WHEN` predicate: a bare name, or `MINT_PREDICATE` + its mint. */\nexport type CalActiveWhenPredicateDto =\n | string\n | { kind: string; mint?: string };\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 active_when?: CalActiveWhenPredicateDto[];\n};\n\nexport type CalHideRuleDto = CalSubstructureDto & {\n rule_set_index?: number;\n target?: CalValueDto;\n condition?: string;\n};\n\nexport type CalAccountResetDto = CalSubstructureDto & {\n account_index?: number;\n require_pre_balance_zero?: boolean;\n value_kind?: string;\n token?: CalTokenValueDto;\n require_native_pre_balance_zero?: boolean;\n};\n\nexport type CalSlotConstraintDto = {\n signer: string;\n writable: string;\n};\n\nexport type CalAccountSchemaDto = {\n count_min?: number;\n count_max?: number;\n remaining_policy?: CalSlotConstraintDto;\n slots?: CalSlotConstraintDto[];\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?: CalOwnerAssociationDto;\n enum_variants?: Record<string, Record<string, CalEnumVariantDto>>;\n display_fields?: CalDisplayFieldDto[];\n value_flow_ports?: CalValueFlowPortDto[];\n hide_rules?: CalHideRuleDto[];\n account_resets?: CalAccountResetDto[];\n /** Absent means \"no ACCOUNT_SCHEMA check\". */\n account_schema?: CalAccountSchemaDto;\n /**\n * Host-side routing tags, outside the signed `descriptor`. Not covered by\n * the program codec: the mapper validates it on its own with\n * {@link calSigningRouteCodec} so a malformed value only drops the tags.\n */\n signing_route?: CalSigningRouteDto;\n};\n\n/** `role` is `\"required\"` or `\"allowed\"`; the mapper drops any other value. */\nexport type CalSigningRouteEntryDto = {\n rule: string;\n role: string;\n};\n\nexport type CalSigningRouteDto = {\n basic_flow?: CalSigningRouteEntryDto[];\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 calSlotConstraintCodec = Codec.interface({\n signer: string,\n writable: string,\n});\n\nconst calAccountSchemaCodec = Codec.interface({\n count_min: optional(number),\n count_max: optional(number),\n remaining_policy: optional(calSlotConstraintCodec),\n slots: optional(array(calSlotConstraintCodec)),\n});\n\nconst calInstructionDescriptorCodec = Codec.interface({\n discriminator_hex: optional(string),\n descriptor: calSignedDescriptorCodec,\n enum_variants: optional(record(string, record(string, calEnumVariantCodec))),\n display_fields: optional(array(calSubstructureCodec)),\n value_flow_ports: optional(array(calSubstructureCodec)),\n hide_rules: optional(array(calSubstructureCodec)),\n account_resets: optional(array(calSubstructureCodec)),\n account_schema: optional(calAccountSchemaCodec),\n});\n\n/**\n * Codec for one instruction's `signing_route`. Kept out of\n * `calInstructionDescriptorCodec` on purpose: routing tags are optional\n * metadata, and a malformed value must not invalidate the program's\n * clear-signing descriptors.\n */\nexport const calSigningRouteCodec = Codec.interface({\n basic_flow: optional(\n array(\n Codec.interface({\n rule: string,\n role: string,\n }),\n ),\n ),\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,EAAA,yBAAAC,IAAA,eAAAC,EAAAJ,GAQA,IAAAK,EAA+D,qBAgK/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,EAAyB,QAAM,UAAU,CAC7C,OAAQ,SACR,SAAU,QACZ,CAAC,EAEKC,EAAwB,QAAM,UAAU,CAC5C,aAAW,YAAS,QAAM,EAC1B,aAAW,YAAS,QAAM,EAC1B,oBAAkB,YAASD,CAAsB,EACjD,SAAO,eAAS,SAAMA,CAAsB,CAAC,CAC/C,CAAC,EAEKE,EAAgC,QAAM,UAAU,CACpD,qBAAmB,YAAS,QAAM,EAClC,WAAYL,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,EACpD,kBAAgB,YAASE,CAAqB,CAChD,CAAC,EAQYR,EAAuB,QAAM,UAAU,CAClD,cAAY,eACV,SACE,QAAM,UAAU,CACd,KAAM,SACN,KAAM,QACR,CAAC,CACH,CACF,CACF,CAAC,EAQYD,EAA6B,QAAM,UAAU,CACxD,GAAI,SACJ,SAAU,SACV,gBAAc,SAAMU,CAA6B,CACnD,CAAC",
6
+ "names": ["InstructionInfoDto_exports", "__export", "calInstructionProgramCodec", "calSigningRouteCodec", "__toCommonJS", "import_purify_ts", "calSignaturesCodec", "calSignedDescriptorCodec", "calEnumVariantCodec", "calSubstructureCodec", "calSlotConstraintCodec", "calAccountSchemaCodec", "calInstructionDescriptorCodec"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var s=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var x=(n,t)=>{for(var a in t)s(n,a,{get:t[a],enumerable:!0})},A=(n,t,a,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of g(t))!R.call(n,e)&&e!==a&&s(n,e,{get:()=>t[e],enumerable:!(o=w(t,e))||o.enumerable});return n};var b=n=>A(s({},"__esModule",{value:!0}),n);var F={};x(F,{toAccountResets:()=>S,toAccountSchema:()=>y,toDisplayFields:()=>D,toHideRules:()=>f,toInstructionInfoPayload:()=>V,toOwnerAssociations:()=>m,toProgramEnumVariants:()=>v,toValueFlowPorts:()=>C});module.exports=b(F);var r=require("purify-ts"),i=require("../../../../modules/solana/model/SolanaPayloads"),_=require("../../../../shared/utils/uIntCodec");function d(n,t){return n[t]}function C(n=[]){return n.map(t=>({account_indices:t.account_indices,optional_account_strategy:t.optional_account_strategy,token_value:t.token_value,active_when:t.active_when}))}function S(n=[]){return n.flatMap(t=>t.account_index===void 0?[]:[{account_index:t.account_index,require_pre_balance_zero:t.require_pre_balance_zero,value_kind:t.value_kind,token:t.token,require_native_pre_balance_zero:t.require_native_pre_balance_zero}])}function f(n=[]){return n.map(t=>({rule_set_index:t.rule_set_index,target:t.target,condition:t.condition}))}function m(n){return n===void 0?[]:n.account_index===void 0||n.owner===void 0?[]:[{account_index:n.account_index,owner:n.owner}]}const l=new Set(["FORBIDDEN","EITHER","REQUIRED"]);function p(n){const t=l.has(n.signer)?n.signer:"EITHER",a=l.has(n.writable)?n.writable:"EITHER";return{signer:t,writable:a}}function y(n){if(n!==void 0)return{count_min:n.count_min??0,count_max:n.count_max??255,remaining_policy:n.remaining_policy?p(n.remaining_policy):{signer:"EITHER",writable:"EITHER"},slots:(n.slots??[]).map(p)}}function D(n=[]){return n.map(t=>({name:t.name,param:t.param??{type:""}}))}function h(n){return[...(n.display_fields??[]).map(t=>({kind:i.SolanaInstructionSubstructureKind.DISPLAY_FIELD,data:t.descriptor})),...(n.value_flow_ports??[]).map(t=>({kind:i.SolanaInstructionSubstructureKind.VALUE_FLOW_PORT,data:t.descriptor})),...(n.hide_rules??[]).map(t=>({kind:i.SolanaInstructionSubstructureKind.HIDE_RULE,data:t.descriptor})),...(n.account_resets??[]).map(t=>({kind:i.SolanaInstructionSubstructureKind.ACCOUNT_RESET,data:t.descriptor}))]}function I(n,t){const a=[];for(const[o,e]of Object.entries(n.enum_variants??{}))for(const[E,c]of Object.entries(e)){const u=Number(E);_.u16Codec.decode(u).isLeft()||a.push({enumId:o,variantIndex:u,descriptor:{data:c.descriptor.data,signature:d(c.descriptor.signatures,t)??""}})}return a}function v(n,t){return Object.values(n).flatMap(a=>I(a,t))}function V(n,t,a,o){const e=d(a.descriptor.signatures,o);return e?(0,r.Right)({programId:n,discriminator:t,instructionName:a.instruction_name,instructionInfo:{data:a.descriptor.data,signature:e},substructures:h(a),enumVariants:I(a,o),idlDescriptor:{typePool:a.idl_descriptor?.type_pool??[],rootType:a.idl_descriptor?.root_type??0},mintAssociations:a.mint_association?[a.mint_association]:[],ownerAssociations:m(a.owner_association),valueFlowPorts:C(a.value_flow_ports),accountResets:S(a.account_resets),displayFields:D(a.display_fields),hideRules:f(a.hide_rules),accountSchema:y(a.account_schema)}):(0,r.Left)(new Error(`[ContextModule] InstructionInfoDataSource: missing '${o}' signature for (${n}, ${t})`))}0&&(module.exports={toAccountResets,toAccountSchema,toDisplayFields,toHideRules,toInstructionInfoPayload,toOwnerAssociations,toProgramEnumVariants,toValueFlowPorts});
1
+ "use strict";var c=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var A=(t,n)=>{for(var a in n)c(t,a,{get:n[a],enumerable:!0})},h=(t,n,a,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of R(n))!x.call(t,e)&&e!==a&&c(t,e,{get:()=>n[e],enumerable:!(o=E(n,e))||o.enumerable});return t};var b=t=>h(c({},"__esModule",{value:!0}),t);var T={};A(T,{toAccountResets:()=>m,toAccountSchema:()=>g,toBasicFlowTags:()=>V,toDisplayFields:()=>I,toHideRules:()=>y,toInstructionInfoPayload:()=>O,toOwnerAssociations:()=>D,toProgramEnumVariants:()=>v,toValueFlowPorts:()=>S});module.exports=b(T);var s=require("purify-ts"),r=require("../../../../modules/solana/model/SolanaPayloads"),d=require("../../../../shared/utils/uIntCodec"),f=require("./InstructionInfoDto");function C(t,n){return t[n]}function S(t=[]){return t.map(n=>({account_indices:n.account_indices,optional_account_strategy:n.optional_account_strategy,token_value:n.token_value,active_when:n.active_when}))}function m(t=[]){return t.flatMap(n=>n.account_index===void 0?[]:[{account_index:n.account_index,require_pre_balance_zero:n.require_pre_balance_zero,value_kind:n.value_kind,token:n.token,require_native_pre_balance_zero:n.require_native_pre_balance_zero}])}function y(t=[]){return t.map(n=>({rule_set_index:n.rule_set_index,target:n.target,condition:n.condition}))}function D(t){return t===void 0?[]:t.account_index===void 0||t.owner===void 0?[]:[{account_index:t.account_index,owner:t.owner}]}const p=new Set(["FORBIDDEN","EITHER","REQUIRED"]);function _(t){const n=p.has(t.signer)?t.signer:"EITHER",a=p.has(t.writable)?t.writable:"EITHER";return{signer:n,writable:a}}function g(t){if(t!==void 0)return{count_min:t.count_min??0,count_max:t.count_max??255,remaining_policy:t.remaining_policy?_(t.remaining_policy):{signer:"EITHER",writable:"EITHER"},slots:(t.slots??[]).map(_)}}function I(t=[]){return t.map(n=>({name:n.name,param:n.param??{type:""}}))}function F(t){return[...(t.display_fields??[]).map(n=>({kind:r.SolanaInstructionSubstructureKind.DISPLAY_FIELD,data:n.descriptor})),...(t.value_flow_ports??[]).map(n=>({kind:r.SolanaInstructionSubstructureKind.VALUE_FLOW_PORT,data:n.descriptor})),...(t.hide_rules??[]).map(n=>({kind:r.SolanaInstructionSubstructureKind.HIDE_RULE,data:n.descriptor})),...(t.account_resets??[]).map(n=>({kind:r.SolanaInstructionSubstructureKind.ACCOUNT_RESET,data:n.descriptor}))]}function w(t,n){const a=[];for(const[o,e]of Object.entries(t.enum_variants??{}))for(const[i,u]of Object.entries(e)){const l=Number(i);d.u16Codec.decode(l).isLeft()||a.push({enumId:o,variantIndex:l,descriptor:{data:u.descriptor.data,signature:C(u.descriptor.signatures,n)??""}})}return a}function v(t,n){return Object.values(t).flatMap(a=>w(a,n))}function V(t){return Object.entries(t).flatMap(([n,a])=>n===""||a.signing_route===void 0?[]:f.calSigningRouteCodec.decode(a.signing_route).caseOf({Left:()=>[],Right:({basic_flow:o=[]})=>o.flatMap(({rule:e,role:i})=>e.length>0&&(i==="required"||i==="allowed")?[{discriminator:n,rule:e,role:i}]:[])}))}function O(t,n,a,o){const e=C(a.descriptor.signatures,o);return e?(0,s.Right)({programId:t,discriminator:n,instructionName:a.instruction_name,instructionInfo:{data:a.descriptor.data,signature:e},substructures:F(a),enumVariants:w(a,o),idlDescriptor:{typePool:a.idl_descriptor?.type_pool??[],rootType:a.idl_descriptor?.root_type??0},mintAssociations:a.mint_association?[a.mint_association]:[],ownerAssociations:D(a.owner_association),valueFlowPorts:S(a.value_flow_ports),accountResets:m(a.account_resets),displayFields:I(a.display_fields),hideRules:y(a.hide_rules),accountSchema:g(a.account_schema)}):(0,s.Left)(new Error(`[ContextModule] InstructionInfoDataSource: missing '${o}' signature for (${t}, ${n})`))}0&&(module.exports={toAccountResets,toAccountSchema,toBasicFlowTags,toDisplayFields,toHideRules,toInstructionInfoPayload,toOwnerAssociations,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 SolanaCalAccountSchema,\n type SolanaCalDisplayField,\n type SolanaCalHideRule,\n type SolanaCalOwnerAssociation,\n type SolanaCalSlotConstraint,\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 CalAccountSchemaDto,\n type CalDisplayFieldDto,\n type CalHideRuleDto,\n type CalInstructionDescriptorDto,\n type CalOwnerAssociationDto,\n type CalSignatures,\n type CalSlotConstraintDto,\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 active_when: port.active_when,\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 value_kind: reset.value_kind,\n token: reset.token,\n require_native_pre_balance_zero:\n reset.require_native_pre_balance_zero,\n },\n ],\n );\n}\n\n/**\n * Every rule is carried, including one CAL served without a `condition`. The\n * rule's signed TLV goes to the device through {@link toSubstructures}\n * regardless, and the device resolves the `target` of every rule it receives \u2014\n * so dropping the entry here would cost the host the `ALT_RESOLUTION` for that\n * target and make the device refuse to sign. A missing condition only means no\n * requirement keys off this rule's predicate.\n */\nexport function toHideRules(dtos: CalHideRuleDto[] = []): SolanaCalHideRule[] {\n return dtos.map((rule) => ({\n rule_set_index: rule.rule_set_index,\n target: rule.target,\n condition: rule.condition,\n }));\n}\n\n/**\n * CAL carries at most one `owner_association` per descriptor; the payload holds\n * a list so the transaction-wide owner map is built the same way as the mint\n * map. Both halves of the pair are required (spec: \"must both be present or\n * both absent\"), so a half-declared association is dropped.\n */\nexport function toOwnerAssociations(\n dto: CalOwnerAssociationDto | undefined,\n): SolanaCalOwnerAssociation[] {\n if (dto === undefined) return [];\n if (dto.account_index === undefined || dto.owner === undefined) return [];\n return [{ account_index: dto.account_index, owner: dto.owner }];\n}\n\nconst VALID_CONSTRAINT_VALUES = new Set([\"FORBIDDEN\", \"EITHER\", \"REQUIRED\"]);\n\n/**\n * Unlike `value_kind` on `ACCOUNT_RESET` (an unknown value is a decode\n * error), an unknown/missing `signer` or `writable` here deliberately fails\n * open to `\"EITHER\"` \u2014 i.e. that slot is left unchecked rather than the whole\n * descriptor rejected. ACCOUNT_SCHEMA is only a host-side optimization (the\n * device is the authority at FINALIZE), so the worst outcome of a malformed\n * value is a missed early exit, not an incorrect signature.\n */\nfunction toSlotConstraint(dto: CalSlotConstraintDto): SolanaCalSlotConstraint {\n const signer = VALID_CONSTRAINT_VALUES.has(dto.signer)\n ? (dto.signer as SolanaCalSlotConstraint[\"signer\"])\n : \"EITHER\";\n const writable = VALID_CONSTRAINT_VALUES.has(dto.writable)\n ? (dto.writable as SolanaCalSlotConstraint[\"writable\"])\n : \"EITHER\";\n return { signer, writable };\n}\n\nexport function toAccountSchema(\n dto: CalAccountSchemaDto | undefined,\n): SolanaCalAccountSchema | undefined {\n if (dto === undefined) return undefined;\n return {\n count_min: dto.count_min ?? 0,\n count_max: dto.count_max ?? 255,\n remaining_policy: dto.remaining_policy\n ? toSlotConstraint(dto.remaining_policy)\n : { signer: \"EITHER\", writable: \"EITHER\" },\n slots: (dto.slots ?? []).map(toSlotConstraint),\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 instructionName: dto.instruction_name,\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 ownerAssociations: toOwnerAssociations(dto.owner_association),\n valueFlowPorts: toValueFlowPorts(dto.value_flow_ports),\n accountResets: toAccountResets(dto.account_resets),\n displayFields: toDisplayFields(dto.display_fields),\n hideRules: toHideRules(dto.hide_rules),\n accountSchema: toAccountSchema(dto.account_schema),\n });\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,EAAA,oBAAAC,EAAA,oBAAAC,EAAA,gBAAAC,EAAA,6BAAAC,EAAA,wBAAAC,EAAA,0BAAAC,EAAA,qBAAAC,IAAA,eAAAC,EAAAV,GAKA,IAAAW,EAAyC,qBAEzCC,EAYO,iDACPC,EAAyB,oCAgBzB,SAASC,EACPC,EACAC,EACoB,CACpB,OAAOD,EAAWC,CAAI,CACxB,CAMO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ACAL,EAC6C,CAC7C,MAAMuB,EAAYzB,EAAcO,EAAI,WAAW,WAAYL,CAAI,EAC/D,OAAKuB,KAQE,SAAM,CACX,UAAAF,EACA,cAAAC,EACA,gBAAiBjB,EAAI,iBACrB,gBAAiB,CACf,KAAMA,EAAI,WAAW,KACrB,UAAAkB,CACF,EACA,cAAeZ,EAAgBN,CAAG,EAClC,aAAcQ,EAAeR,EAAKL,CAAI,EACtC,cAAe,CACb,SAAUK,EAAI,gBAAgB,WAAa,CAAC,EAC5C,SAAUA,EAAI,gBAAgB,WAAa,CAC7C,EACA,iBAAkBA,EAAI,iBAAmB,CAACA,EAAI,gBAAgB,EAAI,CAAC,EACnE,kBAAmBd,EAAoBc,EAAI,iBAAiB,EAC5D,eAAgBZ,EAAiBY,EAAI,gBAAgB,EACrD,cAAenB,EAAgBmB,EAAI,cAAc,EACjD,cAAejB,EAAgBiB,EAAI,cAAc,EACjD,UAAWhB,EAAYgB,EAAI,UAAU,EACrC,cAAelB,EAAgBkB,EAAI,cAAc,CACnD,CAAC,KA5BQ,QACL,IAAI,MACF,uDAAuDL,CAAI,oBAAoBqB,CAAS,KAAKC,CAAa,GAC5G,CACF,CAyBJ",
6
- "names": ["InstructionInfoMapper_exports", "__export", "toAccountResets", "toAccountSchema", "toDisplayFields", "toHideRules", "toInstructionInfoPayload", "toOwnerAssociations", "toProgramEnumVariants", "toValueFlowPorts", "__toCommonJS", "import_purify_ts", "import_SolanaPayloads", "import_uIntCodec", "pickSignature", "signatures", "mode", "dtos", "port", "reset", "rule", "dto", "VALID_CONSTRAINT_VALUES", "toSlotConstraint", "signer", "writable", "field", "toSubstructures", "s", "toEnumVariants", "enumVariants", "enumId", "variants", "variantIndex", "variant", "index", "descriptors", "programId", "discriminator", "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 SolanaCalAccountSchema,\n type SolanaCalDisplayField,\n type SolanaCalHideRule,\n type SolanaCalOwnerAssociation,\n type SolanaCalSlotConstraint,\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 { type SolanaBasicFlowTag } from \"./InstructionInfoDataSource\";\nimport {\n type CalAccountResetDto,\n type CalAccountSchemaDto,\n type CalDisplayFieldDto,\n type CalHideRuleDto,\n type CalInstructionDescriptorDto,\n type CalOwnerAssociationDto,\n type CalSignatures,\n calSigningRouteCodec,\n type CalSlotConstraintDto,\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 active_when: port.active_when,\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 value_kind: reset.value_kind,\n token: reset.token,\n require_native_pre_balance_zero:\n reset.require_native_pre_balance_zero,\n },\n ],\n );\n}\n\n/**\n * Every rule is carried, including one CAL served without a `condition`. The\n * rule's signed TLV goes to the device through {@link toSubstructures}\n * regardless, and the device resolves the `target` of every rule it receives \u2014\n * so dropping the entry here would cost the host the `ALT_RESOLUTION` for that\n * target and make the device refuse to sign. A missing condition only means no\n * requirement keys off this rule's predicate.\n */\nexport function toHideRules(dtos: CalHideRuleDto[] = []): SolanaCalHideRule[] {\n return dtos.map((rule) => ({\n rule_set_index: rule.rule_set_index,\n target: rule.target,\n condition: rule.condition,\n }));\n}\n\n/**\n * CAL carries at most one `owner_association` per descriptor; the payload holds\n * a list so the transaction-wide owner map is built the same way as the mint\n * map. Both halves of the pair are required (spec: \"must both be present or\n * both absent\"), so a half-declared association is dropped.\n */\nexport function toOwnerAssociations(\n dto: CalOwnerAssociationDto | undefined,\n): SolanaCalOwnerAssociation[] {\n if (dto === undefined) return [];\n if (dto.account_index === undefined || dto.owner === undefined) return [];\n return [{ account_index: dto.account_index, owner: dto.owner }];\n}\n\nconst VALID_CONSTRAINT_VALUES = new Set([\"FORBIDDEN\", \"EITHER\", \"REQUIRED\"]);\n\n/**\n * Unlike `value_kind` on `ACCOUNT_RESET` (an unknown value is a decode\n * error), an unknown/missing `signer` or `writable` here deliberately fails\n * open to `\"EITHER\"` \u2014 i.e. that slot is left unchecked rather than the whole\n * descriptor rejected. ACCOUNT_SCHEMA is only a host-side optimization (the\n * device is the authority at FINALIZE), so the worst outcome of a malformed\n * value is a missed early exit, not an incorrect signature.\n */\nfunction toSlotConstraint(dto: CalSlotConstraintDto): SolanaCalSlotConstraint {\n const signer = VALID_CONSTRAINT_VALUES.has(dto.signer)\n ? (dto.signer as SolanaCalSlotConstraint[\"signer\"])\n : \"EITHER\";\n const writable = VALID_CONSTRAINT_VALUES.has(dto.writable)\n ? (dto.writable as SolanaCalSlotConstraint[\"writable\"])\n : \"EITHER\";\n return { signer, writable };\n}\n\nexport function toAccountSchema(\n dto: CalAccountSchemaDto | undefined,\n): SolanaCalAccountSchema | undefined {\n if (dto === undefined) return undefined;\n return {\n count_min: dto.count_min ?? 0,\n count_max: dto.count_max ?? 255,\n remaining_policy: dto.remaining_policy\n ? toSlotConstraint(dto.remaining_policy)\n : { signer: \"EITHER\", writable: \"EITHER\" },\n slots: (dto.slots ?? []).map(toSlotConstraint),\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 * Collect the `signing_route.basic_flow` tags of every descriptor in a\n * program. `signing_route` is validated here rather than by the program codec,\n * so a malformed value drops that instruction's tags without touching its\n * descriptor. Unknown roles are dropped, and so are tags on an instruction\n * without a discriminator (keyed under `\"\"`): CAL rules are instruction-level.\n */\nexport function toBasicFlowTags(\n descriptors: Record<string, CalInstructionDescriptorDto>,\n): SolanaBasicFlowTag[] {\n return Object.entries(descriptors).flatMap(([discriminator, dto]) => {\n if (discriminator === \"\" || dto.signing_route === undefined) return [];\n return calSigningRouteCodec\n .decode(dto.signing_route)\n .caseOf<SolanaBasicFlowTag[]>({\n Left: () => [],\n Right: ({ basic_flow = [] }) =>\n basic_flow.flatMap(({ rule, role }) =>\n rule.length > 0 && (role === \"required\" || role === \"allowed\")\n ? [{ discriminator, rule, role }]\n : [],\n ),\n });\n });\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 instructionName: dto.instruction_name,\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 ownerAssociations: toOwnerAssociations(dto.owner_association),\n valueFlowPorts: toValueFlowPorts(dto.value_flow_ports),\n accountResets: toAccountResets(dto.account_resets),\n displayFields: toDisplayFields(dto.display_fields),\n hideRules: toHideRules(dto.hide_rules),\n accountSchema: toAccountSchema(dto.account_schema),\n });\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,EAAA,oBAAAC,EAAA,oBAAAC,EAAA,oBAAAC,EAAA,gBAAAC,EAAA,6BAAAC,EAAA,wBAAAC,EAAA,0BAAAC,EAAA,qBAAAC,IAAA,eAAAC,EAAAX,GAKA,IAAAY,EAAyC,qBAEzCC,EAYO,iDACPC,EAAyB,oCAGzBC,EAWO,gCAIP,SAASC,EACPC,EACAC,EACoB,CACpB,OAAOD,EAAWC,CAAI,CACxB,CAMO,SAASR,EACdS,EAA8B,CAAC,EACL,CAC1B,OAAOA,EAAK,IAAKC,IAAU,CACzB,gBAAiBA,EAAK,gBACtB,0BAA2BA,EAAK,0BAChC,YAAaA,EAAK,YAClB,YAAaA,EAAK,WACpB,EAAE,CACJ,CAEO,SAASlB,EACdiB,EAA6B,CAAC,EACL,CAGzB,OAAOA,EAAK,QAASE,GACnBA,EAAM,gBAAkB,OACpB,CAAC,EACD,CACE,CACE,cAAeA,EAAM,cACrB,yBAA0BA,EAAM,yBAChC,WAAYA,EAAM,WAClB,MAAOA,EAAM,MACb,gCACEA,EAAM,+BACV,CACF,CACN,CACF,CAUO,SAASf,EAAYa,EAAyB,CAAC,E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P,CACJ,CAAC,CACJ,CACH,CAWO,SAASlC,EACdmC,EACAH,EACAhB,EACAL,EAC6C,CAC7C,MAAMyB,EAAY3B,EAAcO,EAAI,WAAW,WAAYL,CAAI,EAC/D,OAAKyB,KAQE,SAAM,CACX,UAAAD,EACA,cAAAH,EACA,gBAAiBhB,EAAI,iBACrB,gBAAiB,CACf,KAAMA,EAAI,WAAW,KACrB,UAAAoB,CACF,EACA,cAAed,EAAgBN,CAAG,EAClC,aAAcQ,EAAeR,EAAKL,CAAI,EACtC,cAAe,CACb,SAAUK,EAAI,gBAAgB,WAAa,CAAC,EAC5C,SAAUA,EAAI,gBAAgB,WAAa,CAC7C,EACA,iBAAkBA,EAAI,iBAAmB,CAACA,EAAI,gBAAgB,EAAI,CAAC,EACnE,kBAAmBf,EAAoBe,EAAI,iBAAiB,EAC5D,eAAgBb,EAAiBa,EAAI,gBAAgB,EACrD,cAAerB,EAAgBqB,EAAI,cAAc,EACjD,cAAelB,EAAgBkB,EAAI,cAAc,EACjD,UAAWjB,EAAYiB,EAAI,UAAU,EACrC,cAAepB,EAAgBoB,EAAI,cAAc,CACnD,CAAC,KA5BQ,QACL,IAAI,MACF,uDAAuDL,CAAI,oBAAoBwB,CAAS,KAAKH,CAAa,GAC5G,CACF,CAyBJ",
6
+ "names": ["InstructionInfoMapper_exports", "__export", "toAccountResets", "toAccountSchema", "toBasicFlowTags", "toDisplayFields", "toHideRules", "toInstructionInfoPayload", "toOwnerAssociations", "toProgramEnumVariants", "toValueFlowPorts", "__toCommonJS", "import_purify_ts", "import_SolanaPayloads", "import_uIntCodec", "import_InstructionInfoDto", "pickSignature", "signatures", "mode", "dtos", "port", "reset", "rule", "dto", "VALID_CONSTRAINT_VALUES", "toSlotConstraint", "signer", "writable", "field", "toSubstructures", "s", "toEnumVariants", "enumVariants", "enumId", "variants", "variantIndex", "variant", "index", "descriptors", "discriminator", "basic_flow", "role", "programId", "signature"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var e=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var p=(o,t)=>{for(var r in t)e(o,r,{get:t[r],enumerable:!0})},d=(o,t,r,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of m(t))!s.call(o,n)&&n!==r&&e(o,n,{get:()=>t[n],enumerable:!(c=a(t,n))||c.enumerable});return o};var x=o=>d(e({},"__esModule",{value:!0}),o);var l={};p(l,{instructionInfoModuleFactory:()=>C});module.exports=x(l);var f=require("inversify"),u=require("../../../../modules/solana/instruction-info/data/HttpInstructionInfoDataSource"),i=require("../../../../modules/solana/instruction-info/di/instructionInfoTypes"),I=require("../../../../modules/solana/instruction-info/domain/InstructionInfoContextLoader");const C=()=>new f.ContainerModule(({bind:o})=>{o(i.instructionInfoTypes.InstructionInfoDataSource).to(u.HttpInstructionInfoDataSource),o(i.instructionInfoTypes.InstructionInfoContextLoader).to(I.InstructionInfoContextLoader)});0&&(module.exports={instructionInfoModuleFactory});
1
+ "use strict";var a=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var p=(o,t)=>{for(var r in t)a(o,r,{get:t[r],enumerable:!0})},S=(o,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of I(t))!l.call(o,n)&&n!==r&&a(o,n,{get:()=>t[n],enumerable:!(i=s(t,n))||i.enumerable});return o};var x=o=>S(a({},"__esModule",{value:!0}),o);var d={};p(d,{instructionInfoModuleFactory:()=>C});module.exports=x(d);var c=require("inversify"),u=require("../../../../modules/solana/instruction-info/data/HttpInstructionInfoDataSource"),e=require("../../../../modules/solana/instruction-info/di/instructionInfoTypes"),f=require("../../../../modules/solana/instruction-info/domain/InstructionInfoContextLoader"),m=require("../../../../modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader");const C=()=>new c.ContainerModule(({bind:o})=>{o(e.instructionInfoTypes.InstructionInfoDataSource).to(u.HttpInstructionInfoDataSource).inSingletonScope(),o(e.instructionInfoTypes.InstructionInfoContextLoader).to(f.InstructionInfoContextLoader),o(e.instructionInfoTypes.SolanaBasicFlowRuleContextLoader).to(m.SolanaBasicFlowRuleContextLoader)});0&&(module.exports={instructionInfoModuleFactory});
2
2
  //# sourceMappingURL=instructionInfoModuleFactory.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/modules/solana/instruction-info/di/instructionInfoModuleFactory.ts"],
4
- "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpInstructionInfoDataSource } from \"@/modules/solana/instruction-info/data/HttpInstructionInfoDataSource\";\nimport { instructionInfoTypes } from \"@/modules/solana/instruction-info/di/instructionInfoTypes\";\nimport { InstructionInfoContextLoader } from \"@/modules/solana/instruction-info/domain/InstructionInfoContextLoader\";\n\nexport const instructionInfoModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(instructionInfoTypes.InstructionInfoDataSource).to(\n HttpInstructionInfoDataSource,\n );\n bind(instructionInfoTypes.InstructionInfoContextLoader).to(\n InstructionInfoContextLoader,\n );\n });\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,qBAEhCC,EAA8C,gFAC9CC,EAAqC,qEACrCC,EAA6C,iFAEtC,MAAML,EAA+B,IAC1C,IAAI,kBAAgB,CAAC,CAAE,KAAAM,CAAK,IAAM,CAChCA,EAAK,uBAAqB,yBAAyB,EAAE,GACnD,+BACF,EACAA,EAAK,uBAAqB,4BAA4B,EAAE,GACtD,8BACF,CACF,CAAC",
6
- "names": ["instructionInfoModuleFactory_exports", "__export", "instructionInfoModuleFactory", "__toCommonJS", "import_inversify", "import_HttpInstructionInfoDataSource", "import_instructionInfoTypes", "import_InstructionInfoContextLoader", "bind"]
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpInstructionInfoDataSource } from \"@/modules/solana/instruction-info/data/HttpInstructionInfoDataSource\";\nimport { instructionInfoTypes } from \"@/modules/solana/instruction-info/di/instructionInfoTypes\";\nimport { InstructionInfoContextLoader } from \"@/modules/solana/instruction-info/domain/InstructionInfoContextLoader\";\nimport { SolanaBasicFlowRuleContextLoader } from \"@/modules/solana/instruction-info/domain/SolanaBasicFlowRuleContextLoader\";\n\nexport const instructionInfoModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n // Singleton so every consumer (instruction-info, enum-variant and\n // basic-flow rules loaders) shares the data source's response cache.\n bind(instructionInfoTypes.InstructionInfoDataSource)\n .to(HttpInstructionInfoDataSource)\n .inSingletonScope();\n bind(instructionInfoTypes.InstructionInfoContextLoader).to(\n InstructionInfoContextLoader,\n );\n bind(instructionInfoTypes.SolanaBasicFlowRuleContextLoader).to(\n SolanaBasicFlowRuleContextLoader,\n );\n });\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,qBAEhCC,EAA8C,gFAC9CC,EAAqC,qEACrCC,EAA6C,iFAC7CC,EAAiD,qFAE1C,MAAMN,EAA+B,IAC1C,IAAI,kBAAgB,CAAC,CAAE,KAAAO,CAAK,IAAM,CAGhCA,EAAK,uBAAqB,yBAAyB,EAChD,GAAG,+BAA6B,EAChC,iBAAiB,EACpBA,EAAK,uBAAqB,4BAA4B,EAAE,GACtD,8BACF,EACAA,EAAK,uBAAqB,gCAAgC,EAAE,GAC1D,kCACF,CACF,CAAC",
6
+ "names": ["instructionInfoModuleFactory_exports", "__export", "instructionInfoModuleFactory", "__toCommonJS", "import_inversify", "import_HttpInstructionInfoDataSource", "import_instructionInfoTypes", "import_InstructionInfoContextLoader", "import_SolanaBasicFlowRuleContextLoader", "bind"]
7
7
  }