@ledgerhq/device-signer-kit-ethereum 0.0.0-multisig-20250822145545 → 0.0.0-multisig-20250905101831

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 (99) hide show
  1. package/lib/cjs/api/SignerEthBuilder.test.js +1 -1
  2. package/lib/cjs/api/SignerEthBuilder.test.js.map +1 -1
  3. package/lib/cjs/internal/app-binder/EthAppBinder.test.js +1 -1
  4. package/lib/cjs/internal/app-binder/EthAppBinder.test.js.map +2 -2
  5. package/lib/cjs/internal/app-binder/command/ProvideNetworkConfigurationCommand.js +2 -0
  6. package/lib/cjs/internal/app-binder/command/ProvideNetworkConfigurationCommand.js.map +7 -0
  7. package/lib/cjs/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.js +2 -0
  8. package/lib/cjs/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.js.map +7 -0
  9. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js +1 -1
  10. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js.map +2 -2
  11. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js +1 -1
  12. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js.map +2 -2
  13. package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js +1 -1
  14. package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js.map +2 -2
  15. package/lib/cjs/internal/app-binder/task/BuildBaseContexts.js +1 -1
  16. package/lib/cjs/internal/app-binder/task/BuildBaseContexts.js.map +3 -3
  17. package/lib/cjs/internal/app-binder/task/BuildBaseContexts.test.js +1 -1
  18. package/lib/cjs/internal/app-binder/task/BuildBaseContexts.test.js.map +2 -2
  19. package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.test.js +1 -1
  20. package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.test.js.map +2 -2
  21. package/lib/cjs/internal/app-binder/task/BuildFullContextsTask.js +1 -1
  22. package/lib/cjs/internal/app-binder/task/BuildFullContextsTask.js.map +2 -2
  23. package/lib/cjs/internal/app-binder/task/BuildFullContextsTask.test.js +1 -1
  24. package/lib/cjs/internal/app-binder/task/BuildFullContextsTask.test.js.map +3 -3
  25. package/lib/cjs/internal/app-binder/task/BuildSubcontextsTask.js +1 -1
  26. package/lib/cjs/internal/app-binder/task/BuildSubcontextsTask.js.map +3 -3
  27. package/lib/cjs/internal/app-binder/task/BuildSubcontextsTask.test.js +1 -1
  28. package/lib/cjs/internal/app-binder/task/BuildSubcontextsTask.test.js.map +3 -3
  29. package/lib/cjs/internal/app-binder/task/ParseNestedTransactionTask.js.map +2 -2
  30. package/lib/cjs/internal/app-binder/task/ProvideContextsTask.js +1 -1
  31. package/lib/cjs/internal/app-binder/task/ProvideContextsTask.js.map +3 -3
  32. package/lib/cjs/internal/app-binder/task/ProvideContextsTask.test.js +1 -1
  33. package/lib/cjs/internal/app-binder/task/ProvideContextsTask.test.js.map +3 -3
  34. package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.js +1 -1
  35. package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.js.map +3 -3
  36. package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.test.js +1 -1
  37. package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.test.js.map +3 -3
  38. package/lib/cjs/internal/app-binder/task/SendPayloadInChunksTask.js +1 -1
  39. package/lib/cjs/internal/app-binder/task/SendPayloadInChunksTask.js.map +3 -3
  40. package/lib/cjs/internal/app-binder/task/SendPayloadInChunksTask.test.js +1 -1
  41. package/lib/cjs/internal/app-binder/task/SendPayloadInChunksTask.test.js.map +3 -3
  42. package/lib/esm/api/SignerEthBuilder.test.js +1 -1
  43. package/lib/esm/api/SignerEthBuilder.test.js.map +1 -1
  44. package/lib/esm/internal/app-binder/EthAppBinder.test.js +1 -1
  45. package/lib/esm/internal/app-binder/EthAppBinder.test.js.map +2 -2
  46. package/lib/esm/internal/app-binder/command/ProvideNetworkConfigurationCommand.js +2 -0
  47. package/lib/esm/internal/app-binder/command/ProvideNetworkConfigurationCommand.js.map +7 -0
  48. package/lib/esm/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.js +2 -0
  49. package/lib/esm/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.js.map +7 -0
  50. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js +1 -1
  51. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js.map +2 -2
  52. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js +1 -1
  53. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js.map +2 -2
  54. package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js +1 -1
  55. package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js.map +2 -2
  56. package/lib/esm/internal/app-binder/task/BuildBaseContexts.js +1 -1
  57. package/lib/esm/internal/app-binder/task/BuildBaseContexts.js.map +3 -3
  58. package/lib/esm/internal/app-binder/task/BuildBaseContexts.test.js +1 -1
  59. package/lib/esm/internal/app-binder/task/BuildBaseContexts.test.js.map +2 -2
  60. package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.test.js +1 -1
  61. package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.test.js.map +2 -2
  62. package/lib/esm/internal/app-binder/task/BuildFullContextsTask.js +1 -1
  63. package/lib/esm/internal/app-binder/task/BuildFullContextsTask.js.map +2 -2
  64. package/lib/esm/internal/app-binder/task/BuildFullContextsTask.test.js +1 -1
  65. package/lib/esm/internal/app-binder/task/BuildFullContextsTask.test.js.map +3 -3
  66. package/lib/esm/internal/app-binder/task/BuildSubcontextsTask.js +1 -1
  67. package/lib/esm/internal/app-binder/task/BuildSubcontextsTask.js.map +3 -3
  68. package/lib/esm/internal/app-binder/task/BuildSubcontextsTask.test.js +1 -1
  69. package/lib/esm/internal/app-binder/task/BuildSubcontextsTask.test.js.map +3 -3
  70. package/lib/esm/internal/app-binder/task/ParseNestedTransactionTask.js.map +2 -2
  71. package/lib/esm/internal/app-binder/task/ProvideContextsTask.js +1 -1
  72. package/lib/esm/internal/app-binder/task/ProvideContextsTask.js.map +3 -3
  73. package/lib/esm/internal/app-binder/task/ProvideContextsTask.test.js +1 -1
  74. package/lib/esm/internal/app-binder/task/ProvideContextsTask.test.js.map +3 -3
  75. package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.js +1 -1
  76. package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.js.map +3 -3
  77. package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.test.js +1 -1
  78. package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.test.js.map +3 -3
  79. package/lib/esm/internal/app-binder/task/SendPayloadInChunksTask.js +1 -1
  80. package/lib/esm/internal/app-binder/task/SendPayloadInChunksTask.js.map +3 -3
  81. package/lib/esm/internal/app-binder/task/SendPayloadInChunksTask.test.js +1 -1
  82. package/lib/esm/internal/app-binder/task/SendPayloadInChunksTask.test.js.map +3 -3
  83. package/lib/types/internal/app-binder/command/ProvideNetworkConfigurationCommand.d.ts +28 -0
  84. package/lib/types/internal/app-binder/command/ProvideNetworkConfigurationCommand.d.ts.map +1 -0
  85. package/lib/types/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.d.ts +2 -0
  86. package/lib/types/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.d.ts.map +1 -0
  87. package/lib/types/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.d.ts.map +1 -1
  88. package/lib/types/internal/app-binder/task/BuildBaseContexts.d.ts.map +1 -1
  89. package/lib/types/internal/app-binder/task/BuildFullContextsTask.d.ts +2 -1
  90. package/lib/types/internal/app-binder/task/BuildFullContextsTask.d.ts.map +1 -1
  91. package/lib/types/internal/app-binder/task/BuildSubcontextsTask.d.ts +10 -2
  92. package/lib/types/internal/app-binder/task/BuildSubcontextsTask.d.ts.map +1 -1
  93. package/lib/types/internal/app-binder/task/ParseNestedTransactionTask.d.ts.map +1 -1
  94. package/lib/types/internal/app-binder/task/ProvideContextsTask.d.ts.map +1 -1
  95. package/lib/types/internal/app-binder/task/ProvideEIP712ContextTask.d.ts.map +1 -1
  96. package/lib/types/internal/app-binder/task/SendPayloadInChunksTask.d.ts +1 -0
  97. package/lib/types/internal/app-binder/task/SendPayloadInChunksTask.d.ts.map +1 -1
  98. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  99. package/package.json +9 -9
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/task/BuildBaseContexts.test.ts"],
4
- "sourcesContent": ["import {\n type ClearSignContext,\n type ClearSignContextSuccess,\n ClearSignContextType,\n type PkiCertificate,\n} from \"@ledgerhq/context-module\";\nimport {\n CommandResultFactory,\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n hexaStringToBuffer,\n UnknownDeviceExchangeError,\n} from \"@ledgerhq/device-management-kit\";\nimport { Transaction } from \"ethers\";\n\nimport type { GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\n\nimport {\n BuildBaseContexts,\n type BuildBaseContextsArgs,\n} from \"./BuildBaseContexts\";\nimport { GetWeb3CheckTask } from \"./GetWeb3CheckTask\";\n\ndescribe(\"BuildBaseContexts\", () => {\n const contextModuleMock = {\n getContext: vi.fn(),\n getContexts: vi.fn(),\n getTypedDataFilters: vi.fn(),\n getWeb3Checks: vi.fn(),\n getSolanaContext: vi.fn(),\n };\n const defaultOptions = {\n domain: \"domain-name.eth\",\n };\n const defaultTransaction: Uint8Array = hexaStringToBuffer(\n Transaction.from({\n chainId: 1n,\n nonce: 0,\n data: \"0x\",\n }).unsignedSerialized,\n )!;\n const defaultCertificate: PkiCertificate = {\n keyUsageNumber: 1,\n payload: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n let defaultArgs: BuildBaseContextsArgs;\n const apiMock = makeDeviceActionInternalApiMock();\n const getWeb3ChecksFactoryMock = vi.fn();\n\n function createAppConfig(\n web3ChecksEnabled: boolean,\n ): GetConfigCommandResponse {\n return {\n blindSigningEnabled: false,\n web3ChecksEnabled,\n web3ChecksOptIn: false,\n version: \"1.13.0\",\n };\n }\n\n beforeEach(() => {\n vi.resetAllMocks();\n apiMock.sendCommand.mockResolvedValue(\n CommandResultFactory({ data: { challenge: \"challenge\" } }),\n );\n getWeb3ChecksFactoryMock.mockReturnValue({\n run: async () => Promise.resolve({ web3Check: null }),\n });\n\n defaultArgs = {\n contextModule: contextModuleMock,\n subset: { chainId: 1, to: undefined, data: \"0x\", selector: \"0x\" },\n transaction: defaultTransaction,\n options: defaultOptions,\n appConfig: createAppConfig(false),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n });\n\n it(\"should init with a default GetWeb3CheckTaskFactory\", () => {\n // GIVEN\n const task = new BuildBaseContexts(apiMock, defaultArgs);\n\n // THEN\n expect(task[\"getWeb3ChecksFactory\"]).toBeDefined();\n expect(\n task[\"getWeb3ChecksFactory\"](apiMock, {\n contextModule: defaultArgs.contextModule,\n derivationPath: defaultArgs.derivationPath,\n subset: defaultArgs.subset,\n transaction: defaultArgs.transaction!,\n }),\n ).toBeInstanceOf(GetWeb3CheckTask);\n });\n\n it(\"should build the transaction context without clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n const clearSignContextsOptional: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with web3checks\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n const clearSignContextsOptional: ClearSignContext[] = [];\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [expectedWeb3Check, ...clearSignContexts],\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with web3checks and generic-parser clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n ];\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n clearSignContexts[0],\n clearSignContexts[1],\n clearSignContexts[3],\n expectedWeb3Check,\n ],\n clearSignContextsOptional: [clearSignContexts[2]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with web3checks and generic-parser clear sign contexts in the correct order\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n ];\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n clearSignContexts[3], // transaction info\n clearSignContexts[1], // transaction field description\n clearSignContexts[2], // transaction field description\n expectedWeb3Check, // web3 check\n ],\n clearSignContextsOptional: [clearSignContexts[0]], // enum\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with generic-parser context\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n clearSignContexts[0],\n clearSignContexts[1],\n clearSignContexts[3],\n ],\n clearSignContextsOptional: [clearSignContexts[2]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with proxy delegate call context\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: \"payload-2\",\n },\n ];\n const clearSignContextsOptional: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[0]],\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should call the web3checks factory with correct parameters\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(getWeb3ChecksFactoryMock).toHaveBeenCalledWith(apiMock, {\n contextModule: contextModuleMock,\n derivationPath: \"44'/60'/0'/0/0\",\n subset: defaultArgs.subset,\n transaction: defaultTransaction,\n });\n });\n\n it(\"should call the context module with the correct parameters\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith({\n deviceModelId: DeviceModelId.FLEX,\n challenge: \"challenge\",\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n });\n });\n\n it(\"should call the context module without challenge for Nano S\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith({\n deviceModelId: DeviceModelId.NANO_S,\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n });\n });\n\n it(\"should call the context module without context on error\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({ error: new UnknownDeviceExchangeError() }),\n );\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith({\n deviceModelId: DeviceModelId.FLEX,\n challenge: undefined,\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n });\n });\n\n it(\"should exclude error contexts from the result\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result on old apps\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"transaction_info\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"transaction_field\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"enum\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result if no transaction_info was found\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"transaction_field\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"enum\",\n id: 1,\n value: 2,\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.14.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude legacy contexts from the result for generic-parser transactions\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-5\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [clearSignContexts[4]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should exclude generic-parser contexts with a nano s device\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.14.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts with an old app version\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts with a non ready device\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.NOT_CONNECTED,\n deviceModelId: DeviceModelId.FLEX,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should return no clear sign context if the transaction info certificate is missing\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.17.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should not return web3check if the transaction is undefined\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.17.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, transaction: undefined },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(getWeb3ChecksFactoryMock).not.toHaveBeenCalled();\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAKO,oCACPC,EAOO,2CACPC,EAA4B,kBAG5BC,EAAiC,uCACjCC,EAAgD,6EAEhDC,EAGO,+BACPC,EAAiC,8BAEjC,SAAS,oBAAqB,IAAM,CAClC,MAAMC,EAAoB,CACxB,WAAY,GAAG,GAAG,EAClB,YAAa,GAAG,GAAG,EACnB,oBAAqB,GAAG,GAAG,EAC3B,cAAe,GAAG,GAAG,EACrB,iBAAkB,GAAG,GAAG,CAC1B,EACMC,EAAiB,CACrB,OAAQ,iBACV,EACMC,KAAiC,sBACrC,cAAY,KAAK,CACf,QAAS,GACT,MAAO,EACP,KAAM,IACR,CAAC,EAAE,kBACL,EACMC,EAAqC,CACzC,eAAgB,EAChB,QAAS,IAAI,WAAW,CAAC,EAAM,EAAM,CAAI,CAAC,CAC5C,EAEA,IAAIC,EACJ,MAAMC,KAAU,mCAAgC,EAC1CC,EAA2B,GAAG,GAAG,EAEvC,SAASC,EACPC,EAC0B,CAC1B,MAAO,CACL,oBAAqB,GACrB,kBAAAA,EACA,gBAAiB,GACjB,QAAS,QACX,CACF,CAEA,WAAW,IAAM,CACf,GAAG,cAAc,EACjBH,EAAQ,YAAY,qBAClB,wBAAqB,CAAE,KAAM,CAAE,UAAW,WAAY,CAAE,CAAC,CAC3D,EACAC,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,\n type PkiCertificate,\n} from \"@ledgerhq/context-module\";\nimport {\n CommandResultFactory,\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n hexaStringToBuffer,\n UnknownDeviceExchangeError,\n} from \"@ledgerhq/device-management-kit\";\nimport { Transaction } from \"ethers\";\n\nimport type { GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\n\nimport {\n BuildBaseContexts,\n type BuildBaseContextsArgs,\n} from \"./BuildBaseContexts\";\nimport { GetWeb3CheckTask } from \"./GetWeb3CheckTask\";\n\ndescribe(\"BuildBaseContexts\", () => {\n const contextModuleMock = {\n getFieldContext: vi.fn(),\n getContexts: vi.fn(),\n getTypedDataFilters: vi.fn(),\n getWeb3Checks: vi.fn(),\n getSolanaContext: vi.fn(),\n getProxyDelegateCall: vi.fn(),\n };\n const defaultOptions = {\n domain: \"domain-name.eth\",\n };\n const defaultTransaction: Uint8Array = hexaStringToBuffer(\n Transaction.from({\n chainId: 1n,\n nonce: 0,\n data: \"0x\",\n }).unsignedSerialized,\n )!;\n const defaultCertificate: PkiCertificate = {\n keyUsageNumber: 1,\n payload: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n let defaultArgs: BuildBaseContextsArgs;\n const apiMock = makeDeviceActionInternalApiMock();\n const getWeb3ChecksFactoryMock = vi.fn();\n\n function createAppConfig(\n web3ChecksEnabled: boolean,\n ): GetConfigCommandResponse {\n return {\n blindSigningEnabled: false,\n web3ChecksEnabled,\n web3ChecksOptIn: false,\n version: \"1.13.0\",\n };\n }\n\n beforeEach(() => {\n vi.resetAllMocks();\n apiMock.sendCommand.mockResolvedValue(\n CommandResultFactory({ data: { challenge: \"challenge\" } }),\n );\n getWeb3ChecksFactoryMock.mockReturnValue({\n run: async () => Promise.resolve({ web3Check: null }),\n });\n\n defaultArgs = {\n contextModule: contextModuleMock,\n subset: { chainId: 1, to: undefined, data: \"0x\", selector: \"0x\" },\n transaction: defaultTransaction,\n options: defaultOptions,\n appConfig: createAppConfig(false),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n });\n\n it(\"should init with a default GetWeb3CheckTaskFactory\", () => {\n // GIVEN\n const task = new BuildBaseContexts(apiMock, defaultArgs);\n\n // THEN\n expect(task[\"getWeb3ChecksFactory\"]).toBeDefined();\n expect(\n task[\"getWeb3ChecksFactory\"](apiMock, {\n contextModule: defaultArgs.contextModule,\n derivationPath: defaultArgs.derivationPath,\n subset: defaultArgs.subset,\n transaction: defaultArgs.transaction!,\n }),\n ).toBeInstanceOf(GetWeb3CheckTask);\n });\n\n it(\"should build the transaction context without clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n const clearSignContextsOptional: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with web3checks\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n const clearSignContextsOptional: ClearSignContext[] = [];\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [expectedWeb3Check, ...clearSignContexts],\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with web3checks and generic-parser clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n ];\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n clearSignContexts[0],\n clearSignContexts[1],\n clearSignContexts[3],\n expectedWeb3Check,\n ],\n clearSignContextsOptional: [clearSignContexts[2]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with web3checks and generic-parser clear sign contexts in the correct order\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n ];\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n clearSignContexts[3], // transaction info\n clearSignContexts[1], // transaction field description\n clearSignContexts[2], // transaction field description\n expectedWeb3Check, // web3 check\n ],\n clearSignContextsOptional: [clearSignContexts[0]], // enum\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with generic-parser context\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n clearSignContexts[0],\n clearSignContexts[1],\n clearSignContexts[3],\n ],\n clearSignContextsOptional: [clearSignContexts[2]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with proxy delegate call context\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: \"payload-2\",\n },\n ];\n const clearSignContextsOptional: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[0]],\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should call the web3checks factory with correct parameters\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(getWeb3ChecksFactoryMock).toHaveBeenCalledWith(apiMock, {\n contextModule: contextModuleMock,\n derivationPath: \"44'/60'/0'/0/0\",\n subset: defaultArgs.subset,\n transaction: defaultTransaction,\n });\n });\n\n it(\"should call the context module with the correct parameters\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith({\n deviceModelId: DeviceModelId.FLEX,\n challenge: \"challenge\",\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n });\n });\n\n it(\"should call the context module without challenge for Nano S\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith({\n deviceModelId: DeviceModelId.NANO_S,\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n });\n });\n\n it(\"should call the context module without context on error\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({ error: new UnknownDeviceExchangeError() }),\n );\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith({\n deviceModelId: DeviceModelId.FLEX,\n challenge: undefined,\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n });\n });\n\n it(\"should exclude error contexts from the result\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result on old apps\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"transaction_info\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"transaction_field\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"enum\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result if no transaction_info was found\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"transaction_field\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"enum\",\n id: 1,\n value: 2,\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.14.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude legacy contexts from the result for generic-parser transactions\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-5\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [clearSignContexts[4]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should exclude generic-parser contexts with a nano s device\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.14.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts with an old app version\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts with a non ready device\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.NOT_CONNECTED,\n deviceModelId: DeviceModelId.FLEX,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should return no clear sign context if the transaction info certificate is missing\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.17.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should not return web3check if the transaction is undefined\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.17.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, transaction: undefined },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(getWeb3ChecksFactoryMock).not.toHaveBeenCalled();\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAKO,oCACPC,EAOO,2CACPC,EAA4B,kBAG5BC,EAAiC,uCACjCC,EAAgD,6EAEhDC,EAGO,+BACPC,EAAiC,8BAEjC,SAAS,oBA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,0BAA2B,EAC7B,CAAC,EAGD,MAAMO,EAAS,MAAM,IAAI,oBACvBP,EACAD,EACAE,CACF,EAAE,IAAI,EAGN,OAAOM,CAAM,EAAE,QAAQ,CACrB,kBAAmB,CAAC,EACpB,0BAA2B,CAAC,EAC5B,iBAAkB,mBAAiB,KACrC,CAAC,CACH,CAAC,EAED,GAAG,8DAA+D,SAAY,CAE5E,MAAMF,EAAwC,CAAC,EAC/CV,EAAkB,YAAY,sBAAsBU,CAAiB,EACrEL,EAAQ,sBAAsB,oBAAoB,CAChD,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,WAAY,QAAS,QAAS,EAClD,cAAe,gBAAc,KAC7B,0BAA2B,EAC7B,CAAC,EAGD,MAAM,IAAI,oBACRA,EACA,CAAE,GAAGD,EAAa,YAAa,MAAU,EACzCE,CACF,EAAE,IAAI,EAGN,OAAOA,CAAwB,EAAE,IAAI,iBAAiB,CACxD,CAAC,CACH,CAAC",
6
6
  "names": ["import_context_module", "import_device_management_kit", "import_ethers", "import_ClearSigningType", "import_makeInternalApi", "import_BuildBaseContexts", "import_GetWeb3CheckTask", "contextModuleMock", "defaultOptions", "defaultTransaction", "defaultCertificate", "defaultArgs", "apiMock", "getWeb3ChecksFactoryMock", "createAppConfig", "web3ChecksEnabled", "task", "clearSignContexts", "clearSignContextsOptional", "result", "expectedWeb3Check"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("@ledgerhq/device-management-kit"),e=require("purify-ts"),g=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),n=require("../../typed-data/model/Types"),m=require("./BuildEIP712ContextTask");describe("BuildEIP712ContextTask",()=>{const o=(0,g.makeDeviceActionInternalApiMock)(),i={getContext:vi.fn(),getContexts:vi.fn(),getTypedDataFilters:vi.fn(),getWeb3Checks:vi.fn(),getSolanaContext:vi.fn()},s={parse:vi.fn()},c=vi.fn();function f(a){return{blindSigningEnabled:!1,web3ChecksEnabled:a,web3ChecksOptIn:!1,version:"1.13.0"}}const r={domain:{name:"Permit2",chainId:137,verifyingContract:"0x000000000022d473030f116ddee9f6b43ac78ba3"},primaryType:"PermitSingle",message:{details:{token:"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",amount:"69420000000000000000",expiration:"1718184249",nonce:"0"},spender:"0xec7be89e9d109e7e3fec59c222cf297125fefda2",sigDeadline:"1715594049"},types:{PermitSingle:[{name:"details",type:"PermitDetails"},{name:"spender",type:"address"},{name:"sigDeadline",type:"uint256"}],PermitDetails:[{name:"token",type:"address"},{name:"amount",type:"uint"},{name:"expiration",type:"uint"},{name:"nonce",type:"uint"}]}},d={PermitSingle:{details:new n.StructType("PermitDetails"),spender:new n.PrimitiveType("address","address",e.Nothing),sigDeadline:new n.PrimitiveType("uint256","uint",(0,e.Just)(32))},PermitDetails:{token:new n.PrimitiveType("address","address",e.Nothing),amount:new n.PrimitiveType("uint160","uint",(0,e.Just)(20)),expiration:new n.PrimitiveType("uint48","uint",(0,e.Just)(6)),nonce:new n.PrimitiveType("uint48","uint",(0,e.Just)(6))}},u=[{path:"",type:"",value:new n.TypedDataValueRoot("EIP712Domain")},{path:"chainId",type:"uint256",value:new n.TypedDataValueField(Uint8Array.from([137]))}],p=[{path:"",type:"",value:new n.TypedDataValueRoot("PermitSingle")},{path:"details.amount",type:"uint160",value:new n.TypedDataValueField(Uint8Array.from([18]))},{path:"details.expiration",type:"uint48",value:new n.TypedDataValueField(Uint8Array.from([19]))}],C={type:"success",messageInfo:{displayName:"Permit2",filtersCount:1,signature:"3045022100e3c597d13d28a87a88b0239404c668373cf5063362f2a81d09eed4582941dfe802207669aabb504fd5b95b2734057f6b8bbf51f14a69a5f9bdf658a5952cefbf44d3"},trustedNamesAddresses:{},tokens:{},filters:{"details.amount":{displayName:"Amount allowance",path:"details.amount",signature:"304402201a46e6b4ef89eaf9fcf4945d053bfc5616a826400fd758312fbbe976bafc07ec022025a9b408722baf983ee053f90179c75b0c55bb0668f437d55493e36069bbd5a3",tokenIndex:255,type:"amount"}}};beforeEach(()=>{vi.resetAllMocks(),c.mockReturnValue({run:async()=>({web3Check:null})})}),it("Build context with clear signing context not supported by the device",async()=>{const a=new m.BuildEIP712ContextTask(o,i,s,r,"44'/60'/0'/0/0",f(!1),c);s.parse.mockReturnValueOnce((0,e.Right)({types:d,domain:u,message:p})),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:t.DeviceModelId.NANO_S,isSecureConnectionAllowed:!1});const l=await a.run();expect(l).toStrictEqual({web3Check:null,types:d,domain:u,message:p,clearSignContext:e.Nothing})}),it("Build context with no clear signing context",async()=>{const a=new m.BuildEIP712ContextTask(o,i,s,r,"44'/60'/0'/0/0",f(!1),c);s.parse.mockReturnValueOnce((0,e.Right)({types:d,domain:u,message:p})),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),i.getTypedDataFilters.mockResolvedValueOnce({type:"error",error:new Error("no filter")});const l=await a.run();expect(l).toStrictEqual({web3Check:null,types:d,domain:u,message:p,clearSignContext:e.Nothing})}),it("Build context with clear signing context",async()=>{const a="web3Check",l=new m.BuildEIP712ContextTask(o,i,s,r,"44'/60'/0'/0/0",f(!1),c);c.mockReturnValueOnce({run:async()=>({web3Check:a})}),s.parse.mockReturnValueOnce((0,e.Right)({types:d,domain:u,message:p})),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),i.getTypedDataFilters.mockResolvedValueOnce(C);const y=await l.run();expect(y).toStrictEqual({web3Check:null,types:d,domain:u,message:p,clearSignContext:(0,e.Just)(C)}),expect(s.parse).toHaveBeenCalledWith(r),expect(i.getTypedDataFilters).toHaveBeenCalledWith({verifyingContract:"0x000000000022d473030f116ddee9f6b43ac78ba3",chainId:137,version:"v2",schema:r.types,fieldsValues:[{path:"details.amount",value:Uint8Array.from([18])},{path:"details.expiration",value:Uint8Array.from([19])}]})}),it("Build context with clear signing context and web3Check",async()=>{const a="web3Check",l=new m.BuildEIP712ContextTask(o,i,s,r,"44'/60'/0'/0/0",f(!0),c);c.mockReturnValueOnce({run:async()=>({web3Check:a})}),s.parse.mockReturnValueOnce((0,e.Right)({types:d,domain:u,message:p})),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),i.getTypedDataFilters.mockResolvedValueOnce(C);const y=await l.run();expect(y).toStrictEqual({web3Check:a,types:d,domain:u,message:p,clearSignContext:(0,e.Just)(C)}),expect(c).toHaveBeenCalledWith(o,{contextModule:i,derivationPath:"44'/60'/0'/0/0",data:r})}),it("Build context with clear signing context V1",async()=>{const a=new m.BuildEIP712ContextTask(o,i,s,r,"44'/60'/0'/0/0",f(!1),c);s.parse.mockReturnValueOnce((0,e.Right)({types:d,domain:u,message:p})),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),i.getTypedDataFilters.mockResolvedValueOnce(C),await a.run(),expect(i.getTypedDataFilters).toHaveBeenCalledWith({verifyingContract:"0x000000000022d473030f116ddee9f6b43ac78ba3",chainId:137,version:"v1",schema:r.types,fieldsValues:[{path:"details.amount",value:Uint8Array.from([18])},{path:"details.expiration",value:Uint8Array.from([19])}]})}),it("Should throw an error if parsing fails",async()=>{const a=new m.BuildEIP712ContextTask(o,i,s,r,"44'/60'/0'/0/0",f(!1),c);s.parse.mockReturnValueOnce((0,e.Left)(new Error("Parsing error")));try{await a.run()}catch(l){expect(l).toBeInstanceOf(Error),expect(l.message).toBe("Parsing error")}})});
1
+ "use strict";var t=require("@ledgerhq/device-management-kit"),e=require("purify-ts"),g=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),n=require("../../typed-data/model/Types"),m=require("./BuildEIP712ContextTask");describe("BuildEIP712ContextTask",()=>{const o=(0,g.makeDeviceActionInternalApiMock)(),i={getFieldContext:vi.fn(),getContexts:vi.fn(),getTypedDataFilters:vi.fn(),getWeb3Checks:vi.fn(),getSolanaContext:vi.fn(),getProxyDelegateCall:vi.fn()},s={parse:vi.fn()},c=vi.fn();function f(a){return{blindSigningEnabled:!1,web3ChecksEnabled:a,web3ChecksOptIn:!1,version:"1.13.0"}}const r={domain:{name:"Permit2",chainId:137,verifyingContract:"0x000000000022d473030f116ddee9f6b43ac78ba3"},primaryType:"PermitSingle",message:{details:{token:"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",amount:"69420000000000000000",expiration:"1718184249",nonce:"0"},spender:"0xec7be89e9d109e7e3fec59c222cf297125fefda2",sigDeadline:"1715594049"},types:{PermitSingle:[{name:"details",type:"PermitDetails"},{name:"spender",type:"address"},{name:"sigDeadline",type:"uint256"}],PermitDetails:[{name:"token",type:"address"},{name:"amount",type:"uint"},{name:"expiration",type:"uint"},{name:"nonce",type:"uint"}]}},d={PermitSingle:{details:new n.StructType("PermitDetails"),spender:new n.PrimitiveType("address","address",e.Nothing),sigDeadline:new n.PrimitiveType("uint256","uint",(0,e.Just)(32))},PermitDetails:{token:new n.PrimitiveType("address","address",e.Nothing),amount:new n.PrimitiveType("uint160","uint",(0,e.Just)(20)),expiration:new n.PrimitiveType("uint48","uint",(0,e.Just)(6)),nonce:new n.PrimitiveType("uint48","uint",(0,e.Just)(6))}},u=[{path:"",type:"",value:new n.TypedDataValueRoot("EIP712Domain")},{path:"chainId",type:"uint256",value:new n.TypedDataValueField(Uint8Array.from([137]))}],p=[{path:"",type:"",value:new n.TypedDataValueRoot("PermitSingle")},{path:"details.amount",type:"uint160",value:new n.TypedDataValueField(Uint8Array.from([18]))},{path:"details.expiration",type:"uint48",value:new n.TypedDataValueField(Uint8Array.from([19]))}],C={type:"success",messageInfo:{displayName:"Permit2",filtersCount:1,signature:"3045022100e3c597d13d28a87a88b0239404c668373cf5063362f2a81d09eed4582941dfe802207669aabb504fd5b95b2734057f6b8bbf51f14a69a5f9bdf658a5952cefbf44d3"},trustedNamesAddresses:{},tokens:{},filters:{"details.amount":{displayName:"Amount allowance",path:"details.amount",signature:"304402201a46e6b4ef89eaf9fcf4945d053bfc5616a826400fd758312fbbe976bafc07ec022025a9b408722baf983ee053f90179c75b0c55bb0668f437d55493e36069bbd5a3",tokenIndex:255,type:"amount"}}};beforeEach(()=>{vi.resetAllMocks(),c.mockReturnValue({run:async()=>({web3Check:null})})}),it("Build context with clear signing context not supported by the device",async()=>{const a=new m.BuildEIP712ContextTask(o,i,s,r,"44'/60'/0'/0/0",f(!1),c);s.parse.mockReturnValueOnce((0,e.Right)({types:d,domain:u,message:p})),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:t.DeviceModelId.NANO_S,isSecureConnectionAllowed:!1});const l=await a.run();expect(l).toStrictEqual({web3Check:null,types:d,domain:u,message:p,clearSignContext:e.Nothing})}),it("Build context with no clear signing context",async()=>{const a=new m.BuildEIP712ContextTask(o,i,s,r,"44'/60'/0'/0/0",f(!1),c);s.parse.mockReturnValueOnce((0,e.Right)({types:d,domain:u,message:p})),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),i.getTypedDataFilters.mockResolvedValueOnce({type:"error",error:new Error("no filter")});const l=await a.run();expect(l).toStrictEqual({web3Check:null,types:d,domain:u,message:p,clearSignContext:e.Nothing})}),it("Build context with clear signing context",async()=>{const a="web3Check",l=new m.BuildEIP712ContextTask(o,i,s,r,"44'/60'/0'/0/0",f(!1),c);c.mockReturnValueOnce({run:async()=>({web3Check:a})}),s.parse.mockReturnValueOnce((0,e.Right)({types:d,domain:u,message:p})),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),i.getTypedDataFilters.mockResolvedValueOnce(C);const y=await l.run();expect(y).toStrictEqual({web3Check:null,types:d,domain:u,message:p,clearSignContext:(0,e.Just)(C)}),expect(s.parse).toHaveBeenCalledWith(r),expect(i.getTypedDataFilters).toHaveBeenCalledWith({verifyingContract:"0x000000000022d473030f116ddee9f6b43ac78ba3",chainId:137,version:"v2",schema:r.types,fieldsValues:[{path:"details.amount",value:Uint8Array.from([18])},{path:"details.expiration",value:Uint8Array.from([19])}]})}),it("Build context with clear signing context and web3Check",async()=>{const a="web3Check",l=new m.BuildEIP712ContextTask(o,i,s,r,"44'/60'/0'/0/0",f(!0),c);c.mockReturnValueOnce({run:async()=>({web3Check:a})}),s.parse.mockReturnValueOnce((0,e.Right)({types:d,domain:u,message:p})),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),i.getTypedDataFilters.mockResolvedValueOnce(C);const y=await l.run();expect(y).toStrictEqual({web3Check:a,types:d,domain:u,message:p,clearSignContext:(0,e.Just)(C)}),expect(c).toHaveBeenCalledWith(o,{contextModule:i,derivationPath:"44'/60'/0'/0/0",data:r})}),it("Build context with clear signing context V1",async()=>{const a=new m.BuildEIP712ContextTask(o,i,s,r,"44'/60'/0'/0/0",f(!1),c);s.parse.mockReturnValueOnce((0,e.Right)({types:d,domain:u,message:p})),o.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),i.getTypedDataFilters.mockResolvedValueOnce(C),await a.run(),expect(i.getTypedDataFilters).toHaveBeenCalledWith({verifyingContract:"0x000000000022d473030f116ddee9f6b43ac78ba3",chainId:137,version:"v1",schema:r.types,fieldsValues:[{path:"details.amount",value:Uint8Array.from([18])},{path:"details.expiration",value:Uint8Array.from([19])}]})}),it("Should throw an error if parsing fails",async()=>{const a=new m.BuildEIP712ContextTask(o,i,s,r,"44'/60'/0'/0/0",f(!1),c);s.parse.mockReturnValueOnce((0,e.Left)(new Error("Parsing error")));try{await a.run()}catch(l){expect(l).toBeInstanceOf(Error),expect(l.message).toBe("Parsing error")}})});
2
2
  //# sourceMappingURL=BuildEIP712ContextTask.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/task/BuildEIP712ContextTask.test.ts"],
4
- "sourcesContent": ["import type {\n ClearSignContextSuccess,\n ClearSignContextType,\n TypedDataClearSignContextSuccess,\n} from \"@ledgerhq/context-module\";\nimport {\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just, Left, Nothing, Right } from \"purify-ts\";\n\nimport type { GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\nimport {\n PrimitiveType,\n StructType,\n TypedDataValueField,\n TypedDataValueRoot,\n} from \"@internal/typed-data/model/Types\";\n\nimport { BuildEIP712ContextTask } from \"./BuildEIP712ContextTask\";\n\ndescribe(\"BuildEIP712ContextTask\", () => {\n const apiMock = makeDeviceActionInternalApiMock();\n const contextMouleMock = {\n getContext: vi.fn(),\n getContexts: vi.fn(),\n getTypedDataFilters: vi.fn(),\n getWeb3Checks: vi.fn(),\n getSolanaContext: vi.fn(),\n };\n const parserMock = {\n parse: vi.fn(),\n };\n const getWeb3ChecksFactoryMock = vi.fn();\n\n function createAppConfig(\n web3ChecksEnabled: boolean,\n ): GetConfigCommandResponse {\n return {\n blindSigningEnabled: false,\n web3ChecksEnabled,\n web3ChecksOptIn: false,\n version: \"1.13.0\",\n };\n }\n\n const TEST_DATA = {\n domain: {\n name: \"Permit2\",\n chainId: 137,\n verifyingContract: \"0x000000000022d473030f116ddee9f6b43ac78ba3\",\n },\n primaryType: \"PermitSingle\",\n message: {\n details: {\n token: \"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619\",\n amount: \"69420000000000000000\",\n expiration: \"1718184249\",\n nonce: \"0\",\n },\n spender: \"0xec7be89e9d109e7e3fec59c222cf297125fefda2\",\n sigDeadline: \"1715594049\",\n },\n types: {\n PermitSingle: [\n {\n name: \"details\",\n type: \"PermitDetails\",\n },\n {\n name: \"spender\",\n type: \"address\",\n },\n {\n name: \"sigDeadline\",\n type: \"uint256\",\n },\n ],\n PermitDetails: [\n { name: \"token\", type: \"address\" },\n { name: \"amount\", type: \"uint\" },\n { name: \"expiration\", type: \"uint\" },\n { name: \"nonce\", type: \"uint\" },\n ],\n },\n };\n\n const TEST_TYPES = {\n PermitSingle: {\n details: new StructType(\"PermitDetails\"),\n spender: new PrimitiveType(\"address\", \"address\", Nothing),\n sigDeadline: new PrimitiveType(\"uint256\", \"uint\", Just(32)),\n },\n PermitDetails: {\n token: new PrimitiveType(\"address\", \"address\", Nothing),\n amount: new PrimitiveType(\"uint160\", \"uint\", Just(20)),\n expiration: new PrimitiveType(\"uint48\", \"uint\", Just(6)),\n nonce: new PrimitiveType(\"uint48\", \"uint\", Just(6)),\n },\n };\n const TEST_DOMAIN_VALUES = [\n {\n path: \"\",\n type: \"\",\n value: new TypedDataValueRoot(\"EIP712Domain\"),\n },\n {\n path: \"chainId\",\n type: \"uint256\",\n value: new TypedDataValueField(Uint8Array.from([137])),\n },\n ];\n const TEST_MESSAGE_VALUES = [\n {\n path: \"\",\n type: \"\",\n value: new TypedDataValueRoot(\"PermitSingle\"),\n },\n {\n path: \"details.amount\",\n type: \"uint160\",\n value: new TypedDataValueField(Uint8Array.from([0x12])),\n },\n {\n path: \"details.expiration\",\n type: \"uint48\",\n value: new TypedDataValueField(Uint8Array.from([0x13])),\n },\n ];\n const TEST_CLEAR_SIGN_CONTEXT: TypedDataClearSignContextSuccess = {\n type: \"success\",\n messageInfo: {\n displayName: \"Permit2\",\n filtersCount: 1,\n signature:\n \"3045022100e3c597d13d28a87a88b0239404c668373cf5063362f2a81d09eed4582941dfe802207669aabb504fd5b95b2734057f6b8bbf51f14a69a5f9bdf658a5952cefbf44d3\",\n },\n trustedNamesAddresses: {},\n tokens: {},\n filters: {\n \"details.amount\": {\n displayName: \"Amount allowance\",\n path: \"details.amount\",\n signature:\n \"304402201a46e6b4ef89eaf9fcf4945d053bfc5616a826400fd758312fbbe976bafc07ec022025a9b408722baf983ee053f90179c75b0c55bb0668f437d55493e36069bbd5a3\",\n tokenIndex: 255,\n type: \"amount\",\n },\n },\n };\n\n beforeEach(() => {\n vi.resetAllMocks();\n getWeb3ChecksFactoryMock.mockReturnValue({\n run: async () => ({ web3Check: null }),\n });\n });\n\n it(\"Build context with clear signing context not supported by the device\", async () => {\n // GIVEN\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextMouleMock,\n parserMock,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(false),\n getWeb3ChecksFactoryMock,\n );\n parserMock.parse.mockReturnValueOnce(\n Right({\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n }),\n );\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n // WHEN\n const builtContext = await task.run();\n // THEN\n expect(builtContext).toStrictEqual({\n web3Check: null,\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n clearSignContext: Nothing,\n });\n });\n\n it(\"Build context with no clear signing context\", async () => {\n // GIVEN\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextMouleMock,\n parserMock,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(false),\n getWeb3ChecksFactoryMock,\n );\n parserMock.parse.mockReturnValueOnce(\n Right({\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n }),\n );\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n contextMouleMock.getTypedDataFilters.mockResolvedValueOnce({\n type: \"error\",\n error: new Error(\"no filter\"),\n });\n // WHEN\n const builtContext = await task.run();\n // THEN\n expect(builtContext).toStrictEqual({\n web3Check: null,\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n clearSignContext: Nothing,\n });\n });\n\n it(\"Build context with clear signing context\", async () => {\n // GIVEN\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextMouleMock,\n parserMock,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(false),\n getWeb3ChecksFactoryMock,\n );\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => ({ web3Check: expectedWeb3Check }),\n });\n parserMock.parse.mockReturnValueOnce(\n Right({\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n }),\n );\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n contextMouleMock.getTypedDataFilters.mockResolvedValueOnce(\n TEST_CLEAR_SIGN_CONTEXT,\n );\n // WHEN\n const builtContext = await task.run();\n // THEN\n expect(builtContext).toStrictEqual({\n web3Check: null,\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n clearSignContext: Just(TEST_CLEAR_SIGN_CONTEXT),\n });\n expect(parserMock.parse).toHaveBeenCalledWith(TEST_DATA);\n expect(contextMouleMock.getTypedDataFilters).toHaveBeenCalledWith({\n verifyingContract: \"0x000000000022d473030f116ddee9f6b43ac78ba3\",\n chainId: 137,\n version: \"v2\",\n schema: TEST_DATA[\"types\"],\n fieldsValues: [\n {\n path: \"details.amount\",\n value: Uint8Array.from([0x12]),\n },\n {\n path: \"details.expiration\",\n value: Uint8Array.from([0x13]),\n },\n ],\n });\n });\n\n it(\"Build context with clear signing context and web3Check\", async () => {\n // GIVEN\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextMouleMock,\n parserMock,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(true),\n getWeb3ChecksFactoryMock,\n );\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => ({ web3Check: expectedWeb3Check }),\n });\n parserMock.parse.mockReturnValueOnce(\n Right({\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n }),\n );\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n contextMouleMock.getTypedDataFilters.mockResolvedValueOnce(\n TEST_CLEAR_SIGN_CONTEXT,\n );\n // WHEN\n const builtContext = await task.run();\n // THEN\n expect(builtContext).toStrictEqual({\n web3Check: expectedWeb3Check,\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n clearSignContext: Just(TEST_CLEAR_SIGN_CONTEXT),\n });\n expect(getWeb3ChecksFactoryMock).toHaveBeenCalledWith(apiMock, {\n contextModule: contextMouleMock,\n derivationPath: \"44'/60'/0'/0/0\",\n data: TEST_DATA,\n });\n });\n\n it(\"Build context with clear signing context V1\", async () => {\n // GIVEN\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextMouleMock,\n parserMock,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(false),\n getWeb3ChecksFactoryMock,\n );\n parserMock.parse.mockReturnValueOnce(\n Right({\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n }),\n );\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n contextMouleMock.getTypedDataFilters.mockResolvedValueOnce(\n TEST_CLEAR_SIGN_CONTEXT,\n );\n // WHEN\n await task.run();\n // THEN\n expect(contextMouleMock.getTypedDataFilters).toHaveBeenCalledWith({\n verifyingContract: \"0x000000000022d473030f116ddee9f6b43ac78ba3\",\n chainId: 137,\n version: \"v1\",\n schema: TEST_DATA[\"types\"],\n fieldsValues: [\n {\n path: \"details.amount\",\n value: Uint8Array.from([0x12]),\n },\n {\n path: \"details.expiration\",\n value: Uint8Array.from([0x13]),\n },\n ],\n });\n });\n\n it(\"Should throw an error if parsing fails\", async () => {\n // GIVEN\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextMouleMock,\n parserMock,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(false),\n getWeb3ChecksFactoryMock,\n );\n parserMock.parse.mockReturnValueOnce(Left(new Error(\"Parsing error\")));\n // WHEN\n try {\n await task.run();\n } catch (e) {\n // THEN\n expect(e).toBeInstanceOf(Error);\n // @ts-expect-error\n expect(e.message).toBe(\"Parsing error\");\n }\n });\n});\n"],
5
- "mappings": "aAKA,IAAAA,EAIO,2CACPC,EAA2C,qBAG3CC,EAAgD,6EAChDC,EAKO,4CAEPC,EAAuC,oCAEvC,SAAS,yBAA0B,IAAM,CACvC,MAAMC,KAAU,mCAAgC,EAC1CC,EAAmB,CACvB,WAAY,GAAG,GAAG,EAClB,YAAa,GAAG,GAAG,EACnB,oBAAqB,GAAG,GAAG,EAC3B,cAAe,GAAG,GAAG,EACrB,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EAAQ,sBAAsB,oBAAoB,CAChD,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,WAAY,QAAS,QAAS,EAClD,cAAe,gBAAc,KAC7B,0BAA2B,EAC7B,CAAC,EACDC,EAAiB,oBAAoB,sBACnCS,CACF,EAEA,MAAMC,EAAK,IAAI,EAEf,OAAOV,EAAiB,mBAAmB,EAAE,qBAAqB,CAChE,kBAAmB,6CACnB,QAAS,IACT,QAAS,KACT,OAAQK,EAAU,MAClB,aAAc,CACZ,CACE,KAAM,iBACN,MAAO,WAAW,KAAK,CAAC,EAAI,CAAC,CAC/B,EACA,CACE,KAAM,qBACN,MAAO,WAAW,KAAK,CAAC,EAAI,CAAC,CAC/B,CACF,CACF,CAAC,CACH,CAAC,EAED,GAAG,yCAA0C,SAAY,CAEvD,MAAMK,EAAO,IAAI,yBACfX,EACAC,EACAC,EACAI,EACA,iBACAF,EAAgB,EAAK,EACrBD,CACF,EACAD,EAAW,MAAM,uBAAoB,QAAK,IAAI,MAAM,eAAe,CAAC,CAAC,EAErE,GAAI,CACF,MAAMS,EAAK,IAAI,CACjB,OAASG,EAAG,CAEV,OAAOA,CAAC,EAAE,eAAe,KAAK,EAE9B,OAAOA,EAAE,OAAO,EAAE,KAAK,eAAe,CACxC,CACF,CAAC,CACH,CAAC",
4
+ "sourcesContent": ["import type {\n ClearSignContextSuccess,\n ClearSignContextType,\n TypedDataClearSignContextSuccess,\n} from \"@ledgerhq/context-module\";\nimport {\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just, Left, Nothing, Right } from \"purify-ts\";\n\nimport type { GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\nimport {\n PrimitiveType,\n StructType,\n TypedDataValueField,\n TypedDataValueRoot,\n} from \"@internal/typed-data/model/Types\";\n\nimport { BuildEIP712ContextTask } from \"./BuildEIP712ContextTask\";\n\ndescribe(\"BuildEIP712ContextTask\", () => {\n const apiMock = makeDeviceActionInternalApiMock();\n const contextMouleMock = {\n getFieldContext: vi.fn(),\n getContexts: vi.fn(),\n getTypedDataFilters: vi.fn(),\n getWeb3Checks: vi.fn(),\n getSolanaContext: vi.fn(),\n getProxyDelegateCall: vi.fn(),\n };\n const parserMock = {\n parse: vi.fn(),\n };\n const getWeb3ChecksFactoryMock = vi.fn();\n\n function createAppConfig(\n web3ChecksEnabled: boolean,\n ): GetConfigCommandResponse {\n return {\n blindSigningEnabled: false,\n web3ChecksEnabled,\n web3ChecksOptIn: false,\n version: \"1.13.0\",\n };\n }\n\n const TEST_DATA = {\n domain: {\n name: \"Permit2\",\n chainId: 137,\n verifyingContract: \"0x000000000022d473030f116ddee9f6b43ac78ba3\",\n },\n primaryType: \"PermitSingle\",\n message: {\n details: {\n token: \"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619\",\n amount: \"69420000000000000000\",\n expiration: \"1718184249\",\n nonce: \"0\",\n },\n spender: \"0xec7be89e9d109e7e3fec59c222cf297125fefda2\",\n sigDeadline: \"1715594049\",\n },\n types: {\n PermitSingle: [\n {\n name: \"details\",\n type: \"PermitDetails\",\n },\n {\n name: \"spender\",\n type: \"address\",\n },\n {\n name: \"sigDeadline\",\n type: \"uint256\",\n },\n ],\n PermitDetails: [\n { name: \"token\", type: \"address\" },\n { name: \"amount\", type: \"uint\" },\n { name: \"expiration\", type: \"uint\" },\n { name: \"nonce\", type: \"uint\" },\n ],\n },\n };\n\n const TEST_TYPES = {\n PermitSingle: {\n details: new StructType(\"PermitDetails\"),\n spender: new PrimitiveType(\"address\", \"address\", Nothing),\n sigDeadline: new PrimitiveType(\"uint256\", \"uint\", Just(32)),\n },\n PermitDetails: {\n token: new PrimitiveType(\"address\", \"address\", Nothing),\n amount: new PrimitiveType(\"uint160\", \"uint\", Just(20)),\n expiration: new PrimitiveType(\"uint48\", \"uint\", Just(6)),\n nonce: new PrimitiveType(\"uint48\", \"uint\", Just(6)),\n },\n };\n const TEST_DOMAIN_VALUES = [\n {\n path: \"\",\n type: \"\",\n value: new TypedDataValueRoot(\"EIP712Domain\"),\n },\n {\n path: \"chainId\",\n type: \"uint256\",\n value: new TypedDataValueField(Uint8Array.from([137])),\n },\n ];\n const TEST_MESSAGE_VALUES = [\n {\n path: \"\",\n type: \"\",\n value: new TypedDataValueRoot(\"PermitSingle\"),\n },\n {\n path: \"details.amount\",\n type: \"uint160\",\n value: new TypedDataValueField(Uint8Array.from([0x12])),\n },\n {\n path: \"details.expiration\",\n type: \"uint48\",\n value: new TypedDataValueField(Uint8Array.from([0x13])),\n },\n ];\n const TEST_CLEAR_SIGN_CONTEXT: TypedDataClearSignContextSuccess = {\n type: \"success\",\n messageInfo: {\n displayName: \"Permit2\",\n filtersCount: 1,\n signature:\n \"3045022100e3c597d13d28a87a88b0239404c668373cf5063362f2a81d09eed4582941dfe802207669aabb504fd5b95b2734057f6b8bbf51f14a69a5f9bdf658a5952cefbf44d3\",\n },\n trustedNamesAddresses: {},\n tokens: {},\n filters: {\n \"details.amount\": {\n displayName: \"Amount allowance\",\n path: \"details.amount\",\n signature:\n \"304402201a46e6b4ef89eaf9fcf4945d053bfc5616a826400fd758312fbbe976bafc07ec022025a9b408722baf983ee053f90179c75b0c55bb0668f437d55493e36069bbd5a3\",\n tokenIndex: 255,\n type: \"amount\",\n },\n },\n };\n\n beforeEach(() => {\n vi.resetAllMocks();\n getWeb3ChecksFactoryMock.mockReturnValue({\n run: async () => ({ web3Check: null }),\n });\n });\n\n it(\"Build context with clear signing context not supported by the device\", async () => {\n // GIVEN\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextMouleMock,\n parserMock,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(false),\n getWeb3ChecksFactoryMock,\n );\n parserMock.parse.mockReturnValueOnce(\n Right({\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n }),\n );\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n // WHEN\n const builtContext = await task.run();\n // THEN\n expect(builtContext).toStrictEqual({\n web3Check: null,\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n clearSignContext: Nothing,\n });\n });\n\n it(\"Build context with no clear signing context\", async () => {\n // GIVEN\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextMouleMock,\n parserMock,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(false),\n getWeb3ChecksFactoryMock,\n );\n parserMock.parse.mockReturnValueOnce(\n Right({\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n }),\n );\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n contextMouleMock.getTypedDataFilters.mockResolvedValueOnce({\n type: \"error\",\n error: new Error(\"no filter\"),\n });\n // WHEN\n const builtContext = await task.run();\n // THEN\n expect(builtContext).toStrictEqual({\n web3Check: null,\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n clearSignContext: Nothing,\n });\n });\n\n it(\"Build context with clear signing context\", async () => {\n // GIVEN\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextMouleMock,\n parserMock,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(false),\n getWeb3ChecksFactoryMock,\n );\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => ({ web3Check: expectedWeb3Check }),\n });\n parserMock.parse.mockReturnValueOnce(\n Right({\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n }),\n );\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n contextMouleMock.getTypedDataFilters.mockResolvedValueOnce(\n TEST_CLEAR_SIGN_CONTEXT,\n );\n // WHEN\n const builtContext = await task.run();\n // THEN\n expect(builtContext).toStrictEqual({\n web3Check: null,\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n clearSignContext: Just(TEST_CLEAR_SIGN_CONTEXT),\n });\n expect(parserMock.parse).toHaveBeenCalledWith(TEST_DATA);\n expect(contextMouleMock.getTypedDataFilters).toHaveBeenCalledWith({\n verifyingContract: \"0x000000000022d473030f116ddee9f6b43ac78ba3\",\n chainId: 137,\n version: \"v2\",\n schema: TEST_DATA[\"types\"],\n fieldsValues: [\n {\n path: \"details.amount\",\n value: Uint8Array.from([0x12]),\n },\n {\n path: \"details.expiration\",\n value: Uint8Array.from([0x13]),\n },\n ],\n });\n });\n\n it(\"Build context with clear signing context and web3Check\", async () => {\n // GIVEN\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextMouleMock,\n parserMock,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(true),\n getWeb3ChecksFactoryMock,\n );\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => ({ web3Check: expectedWeb3Check }),\n });\n parserMock.parse.mockReturnValueOnce(\n Right({\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n }),\n );\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n contextMouleMock.getTypedDataFilters.mockResolvedValueOnce(\n TEST_CLEAR_SIGN_CONTEXT,\n );\n // WHEN\n const builtContext = await task.run();\n // THEN\n expect(builtContext).toStrictEqual({\n web3Check: expectedWeb3Check,\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n clearSignContext: Just(TEST_CLEAR_SIGN_CONTEXT),\n });\n expect(getWeb3ChecksFactoryMock).toHaveBeenCalledWith(apiMock, {\n contextModule: contextMouleMock,\n derivationPath: \"44'/60'/0'/0/0\",\n data: TEST_DATA,\n });\n });\n\n it(\"Build context with clear signing context V1\", async () => {\n // GIVEN\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextMouleMock,\n parserMock,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(false),\n getWeb3ChecksFactoryMock,\n );\n parserMock.parse.mockReturnValueOnce(\n Right({\n types: TEST_TYPES,\n domain: TEST_DOMAIN_VALUES,\n message: TEST_MESSAGE_VALUES,\n }),\n );\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n contextMouleMock.getTypedDataFilters.mockResolvedValueOnce(\n TEST_CLEAR_SIGN_CONTEXT,\n );\n // WHEN\n await task.run();\n // THEN\n expect(contextMouleMock.getTypedDataFilters).toHaveBeenCalledWith({\n verifyingContract: \"0x000000000022d473030f116ddee9f6b43ac78ba3\",\n chainId: 137,\n version: \"v1\",\n schema: TEST_DATA[\"types\"],\n fieldsValues: [\n {\n path: \"details.amount\",\n value: Uint8Array.from([0x12]),\n },\n {\n path: \"details.expiration\",\n value: Uint8Array.from([0x13]),\n },\n ],\n });\n });\n\n it(\"Should throw an error if parsing fails\", async () => {\n // GIVEN\n const task = new BuildEIP712ContextTask(\n apiMock,\n contextMouleMock,\n parserMock,\n TEST_DATA,\n \"44'/60'/0'/0/0\",\n createAppConfig(false),\n getWeb3ChecksFactoryMock,\n );\n parserMock.parse.mockReturnValueOnce(Left(new Error(\"Parsing error\")));\n // WHEN\n try {\n await task.run();\n } catch (e) {\n // THEN\n expect(e).toBeInstanceOf(Error);\n // @ts-expect-error\n expect(e.message).toBe(\"Parsing error\");\n }\n });\n});\n"],
5
+ "mappings": "aAKA,IAAAA,EAIO,2CACPC,EAA2C,qBAG3CC,EAAgD,6EAChDC,EAKO,4CAEPC,EAAuC,oCAEvC,SAAS,yBAA0B,IAAM,CACvC,MAAMC,KAAU,mCAAgC,EAC1CC,EAAmB,CACvB,gBAAiB,GAAG,GAAG,EACvB,YAAa,GAAG,GAAG,EACnB,oBAAqB,GAAG,GAAG,EAC3B,cAAe,GAAG,GAAG,EACrB,iBAAkB,GAAG,GAAG,EACxB,qBAAsB,GAAG,GAAG,CAC9B,EACMC,EAAa,CACjB,MAAO,GAAG,GAAG,CACf,EACMC,EAA2B,GAAG,GAAG,EAEvC,SAASC,EACPC,EAC0B,CAC1B,MAAO,CACL,oBAAqB,GACrB,kBAAAA,EACA,gBAAiB,GACjB,QAAS,QACX,CACF,CAEA,MAAMC,EAAY,CAChB,OAAQ,CACN,KAAM,UACN,QAAS,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AAiB,mBAAmB,EAAE,qBAAqB,CAChE,kBAAmB,6CACnB,QAAS,IACT,QAAS,KACT,OAAQK,EAAU,MAClB,aAAc,CACZ,CACE,KAAM,iBACN,MAAO,WAAW,KAAK,CAAC,EAAI,CAAC,CAC/B,EACA,CACE,KAAM,qBACN,MAAO,WAAW,KAAK,CAAC,EAAI,CAAC,CAC/B,CACF,CACF,CAAC,CACH,CAAC,EAED,GAAG,yCAA0C,SAAY,CAEvD,MAAMK,EAAO,IAAI,yBACfX,EACAC,EACAC,EACAI,EACA,iBACAF,EAAgB,EAAK,EACrBD,CACF,EACAD,EAAW,MAAM,uBAAoB,QAAK,IAAI,MAAM,eAAe,CAAC,CAAC,EAErE,GAAI,CACF,MAAMS,EAAK,IAAI,CACjB,OAASG,EAAG,CAEV,OAAOA,CAAC,EAAE,eAAe,KAAK,EAE9B,OAAOA,EAAE,OAAO,EAAE,KAAK,eAAe,CACxC,CACF,CAAC,CACH,CAAC",
6
6
  "names": ["import_device_management_kit", "import_purify_ts", "import_makeInternalApi", "import_Types", "import_BuildEIP712ContextTask", "apiMock", "contextMouleMock", "parserMock", "getWeb3ChecksFactoryMock", "createAppConfig", "web3ChecksEnabled", "TEST_DATA", "TEST_TYPES", "TEST_DOMAIN_VALUES", "TEST_MESSAGE_VALUES", "TEST_CLEAR_SIGN_CONTEXT", "task", "builtContext", "expectedWeb3Check", "e"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var p=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var b=(n,e)=>{for(var a in e)p(n,a,{get:e[a],enumerable:!0})},m=(n,e,a,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of T(e))!S.call(n,s)&&s!==a&&p(n,s,{get:()=>e[s],enumerable:!(o=g(e,s))||o.enumerable});return n};var h=n=>m(p({},"__esModule",{value:!0}),n);var _={};b(_,{BuildFullContextsTask:()=>c});module.exports=h(_);var l=require("@ledgerhq/context-module"),u=require("./BuildBaseContexts"),x=require("./BuildSubcontextsTask"),C=require("./ParseNestedTransactionTask");class c{constructor(e,a,o=(t,r)=>new x.BuildSubcontextsTask(t,r),s=(t,r)=>new u.BuildBaseContexts(t,r),i=t=>new C.ParseNestedTransactionTask(t)){this._api=e;this._args=a;this._buildSubcontextsTaskFactory=o;this._buildBaseContextsTaskFactory=s;this._preBuildNestedCallDataTaskFactory=i}async run(){const{clearSignContexts:e,clearSigningType:a,clearSignContextsOptional:o}=await this._buildBaseContextsTaskFactory(this._api,this._args).run(),s=e.map(t=>{const{subcontextCallbacks:r}=this._buildSubcontextsTaskFactory(this._api,{context:t,contextOptional:o,contextModule:this._args.contextModule,subset:this._args.subset,transactionParser:this._args.parser}).run();return{context:t,subcontextCallbacks:r}});let i=[];for(const t of s)if(t.context.type===l.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION&&t.context.reference?.type===l.ClearSignContextReferenceType.CALLDATA){const{subsets:r}=this._preBuildNestedCallDataTaskFactory({parser:this._args.parser,subset:this._args.subset,context:t.context}).run();for(const d of r){const{clearSignContexts:y}=await new c(this._api,{...this._args,subset:d},this._buildSubcontextsTaskFactory,this._buildBaseContextsTaskFactory,this._preBuildNestedCallDataTaskFactory).run();i=[...i,...y,t]}}else i.push(t);return{clearSignContexts:i,clearSigningType:a}}}0&&(module.exports={BuildFullContextsTask});
1
+ "use strict";var c=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var b=(n,e)=>{for(var a in e)c(n,a,{get:e[a],enumerable:!0})},m=(n,e,a,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of T(e))!S.call(n,s)&&s!==a&&c(n,s,{get:()=>e[s],enumerable:!(r=g(e,s))||r.enumerable});return n};var h=n=>m(c({},"__esModule",{value:!0}),n);var _={};b(_,{BuildFullContextsTask:()=>p});module.exports=h(_);var l=require("@ledgerhq/context-module"),d=require("./BuildBaseContexts"),u=require("./BuildSubcontextsTask"),x=require("./ParseNestedTransactionTask");class p{constructor(e,a,r=(t,o)=>new u.BuildSubcontextsTask(t,o),s=(t,o)=>new d.BuildBaseContexts(t,o),i=t=>new x.ParseNestedTransactionTask(t)){this._api=e;this._args=a;this._buildSubcontextsTaskFactory=r;this._buildBaseContextsTaskFactory=s;this._preBuildNestedCallDataTaskFactory=i}async run(){const{clearSignContexts:e,clearSigningType:a,clearSignContextsOptional:r}=await this._buildBaseContextsTaskFactory(this._api,this._args).run(),s=e.map(t=>{const{subcontextCallbacks:o}=this._buildSubcontextsTaskFactory(this._api,{context:t,contextOptional:r,contextModule:this._args.contextModule,subset:this._args.subset,transactionParser:this._args.parser,deviceModelId:this._args.deviceModelId}).run();return{context:t,subcontextCallbacks:o}});let i=[];for(const t of s)if(t.context.type===l.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION&&t.context.reference?.type===l.ClearSignContextReferenceType.CALLDATA){const{subsets:o}=this._preBuildNestedCallDataTaskFactory({parser:this._args.parser,subset:this._args.subset,context:t.context}).run();for(const C of o){const{clearSignContexts:y}=await new p(this._api,{...this._args,subset:C},this._buildSubcontextsTaskFactory,this._buildBaseContextsTaskFactory,this._preBuildNestedCallDataTaskFactory).run();i=[...i,...y,t]}}else i.push(t);return{clearSignContexts:i,clearSigningType:a}}}0&&(module.exports={BuildFullContextsTask});
2
2
  //# sourceMappingURL=BuildFullContextsTask.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/task/BuildFullContextsTask.ts"],
4
- "sourcesContent": ["import {\n type ClearSignContext,\n ClearSignContextReferenceType,\n type ClearSignContextSuccess,\n ClearSignContextType,\n type ContextModule,\n type TransactionSubset,\n} from \"@ledgerhq/context-module\";\nimport { type InternalApi } from \"@ledgerhq/device-management-kit\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { type ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { type TransactionOptions } from \"@api/model/TransactionOptions\";\nimport { type TransactionMapperService } from \"@internal/transaction/service/mapper/TransactionMapperService\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\n\nimport {\n BuildBaseContexts,\n type BuildBaseContextsArgs,\n} from \"./BuildBaseContexts\";\nimport {\n BuildSubcontextsTask,\n type BuildSubcontextsTaskArgs,\n} from \"./BuildSubcontextsTask\";\nimport {\n ParseNestedTransactionTask,\n type ParseNestedTransactionTaskArgs,\n} from \"./ParseNestedTransactionTask\";\n\nexport type BuildFullContextsTaskResult = {\n readonly clearSignContexts: ContextWithSubContexts[];\n readonly clearSigningType: ClearSigningType;\n};\n\nexport type BuildFullContextsTaskArgs = {\n readonly contextModule: ContextModule;\n readonly mapper: TransactionMapperService;\n readonly parser: TransactionParserService;\n readonly options: TransactionOptions;\n readonly appConfig: GetConfigCommandResponse;\n readonly derivationPath: string;\n readonly subset: TransactionSubset;\n readonly transaction?: Uint8Array;\n};\n\nexport type ContextWithSubContexts = {\n context: ClearSignContextSuccess;\n subcontextCallbacks: (() => Promise<ClearSignContext>)[];\n};\n\nexport class BuildFullContextsTask {\n constructor(\n private readonly _api: InternalApi,\n private readonly _args: BuildFullContextsTaskArgs,\n private readonly _buildSubcontextsTaskFactory = (\n api: InternalApi,\n args: BuildSubcontextsTaskArgs,\n ) => new BuildSubcontextsTask(api, args),\n private readonly _buildBaseContextsTaskFactory = (\n api: InternalApi,\n args: BuildBaseContextsArgs,\n ) => new BuildBaseContexts(api, args),\n private readonly _preBuildNestedCallDataTaskFactory = (\n args: ParseNestedTransactionTaskArgs,\n ) => new ParseNestedTransactionTask(args),\n ) {}\n\n async run(): Promise<BuildFullContextsTaskResult> {\n // get the base contexts\n const { clearSignContexts, clearSigningType, clearSignContextsOptional } =\n await this._buildBaseContextsTaskFactory(this._api, this._args).run();\n\n // for each context, build the subcontexts\n const contextsWithSubContexts: ContextWithSubContexts[] =\n clearSignContexts.map((context: ClearSignContextSuccess) => {\n const { subcontextCallbacks } = this._buildSubcontextsTaskFactory(\n this._api,\n {\n context,\n contextOptional: clearSignContextsOptional,\n contextModule: this._args.contextModule,\n subset: this._args.subset,\n transactionParser: this._args.parser,\n },\n ).run();\n\n return {\n context,\n subcontextCallbacks,\n };\n });\n\n // recursively build the nested contexts\n let contextWithNestedContexts: ContextWithSubContexts[] = [];\n for (const context of contextsWithSubContexts) {\n if (\n context.context.type ===\n ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION &&\n context.context.reference?.type ===\n ClearSignContextReferenceType.CALLDATA\n ) {\n const { subsets } = this._preBuildNestedCallDataTaskFactory({\n parser: this._args.parser,\n subset: this._args.subset,\n context: context.context,\n }).run();\n\n for (const subset of subsets) {\n const { clearSignContexts: nestedContexts } =\n await new BuildFullContextsTask(\n this._api,\n {\n ...this._args,\n subset,\n },\n // inject the factories for testing\n this._buildSubcontextsTaskFactory,\n this._buildBaseContextsTaskFactory,\n this._preBuildNestedCallDataTaskFactory,\n ).run();\n\n // TODO: this order will change with app optimizations\n // currently the order is:\n // previous contexts, nested transaction info and nested fields, calldata field from the parent,\n // futurre order:\n // previous contexts, nested transaction info, calldata field from the parent, then nested fields\n contextWithNestedContexts = [\n ...contextWithNestedContexts, // previous contexts\n ...nestedContexts, // nested transaction info and nested fields\n context, // calldatafield from the parent,\n ];\n }\n } else {\n contextWithNestedContexts.push(context);\n }\n }\n\n return {\n clearSignContexts: contextWithNestedContexts,\n clearSigningType,\n };\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,2BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAOO,oCASPC,EAGO,+BACPC,EAGO,kCACPC,EAGO,wCAuBA,MAAML,CAAsB,CACjC,YACmBM,EACAC,EACAC,EAA+B,CAC9CC,EACAC,IACG,IAAI,uBAAqBD,EAAKC,CAAI,EACtBC,EAAgC,CAC/CF,EACAC,IACG,IAAI,oBAAkBD,E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ClearSignContextSuccess,\n ClearSignContextType,\n type ContextModule,\n type TransactionSubset,\n} from \"@ledgerhq/context-module\";\nimport {\n type DeviceModelId,\n type InternalApi,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { type ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { type TransactionOptions } from \"@api/model/TransactionOptions\";\nimport { type TransactionMapperService } from \"@internal/transaction/service/mapper/TransactionMapperService\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\n\nimport {\n BuildBaseContexts,\n type BuildBaseContextsArgs,\n} from \"./BuildBaseContexts\";\nimport {\n BuildSubcontextsTask,\n type BuildSubcontextsTaskArgs,\n} from \"./BuildSubcontextsTask\";\nimport {\n ParseNestedTransactionTask,\n type ParseNestedTransactionTaskArgs,\n} from \"./ParseNestedTransactionTask\";\n\nexport type BuildFullContextsTaskResult = {\n readonly clearSignContexts: ContextWithSubContexts[];\n readonly clearSigningType: ClearSigningType;\n};\n\nexport type BuildFullContextsTaskArgs = {\n readonly contextModule: ContextModule;\n readonly mapper: TransactionMapperService;\n readonly parser: TransactionParserService;\n readonly options: TransactionOptions;\n readonly appConfig: GetConfigCommandResponse;\n readonly derivationPath: string;\n readonly subset: TransactionSubset;\n readonly deviceModelId: DeviceModelId;\n readonly transaction?: Uint8Array;\n};\n\nexport type ContextWithSubContexts = {\n context: ClearSignContextSuccess;\n subcontextCallbacks: (() => Promise<ClearSignContext>)[];\n};\n\nexport class BuildFullContextsTask {\n constructor(\n private readonly _api: InternalApi,\n private readonly _args: BuildFullContextsTaskArgs,\n private readonly _buildSubcontextsTaskFactory = (\n api: InternalApi,\n args: BuildSubcontextsTaskArgs,\n ) => new BuildSubcontextsTask(api, args),\n private readonly _buildBaseContextsTaskFactory = (\n api: InternalApi,\n args: BuildBaseContextsArgs,\n ) => new BuildBaseContexts(api, args),\n private readonly _preBuildNestedCallDataTaskFactory = (\n args: ParseNestedTransactionTaskArgs,\n ) => new ParseNestedTransactionTask(args),\n ) {}\n\n async run(): Promise<BuildFullContextsTaskResult> {\n // get the base contexts\n const { clearSignContexts, clearSigningType, clearSignContextsOptional } =\n await this._buildBaseContextsTaskFactory(this._api, this._args).run();\n\n // for each context, build the subcontexts\n const contextsWithSubContexts: ContextWithSubContexts[] =\n clearSignContexts.map((context: ClearSignContextSuccess) => {\n const { subcontextCallbacks } = this._buildSubcontextsTaskFactory(\n this._api,\n {\n context,\n contextOptional: clearSignContextsOptional,\n contextModule: this._args.contextModule,\n subset: this._args.subset,\n transactionParser: this._args.parser,\n deviceModelId: this._args.deviceModelId,\n },\n ).run();\n\n return {\n context,\n subcontextCallbacks,\n };\n });\n\n // recursively build the nested contexts\n let contextWithNestedContexts: ContextWithSubContexts[] = [];\n for (const context of contextsWithSubContexts) {\n if (\n context.context.type ===\n ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION &&\n context.context.reference?.type ===\n ClearSignContextReferenceType.CALLDATA\n ) {\n const { subsets } = this._preBuildNestedCallDataTaskFactory({\n parser: this._args.parser,\n subset: this._args.subset,\n context: context.context,\n }).run();\n\n for (const subset of subsets) {\n const { clearSignContexts: nestedContexts } =\n await new BuildFullContextsTask(\n this._api,\n {\n ...this._args,\n subset,\n },\n // inject the factories for testing\n this._buildSubcontextsTaskFactory,\n this._buildBaseContextsTaskFactory,\n this._preBuildNestedCallDataTaskFactory,\n ).run();\n\n // TODO: this order will change with app optimizations\n // currently the order is:\n // previous contexts, nested transaction info and nested fields, calldata field from the parent,\n // futurre order:\n // previous contexts, nested transaction info, calldata field from the parent, then nested fields\n contextWithNestedContexts = [\n ...contextWithNestedContexts, // previous contexts\n ...nestedContexts, // nested transaction info and nested fields\n context, // calldatafield from the parent,\n ];\n }\n } else {\n contextWithNestedContexts.push(context);\n }\n }\n\n return {\n clearSignContexts: contextWithNestedContexts,\n clearSigningType,\n };\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,G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ACE,GAAG,KAAK,MACR,OAAAqB,CACF,EAEA,KAAK,6BACL,KAAK,8BACL,KAAK,kCACP,EAAE,IAAI,EAORF,EAA4B,CAC1B,GAAGA,EACH,GAAGG,EACHL,CACF,CACF,CACF,MACEE,EAA0B,KAAKF,CAAO,EAI1C,MAAO,CACL,kBAAmBE,EACnB,iBAAAL,CACF,CACF,CACF",
6
6
  "names": ["BuildFullContextsTask_exports", "__export", "BuildFullContextsTask", "__toCommonJS", "import_context_module", "import_BuildBaseContexts", "import_BuildSubcontextsTask", "import_ParseNestedTransactionTask", "_api", "_args", "_buildSubcontextsTaskFactory", "api", "args", "_buildBaseContextsTaskFactory", "_preBuildNestedCallDataTaskFactory", "clearSignContexts", "clearSigningType", "clearSignContextsOptional", "contextsWithSubContexts", "context", "subcontextCallbacks", "contextWithNestedContexts", "subsets", "subset", "nestedContexts"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("@ledgerhq/context-module"),o=require("../../../api/model/ClearSigningType"),b=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),I=require("./BuildBaseContexts"),c=require("./BuildFullContextsTask"),N=require("./BuildSubcontextsTask"),g=require("./ParseNestedTransactionTask");describe("BuildFullContextsTask",()=>{const n=(0,b.makeDeviceActionInternalApiMock)(),l={},p={},r={},i={blindSigningEnabled:!1,web3ChecksEnabled:!1,web3ChecksOptIn:!1,version:"1.0.0"},u={},d={chainId:1,data:"0x",selector:"0x"},y="44'/60'/0'/0/0",x=vi.fn(),T=(a,e)=>({run:x}),s=vi.fn(),C=(a,e)=>({run:s}),k=vi.fn(),S=a=>({run:k});describe("Init",()=>{it("should init with defaults tasks",()=>{const a=new c.BuildFullContextsTask(n,{contextModule:l,mapper:p,parser:r,options:u,appConfig:i,derivationPath:y,subset:d});expect(a).toBeDefined(),expect(a._buildSubcontextsTaskFactory(n,{})).toBeInstanceOf(N.BuildSubcontextsTask),expect(a._buildBaseContextsTaskFactory(n,{})).toBeInstanceOf(I.BuildBaseContexts),expect(a._preBuildNestedCallDataTaskFactory({})).toBeInstanceOf(g.ParseNestedTransactionTask)})}),describe("Happy path",()=>{beforeEach(()=>{vi.resetAllMocks()}),it("should build with no context",async()=>{s.mockReturnValue({clearSignContexts:[],clearSignContextsOptional:[],clearSigningType:o.ClearSigningType.BASIC});const e=await new c.BuildFullContextsTask(n,{contextModule:l,mapper:p,parser:r,options:u,appConfig:i,derivationPath:y,subset:d},T,C,S).run();expect(e).toEqual({clearSignContexts:[],clearSigningType:o.ClearSigningType.BASIC})}),it("should build with multiple contexts and no subcontexts",async()=>{s.mockReturnValueOnce({clearSignContexts:[{type:t.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},{type:t.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:t.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"}],clearSigningType:o.ClearSigningType.EIP7730}),x.mockReturnValue({subcontextCallbacks:[]});const e=await new c.BuildFullContextsTask(n,{contextModule:l,mapper:p,parser:r,options:u,appConfig:i,derivationPath:y,subset:d},T,C,S).run();expect(e).toEqual({clearSignContexts:[{context:{type:t.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},subcontextCallbacks:[]},{context:{type:t.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},subcontextCallbacks:[]},{context:{type:t.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},subcontextCallbacks:[]}],clearSigningType:o.ClearSigningType.EIP7730})}),it("should build with multiple contexts and subcontexts",async()=>{s.mockReturnValueOnce({clearSignContexts:[{type:t.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},{type:t.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"}],clearSignContextsOptional:[],clearSigningType:o.ClearSigningType.EIP7730}),x.mockReturnValueOnce({subcontextCallbacks:[]}),x.mockReturnValueOnce({subcontextCallbacks:[()=>Promise.resolve({type:t.ClearSignContextType.TOKEN,payload:"payload-3"}),()=>Promise.resolve({type:t.ClearSignContextType.TOKEN,payload:"payload-4"})]});const e=await new c.BuildFullContextsTask(n,{contextModule:l,mapper:p,parser:r,options:u,appConfig:i,derivationPath:y,subset:d},T,C,S).run();expect(e.clearSignContexts[0]).toEqual({context:{type:t.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},subcontextCallbacks:[]}),expect(e.clearSignContexts[1]).toEqual({context:{type:t.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},subcontextCallbacks:[expect.any(Function),expect.any(Function)]}),expect(e.clearSignContexts[1].subcontextCallbacks[0]()).resolves.toEqual({type:t.ClearSignContextType.TOKEN,payload:"payload-3"}),expect(e.clearSignContexts[1].subcontextCallbacks[1]()).resolves.toEqual({type:t.ClearSignContextType.TOKEN,payload:"payload-4"})}),it("should build with nested contexts",async()=>{s.mockReturnValueOnce({clearSignContexts:[{type:t.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},{type:t.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2",reference:{type:t.ClearSignContextReferenceType.CALLDATA,subset:{chainId:1,data:"0x",selector:"0x"}}}],clearSigningType:o.ClearSigningType.EIP7730}),s.mockReturnValueOnce({clearSignContexts:[{type:t.ClearSignContextType.TRANSACTION_INFO,payload:"payload-3"},{type:t.ClearSignContextType.TOKEN,payload:"payload-4"}],clearSignContextsOptional:[],clearSigningType:o.ClearSigningType.EIP7730}),x.mockReturnValue({subcontextCallbacks:[]}),k.mockReturnValue({subsets:[{chainId:1,data:"0x",selector:"0x"}]});const e=await new c.BuildFullContextsTask(n,{contextModule:l,mapper:p,parser:r,options:u,appConfig:i,derivationPath:y,subset:d},T,C,S).run();expect(e).toEqual({clearSignContexts:expect.any(Array),clearSigningType:o.ClearSigningType.EIP7730}),expect(e.clearSignContexts[0]).toEqual({context:{type:t.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},subcontextCallbacks:[]}),expect(e.clearSignContexts[1]).toEqual({context:{type:t.ClearSignContextType.TRANSACTION_INFO,payload:"payload-3"},subcontextCallbacks:[]}),expect(e.clearSignContexts[2]).toEqual({context:{type:t.ClearSignContextType.TOKEN,payload:"payload-4"},subcontextCallbacks:[]}),expect(e.clearSignContexts[3]).toEqual({context:{type:t.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2",reference:{type:t.ClearSignContextReferenceType.CALLDATA,subset:{chainId:1,data:"0x",selector:"0x"}}},subcontextCallbacks:[]})})})});
1
+ "use strict";var e=require("@ledgerhq/context-module"),c=require("@ledgerhq/device-management-kit"),o=require("../../../api/model/ClearSigningType"),b=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),A=require("./BuildBaseContexts"),l=require("./BuildFullContextsTask"),N=require("./BuildSubcontextsTask"),g=require("./ParseNestedTransactionTask");describe("BuildFullContextsTask",()=>{const n=(0,b.makeDeviceActionInternalApiMock)(),p={},i={},r={},d={blindSigningEnabled:!1,web3ChecksEnabled:!1,web3ChecksOptIn:!1,version:"1.0.0"},u={},y={chainId:1,data:"0x",selector:"0x"},x="44'/60'/0'/0/0",T=vi.fn(),C=(a,t)=>({run:T}),s=vi.fn(),S=(a,t)=>({run:s}),k=vi.fn(),I=a=>({run:k});describe("Init",()=>{it("should init with defaults tasks",()=>{const a=new l.BuildFullContextsTask(n,{contextModule:p,mapper:i,parser:r,options:u,appConfig:d,derivationPath:x,subset:y,deviceModelId:c.DeviceModelId.STAX});expect(a).toBeDefined(),expect(a._buildSubcontextsTaskFactory(n,{})).toBeInstanceOf(N.BuildSubcontextsTask),expect(a._buildBaseContextsTaskFactory(n,{})).toBeInstanceOf(A.BuildBaseContexts),expect(a._preBuildNestedCallDataTaskFactory({})).toBeInstanceOf(g.ParseNestedTransactionTask)})}),describe("Happy path",()=>{beforeEach(()=>{vi.resetAllMocks()}),it("should build with no context",async()=>{s.mockReturnValue({clearSignContexts:[],clearSignContextsOptional:[],clearSigningType:o.ClearSigningType.BASIC});const t=await new l.BuildFullContextsTask(n,{contextModule:p,mapper:i,parser:r,options:u,appConfig:d,derivationPath:x,subset:y,deviceModelId:c.DeviceModelId.STAX},C,S,I).run();expect(t).toEqual({clearSignContexts:[],clearSigningType:o.ClearSigningType.BASIC})}),it("should build with multiple contexts and no subcontexts",async()=>{s.mockReturnValueOnce({clearSignContexts:[{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"}],clearSigningType:o.ClearSigningType.EIP7730}),T.mockReturnValue({subcontextCallbacks:[]});const t=await new l.BuildFullContextsTask(n,{contextModule:p,mapper:i,parser:r,options:u,appConfig:d,derivationPath:x,subset:y,deviceModelId:c.DeviceModelId.STAX},C,S,I).run();expect(t).toEqual({clearSignContexts:[{context:{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},subcontextCallbacks:[]},{context:{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},subcontextCallbacks:[]},{context:{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},subcontextCallbacks:[]}],clearSigningType:o.ClearSigningType.EIP7730})}),it("should build with multiple contexts and subcontexts",async()=>{s.mockReturnValueOnce({clearSignContexts:[{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"}],clearSignContextsOptional:[],clearSigningType:o.ClearSigningType.EIP7730}),T.mockReturnValueOnce({subcontextCallbacks:[]}),T.mockReturnValueOnce({subcontextCallbacks:[()=>Promise.resolve({type:e.ClearSignContextType.TOKEN,payload:"payload-3"}),()=>Promise.resolve({type:e.ClearSignContextType.TOKEN,payload:"payload-4"})]});const t=await new l.BuildFullContextsTask(n,{contextModule:p,mapper:i,parser:r,options:u,appConfig:d,derivationPath:x,subset:y,deviceModelId:c.DeviceModelId.STAX},C,S,I).run();expect(t.clearSignContexts[0]).toEqual({context:{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},subcontextCallbacks:[]}),expect(t.clearSignContexts[1]).toEqual({context:{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},subcontextCallbacks:[expect.any(Function),expect.any(Function)]}),expect(t.clearSignContexts[1].subcontextCallbacks[0]()).resolves.toEqual({type:e.ClearSignContextType.TOKEN,payload:"payload-3"}),expect(t.clearSignContexts[1].subcontextCallbacks[1]()).resolves.toEqual({type:e.ClearSignContextType.TOKEN,payload:"payload-4"})}),it("should build with nested contexts",async()=>{s.mockReturnValueOnce({clearSignContexts:[{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2",reference:{type:e.ClearSignContextReferenceType.CALLDATA,subset:{chainId:1,data:"0x",selector:"0x"}}}],clearSigningType:o.ClearSigningType.EIP7730}),s.mockReturnValueOnce({clearSignContexts:[{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"payload-3"},{type:e.ClearSignContextType.TOKEN,payload:"payload-4"}],clearSignContextsOptional:[],clearSigningType:o.ClearSigningType.EIP7730}),T.mockReturnValue({subcontextCallbacks:[]}),k.mockReturnValue({subsets:[{chainId:1,data:"0x",selector:"0x"}]});const t=await new l.BuildFullContextsTask(n,{contextModule:p,mapper:i,parser:r,options:u,appConfig:d,derivationPath:x,subset:y,deviceModelId:c.DeviceModelId.STAX},C,S,I).run();expect(t).toEqual({clearSignContexts:expect.any(Array),clearSigningType:o.ClearSigningType.EIP7730}),expect(t.clearSignContexts[0]).toEqual({context:{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},subcontextCallbacks:[]}),expect(t.clearSignContexts[1]).toEqual({context:{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"payload-3"},subcontextCallbacks:[]}),expect(t.clearSignContexts[2]).toEqual({context:{type:e.ClearSignContextType.TOKEN,payload:"payload-4"},subcontextCallbacks:[]}),expect(t.clearSignContexts[3]).toEqual({context:{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2",reference:{type:e.ClearSignContextReferenceType.CALLDATA,subset:{chainId:1,data:"0x",selector:"0x"}}},subcontextCallbacks:[]})})})});
2
2
  //# sourceMappingURL=BuildFullContextsTask.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/task/BuildFullContextsTask.test.ts"],
4
- "sourcesContent": ["import {\n ClearSignContextReferenceType,\n ClearSignContextType,\n type ContextModule,\n type TransactionSubset,\n} from \"@ledgerhq/context-module\";\nimport { type InternalApi } from \"@ledgerhq/device-management-kit\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { type TransactionOptions } from \"@api/index\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\nimport { type TransactionMapperService } from \"@internal/transaction/service/mapper/TransactionMapperService\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\n\nimport {\n BuildBaseContexts,\n type BuildBaseContextsArgs,\n} from \"./BuildBaseContexts\";\nimport { BuildFullContextsTask } from \"./BuildFullContextsTask\";\nimport {\n BuildSubcontextsTask,\n type BuildSubcontextsTaskArgs,\n} from \"./BuildSubcontextsTask\";\nimport {\n ParseNestedTransactionTask,\n type ParseNestedTransactionTaskArgs,\n} from \"./ParseNestedTransactionTask\";\n\ndescribe(\"BuildFullContextsTask\", () => {\n const apiMock = makeDeviceActionInternalApiMock();\n const contextModuleMock = {} as ContextModule;\n const mapperMock = {} as TransactionMapperService;\n const parserMock = {} as TransactionParserService;\n\n const defaultAppConfig: GetConfigCommandResponse = {\n blindSigningEnabled: false,\n web3ChecksEnabled: false,\n web3ChecksOptIn: false,\n version: \"1.0.0\",\n };\n const defaultOptions: TransactionOptions = {};\n const defaultSubset: TransactionSubset = {\n chainId: 1,\n data: \"0x\",\n selector: \"0x\",\n };\n const defaultDerivationPath = \"44'/60'/0'/0/0\";\n\n const buildSubContextTaskRunMock = vi.fn();\n const buildSubcontextsTaskFactory = (\n _api: InternalApi,\n _args: BuildSubcontextsTaskArgs,\n ) =>\n ({\n run: buildSubContextTaskRunMock,\n }) as unknown as BuildSubcontextsTask;\n\n const buildBaseContextsTaskRunMock = vi.fn();\n const buildBaseContextsTaskFactory = (\n _api: InternalApi,\n _args: BuildBaseContextsArgs,\n ) =>\n ({\n run: buildBaseContextsTaskRunMock,\n }) as unknown as BuildBaseContexts;\n\n const parseNestedTransactionTaskRunMock = vi.fn();\n const parseNestedTransactionTaskFactory = (\n _args: ParseNestedTransactionTaskArgs,\n ) =>\n ({\n run: parseNestedTransactionTaskRunMock,\n }) as unknown as ParseNestedTransactionTask;\n\n describe(\"Init\", () => {\n it(\"should init with defaults tasks\", () => {\n const task = new BuildFullContextsTask(apiMock, {\n contextModule: contextModuleMock,\n mapper: mapperMock,\n parser: parserMock,\n options: defaultOptions,\n appConfig: defaultAppConfig,\n derivationPath: defaultDerivationPath,\n subset: defaultSubset,\n });\n\n expect(task).toBeDefined();\n expect(\n task[\"_buildSubcontextsTaskFactory\"](\n apiMock,\n {} as BuildSubcontextsTaskArgs,\n ),\n ).toBeInstanceOf(BuildSubcontextsTask);\n expect(\n task[\"_buildBaseContextsTaskFactory\"](\n apiMock,\n {} as BuildBaseContextsArgs,\n ),\n ).toBeInstanceOf(BuildBaseContexts);\n expect(\n task[\"_preBuildNestedCallDataTaskFactory\"](\n {} as ParseNestedTransactionTaskArgs,\n ),\n ).toBeInstanceOf(ParseNestedTransactionTask);\n });\n });\n\n describe(\"Happy path\", () => {\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should build with no context\", async () => {\n // GIVEN\n buildBaseContextsTaskRunMock.mockReturnValue({\n clearSignContexts: [],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n\n const task = new BuildFullContextsTask(\n apiMock,\n {\n contextModule: contextModuleMock,\n mapper: mapperMock,\n parser: parserMock,\n options: defaultOptions,\n appConfig: defaultAppConfig,\n derivationPath: defaultDerivationPath,\n subset: defaultSubset,\n },\n buildSubcontextsTaskFactory,\n buildBaseContextsTaskFactory,\n parseNestedTransactionTaskFactory,\n );\n\n // WHEN\n const result = await task.run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build with multiple contexts and no subcontexts\", async () => {\n // GIVEN\n buildBaseContextsTaskRunMock.mockReturnValueOnce({\n clearSignContexts: [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n ],\n clearSigningType: ClearSigningType.EIP7730,\n });\n buildSubContextTaskRunMock.mockReturnValue({\n subcontextCallbacks: [],\n });\n\n const task = new BuildFullContextsTask(\n apiMock,\n {\n contextModule: contextModuleMock,\n mapper: mapperMock,\n parser: parserMock,\n options: defaultOptions,\n appConfig: defaultAppConfig,\n derivationPath: defaultDerivationPath,\n subset: defaultSubset,\n },\n buildSubcontextsTaskFactory,\n buildBaseContextsTaskFactory,\n parseNestedTransactionTaskFactory,\n );\n\n // WHEN\n const result = await task.run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n {\n context: {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n subcontextCallbacks: [],\n },\n {\n context: {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n subcontextCallbacks: [],\n },\n {\n context: {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n subcontextCallbacks: [],\n },\n ],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build with multiple contexts and subcontexts\", async () => {\n // GIVEN\n buildBaseContextsTaskRunMock.mockReturnValueOnce({\n clearSignContexts: [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n ],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.EIP7730,\n });\n buildSubContextTaskRunMock.mockReturnValueOnce({\n subcontextCallbacks: [],\n });\n buildSubContextTaskRunMock.mockReturnValueOnce({\n subcontextCallbacks: [\n () =>\n Promise.resolve({\n type: ClearSignContextType.TOKEN,\n payload: \"payload-3\",\n }),\n () =>\n Promise.resolve({\n type: ClearSignContextType.TOKEN,\n payload: \"payload-4\",\n }),\n ],\n });\n\n const task = new BuildFullContextsTask(\n apiMock,\n {\n contextModule: contextModuleMock,\n mapper: mapperMock,\n parser: parserMock,\n options: defaultOptions,\n appConfig: defaultAppConfig,\n derivationPath: defaultDerivationPath,\n subset: defaultSubset,\n },\n buildSubcontextsTaskFactory,\n buildBaseContextsTaskFactory,\n parseNestedTransactionTaskFactory,\n );\n\n // WHEN\n const result = await task.run();\n\n // THEN\n expect(result.clearSignContexts[0]).toEqual({\n context: {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n subcontextCallbacks: [],\n });\n expect(result.clearSignContexts[1]).toEqual({\n context: {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n subcontextCallbacks: [expect.any(Function), expect.any(Function)],\n });\n expect(\n result.clearSignContexts[1]!.subcontextCallbacks[0]!(),\n ).resolves.toEqual({\n type: ClearSignContextType.TOKEN,\n payload: \"payload-3\",\n });\n expect(\n result.clearSignContexts[1]!.subcontextCallbacks[1]!(),\n ).resolves.toEqual({\n type: ClearSignContextType.TOKEN,\n payload: \"payload-4\",\n });\n });\n\n it(\"should build with nested contexts\", async () => {\n // GIVEN\n buildBaseContextsTaskRunMock.mockReturnValueOnce({\n clearSignContexts: [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n reference: {\n type: ClearSignContextReferenceType.CALLDATA,\n subset: {\n chainId: 1,\n data: \"0x\",\n selector: \"0x\",\n },\n },\n },\n ],\n clearSigningType: ClearSigningType.EIP7730,\n });\n // nested context\n buildBaseContextsTaskRunMock.mockReturnValueOnce({\n clearSignContexts: [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-4\",\n },\n ],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.EIP7730,\n });\n buildSubContextTaskRunMock.mockReturnValue({\n subcontextCallbacks: [],\n });\n parseNestedTransactionTaskRunMock.mockReturnValue({\n subsets: [\n {\n chainId: 1,\n data: \"0x\",\n selector: \"0x\",\n },\n ],\n });\n\n const task = new BuildFullContextsTask(\n apiMock,\n {\n contextModule: contextModuleMock,\n mapper: mapperMock,\n parser: parserMock,\n options: defaultOptions,\n appConfig: defaultAppConfig,\n derivationPath: defaultDerivationPath,\n subset: defaultSubset,\n },\n buildSubcontextsTaskFactory,\n buildBaseContextsTaskFactory,\n parseNestedTransactionTaskFactory,\n );\n\n // WHEN\n const result = await task.run();\n\n // THEN\n expect(result).toEqual({\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n clearSignContexts: expect.any(Array),\n clearSigningType: ClearSigningType.EIP7730,\n });\n expect(result.clearSignContexts[0]).toEqual({\n context: {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n subcontextCallbacks: [],\n });\n expect(result.clearSignContexts[1]).toEqual({\n context: {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-3\",\n },\n subcontextCallbacks: [],\n });\n expect(result.clearSignContexts[2]).toEqual({\n context: {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-4\",\n },\n subcontextCallbacks: [],\n });\n expect(result.clearSignContexts[3]).toEqual({\n context: {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n reference: {\n type: ClearSignContextReferenceType.CALLDATA,\n subset: {\n chainId: 1,\n data: \"0x\",\n selector: \"0x\",\n },\n },\n },\n subcontextCallbacks: [],\n });\n });\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAKO,oCAKPC,EAAiC,uCACjCC,EAAgD,6EAIhDC,EAGO,+BACPC,EAAsC,mCACtCC,EAGO,kCACPC,EAGO,wCAEP,SAAS,wBAAyB,IAAM,CACtC,MAAMC,KAAU,mCAAgC,EAC1CC,EAAoB,CAAC,EACrBC,EAAa,CAAC,EACdC,EAAa,CAAC,EAEdC,EAA6C,CACjD,oBAAqB,GACrB,kBAAmB,GACnB,gBAAiB,GACjB,QAAS,OACX,EACMC,EAAqC,CAAC,EACtCC,EAAmC,CACvC,QAAS,EACT,KAAM,KACN,SAAU,IACZ,EACMC,EAAwB,iBAExBC,EAA6B,GAAG,GAAG,EACnCC,EAA8B,CAClCC,EACAC,KAEC,CACC,IAAKH,CACP,GAEII,EAA+B,GAAG,GAAG,EACrCC,EAA+B,CACnCH,EACAC,KAEC,CACC,IAAKC,CACP,GAEIE,EAAoC,GAAG,GAAG,EAC1CC,EACJJ,IAEC,CACC,IAAKG,CACP,GAEF,SAAS,OAAQ,IAAM,CACrB,GAAG,kCAAmC,IAAM,CAC1C,MAAME,EAAO,IAAI,wBAAsBhB,EAAS,CAC9C,cAAeC,EACf,OAAQC,EACR,OAAQC,EACR,QAASE,EACT,UAAWD,EACX,eAAgBG,EAChB,OAAQD,CACV,CAAC,EAED,OAAOU,CAAI,EAAE,YAAY,EACz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X,EACA,oBAAqB,CAAC,CACxB,CAAC,EACD,OAAOA,EAAO,kBAAkB,CAAC,CAAC,EAAE,QAAQ,CAC1C,QAAS,CACP,KAAM,uBAAqB,iBAC3B,QAAS,WACX,EACA,oBAAqB,CAAC,CACxB,CAAC,EACD,OAAOA,EAAO,kBAAkB,CAAC,CAAC,EAAE,QAAQ,CAC1C,QAAS,CACP,KAAM,uBAAqB,MAC3B,QAAS,WACX,EACA,oBAAqB,CAAC,CACxB,CAAC,EACD,OAAOA,EAAO,kBAAkB,CAAC,CAAC,EAAE,QAAQ,CAC1C,QAAS,CACP,KAAM,uBAAqB,8BAC3B,QAAS,YACT,UAAW,CACT,KAAM,gCAA8B,SACpC,OAAQ,CACN,QAAS,EACT,KAAM,KACN,SAAU,IACZ,CACF,CACF,EACA,oBAAqB,CAAC,CACxB,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["import_context_module", "import_ClearSigningType", "import_makeInternalApi", "import_BuildBaseContexts", "import_BuildFullContextsTask", "import_BuildSubcontextsTask", "import_ParseNestedTransactionTask", "apiMock", "contextModuleMock", "mapperMock", "parserMock", "defaultAppConfig", "defaultOptions", "defaultSubset", "defaultDerivationPath", "buildSubContextTaskRunMock", "buildSubcontextsTaskFactory", "_api", "_args", "buildBaseContextsTaskRunMock", "buildBaseContextsTaskFactory", "parseNestedTransactionTaskRunMock", "parseNestedTransactionTaskFactory", "task", "result"]
4
+ "sourcesContent": ["import {\n ClearSignContextReferenceType,\n ClearSignContextType,\n type ContextModule,\n type TransactionSubset,\n} from \"@ledgerhq/context-module\";\nimport {\n DeviceModelId,\n type InternalApi,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { type TransactionOptions } from \"@api/index\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\nimport { type TransactionMapperService } from \"@internal/transaction/service/mapper/TransactionMapperService\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\n\nimport {\n BuildBaseContexts,\n type BuildBaseContextsArgs,\n} from \"./BuildBaseContexts\";\nimport { BuildFullContextsTask } from \"./BuildFullContextsTask\";\nimport {\n BuildSubcontextsTask,\n type BuildSubcontextsTaskArgs,\n} from \"./BuildSubcontextsTask\";\nimport {\n ParseNestedTransactionTask,\n type ParseNestedTransactionTaskArgs,\n} from \"./ParseNestedTransactionTask\";\n\ndescribe(\"BuildFullContextsTask\", () => {\n const apiMock = makeDeviceActionInternalApiMock();\n const contextModuleMock = {} as ContextModule;\n const mapperMock = {} as TransactionMapperService;\n const parserMock = {} as TransactionParserService;\n\n const defaultAppConfig: GetConfigCommandResponse = {\n blindSigningEnabled: false,\n web3ChecksEnabled: false,\n web3ChecksOptIn: false,\n version: \"1.0.0\",\n };\n const defaultOptions: TransactionOptions = {};\n const defaultSubset: TransactionSubset = {\n chainId: 1,\n data: \"0x\",\n selector: \"0x\",\n };\n const defaultDerivationPath = \"44'/60'/0'/0/0\";\n\n const buildSubContextTaskRunMock = vi.fn();\n const buildSubcontextsTaskFactory = (\n _api: InternalApi,\n _args: BuildSubcontextsTaskArgs,\n ) =>\n ({\n run: buildSubContextTaskRunMock,\n }) as unknown as BuildSubcontextsTask;\n\n const buildBaseContextsTaskRunMock = vi.fn();\n const buildBaseContextsTaskFactory = (\n _api: InternalApi,\n _args: BuildBaseContextsArgs,\n ) =>\n ({\n run: buildBaseContextsTaskRunMock,\n }) as unknown as BuildBaseContexts;\n\n const parseNestedTransactionTaskRunMock = vi.fn();\n const parseNestedTransactionTaskFactory = (\n _args: ParseNestedTransactionTaskArgs,\n ) =>\n ({\n run: parseNestedTransactionTaskRunMock,\n }) as unknown as ParseNestedTransactionTask;\n\n describe(\"Init\", () => {\n it(\"should init with defaults tasks\", () => {\n const task = new BuildFullContextsTask(apiMock, {\n contextModule: contextModuleMock,\n mapper: mapperMock,\n parser: parserMock,\n options: defaultOptions,\n appConfig: defaultAppConfig,\n derivationPath: defaultDerivationPath,\n subset: defaultSubset,\n deviceModelId: DeviceModelId.STAX,\n });\n\n expect(task).toBeDefined();\n expect(\n task[\"_buildSubcontextsTaskFactory\"](\n apiMock,\n {} as BuildSubcontextsTaskArgs,\n ),\n ).toBeInstanceOf(BuildSubcontextsTask);\n expect(\n task[\"_buildBaseContextsTaskFactory\"](\n apiMock,\n {} as BuildBaseContextsArgs,\n ),\n ).toBeInstanceOf(BuildBaseContexts);\n expect(\n task[\"_preBuildNestedCallDataTaskFactory\"](\n {} as ParseNestedTransactionTaskArgs,\n ),\n ).toBeInstanceOf(ParseNestedTransactionTask);\n });\n });\n\n describe(\"Happy path\", () => {\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should build with no context\", async () => {\n // GIVEN\n buildBaseContextsTaskRunMock.mockReturnValue({\n clearSignContexts: [],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n\n const task = new BuildFullContextsTask(\n apiMock,\n {\n contextModule: contextModuleMock,\n mapper: mapperMock,\n parser: parserMock,\n options: defaultOptions,\n appConfig: defaultAppConfig,\n derivationPath: defaultDerivationPath,\n subset: defaultSubset,\n deviceModelId: DeviceModelId.STAX,\n },\n buildSubcontextsTaskFactory,\n buildBaseContextsTaskFactory,\n parseNestedTransactionTaskFactory,\n );\n\n // WHEN\n const result = await task.run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build with multiple contexts and no subcontexts\", async () => {\n // GIVEN\n buildBaseContextsTaskRunMock.mockReturnValueOnce({\n clearSignContexts: [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n ],\n clearSigningType: ClearSigningType.EIP7730,\n });\n buildSubContextTaskRunMock.mockReturnValue({\n subcontextCallbacks: [],\n });\n\n const task = new BuildFullContextsTask(\n apiMock,\n {\n contextModule: contextModuleMock,\n mapper: mapperMock,\n parser: parserMock,\n options: defaultOptions,\n appConfig: defaultAppConfig,\n derivationPath: defaultDerivationPath,\n subset: defaultSubset,\n deviceModelId: DeviceModelId.STAX,\n },\n buildSubcontextsTaskFactory,\n buildBaseContextsTaskFactory,\n parseNestedTransactionTaskFactory,\n );\n\n // WHEN\n const result = await task.run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n {\n context: {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n subcontextCallbacks: [],\n },\n {\n context: {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n subcontextCallbacks: [],\n },\n {\n context: {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n subcontextCallbacks: [],\n },\n ],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build with multiple contexts and subcontexts\", async () => {\n // GIVEN\n buildBaseContextsTaskRunMock.mockReturnValueOnce({\n clearSignContexts: [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n ],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.EIP7730,\n });\n buildSubContextTaskRunMock.mockReturnValueOnce({\n subcontextCallbacks: [],\n });\n buildSubContextTaskRunMock.mockReturnValueOnce({\n subcontextCallbacks: [\n () =>\n Promise.resolve({\n type: ClearSignContextType.TOKEN,\n payload: \"payload-3\",\n }),\n () =>\n Promise.resolve({\n type: ClearSignContextType.TOKEN,\n payload: \"payload-4\",\n }),\n ],\n });\n\n const task = new BuildFullContextsTask(\n apiMock,\n {\n contextModule: contextModuleMock,\n mapper: mapperMock,\n parser: parserMock,\n options: defaultOptions,\n appConfig: defaultAppConfig,\n derivationPath: defaultDerivationPath,\n subset: defaultSubset,\n deviceModelId: DeviceModelId.STAX,\n },\n buildSubcontextsTaskFactory,\n buildBaseContextsTaskFactory,\n parseNestedTransactionTaskFactory,\n );\n\n // WHEN\n const result = await task.run();\n\n // THEN\n expect(result.clearSignContexts[0]).toEqual({\n context: {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n subcontextCallbacks: [],\n });\n expect(result.clearSignContexts[1]).toEqual({\n context: {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n subcontextCallbacks: [expect.any(Function), expect.any(Function)],\n });\n expect(\n result.clearSignContexts[1]!.subcontextCallbacks[0]!(),\n ).resolves.toEqual({\n type: ClearSignContextType.TOKEN,\n payload: \"payload-3\",\n });\n expect(\n result.clearSignContexts[1]!.subcontextCallbacks[1]!(),\n ).resolves.toEqual({\n type: ClearSignContextType.TOKEN,\n payload: \"payload-4\",\n });\n });\n\n it(\"should build with nested contexts\", async () => {\n // GIVEN\n buildBaseContextsTaskRunMock.mockReturnValueOnce({\n clearSignContexts: [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n reference: {\n type: ClearSignContextReferenceType.CALLDATA,\n subset: {\n chainId: 1,\n data: \"0x\",\n selector: \"0x\",\n },\n },\n },\n ],\n clearSigningType: ClearSigningType.EIP7730,\n });\n // nested context\n buildBaseContextsTaskRunMock.mockReturnValueOnce({\n clearSignContexts: [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-4\",\n },\n ],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.EIP7730,\n });\n buildSubContextTaskRunMock.mockReturnValue({\n subcontextCallbacks: [],\n });\n parseNestedTransactionTaskRunMock.mockReturnValue({\n subsets: [\n {\n chainId: 1,\n data: \"0x\",\n selector: \"0x\",\n },\n ],\n });\n\n const task = new BuildFullContextsTask(\n apiMock,\n {\n contextModule: contextModuleMock,\n mapper: mapperMock,\n parser: parserMock,\n options: defaultOptions,\n appConfig: defaultAppConfig,\n derivationPath: defaultDerivationPath,\n subset: defaultSubset,\n deviceModelId: DeviceModelId.STAX,\n },\n buildSubcontextsTaskFactory,\n buildBaseContextsTaskFactory,\n parseNestedTransactionTaskFactory,\n );\n\n // WHEN\n const result = await task.run();\n\n // THEN\n expect(result).toEqual({\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n clearSignContexts: expect.any(Array),\n clearSigningType: ClearSigningType.EIP7730,\n });\n expect(result.clearSignContexts[0]).toEqual({\n context: {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n subcontextCallbacks: [],\n });\n expect(result.clearSignContexts[1]).toEqual({\n context: {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-3\",\n },\n subcontextCallbacks: [],\n });\n expect(result.clearSignContexts[2]).toEqual({\n context: {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-4\",\n },\n subcontextCallbacks: [],\n });\n expect(result.clearSignContexts[3]).toEqual({\n context: {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n reference: {\n type: ClearSignContextReferenceType.CALLDATA,\n subset: {\n chainId: 1,\n data: \"0x\",\n selector: \"0x\",\n },\n },\n },\n subcontextCallbacks: [],\n });\n });\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAKO,oCACPC,EAGO,2CAIPC,EAAiC,uCACjCC,EAAgD,6EAIhDC,EAGO,+BACPC,EAAsC,mCACtCC,EAGO,kCACPC,EAGO,wCAEP,SAAS,wBAAyB,IAAM,CACtC,MAAMC,KAAU,mCAAgC,EAC1CC,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AU,IACZ,CACF,CACF,EACA,oBAAqB,CAAC,CACxB,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_context_module", "import_device_management_kit", "import_ClearSigningType", "import_makeInternalApi", "import_BuildBaseContexts", "import_BuildFullContextsTask", "import_BuildSubcontextsTask", "import_ParseNestedTransactionTask", "apiMock", "contextModuleMock", "mapperMock", "parserMock", "defaultAppConfig", "defaultOptions", "defaultSubset", "defaultDerivationPath", "buildSubContextTaskRunMock", "buildSubcontextsTaskFactory", "_api", "_args", "buildBaseContextsTaskRunMock", "buildBaseContextsTaskFactory", "parseNestedTransactionTaskRunMock", "parseNestedTransactionTaskFactory", "task", "result"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var C=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var y=(s,e)=>{for(var r in e)C(s,r,{get:e[r],enumerable:!0})},T=(s,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of d(e))!g.call(s,n)&&n!==r&&C(s,n,{get:()=>e[n],enumerable:!(a=p(e,n))||a.enumerable});return s};var S=s=>T(C({},"__esModule",{value:!0}),s);var b={};y(b,{BuildSubcontextsTask:()=>h});module.exports=S(b);var t=require("@ledgerhq/context-module"),i=require("@ledgerhq/device-management-kit"),f=require("../../app-binder/command/GetChallengeCommand");class h{constructor(e,r){this.api=e;this.args=r}run(){const e=this.args.context;if(e.type===t.ClearSignContextType.TRANSACTION_INFO||e.type===t.ClearSignContextType.ENUM||e.type===t.ClearSignContextType.WEB3_CHECK||e.type===t.ClearSignContextType.PLUGIN||e.type===t.ClearSignContextType.EXTERNAL_PLUGIN)return{subcontextCallbacks:[]};if(e.reference!==void 0&&"value"in e.reference&&e.reference.value!==void 0){const r={type:e.reference.type===t.ClearSignContextReferenceType.TOKEN?t.ClearSignContextType.TOKEN:t.ClearSignContextType.NFT,chainId:this.args.subset.chainId,address:e.reference.value};return{subcontextCallbacks:[()=>this.args.contextModule.getContext(r)]}}if(e.reference!==void 0&&e.reference.valuePath!==void 0){const r=this.args.transactionParser.extractValue(this.args.subset,e.reference.valuePath);if(r.isRight()){const a=[];for(const n of r.extract()){if(e.reference.type===t.ClearSignContextReferenceType.ENUM){const o=e.reference,c=n[n.length-1];if(!c)continue;const x=this.args.contextOptional.filter(l=>l.type===t.ClearSignContextType.ENUM).find(l=>l.value===c&&l.id===o.id);x&&a.push(()=>Promise.resolve(x))}if(e.reference.type===t.ClearSignContextReferenceType.TOKEN||e.reference.type===t.ClearSignContextReferenceType.NFT){const o=e.reference,c=(0,i.bufferToHexaString)(n.slice(Math.max(0,n.length-20)));a.push(()=>this.args.contextModule.getContext({type:o.type===t.ClearSignContextReferenceType.TOKEN?t.ClearSignContextType.TOKEN:t.ClearSignContextType.NFT,chainId:this.args.subset.chainId,address:c}))}if(e.reference.type===t.ClearSignContextReferenceType.TRUSTED_NAME){const o=e.reference;a.push(async()=>{const c=(0,i.bufferToHexaString)(n.slice(Math.max(0,n.length-20))),u=await this.api.sendCommand(new f.GetChallengeCommand);return(0,i.isSuccessCommandResult)(u)?await this.args.contextModule.getContext({type:t.ClearSignContextType.TRUSTED_NAME,chainId:this.args.subset.chainId,address:c,challenge:u.data.challenge,types:o.types,sources:o.sources}):{type:t.ClearSignContextType.ERROR,error:new Error("Failed to get challenge")}})}}return{subcontextCallbacks:a}}}return{subcontextCallbacks:[]}}}0&&(module.exports={BuildSubcontextsTask});
1
+ "use strict";var d=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var S=(s,e)=>{for(var t in e)d(s,t,{get:e[t],enumerable:!0})},h=(s,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of b(e))!p.call(s,r)&&r!==t&&d(s,r,{get:()=>e[r],enumerable:!(a=g(e,r))||a.enumerable});return s};var T=s=>h(d({},"__esModule",{value:!0}),s);var f={};S(f,{BuildSubcontextsTask:()=>y});module.exports=T(f);var n=require("@ledgerhq/context-module"),c=require("@ledgerhq/context-module/src/shared/domain/ContextFieldLoader.js"),l=require("@ledgerhq/device-management-kit"),C=require("../../app-binder/command/GetChallengeCommand");class y{constructor(e,t){this.api=e;this.args=t}run(){const e=this.args.context,t=e.type;switch(t){case n.ClearSignContextType.TRANSACTION_INFO:case n.ClearSignContextType.WEB3_CHECK:case n.ClearSignContextType.PLUGIN:case n.ClearSignContextType.EXTERNAL_PLUGIN:case n.ClearSignContextType.DYNAMIC_NETWORK:case n.ClearSignContextType.DYNAMIC_NETWORK_ICON:case n.ClearSignContextType.ENUM:case n.ClearSignContextType.TRUSTED_NAME:case n.ClearSignContextType.TOKEN:case n.ClearSignContextType.NFT:return{subcontextCallbacks:[]};case n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:return{subcontextCallbacks:e.reference?this._getSubcontextsFromReference(e.reference):[]};case n.ClearSignContextType.PROXY_DELEGATE_CALL:return{subcontextCallbacks:this._getSubcontextFromProxy(e)};default:{const a=t;throw new Error(`Uncovered type: ${a}`)}}}_getSubcontextsFromReference(e){const t=e.type;switch(t){case n.ClearSignContextReferenceType.TOKEN:case n.ClearSignContextReferenceType.NFT:return this._getSubcontextsFromTokenOrNftReference(e);case n.ClearSignContextReferenceType.ENUM:return this._getSubcontextsFromEnumReference(e);case n.ClearSignContextReferenceType.TRUSTED_NAME:return this._getSubcontextsFromTrustedNameReference(e);case n.ClearSignContextReferenceType.CALLDATA:return[];default:{const a=t;throw new Error(`Uncovered reference type: ${a}`)}}}_getSubcontextsFromTokenOrNftReference(e){if(e.value!==void 0){const a={kind:e.type===n.ClearSignContextReferenceType.TOKEN?c.ContextFieldLoaderKind.TOKEN:c.ContextFieldLoaderKind.NFT,chainId:this.args.subset.chainId,address:e.value};return[()=>this.args.contextModule.getFieldContext(a)]}const t=[];if(e.valuePath!==void 0){const a=this.args.transactionParser.extractValue(this.args.subset,e.valuePath).orDefault([]);for(const r of a){const o=(0,l.bufferToHexaString)(r.slice(Math.max(0,r.length-20)));t.push(()=>this.args.contextModule.getFieldContext({kind:e.type===n.ClearSignContextReferenceType.TOKEN?c.ContextFieldLoaderKind.TOKEN:c.ContextFieldLoaderKind.NFT,chainId:this.args.subset.chainId,address:o}))}}return t}_getSubcontextsFromEnumReference(e){const t=[];if(!e.valuePath)return t;const a=this.args.transactionParser.extractValue(this.args.subset,e.valuePath).orDefault([]);for(const r of a){const o=r[r.length-1];if(o===void 0)continue;const x=this.args.contextOptional.filter(u=>u.type===n.ClearSignContextType.ENUM).find(u=>u.value===o&&u.id===e.id);x&&t.push(()=>Promise.resolve(x))}return t}_getSubcontextsFromTrustedNameReference(e){const t=[];if(!e.valuePath)return t;const a=this.args.transactionParser.extractValue(this.args.subset,e.valuePath).orDefault([]);for(const r of a)t.push(async()=>{const o=(0,l.bufferToHexaString)(r.slice(Math.max(0,r.length-20))),i=await this.api.sendCommand(new C.GetChallengeCommand);return(0,l.isSuccessCommandResult)(i)?await this.args.contextModule.getFieldContext({kind:c.ContextFieldLoaderKind.TRUSTED_NAME,chainId:this.args.subset.chainId,address:o,challenge:i.data.challenge,types:e.types,sources:e.sources}):{type:n.ClearSignContextType.ERROR,error:new Error("Failed to get challenge")}});return t}_getSubcontextFromProxy(e){return console.log("LAU: _getSubcontextsFromCallDataReference"),[async()=>{const t=await this.api.sendCommand(new C.GetChallengeCommand);if(console.log("LAU: getChallengeResult",t),!(0,l.isSuccessCommandResult)(t))return{type:n.ClearSignContextType.ERROR,error:new Error("Failed to get challenge")};const a=await this.args.contextModule.getProxyDelegateCall({...this.args.subset,deviceModelId:this.args.deviceModelId,challenge:t.data.challenge});return console.log("LAU: subcontext",a),a||{type:n.ClearSignContextType.ERROR,error:new Error("Failed to get proxy delegate call")}}]}}0&&(module.exports={BuildSubcontextsTask});
2
2
  //# sourceMappingURL=BuildSubcontextsTask.js.map