@ledgerhq/context-module 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/lib/cjs/package.json +1 -1
  2. package/lib/cjs/src/ContextModuleBuilder.js +1 -1
  3. package/lib/cjs/src/ContextModuleBuilder.js.map +3 -3
  4. package/lib/cjs/src/ContextModuleBuilder.test.js +1 -1
  5. package/lib/cjs/src/ContextModuleBuilder.test.js.map +2 -2
  6. package/lib/cjs/src/DefaultContextModule.js +1 -1
  7. package/lib/cjs/src/DefaultContextModule.js.map +3 -3
  8. package/lib/cjs/src/DefaultContextModule.test.js +1 -1
  9. package/lib/cjs/src/DefaultContextModule.test.js.map +2 -2
  10. package/lib/cjs/src/config/model/ContextModuleConfig.js +1 -1
  11. package/lib/cjs/src/config/model/ContextModuleConfig.js.map +1 -1
  12. package/lib/cjs/src/di.js +1 -1
  13. package/lib/cjs/src/di.js.map +3 -3
  14. package/lib/cjs/src/dynamic-network/data/DynamicNetworkDataSource.js +2 -0
  15. package/lib/cjs/src/dynamic-network/data/DynamicNetworkDataSource.js.map +7 -0
  16. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.js +2 -0
  17. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.js.map +7 -0
  18. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js +2 -0
  19. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js.map +7 -0
  20. package/lib/cjs/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.js +2 -0
  21. package/lib/cjs/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.js.map +7 -0
  22. package/lib/cjs/src/dynamic-network/di/dynamicNetworkModuleFactory.js +2 -0
  23. package/lib/cjs/src/dynamic-network/di/dynamicNetworkModuleFactory.js.map +7 -0
  24. package/lib/cjs/src/dynamic-network/di/dynamicNetworkTypes.js +2 -0
  25. package/lib/cjs/src/dynamic-network/di/dynamicNetworkTypes.js.map +7 -0
  26. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.js +2 -0
  27. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +7 -0
  28. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js +2 -0
  29. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +7 -0
  30. package/lib/cjs/src/dynamic-network/model/DynamicNetworkConfiguration.js +2 -0
  31. package/lib/cjs/src/dynamic-network/model/DynamicNetworkConfiguration.js.map +7 -0
  32. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
  33. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +2 -2
  34. package/lib/cjs/src/index.js +1 -1
  35. package/lib/cjs/src/index.js.map +2 -2
  36. package/lib/cjs/src/nft/data/HttpNftDataSource.js +1 -1
  37. package/lib/cjs/src/nft/data/HttpNftDataSource.js.map +2 -2
  38. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js +1 -1
  39. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js.map +2 -2
  40. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.js +1 -1
  41. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.js.map +3 -3
  42. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js +1 -1
  43. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +3 -3
  44. package/lib/cjs/src/shared/model/ClearSignContext.js +1 -1
  45. package/lib/cjs/src/shared/model/ClearSignContext.js.map +2 -2
  46. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js +1 -1
  47. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +2 -2
  48. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +1 -1
  49. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +2 -2
  50. package/lib/cjs/src/transaction/data/HttpProxyDataSource.js +1 -1
  51. package/lib/cjs/src/transaction/data/HttpProxyDataSource.js.map +3 -3
  52. package/lib/cjs/src/transaction/data/HttpProxyDataSource.test.js +1 -1
  53. package/lib/cjs/src/transaction/data/HttpProxyDataSource.test.js.map +2 -2
  54. package/lib/cjs/src/transaction/data/dto/ProxyDelegateCallDto.js +1 -1
  55. package/lib/cjs/src/transaction/data/dto/ProxyDelegateCallDto.js.map +1 -1
  56. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js +1 -1
  57. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js.map +3 -3
  58. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js +1 -1
  59. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js.map +3 -3
  60. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
  61. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js.map +2 -2
  62. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  63. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +2 -2
  64. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
  65. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +2 -2
  66. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js +1 -1
  67. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js.map +2 -2
  68. package/lib/esm/package.json +1 -1
  69. package/lib/esm/src/ContextModuleBuilder.js +1 -1
  70. package/lib/esm/src/ContextModuleBuilder.js.map +3 -3
  71. package/lib/esm/src/ContextModuleBuilder.test.js +1 -1
  72. package/lib/esm/src/ContextModuleBuilder.test.js.map +2 -2
  73. package/lib/esm/src/DefaultContextModule.js +1 -1
  74. package/lib/esm/src/DefaultContextModule.js.map +3 -3
  75. package/lib/esm/src/DefaultContextModule.test.js +1 -1
  76. package/lib/esm/src/DefaultContextModule.test.js.map +2 -2
  77. package/lib/esm/src/di.js +1 -1
  78. package/lib/esm/src/di.js.map +3 -3
  79. package/lib/esm/src/dynamic-network/data/DynamicNetworkDataSource.js +1 -0
  80. package/lib/esm/src/dynamic-network/data/DynamicNetworkDataSource.js.map +7 -0
  81. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.js +2 -0
  82. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.js.map +7 -0
  83. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js +2 -0
  84. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js.map +7 -0
  85. package/lib/esm/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.js +1 -0
  86. package/lib/esm/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.js.map +7 -0
  87. package/lib/esm/src/dynamic-network/di/dynamicNetworkModuleFactory.js +2 -0
  88. package/lib/esm/src/dynamic-network/di/dynamicNetworkModuleFactory.js.map +7 -0
  89. package/lib/esm/src/dynamic-network/di/dynamicNetworkTypes.js +2 -0
  90. package/lib/esm/src/dynamic-network/di/dynamicNetworkTypes.js.map +7 -0
  91. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js +2 -0
  92. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +7 -0
  93. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js +2 -0
  94. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +7 -0
  95. package/lib/esm/src/dynamic-network/model/DynamicNetworkConfiguration.js +1 -0
  96. package/lib/esm/src/dynamic-network/model/DynamicNetworkConfiguration.js.map +7 -0
  97. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
  98. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +2 -2
  99. package/lib/esm/src/index.js +1 -1
  100. package/lib/esm/src/index.js.map +2 -2
  101. package/lib/esm/src/nft/data/HttpNftDataSource.js +1 -1
  102. package/lib/esm/src/nft/data/HttpNftDataSource.js.map +2 -2
  103. package/lib/esm/src/nft/data/HttpNftDataSource.test.js +1 -1
  104. package/lib/esm/src/nft/data/HttpNftDataSource.test.js.map +2 -2
  105. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.js +1 -1
  106. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.js.map +3 -3
  107. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js +1 -1
  108. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +3 -3
  109. package/lib/esm/src/shared/model/ClearSignContext.js +1 -1
  110. package/lib/esm/src/shared/model/ClearSignContext.js.map +2 -2
  111. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js +1 -1
  112. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +2 -2
  113. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +1 -1
  114. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +2 -2
  115. package/lib/esm/src/transaction/data/HttpProxyDataSource.js +1 -1
  116. package/lib/esm/src/transaction/data/HttpProxyDataSource.js.map +3 -3
  117. package/lib/esm/src/transaction/data/HttpProxyDataSource.test.js +1 -1
  118. package/lib/esm/src/transaction/data/HttpProxyDataSource.test.js.map +2 -2
  119. package/lib/esm/src/transaction/domain/TransactionContextLoader.js +1 -1
  120. package/lib/esm/src/transaction/domain/TransactionContextLoader.js.map +3 -3
  121. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js +1 -1
  122. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js.map +3 -3
  123. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
  124. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js.map +2 -2
  125. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  126. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +2 -2
  127. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
  128. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +2 -2
  129. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js +1 -1
  130. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js.map +2 -2
  131. package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
  132. package/lib/types/src/config/model/ContextModuleConfig.d.ts +1 -1
  133. package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -1
  134. package/lib/types/src/di.d.ts.map +1 -1
  135. package/lib/types/src/dynamic-network/data/DynamicNetworkDataSource.d.ts +6 -0
  136. package/lib/types/src/dynamic-network/data/DynamicNetworkDataSource.d.ts.map +1 -0
  137. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.d.ts +13 -0
  138. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.d.ts.map +1 -0
  139. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.d.ts +2 -0
  140. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.d.ts.map +1 -0
  141. package/lib/types/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.d.ts +14 -0
  142. package/lib/types/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.d.ts.map +1 -0
  143. package/lib/types/src/dynamic-network/di/dynamicNetworkModuleFactory.d.ts +3 -0
  144. package/lib/types/src/dynamic-network/di/dynamicNetworkModuleFactory.d.ts.map +1 -0
  145. package/lib/types/src/dynamic-network/di/dynamicNetworkTypes.d.ts +5 -0
  146. package/lib/types/src/dynamic-network/di/dynamicNetworkTypes.d.ts.map +1 -0
  147. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts +15 -0
  148. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts.map +1 -0
  149. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.test.d.ts +2 -0
  150. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.test.d.ts.map +1 -0
  151. package/lib/types/src/dynamic-network/model/DynamicNetworkConfiguration.d.ts +16 -0
  152. package/lib/types/src/dynamic-network/model/DynamicNetworkConfiguration.d.ts.map +1 -0
  153. package/lib/types/src/index.d.ts +2 -0
  154. package/lib/types/src/index.d.ts.map +1 -1
  155. package/lib/types/src/pki/domain/DefaultPkiCertificateLoader.d.ts.map +1 -1
  156. package/lib/types/src/shared/model/ClearSignContext.d.ts +3 -0
  157. package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -1
  158. package/lib/types/src/transaction/data/HttpProxyDataSource.d.ts +2 -1
  159. package/lib/types/src/transaction/data/HttpProxyDataSource.d.ts.map +1 -1
  160. package/lib/types/src/transaction/data/dto/ProxyDelegateCallDto.d.ts +1 -1
  161. package/lib/types/src/transaction/data/dto/ProxyDelegateCallDto.d.ts.map +1 -1
  162. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts +3 -1
  163. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts.map +1 -1
  164. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  165. package/package.json +4 -4
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/transaction/data/HttpProxyDataSource.test.ts"],
4
- "sourcesContent": ["import axios from \"axios\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport type { ProxyDelegateCall } from \"@/transaction/model/ProxyDelegateCall\";\nimport type { ProxyImplementationAddress } from \"@/transaction/model/ProxyImplementationAddress\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { type ProxyImplementationAddressDto } from \"./dto/ProxyImplementationAddressDto\";\nimport type {\n GetProxyDelegateCallParam,\n GetProxyImplementationAddressParam,\n ProxyDataSource,\n} from \"./HttpProxyDataSource\";\nimport { HttpProxyDataSource } from \"./HttpProxyDataSource\";\n\nvi.mock(\"axios\");\n\ndescribe(\"HttpProxyDataSource\", () => {\n const config = {\n web3checks: {\n url: \"web3checksUrl\",\n },\n originToken: \"originToken\",\n } as ContextModuleConfig;\n\n let datasource: ProxyDataSource;\n const defaultParams: GetProxyDelegateCallParam = {\n proxyAddress: \"0x72CBdEaAdddD14Ec95b92995933CeC69566650f0\",\n calldata:\n \"0x6a76120200000000000000000000000072cbdeaadddd14ec95b92995933cec69566650f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000440d582f13000000000000000000000000cfa7eae32032bf431aed95532142a9c2b35715d40000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041000000000000000000000000a0766b65a4f7b1da79a1af79ac695456efa2864400000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000\",\n chainId: 1,\n };\n const defaultImplementAddressParams: GetProxyImplementationAddressParam = {\n proxyAddress: \"0xee6a57ec80ea46401049e92587e52f5ec1c24785\",\n chainId: 1,\n };\n const delegateProxyResponse: ProxyDelegateCall = {\n delegateAddresses: [\"0xd9db270c1b5e3bd161e8c8503c55ceabee709552\"],\n signedDescriptor: \"0x1234567890abcdef\",\n };\n const implementationAddressResponse: ProxyImplementationAddress = {\n implementationAddress: \"0x91ae842a5ffd8d12023116943e72a606179294f3\",\n };\n const implementationAddressDto: ProxyImplementationAddressDto = {\n implementationAddress: \"0x91ae842a5ffd8d12023116943e72a606179294f3\",\n proxyAddress: \"0xee6a57ec80ea46401049e92587e52f5ec1c24785\",\n standard: \"proxy\",\n };\n\n beforeEach(() => {\n vi.clearAllMocks();\n datasource = new HttpProxyDataSource({\n metadataService: {\n url: \"https://nft.api.live.ledger.com/v2\",\n },\n originToken: \"originToken\",\n } as ContextModuleConfig);\n });\n\n describe(\"getDelegateProxy\", () => {\n it(\"should call axios with the ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() =>\n Promise.resolve({ data: delegateProxyResponse }),\n );\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getProxyDelegateCall(defaultParams);\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: version,\n [LEDGER_ORIGIN_TOKEN_HEADER]: config.originToken,\n },\n }),\n );\n });\n\n it(\"should return the delegate proxy response on success\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: delegateProxyResponse,\n });\n\n // WHEN\n const result = await datasource.getProxyDelegateCall(defaultParams);\n\n // THEN\n expect(result).toEqual(Right(delegateProxyResponse));\n });\n\n it(\"should return an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"fail\"));\n\n // WHEN\n const result = await datasource.getProxyDelegateCall(defaultParams);\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: Failed to fetch delegate proxy\",\n ),\n ),\n );\n });\n\n it(\"should return an error if response shape is invalid\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: { foo: \"bar\" } });\n\n // WHEN\n const result = await datasource.getProxyDelegateCall(defaultParams);\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy 0x72CBdEaAdddD14Ec95b92995933CeC69566650f0 on chain 1\",\n ),\n ),\n );\n });\n\n it(\"should use the provided chainId in the URL\", async () => {\n // GIVEN\n const requestSpy = vi.fn(() =>\n Promise.resolve({ data: delegateProxyResponse }),\n );\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n const paramsWithDifferentChainId: GetProxyDelegateCallParam = {\n proxyAddress: \"0x72CBdEaAdddD14Ec95b92995933CeC69566650f0\",\n calldata:\n \"0x6a76120200000000000000000000000072cbdeaadddd14ec95b92995933cec69566650f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000440d582f13000000000000000000000000cfa7eae32032bf431aed95532142a9c2b35715d40000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041000000000000000000000000a0766b65a4f7b1da79a1af79ac695456efa2864400000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000\",\n chainId: 137, // Polygon\n };\n\n // WHEN\n await datasource.getProxyDelegateCall(paramsWithDifferentChainId);\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n method: \"POST\",\n url: \"https://nft.api.live.ledger.com/v2/ethereum/137/contract/proxy/delegate\",\n }),\n );\n });\n\n it(\"should return an error if no dto is returned from the api\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: undefined,\n });\n\n // WHEN\n const result = await datasource.getProxyDelegateCall(defaultParams);\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: No data received for proxy 0x72CBdEaAdddD14Ec95b92995933CeC69566650f0 on chain 1\",\n ),\n ),\n );\n });\n });\n\n describe(\"getImplementAddress\", () => {\n it(\"should call axios with the ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() =>\n Promise.resolve({ data: implementationAddressDto }),\n );\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: version,\n [LEDGER_ORIGIN_TOKEN_HEADER]: config.originToken,\n },\n }),\n );\n });\n\n it(\"should make a GET request to the correct URL\", async () => {\n // GIVEN\n const requestSpy = vi.fn(() =>\n Promise.resolve({ data: implementationAddressDto }),\n );\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n method: \"GET\",\n url: \"https://nft.api.live.ledger.com/v2/ethereum/1/contract/proxy/0xee6a57ec80ea46401049e92587e52f5ec1c24785\",\n }),\n );\n });\n\n it(\"should use the provided chainId in the URL\", async () => {\n // GIVEN\n const requestSpy = vi.fn(() =>\n Promise.resolve({ data: implementationAddressDto }),\n );\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n const paramsWithDifferentChainId: GetProxyImplementationAddressParam = {\n proxyAddress: \"0xee6a57ec80ea46401049e92587e52f5ec1c24785\",\n chainId: 137, // Polygon\n };\n\n // WHEN\n await datasource.getProxyImplementationAddress(\n paramsWithDifferentChainId,\n );\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n method: \"GET\",\n url: \"https://nft.api.live.ledger.com/v2/ethereum/137/contract/proxy/0xee6a57ec80ea46401049e92587e52f5ec1c24785\",\n }),\n );\n });\n\n it(\"should return the implementation address response on success\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: implementationAddressDto,\n });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(result).toEqual(Right(implementationAddressResponse));\n });\n\n it(\"should return an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"network error\"));\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: Failed to fetch implementation address\",\n ),\n ),\n );\n });\n\n it(\"should return an error if response shape is invalid\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: { invalid: \"data\" },\n });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: Invalid proxy implementation address response format for proxy 0xee6a57ec80ea46401049e92587e52f5ec1c24785 on chain 1\",\n ),\n ),\n );\n });\n\n it(\"should return an error if no dto is returned from the api\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: undefined,\n });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: No data received for proxy 0xee6a57ec80ea46401049e92587e52f5ec1c24785 on chain 1\",\n ),\n ),\n );\n });\n });\n});\n"],
5
- "mappings": "AAAA,OAAOA,MAAW,QAClB,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAG5B,OACE,gCAAAC,EACA,8BAAAC,MACK,gCAGP,OAAOC,MAAa,qBAQpB,OAAS,uBAAAC,MAA2B,wBAEpC,GAAG,KAAK,OAAO,EAEf,SAAS,sBAAuB,IAAM,CACpC,MAAMC,EAAS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S,MAAO,CAC1B,CAAC,EAGD,MAAMgB,EAAS,MAAMR,EAAW,8BAC9BE,CACF,EAGA,OAAOM,CAAM,EAAE,QACbf,EACE,IAAI,MACF,2JACF,CACF,CACF,CACF,CAAC,EAED,GAAG,4DAA6D,SAAY,CAE1E,GAAG,MAAMD,EAAO,SAAS,EAAE,kBAAkB,CAC3C,KAAM,MACR,CAAC,EAGD,MAAMgB,EAAS,MAAMR,EAAW,8BAC9BE,CACF,EAGA,OAAOM,CAAM,EAAE,QACbf,EACE,IAAI,MACF,uHACF,CACF,CACF,CACF,CAAC,CACH,CAAC,CACH,CAAC",
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport type { ProxyImplementationAddress } from \"@/transaction/model/ProxyImplementationAddress\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { type ProxyDelegateCallDto } from \"./dto/ProxyDelegateCallDto\";\nimport { type ProxyImplementationAddressDto } from \"./dto/ProxyImplementationAddressDto\";\nimport type {\n GetProxyDelegateCallParam,\n GetProxyImplementationAddressParam,\n ProxyDataSource,\n} from \"./HttpProxyDataSource\";\nimport { HttpProxyDataSource } from \"./HttpProxyDataSource\";\n\nvi.mock(\"axios\");\n\ndescribe(\"HttpProxyDataSource\", () => {\n const config = {\n web3checks: {\n url: \"web3checksUrl\",\n },\n originToken: \"originToken\",\n } as ContextModuleConfig;\n\n let datasource: ProxyDataSource;\n const defaultParams: GetProxyDelegateCallParam = {\n proxyAddress: \"0x72CBdEaAdddD14Ec95b92995933CeC69566650f0\",\n calldata:\n \"0x6a76120200000000000000000000000072cbdeaadddd14ec95b92995933cec69566650f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000440d582f13000000000000000000000000cfa7eae32032bf431aed95532142a9c2b35715d40000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041000000000000000000000000a0766b65a4f7b1da79a1af79ac695456efa2864400000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000\",\n chainId: 1,\n challenge: \"0x1234567890abcdef\",\n };\n const defaultImplementAddressParams: GetProxyImplementationAddressParam = {\n proxyAddress: \"0xee6a57ec80ea46401049e92587e52f5ec1c24785\",\n chainId: 1,\n };\n const delegateProxyResponse: ProxyDelegateCallDto = {\n addresses: [\"0xd9db270c1b5e3bd161e8c8503c55ceabee709552\"],\n signedDescriptor: \"0x1234567890abcdef\",\n };\n const implementationAddressResponse: ProxyImplementationAddress = {\n implementationAddress: \"0x91ae842a5ffd8d12023116943e72a606179294f3\",\n };\n const implementationAddressDto: ProxyImplementationAddressDto = {\n implementationAddress: \"0x91ae842a5ffd8d12023116943e72a606179294f3\",\n proxyAddress: \"0xee6a57ec80ea46401049e92587e52f5ec1c24785\",\n standard: \"proxy\",\n };\n\n beforeEach(() => {\n vi.clearAllMocks();\n datasource = new HttpProxyDataSource({\n metadataServiceDomain: {\n url: \"https://nft.api.live.ledger.com\",\n },\n originToken: \"originToken\",\n } as ContextModuleConfig);\n });\n\n describe(\"getDelegateProxy\", () => {\n it(\"should call axios with the ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() =>\n Promise.resolve({ data: delegateProxyResponse }),\n );\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getProxyDelegateCall(defaultParams);\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: version,\n [LEDGER_ORIGIN_TOKEN_HEADER]: config.originToken,\n },\n }),\n );\n });\n\n it(\"should return the delegate proxy response on success\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: delegateProxyResponse,\n });\n\n // WHEN\n const result = await datasource.getProxyDelegateCall(defaultParams);\n\n // THEN\n expect(result).toEqual(\n Right({\n delegateAddresses: [\"0xd9db270c1b5e3bd161e8c8503c55ceabee709552\"],\n signedDescriptor: \"0x1234567890abcdef\",\n }),\n );\n });\n\n it(\"should return an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"fail\"));\n\n // WHEN\n const result = await datasource.getProxyDelegateCall(defaultParams);\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: Failed to fetch delegate proxy\",\n ),\n ),\n );\n });\n\n it(\"should return an error if response shape is invalid\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: { foo: \"bar\" } });\n\n // WHEN\n const result = await datasource.getProxyDelegateCall(defaultParams);\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy 0x72CBdEaAdddD14Ec95b92995933CeC69566650f0 on chain 1\",\n ),\n ),\n );\n });\n\n it(\"should use the provided chainId in the URL\", async () => {\n // GIVEN\n const requestSpy = vi.fn(() =>\n Promise.resolve({ data: delegateProxyResponse }),\n );\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n const paramsWithDifferentChainId: GetProxyDelegateCallParam = {\n proxyAddress: \"0x72CBdEaAdddD14Ec95b92995933CeC69566650f0\",\n calldata:\n \"0x6a76120200000000000000000000000072cbdeaadddd14ec95b92995933cec69566650f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000440d582f13000000000000000000000000cfa7eae32032bf431aed95532142a9c2b35715d40000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041000000000000000000000000a0766b65a4f7b1da79a1af79ac695456efa2864400000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000\",\n chainId: 137, // Polygon\n challenge: \"0x1234567890abcdef\",\n };\n\n // WHEN\n await datasource.getProxyDelegateCall(paramsWithDifferentChainId);\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n method: \"POST\",\n url: \"https://nft.api.live.ledger.com/v2/ethereum/137/contract/proxy/delegate\",\n }),\n );\n });\n\n it(\"should return an error if no dto is returned from the api\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: undefined,\n });\n\n // WHEN\n const result = await datasource.getProxyDelegateCall(defaultParams);\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: No data received for proxy 0x72CBdEaAdddD14Ec95b92995933CeC69566650f0 on chain 1\",\n ),\n ),\n );\n });\n });\n\n describe(\"getImplementAddress\", () => {\n it(\"should call axios with the ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() =>\n Promise.resolve({ data: implementationAddressDto }),\n );\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: version,\n [LEDGER_ORIGIN_TOKEN_HEADER]: config.originToken,\n },\n }),\n );\n });\n\n it(\"should make a GET request to the correct URL\", async () => {\n // GIVEN\n const requestSpy = vi.fn(() =>\n Promise.resolve({ data: implementationAddressDto }),\n );\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n method: \"GET\",\n url: \"https://nft.api.live.ledger.com/v2/ethereum/1/contract/proxy/0xee6a57ec80ea46401049e92587e52f5ec1c24785\",\n }),\n );\n });\n\n it(\"should use the provided chainId in the URL\", async () => {\n // GIVEN\n const requestSpy = vi.fn(() =>\n Promise.resolve({ data: implementationAddressDto }),\n );\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n const paramsWithDifferentChainId: GetProxyImplementationAddressParam = {\n proxyAddress: \"0xee6a57ec80ea46401049e92587e52f5ec1c24785\",\n chainId: 137, // Polygon\n };\n\n // WHEN\n await datasource.getProxyImplementationAddress(\n paramsWithDifferentChainId,\n );\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n method: \"GET\",\n url: \"https://nft.api.live.ledger.com/v2/ethereum/137/contract/proxy/0xee6a57ec80ea46401049e92587e52f5ec1c24785\",\n }),\n );\n });\n\n it(\"should return the implementation address response on success\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: implementationAddressDto,\n });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(result).toEqual(Right(implementationAddressResponse));\n });\n\n it(\"should return an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"network error\"));\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: Failed to fetch implementation address\",\n ),\n ),\n );\n });\n\n it(\"should return an error if response shape is invalid\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: { invalid: \"data\" },\n });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: Invalid proxy implementation address response format for proxy 0xee6a57ec80ea46401049e92587e52f5ec1c24785 on chain 1\",\n ),\n ),\n );\n });\n\n it(\"should return an error if no dto is returned from the api\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: undefined,\n });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: No data received for proxy 0xee6a57ec80ea46401049e92587e52f5ec1c24785 on chain 1\",\n ),\n ),\n );\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAOA,MAAW,QAClB,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAG5B,OACE,gCAAAC,EACA,8BAAAC,MACK,gCAEP,OAAOC,MAAa,qBASpB,OAAS,uBAAAC,MAA2B,wBAEpC,GAAG,KAAK,OAAO,EAEf,SAAS,sBAAuB,IAAM,CACpC,MAAMC,EAAS,CACb,WAAY,CACV,IAAK,eACP,EACA,YAAa,aACf,EAEA,IAAIC,EACJ,MAAMC,EAA2C,CAC/C,aAAc,6CACd,SACE,0oCACF,QAAS,EACT,UAAW,oBACb,EACMC,EAAoE,CACxE,aAAc,6CACd,QAAS,CACX,EACMC,EAA8C,CAClD,UAAW,CAAC,4CAA4C,EACxD,iBAAkB,oBACpB,EACMC,EAA4D,CAChE,sBAAuB,4CACzB,EACMC,EAA0D,CAC9D,sBAAuB,6CACvB,aAAc,6CACd,SAAU,OACZ,EAEA,WAAW,IAAM,C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CACF,EAGA,OAAOM,CAAM,EAAE,QACbf,EACE,IAAI,MACF,uHACF,CACF,CACF,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
6
  "names": ["axios", "Left", "Right", "LEDGER_CLIENT_VERSION_HEADER", "LEDGER_ORIGIN_TOKEN_HEADER", "PACKAGE", "HttpProxyDataSource", "config", "datasource", "defaultParams", "defaultImplementAddressParams", "delegateProxyResponse", "implementationAddressResponse", "implementationAddressDto", "version", "requestSpy", "result", "paramsWithDifferentChainId"]
7
7
  }
@@ -1,2 +1,2 @@
1
- var u=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var m=(o,r,e,a)=>{for(var t=a>1?void 0:a?f(r,e):r,n=o.length-1,i;n>=0;n--)(i=o[n])&&(t=(a?i(r,e,t):i(t))||t);return a&&t&&u(r,e,t),t},p=(o,r)=>(e,a)=>r(e,a,o);import{isHexaString as S}from"@ledgerhq/device-management-kit";import{inject as d,injectable as C}from"inversify";import{ClearSignContextType as l}from"../../shared/model/ClearSignContext";import{transactionTypes as x}from"../../transaction/di/transactionTypes";let c=class{constructor(r){this.transactionDataSource=r}async load(r){const{to:e,data:a,selector:t,chainId:n,deviceModelId:i}=r;return e===void 0||a==="0x"?[]:S(t)?(await this.transactionDataSource.getTransactionDescriptors({deviceModelId:i,address:e,chainId:n,selector:t})).caseOf({Left:s=>[{type:l.ERROR,error:s}],Right:s=>s}):[{type:l.ERROR,error:new Error("Invalid selector")}]}};c=m([C(),p(0,d(x.TransactionDataSource))],c);export{c as TransactionContextLoader};
1
+ var S=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var m=(a,e,r,i)=>{for(var t=i>1?void 0:i?D(e,r):e,o=a.length-1,n;o>=0;o--)(n=a[o])&&(t=(i?n(e,r,t):n(t))||t);return i&&t&&S(e,r,t),t},f=(a,e)=>(r,i)=>e(r,i,a);import{DeviceModelId as x,isHexaString as k}from"@ledgerhq/device-management-kit";import{inject as C,injectable as v}from"inversify";import{pkiTypes as L}from"../../pki/di/pkiTypes";import{KeyId as I}from"../../pki/model/KeyId";import{KeyUsage as P}from"../../pki/model/KeyUsage";import{ClearSignContextType as l}from"../../shared/model/ClearSignContext";import{transactionTypes as R}from"../../transaction/di/transactionTypes";let c=class{constructor(e,r){this.transactionDataSource=e;this.certificateLoader=r}async load(e){if(e.deviceModelId===x.NANO_S)return[];const{to:r,data:i,selector:t,chainId:o,deviceModelId:n}=e;if(r===void 0||i==="0x")return[];if(!k(t))return[{type:l.ERROR,error:new Error("Invalid selector")}];const d=void 0,u=r;let p;d&&(p=await this.certificateLoader.loadCertificate({keyId:I.CalCalldataKey,keyUsage:P.Calldata,targetDevice:e.deviceModelId}));const y=d?[{type:l.PROXY_DELEGATE_CALL,payload:d,certificate:p}]:[],g=(await this.transactionDataSource.getTransactionDescriptors({deviceModelId:n,address:u,chainId:o,selector:t})).caseOf({Left:s=>[{type:l.ERROR,error:s}],Right:s=>s});return[...y,...g]}};c=m([v(),f(0,C(R.TransactionDataSource)),f(1,C(L.PkiCertificateLoader))],c);export{c as TransactionContextLoader};
2
2
  //# sourceMappingURL=TransactionContextLoader.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/transaction/domain/TransactionContextLoader.ts"],
4
- "sourcesContent": ["import { isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { TransactionContext } from \"@/shared/model/TransactionContext\";\nimport type { TransactionDataSource } from \"@/transaction/data/TransactionDataSource\";\nimport { transactionTypes } from \"@/transaction/di/transactionTypes\";\n\n@injectable()\nexport class TransactionContextLoader implements ContextLoader {\n constructor(\n @inject(transactionTypes.TransactionDataSource)\n private transactionDataSource: TransactionDataSource,\n ) {}\n\n async load(ctx: TransactionContext): Promise<ClearSignContext[]> {\n const { to, data, selector, chainId, deviceModelId } = ctx;\n if (to === undefined || data === \"0x\") {\n return [];\n }\n\n if (!isHexaString(selector)) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ];\n }\n\n const result = await this.transactionDataSource.getTransactionDescriptors({\n deviceModelId,\n address: to,\n chainId,\n selector,\n });\n\n return result.caseOf({\n Left: (error): ClearSignContext[] => [\n {\n type: ClearSignContextType.ERROR,\n error,\n },\n ],\n Right: (contexts): ClearSignContext[] => contexts,\n });\n }\n}\n"],
5
- "mappings": "iOAAA,OAAS,gBAAAA,MAAoB,kCAC7B,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YAGnC,OAEE,wBAAAC,MACK,kCAGP,OAAS,oBAAAC,MAAwB,oCAG1B,IAAMC,EAAN,KAAwD,CAC7D,YAEUC,EACR,CADQ,2BAAAA,CACP,CAEH,MAAM,KAAKC,EAAsD,CAC/D,KAAM,CAAE,GAAAC,EAAI,KAAAC,EAAM,SAAAC,EAAU,QAAAC,EAAS,cAAAC,CAAc,EAAIL,EACvD,OAAIC,IAAO,QAAaC,IAAS,KACxB,CAAC,EAGLI,EAAaH,CAAQ,GASX,MAAM,KAAK,sBAAsB,0BAA0B,CACxE,cAAAE,EACA,QAASJ,EACT,QAAAG,EACA,SAAAD,CACF,CAAC,GAEa,OAAO,CACnB,KAAOI,GAA8B,CACnC,CACE,KAAMC,EAAqB,MAC3B,MAAAD,CACF,CACF,EACA,MAAQE,GAAiCA,CAC3C,CAAC,EAvBQ,CACL,CACE,KAAMD,EAAqB,MAC3B,MAAO,IAAI,MAAM,kBAAkB,CACrC,CACF,CAmBJ,CACF,EAtCaV,EAANY,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAiB,qBAAqB,IAFrChB",
6
- "names": ["isHexaString", "inject", "injectable", "ClearSignContextType", "transactionTypes", "TransactionContextLoader", "transactionDataSource", "ctx", "to", "data", "selector", "chainId", "deviceModelId", "isHexaString", "error", "ClearSignContextType", "contexts", "__decorateClass", "injectable", "__decorateParam", "inject", "transactionTypes"]
4
+ "sourcesContent": ["import { DeviceModelId, isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport type { PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { TransactionContext } from \"@/shared/model/TransactionContext\";\n//import type { ProxyDataSource } from \"@/transaction/data/HttpProxyDataSource\";\nimport type { TransactionDataSource } from \"@/transaction/data/TransactionDataSource\";\nimport { transactionTypes } from \"@/transaction/di/transactionTypes\";\n\n@injectable()\nexport class TransactionContextLoader implements ContextLoader {\n constructor(\n @inject(transactionTypes.TransactionDataSource)\n private transactionDataSource: TransactionDataSource,\n /*@inject(transactionTypes.ProxyDataSource)\n private _proxyDataSource: ProxyDataSource,*/\n @inject(pkiTypes.PkiCertificateLoader)\n private certificateLoader: PkiCertificateLoader,\n ) {}\n\n async load(ctx: TransactionContext): Promise<ClearSignContext[]> {\n if (ctx.deviceModelId === DeviceModelId.NANO_S) {\n return [];\n }\n\n //TODO add challenge when proxy is enabled\n const { to, data, selector, chainId, deviceModelId } = ctx;\n if (to === undefined || data === \"0x\") {\n return [];\n }\n\n if (!isHexaString(selector)) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ];\n }\n /*\nDISABLE PROXY FOR NOW, to be enabled later\n\n const proxyDelegateCall = await this.proxyDataSource.getProxyDelegateCall({\n calldata: data,\n proxyAddress: to,\n chainId,\n challenge: challenge || \"\",\n });\n\n // get the resolved address from the list of delegate addresses\n // if the transaction.to is not in the list of delegate addresses,\n // return the first element as the resolved address,\n // and undefined as the proxy delegate call descriptor\n // if the transaction.to is in the list of delegate addresses,\n // return the transaction.to as the resolved address,\n // and the proxy delegate call descriptor\n const [resolvedAddress, proxyDelegateCallDescriptor]: [\n string,\n string | undefined,\n ] = proxyDelegateCall.caseOf({\n Left: () => [to!, undefined],\n Right: (proxyData: ProxyDelegateCall): [string, string | undefined] => {\n return [\n proxyData.delegateAddresses.find((address) => address === to) ||\n proxyData.delegateAddresses[0]!,\n proxyData.signedDescriptor,\n ];\n },\n });\n*/\n // TMP Values to be removed when proxy is enabled\n const proxyDelegateCallDescriptor: string | undefined = undefined;\n const resolvedAddress: string | undefined = to;\n\n let certificate: PkiCertificate | undefined = undefined;\n if (proxyDelegateCallDescriptor) {\n certificate = await this.certificateLoader.loadCertificate({\n keyId: KeyId.CalCalldataKey,\n keyUsage: KeyUsage.Calldata,\n targetDevice: ctx.deviceModelId,\n });\n }\n\n const proxyDelegateCallContext: ClearSignContext[] =\n proxyDelegateCallDescriptor\n ? [\n {\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: proxyDelegateCallDescriptor,\n certificate: certificate,\n },\n ]\n : [];\n\n const transactionContexts = (\n await this.transactionDataSource.getTransactionDescriptors({\n deviceModelId,\n address: resolvedAddress,\n chainId,\n selector,\n })\n ).caseOf({\n Left: (error): ClearSignContext[] => [\n {\n type: ClearSignContextType.ERROR,\n error,\n },\n ],\n Right: (contexts): ClearSignContext[] => contexts,\n });\n\n return [...proxyDelegateCallContext, ...transactionContexts];\n }\n}\n"],
5
+ "mappings": "iOAAA,OAAS,iBAAAA,EAAe,gBAAAC,MAAoB,kCAC5C,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YAEnC,OAAS,YAAAC,MAAgB,oBAEzB,OAAS,SAAAC,MAAa,oBACtB,OAAS,YAAAC,MAAgB,uBAGzB,OAEE,wBAAAC,MACK,kCAIP,OAAS,oBAAAC,MAAwB,oCAG1B,IAAMC,EAAN,KAAwD,CAC7D,YAEUC,EAIAC,EACR,CALQ,2BAAAD,EAIA,uBAAAC,CACP,CAEH,MAAM,KAAKC,EAAsD,CAC/D,GAAIA,EAAI,gBAAkBC,EAAc,OACtC,MAAO,CAAC,EAIV,KAAM,CAAE,GAAAC,EAAI,KAAAC,EAAM,SAAAC,EAAU,QAAAC,EAAS,cAAAC,CAAc,EAAIN,EACvD,GAAIE,IAAO,QAAaC,IAAS,KAC/B,MAAO,CAAC,EAGV,GAAI,CAACI,EAAaH,CAAQ,EACxB,MAAO,CACL,CACE,KAAMI,EAAqB,MAC3B,MAAO,IAAI,MAAM,kBAAkB,CACrC,CACF,EAkCF,MAAMC,EAAkD,OAClDC,EAAsCR,EAE5C,IAAIS,EACAF,IACFE,EAAc,MAAM,KAAK,kBAAkB,gBAAgB,CACzD,MAAOC,EAAM,eACb,SAAUC,EAAS,SACnB,aAAcb,EAAI,aACpB,CAAC,GAGH,MAAMc,EACJL,EACI,CACE,CACE,KAAMD,EAAqB,oBAC3B,QAASC,EACT,YAAaE,CACf,CACF,EACA,CAAC,EAEDI,GACJ,MAAM,KAAK,sBAAsB,0BAA0B,CACzD,cAAAT,EACA,QAASI,EACT,QAAAL,EACA,SAAAD,CACF,CAAC,GACD,OAAO,CACP,KAAOY,GAA8B,CACnC,CACE,KAAMR,EAAqB,MAC3B,MAAAQ,CACF,CACF,EACA,MAAQC,GAAiCA,CAC3C,CAAC,EAED,MAAO,CAAC,GAAGH,EAA0B,GAAGC,CAAmB,CAC7D,CACF,EAvGalB,EAANqB,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAiB,qBAAqB,GAI7CF,EAAA,EAAAC,EAAOE,EAAS,oBAAoB,IAN5B1B",
6
+ "names": ["DeviceModelId", "isHexaString", "inject", "injectable", "pkiTypes", "KeyId", "KeyUsage", "ClearSignContextType", "transactionTypes", "TransactionContextLoader", "transactionDataSource", "certificateLoader", "ctx", "DeviceModelId", "to", "data", "selector", "chainId", "deviceModelId", "isHexaString", "ClearSignContextType", "proxyDelegateCallDescriptor", "resolvedAddress", "certificate", "KeyId", "KeyUsage", "proxyDelegateCallContext", "transactionContexts", "error", "contexts", "__decorateClass", "injectable", "__decorateParam", "inject", "transactionTypes", "pkiTypes"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{Left as s,Right as c}from"purify-ts";import{ClearSignContextType as o}from"../../shared/model/ClearSignContext";import{TransactionContextLoader as i}from"../../transaction/domain/TransactionContextLoader";describe("TransactionContextLoader",()=>{const r=vi.fn(),n={getTransactionDescriptors:r},e=new i(n);beforeEach(()=>{vi.clearAllMocks()}),it("should return an empty array if no destination address is provided",async()=>{const a={},t=await e.load(a);expect(t).toEqual([])}),it("should return an empty array if no data provided",async()=>{const a={to:"0x0",data:"0x"},t=await e.load(a);expect(t).toEqual([])}),it("should return an error if selector is invalid",async()=>{const a={to:"0x7",chainId:3,data:"0xzf68b302000000000000000000000000000000000000000000000000000000000002"},t=await e.load(a);expect(t).toEqual([{type:o.ERROR,error:new Error("Invalid selector")}])}),it("should return an error if data source fails",async()=>{r.mockResolvedValue(s(new Error("data source error")));const a={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await e.load(a);expect(r).toHaveBeenCalledWith({address:"0x7",chainId:3,selector:"0xaf68b302"}),expect(t).toEqual([{type:o.ERROR,error:new Error("data source error")}])}),it("should return the contexts on success",async()=>{r.mockResolvedValue(c([{type:o.TRANSACTION_INFO,payload:"1234567890"},{type:o.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}]));const a={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await e.load(a);expect(t).toEqual([{type:o.TRANSACTION_INFO,payload:"1234567890"},{type:o.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])})});
1
+ import{Left as c,Right as s}from"purify-ts";import{ClearSignContextType as e}from"../../shared/model/ClearSignContext";import{TransactionContextLoader as l}from"../../transaction/domain/TransactionContextLoader";describe("TransactionContextLoader",()=>{const r=vi.fn(),n=vi.fn(),d={getTransactionDescriptors:r},i={loadCertificate:vi.fn()},o=new l(d,i);beforeEach(()=>{vi.resetAllMocks()}),it("should return an empty array if no destination address is provided",async()=>{const a={},t=await o.load(a);expect(t).toEqual([])}),it("should return an empty array if no data provided",async()=>{const a={to:"0x0",data:"0x"},t=await o.load(a);expect(t).toEqual([])}),it("should return an error if selector is invalid",async()=>{const a={to:"0x7",chainId:3,data:"0xzf68b302000000000000000000000000000000000000000000000000000000000002"},t=await o.load(a);expect(t).toEqual([{type:e.ERROR,error:new Error("Invalid selector")}])}),it("should return an error if data source fails",async()=>{n.mockResolvedValue(c(new Error("data source error"))),r.mockResolvedValue(c(new Error("data source error")));const a={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await o.load(a);expect(r).toHaveBeenCalledWith({address:"0x7",chainId:3,selector:"0xaf68b302"}),expect(t).toEqual([{type:e.ERROR,error:new Error("data source error")}])}),it("should return the contexts on success",async()=>{r.mockResolvedValue(s([{type:e.TRANSACTION_INFO,payload:"1234567890"},{type:e.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])),n.mockResolvedValue(c(new Error("data source error")));const a={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await o.load(a);expect(t).toEqual([{type:e.TRANSACTION_INFO,payload:"1234567890"},{type:e.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])}),it("should return the proxy delegate call context on success",async()=>{r.mockResolvedValue(s([{type:e.TRANSACTION_INFO,payload:"1234567890"},{type:e.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])),n.mockResolvedValue(s({delegateAddresses:["0x7"],signedDescriptor:"0x1234567890abcdef"}));const a={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await o.load(a);expect(t).toEqual([{type:e.TRANSACTION_INFO,payload:"1234567890"},{type:e.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])}),it("should return the proxy delegate call context if the transaction.to is in the delegate addresses and the transaction.to is not the first element",async()=>{r.mockResolvedValue(s([{type:e.TRANSACTION_INFO,payload:"1234567890"},{type:e.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])),n.mockResolvedValue(s({delegateAddresses:["0x7","0x8"],signedDescriptor:"0x1234567890abcdef"}));const a={to:"0x8",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await o.load(a);expect(t).toEqual([{type:e.TRANSACTION_INFO,payload:"1234567890"},{type:e.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])}),it("should return the proxy delegate call context if the transaction.to is not in the delegate addresses",async()=>{r.mockResolvedValue(s([{type:e.TRANSACTION_INFO,payload:"1234567890"},{type:e.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])),n.mockResolvedValue(s({delegateAddresses:["0x8"],signedDescriptor:"0x1234567890abcdef"}));const a={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await o.load(a);expect(t).toEqual([{type:e.TRANSACTION_INFO,payload:"1234567890"},{type:e.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])})});
2
2
  //# sourceMappingURL=TransactionContextLoader.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/transaction/domain/TransactionContextLoader.test.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport type { TransactionContext } from \"@/shared/model/TransactionContext\";\nimport type { TransactionDataSource } from \"@/transaction/data/TransactionDataSource\";\nimport { TransactionContextLoader } from \"@/transaction/domain/TransactionContextLoader\";\n\ndescribe(\"TransactionContextLoader\", () => {\n const getTransactionDescriptorsMock = vi.fn();\n const mockTransactionDataSource: TransactionDataSource = {\n getTransactionDescriptors: getTransactionDescriptorsMock,\n };\n const loader = new TransactionContextLoader(mockTransactionDataSource);\n\n beforeEach(() => {\n vi.clearAllMocks();\n });\n\n it(\"should return an empty array if no destination address is provided\", async () => {\n // GIVEN\n const transaction = {} as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if no data provided\", async () => {\n // GIVEN\n const transaction = { to: \"0x0\", data: \"0x\" } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an error if selector is invalid\", async () => {\n // GIVEN\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xzf68b302000000000000000000000000000000000000000000000000000000000002\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ]);\n });\n\n it(\"should return an error if data source fails\", async () => {\n // GIVEN\n getTransactionDescriptorsMock.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(getTransactionDescriptorsMock).toHaveBeenCalledWith({\n address: \"0x7\",\n chainId: 3,\n selector: \"0xaf68b302\",\n });\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"data source error\"),\n },\n ]);\n });\n\n it(\"should return the contexts on success\", async () => {\n // GIVEN\n getTransactionDescriptorsMock.mockResolvedValue(\n Right([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]);\n });\n});\n"],
5
- "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAE5B,OAAS,wBAAAC,MAA4B,kCAGrC,OAAS,4BAAAC,MAAgC,gDAEzC,SAAS,2BAA4B,IAAM,CACzC,MAAMC,EAAgC,GAAG,GAAG,EACtCC,EAAmD,CACvD,0BAA2BD,CAC7B,EACME,EAAS,IAAIH,EAAyBE,CAAyB,EAErE,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,GAAG,qEAAsE,SAAY,CAEnF,MAAME,EAAc,CAAC,EAGfC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,EAED,GAAG,mDAAoD,SAAY,CAEjE,MAAMD,EAAc,CAAE,GAAI,MAAO,KAAM,IAAK,EAGtCC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,EAED,GAAG,gDAAiD,SAAY,CAE9D,MAAMD,EAAc,CAClB,GAAI,MACJ,QAAS,EACT,KAAM,wEACR,EAGMC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CACrB,CACE,KAAMN,EAAqB,MAC3B,MAAO,IAAI,MAAM,kBAAkB,CACrC,CACF,CAAC,CACH,CAAC,EAED,GAAG,8CAA+C,SAAY,CAE5DE,EAA8B,kBAC5BJ,EAAK,IAAI,MAAM,mBAAmB,CAAC,CACrC,EACA,MAAMO,EAAc,CAClB,GAAI,MACJ,QAAS,EACT,KAAM,yEACN,SAAU,YACZ,EAGMC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOH,CAA6B,EAAE,qBAAqB,CACzD,QAAS,MACT,QAAS,EACT,SAAU,YACZ,CAAC,EACD,OAAOI,CAAM,EAAE,QAAQ,CACrB,CACE,KAAMN,EAAqB,MAC3B,MAAO,IAAI,MAAM,mBAAmB,CACtC,CACF,CAAC,CACH,CAAC,EAED,GAAG,wCAAyC,SAAY,CAEtDE,EAA8B,kBAC5BH,EAAM,CACJ,CACE,KAAMC,EAAqB,iBAC3B,QAAS,YACX,EACA,CACE,KAAMA,EAAqB,8BAC3B,QAAS,UACX,CACF,CAAC,CACH,EACA,MAAMK,EAAc,CAClB,GAAI,MACJ,QAAS,EACT,KAAM,yEACN,SAAU,YACZ,EAGMC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CACrB,CACE,KAAMN,EAAqB,iBAC3B,QAAS,YACX,EACA,CACE,KAAMA,EAAqB,8BAC3B,QAAS,UACX,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["Left", "Right", "ClearSignContextType", "TransactionContextLoader", "getTransactionDescriptorsMock", "mockTransactionDataSource", "loader", "transaction", "result"]
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport type { TransactionContext } from \"@/shared/model/TransactionContext\";\nimport type { TransactionDataSource } from \"@/transaction/data/TransactionDataSource\";\nimport { TransactionContextLoader } from \"@/transaction/domain/TransactionContextLoader\";\n\ndescribe(\"TransactionContextLoader\", () => {\n const getTransactionDescriptorsMock = vi.fn();\n const getProxyDelegateCallMock = vi.fn();\n const mockTransactionDataSource: TransactionDataSource = {\n getTransactionDescriptors: getTransactionDescriptorsMock,\n };\n /* const mockProxyDatasource: ProxyDataSource = {\n getProxyDelegateCall: getProxyDelegateCallMock,\n getProxyImplementationAddress: vi.fn(),\n }; */\n const mockCertificateLoader: PkiCertificateLoader = {\n loadCertificate: vi.fn(),\n };\n const loader = new TransactionContextLoader(\n mockTransactionDataSource,\n //mockProxyDatasource,\n mockCertificateLoader,\n );\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should return an empty array if no destination address is provided\", async () => {\n // GIVEN\n const transaction = {} as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if no data provided\", async () => {\n // GIVEN\n const transaction = { to: \"0x0\", data: \"0x\" } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an error if selector is invalid\", async () => {\n // GIVEN\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xzf68b302000000000000000000000000000000000000000000000000000000000002\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ]);\n });\n\n it(\"should return an error if data source fails\", async () => {\n // GIVEN\n getProxyDelegateCallMock.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n getTransactionDescriptorsMock.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(getTransactionDescriptorsMock).toHaveBeenCalledWith({\n address: \"0x7\",\n chainId: 3,\n selector: \"0xaf68b302\",\n });\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"data source error\"),\n },\n ]);\n });\n\n it(\"should return the contexts on success\", async () => {\n // GIVEN\n getTransactionDescriptorsMock.mockResolvedValue(\n Right([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]),\n );\n getProxyDelegateCallMock.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]);\n });\n\n it(\"should return the proxy delegate call context on success\", async () => {\n // GIVEN\n getTransactionDescriptorsMock.mockResolvedValue(\n Right([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]),\n );\n getProxyDelegateCallMock.mockResolvedValue(\n Right({\n delegateAddresses: [\"0x7\"],\n signedDescriptor: \"0x1234567890abcdef\",\n }),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n /* TODO reenable when proxy is enabled\n {\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: \"0x1234567890abcdef\",\n },*/\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]);\n });\n\n it(\"should return the proxy delegate call context if the transaction.to is in the delegate addresses and the transaction.to is not the first element\", async () => {\n // GIVEN\n getTransactionDescriptorsMock.mockResolvedValue(\n Right([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]),\n );\n getProxyDelegateCallMock.mockResolvedValue(\n Right({\n delegateAddresses: [\"0x7\", \"0x8\"],\n signedDescriptor: \"0x1234567890abcdef\",\n }),\n );\n const transaction = {\n to: \"0x8\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n /* TODO reenable when proxy is enabled\n {\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: \"0x1234567890abcdef\",\n },*/\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]);\n });\n\n it(\"should return the proxy delegate call context if the transaction.to is not in the delegate addresses\", async () => {\n // GIVEN\n getTransactionDescriptorsMock.mockResolvedValue(\n Right([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]),\n );\n getProxyDelegateCallMock.mockResolvedValue(\n Right({\n delegateAddresses: [\"0x8\"],\n signedDescriptor: \"0x1234567890abcdef\",\n }),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n /* TODO reenable when proxy is enabled\n {\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: \"0x1234567890abcdef\",\n },*/\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]);\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAG5B,OAAS,wBAAAC,MAA4B,kCAGrC,OAAS,4BAAAC,MAAgC,gDAEzC,SAAS,2BAA4B,IAAM,CACzC,MAAMC,EAAgC,GAAG,GAAG,EACtCC,EAA2B,GAAG,GAAG,EACjCC,EAAmD,CACvD,0BAA2BF,CAC7B,EAKMG,EAA8C,CAClD,gBAAiB,GAAG,GAAG,CACzB,EACMC,EAAS,IAAIL,EACjBG,EAEAC,CACF,EAEA,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,GAAG,qEAAsE,SAAY,CAEnF,MAAME,EAAc,CAAC,EAGfC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,EAED,GAAG,mDAAoD,SAAY,CAEjE,MAAMD,EAAc,CAAE,GAAI,MAAO,KAAM,IAAK,EAGtCC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,EAED,GAAG,gDAAiD,SAAY,CAE9D,MAAMD,EAAc,CAClB,GAAI,MACJ,QAAS,EACT,KAAM,wEACR,EAGMC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CACrB,CACE,KAAMR,EAAqB,MAC3B,MAAO,IAAI,MAAM,kBAAkB,CACrC,CACF,CAAC,CACH,CAAC,EAED,GAAG,8CAA+C,SAAY,CAE5DG,EAAyB,kBACvBL,EAAK,IAAI,MAAM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5C,OAAOC,CAAM,EAAE,QAAQ,CAMrB,CACE,KAAMR,EAAqB,iBAC3B,QAAS,YACX,EACA,CACE,KAAMA,EAAqB,8BAC3B,QAAS,UACX,CACF,CAAC,CACH,CAAC,EAED,GAAG,mJAAoJ,SAAY,CAEjKE,EAA8B,kBAC5BH,EAAM,CACJ,CACE,KAAMC,EAAqB,iBAC3B,QAAS,YACX,EACA,CACE,KAAMA,EAAqB,8BAC3B,QAAS,UACX,CACF,CAAC,CACH,EACAG,EAAyB,kBACvBJ,EAAM,CACJ,kBAAmB,CAAC,MAAO,KAAK,EAChC,iBAAkB,oBACpB,CAAC,CACH,EACA,MAAMQ,EAAc,CAClB,GAAI,MACJ,QAAS,EACT,KAAM,yEACN,SAAU,YACZ,EAGMC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CAMrB,CACE,KAAMR,EAAqB,iBAC3B,QAAS,YACX,EACA,CACE,KAAMA,EAAqB,8BAC3B,QAAS,UACX,CACF,CAAC,CACH,CAAC,EAED,GAAG,uGAAwG,SAAY,CAErHE,EAA8B,kBAC5BH,EAAM,CACJ,CACE,KAAMC,EAAqB,iBAC3B,QAAS,YACX,EACA,CACE,KAAMA,EAAqB,8BAC3B,QAAS,UACX,CACF,CAAC,CACH,EACAG,EAAyB,kBACvBJ,EAAM,CACJ,kBAAmB,CAAC,KAAK,EACzB,iBAAkB,oBACpB,CAAC,CACH,EACA,MAAMQ,EAAc,CAClB,GAAI,MACJ,QAAS,EACT,KAAM,yEACN,SAAU,YACZ,EAGMC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CAMrB,CACE,KAAMR,EAAqB,iBAC3B,QAAS,YACX,EACA,CACE,KAAMA,EAAqB,8BAC3B,QAAS,UACX,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["Left", "Right", "ClearSignContextType", "TransactionContextLoader", "getTransactionDescriptorsMock", "getProxyDelegateCallMock", "mockTransactionDataSource", "mockCertificateLoader", "loader", "transaction", "result"]
7
7
  }
@@ -1,2 +1,2 @@
1
- var T=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var f=(s,r,e,o)=>{for(var t=o>1?void 0:o?$(r,e):r,n=s.length-1,a;n>=0;n--)(a=s[n])&&(t=(o?a(r,e,t):a(t))||t);return o&&t&&T(r,e,t),t},l=(s,r)=>(e,o)=>r(e,o,s);import p from"axios";import{inject as y,injectable as C}from"inversify";import{Left as m,Right as c}from"purify-ts";import{configTypes as x}from"../../config/di/configTypes";import{LEDGER_CLIENT_VERSION_HEADER as h,LEDGER_ORIGIN_TOKEN_HEADER as E}from"../../shared/constant/HttpHeaders";import D from"../../../package.json";let d=class{constructor(r){this.config=r}async getDomainNamePayload({chainId:r,domain:e,challenge:o}){try{const a=await p.request({method:"GET",url:`${this.config.metadataService.url}/names/ethereum/${r}/forward/${e}?types=eoa&sources=ens&challenge=${o}`,headers:{[h]:`context-module/${D.version}`,[E]:this.config.originToken}});return a.data.signedDescriptor?.data?c(a.data.signedDescriptor.data):m(new Error("[ContextModule] HttpTrustedNameDataSource: error getting domain payload"))}catch{return m(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name"))}}async getTrustedNamePayload({chainId:r,address:e,challenge:o,sources:t,types:n}){try{t=t.filter(g=>g==="ens"||g==="crypto_asset_list");const i=(await p.request({method:"GET",url:`${this.config.metadataService.url}/names/ethereum/${r}/reverse/${e}?types=${n.join(",")}&sources=${t.join(",")}&challenge=${o}`,headers:{[h]:`context-module/${D.version}`,[E]:this.config.originToken}})).data;if(!i?.signedDescriptor?.data)return m(new Error(`[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address ${e}`));const u=i.signedDescriptor.data;if(!i.signedDescriptor.signatures||typeof i.signedDescriptor.signatures[this.config.cal.mode]!="string")return c(u);const N=i.signedDescriptor.signatures[this.config.cal.mode];return c(this.formatTrustedName(u,N))}catch{return m(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name"))}}formatTrustedName(r,e){e.length%2!==0&&(e="0"+e);const o="15",t=(e.length/2).toString(16);return`${r}${o}${t}${e}`}};d=f([C(),l(0,y(x.Config))],d);export{d as HttpTrustedNameDataSource};
1
+ var T=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var f=(s,r,e,o)=>{for(var t=o>1?void 0:o?$(r,e):r,n=s.length-1,a;n>=0;n--)(a=s[n])&&(t=(o?a(r,e,t):a(t))||t);return o&&t&&T(r,e,t),t},l=(s,r)=>(e,o)=>r(e,o,s);import p from"axios";import{inject as y,injectable as C}from"inversify";import{Left as m,Right as c}from"purify-ts";import{configTypes as x}from"../../config/di/configTypes";import{LEDGER_CLIENT_VERSION_HEADER as h,LEDGER_ORIGIN_TOKEN_HEADER as E}from"../../shared/constant/HttpHeaders";import D from"../../../package.json";let d=class{constructor(r){this.config=r}async getDomainNamePayload({chainId:r,domain:e,challenge:o}){try{const a=await p.request({method:"GET",url:`${this.config.metadataServiceDomain.url}/v2/names/ethereum/${r}/forward/${e}?types=eoa&sources=ens&challenge=${o}`,headers:{[h]:`context-module/${D.version}`,[E]:this.config.originToken}});return a.data.signedDescriptor?.data?c(a.data.signedDescriptor.data):m(new Error("[ContextModule] HttpTrustedNameDataSource: error getting domain payload"))}catch{return m(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name"))}}async getTrustedNamePayload({chainId:r,address:e,challenge:o,sources:t,types:n}){try{t=t.filter(g=>g==="ens"||g==="crypto_asset_list");const i=(await p.request({method:"GET",url:`${this.config.metadataServiceDomain.url}/v2/names/ethereum/${r}/reverse/${e}?types=${n.join(",")}&sources=${t.join(",")}&challenge=${o}`,headers:{[h]:`context-module/${D.version}`,[E]:this.config.originToken}})).data;if(!i?.signedDescriptor?.data)return m(new Error(`[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address ${e}`));const u=i.signedDescriptor.data;if(!i.signedDescriptor.signatures||typeof i.signedDescriptor.signatures[this.config.cal.mode]!="string")return c(u);const N=i.signedDescriptor.signatures[this.config.cal.mode];return c(this.formatTrustedName(u,N))}catch{return m(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name"))}}formatTrustedName(r,e){e.length%2!==0&&(e="0"+e);const o="15",t=(e.length/2).toString(16);return`${r}${o}${t}${e}`}};d=f([C(),l(0,y(x.Config))],d);export{d as HttpTrustedNameDataSource};
2
2
  //# sourceMappingURL=HttpTrustedNameDataSource.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/trusted-name/data/HttpTrustedNameDataSource.ts"],
4
- "sourcesContent": ["import axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport type { ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport {\n GetDomainNameInfosParams,\n GetTrustedNameInfosParams,\n TrustedNameDataSource,\n} from \"@/trusted-name/data/TrustedNameDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { TrustedNameDto } from \"./TrustedNameDto\";\n\n@injectable()\nexport class HttpTrustedNameDataSource implements TrustedNameDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n public async getDomainNamePayload({\n chainId,\n domain,\n challenge,\n }: GetDomainNameInfosParams): Promise<Either<Error, string>> {\n try {\n const type = \"eoa\"; // Externally owned account\n const source = \"ens\"; // Ethereum name service\n const response = await axios.request<TrustedNameDto>({\n method: \"GET\",\n url: `${this.config.metadataService.url}/names/ethereum/${chainId}/forward/${domain}?types=${type}&sources=${source}&challenge=${challenge}`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n });\n\n return response.data.signedDescriptor?.data\n ? Right(response.data.signedDescriptor.data)\n : Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: error getting domain payload\",\n ),\n );\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name\",\n ),\n );\n }\n }\n\n public async getTrustedNamePayload({\n chainId,\n address,\n challenge,\n sources,\n types,\n }: GetTrustedNameInfosParams): Promise<Either<Error, string>> {\n try {\n // TODO remove that filtering once https://ledgerhq.atlassian.net/browse/BACK-8075 is done\n // For now we have to filter or trusted names won't work with the generic parser, because transaction\n // fields descriptors can contain unsupported sources.\n sources = sources.filter(\n (source) => source === \"ens\" || source === \"crypto_asset_list\",\n );\n const response = await axios.request<TrustedNameDto>({\n method: \"GET\",\n url: `${this.config.metadataService.url}/names/ethereum/${chainId}/reverse/${address}?types=${types.join(\",\")}&sources=${sources.join(\",\")}&challenge=${challenge}`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n });\n const trustedName = response.data;\n if (!trustedName?.signedDescriptor?.data) {\n return Left(\n new Error(\n `[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address ${address}`,\n ),\n );\n }\n const payload = trustedName.signedDescriptor.data;\n\n if (\n !trustedName.signedDescriptor.signatures ||\n typeof trustedName.signedDescriptor.signatures[this.config.cal.mode] !==\n \"string\"\n ) {\n // If we have no separated signature but a valid descriptor, it may mean the descriptor was\n // signed on-the-fly for dynamic sources such as ens\n return Right(payload);\n }\n\n const signature =\n trustedName.signedDescriptor.signatures[this.config.cal.mode]!;\n return Right(this.formatTrustedName(payload, signature));\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name\",\n ),\n );\n }\n }\n\n private formatTrustedName(payload: string, signature: string): string {\n // Ensure correct padding\n if (signature.length % 2 !== 0) {\n signature = \"0\" + signature;\n }\n // TLV encoding as according to trusted name documentation\n const signatureTag = \"15\";\n const signatureLength = (signature.length / 2).toString(16);\n return `${payload}${signatureTag}${signatureLength}${signature}`;\n }\n}\n"],
5
- "mappings": "iOAAA,OAAOA,MAAW,QAClB,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAE5B,OACE,gCAAAC,EACA,8BAAAC,MACK,gCAMP,OAAOC,MAAa,qBAKb,IAAMC,EAAN,KAAiE,CACtE,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CAEH,MAAa,qBAAqB,CAChC,QAAAC,EACA,OAAAC,EACA,UAAAC,CACF,EAA6D,CAC3D,GAAI,CAGF,MAAMC,EAAW,MAAMC,EAAM,QAAwB,CACnD,OAAQ,MACR,IAAK,GAAG,KAAK,OAAO,gBAAgB,GAAG,mBAAmBJ,CAAO,YAAYC,CAAM,oCAA8CC,CAAS,GAC1I,QAAS,CACP,CAACG,CAA4B,EAAG,kBAAkBC,EAAQ,OAAO,GACjE,CAACC,CAA0B,EAAG,KAAK,OAAO,WAC5C,CACF,CAAC,EAED,OAAOJ,EAAS,KAAK,kBAAkB,KACnCK,EAAML,EAAS,KAAK,iBAAiB,IAAI,EACzCM,EACE,IAAI,MACF,yEACF,CACF,CACN,MAAiB,CACf,OAAOA,EACL,IAAI,MACF,wEACF,CACF,CACF,CACF,CAEA,MAAa,sBAAsB,CACjC,QAAAT,EACA,QAAAU,EACA,UAAAR,EACA,QAAAS,EACA,MAAAC,CACF,EAA8D,CAC5D,GAAI,CAIFD,EAAUA,EAAQ,OACfE,GAAWA,IAAW,OAASA,IAAW,mBAC7C,EASA,MAAMC,GARW,MAAMV,EAAM,QAAwB,CACnD,OAAQ,MACR,IAAK,GAAG,KAAK,OAAO,gBAAgB,GAAG,mBAAmBJ,CAAO,YAAYU,CAAO,UAAUE,EAAM,KAAK,GAAG,CAAC,YAAYD,EAAQ,KAAK,GAAG,CAAC,cAAcT,CAAS,GACjK,QAAS,CACP,CAACG,CAA4B,EAAG,kBAAkBC,EAAQ,OAAO,GACjE,CAACC,CAA0B,EAAG,KAAK,OAAO,WAC5C,CACF,CAAC,GAC4B,KAC7B,GAAI,CAACO,GAAa,kBAAkB,KAClC,OAAOL,EACL,IAAI,MACF,mFAAmFC,CAAO,EAC5F,CACF,EAEF,MAAMK,EAAUD,EAAY,iBAAiB,KAE7C,GACE,CAACA,EAAY,iBAAiB,YAC9B,OAAOA,EAAY,iBAAiB,WAAW,KAAK,OAAO,IAAI,IAAI,GACjE,SAIF,OAAON,EAAMO,CAAO,EAGtB,MAAMC,EACJF,EAAY,iBAAiB,WAAW,KAAK,OAAO,IAAI,IAAI,EAC9D,OAAON,EAAM,KAAK,kBAAkBO,EAASC,CAAS,CAAC,CACzD,MAAiB,CACf,OAAOP,EACL,IAAI,MACF,yEACF,CACF,CACF,CACF,CAEQ,kBAAkBM,EAAiBC,EAA2B,CAEhEA,EAAU,OAAS,IAAM,IAC3BA,EAAY,IAAMA,GAGpB,MAAMC,EAAe,KACfC,GAAmBF,EAAU,OAAS,GAAG,SAAS,EAAE,EAC1D,MAAO,GAAGD,CAAO,GAAGE,CAAY,GAAGC,CAAe,GAAGF,CAAS,EAChE,CACF,EAtGalB,EAANqB,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,IAFjBzB",
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport type { ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport {\n GetDomainNameInfosParams,\n GetTrustedNameInfosParams,\n TrustedNameDataSource,\n} from \"@/trusted-name/data/TrustedNameDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { TrustedNameDto } from \"./TrustedNameDto\";\n\n@injectable()\nexport class HttpTrustedNameDataSource implements TrustedNameDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n public async getDomainNamePayload({\n chainId,\n domain,\n challenge,\n }: GetDomainNameInfosParams): Promise<Either<Error, string>> {\n try {\n const type = \"eoa\"; // Externally owned account\n const source = \"ens\"; // Ethereum name service\n const response = await axios.request<TrustedNameDto>({\n method: \"GET\",\n url: `${this.config.metadataServiceDomain.url}/v2/names/ethereum/${chainId}/forward/${domain}?types=${type}&sources=${source}&challenge=${challenge}`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n });\n\n return response.data.signedDescriptor?.data\n ? Right(response.data.signedDescriptor.data)\n : Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: error getting domain payload\",\n ),\n );\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name\",\n ),\n );\n }\n }\n\n public async getTrustedNamePayload({\n chainId,\n address,\n challenge,\n sources,\n types,\n }: GetTrustedNameInfosParams): Promise<Either<Error, string>> {\n try {\n // TODO remove that filtering once https://ledgerhq.atlassian.net/browse/BACK-8075 is done\n // For now we have to filter or trusted names won't work with the generic parser, because transaction\n // fields descriptors can contain unsupported sources.\n sources = sources.filter(\n (source) => source === \"ens\" || source === \"crypto_asset_list\",\n );\n const response = await axios.request<TrustedNameDto>({\n method: \"GET\",\n url: `${this.config.metadataServiceDomain.url}/v2/names/ethereum/${chainId}/reverse/${address}?types=${types.join(\",\")}&sources=${sources.join(\",\")}&challenge=${challenge}`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n });\n const trustedName = response.data;\n if (!trustedName?.signedDescriptor?.data) {\n return Left(\n new Error(\n `[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address ${address}`,\n ),\n );\n }\n const payload = trustedName.signedDescriptor.data;\n\n if (\n !trustedName.signedDescriptor.signatures ||\n typeof trustedName.signedDescriptor.signatures[this.config.cal.mode] !==\n \"string\"\n ) {\n // If we have no separated signature but a valid descriptor, it may mean the descriptor was\n // signed on-the-fly for dynamic sources such as ens\n return Right(payload);\n }\n\n const signature =\n trustedName.signedDescriptor.signatures[this.config.cal.mode]!;\n return Right(this.formatTrustedName(payload, signature));\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name\",\n ),\n );\n }\n }\n\n private formatTrustedName(payload: string, signature: string): string {\n // Ensure correct padding\n if (signature.length % 2 !== 0) {\n signature = \"0\" + signature;\n }\n // TLV encoding as according to trusted name documentation\n const signatureTag = \"15\";\n const signatureLength = (signature.length / 2).toString(16);\n return `${payload}${signatureTag}${signatureLength}${signature}`;\n }\n}\n"],
5
+ "mappings": "iOAAA,OAAOA,MAAW,QAClB,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAE5B,OACE,gCAAAC,EACA,8BAAAC,MACK,gCAMP,OAAOC,MAAa,qBAKb,IAAMC,EAAN,KAAiE,CACtE,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CAEH,MAAa,qBAAqB,CAChC,QAAAC,EACA,OAAAC,EACA,UAAAC,CACF,EAA6D,CAC3D,GAAI,CAGF,MAAMC,EAAW,MAAMC,EAAM,QAAwB,CACnD,OAAQ,MACR,IAAK,GAAG,KAAK,OAAO,sBAAsB,GAAG,sBAAsBJ,CAAO,YAAYC,CAAM,oCAA8CC,CAAS,GACnJ,QAAS,CACP,CAACG,CAA4B,EAAG,kBA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Y,IAAMA,GAGpB,MAAMC,EAAe,KACfC,GAAmBF,EAAU,OAAS,GAAG,SAAS,EAAE,EAC1D,MAAO,GAAGD,CAAO,GAAGE,CAAY,GAAGC,CAAe,GAAGF,CAAS,EAChE,CACF,EAtGalB,EAANqB,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,IAFjBzB",
6
6
  "names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "LEDGER_CLIENT_VERSION_HEADER", "LEDGER_ORIGIN_TOKEN_HEADER", "PACKAGE", "HttpTrustedNameDataSource", "config", "chainId", "domain", "challenge", "response", "axios", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "LEDGER_ORIGIN_TOKEN_HEADER", "Right", "Left", "address", "sources", "types", "source", "trustedName", "payload", "signature", "signatureTag", "signatureLength", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import o from"axios";import{Left as r,Right as s}from"purify-ts";import{LEDGER_CLIENT_VERSION_HEADER as l,LEDGER_ORIGIN_TOKEN_HEADER as d}from"../../shared/constant/HttpHeaders";import{HttpTrustedNameDataSource as c}from"../../trusted-name/data/HttpTrustedNameDataSource";import i from"../../../package.json";vi.mock("axios");const n={cal:{url:"https://crypto-assets-service.api.ledger.com/v1",mode:"prod",branch:"main"},metadataService:{url:"https://nft.api.live.ledger.com/v2"},originToken:"originToken"};describe("HttpTrustedNameDataSource",()=>{let t;beforeAll(()=>{t=new c(n),vi.clearAllMocks()}),describe("getDomainNamePayload",()=>{it("should call axios with the correct url and ledger client version header",async()=>{const e=`context-module/${i.version}`,a=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(o,"request").mockImplementation(a),await t.getDomainNamePayload({chainId:137,challenge:"9876",domain:"hello.eth"}),expect(a).toHaveBeenCalledWith(expect.objectContaining({url:"https://nft.api.live.ledger.com/v2/names/ethereum/137/forward/hello.eth?types=eoa&sources=ens&challenge=9876",headers:{[l]:e,[d]:n.originToken}}))}),it("should throw an error when axios throws an error",async()=>{vi.spyOn(o,"request").mockRejectedValue(new Error);const e=await t.getDomainNamePayload({chainId:137,challenge:"",domain:"hello.eth"});expect(e).toEqual(r(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name")))}),it("should return an error when no payload is returned",async()=>{const e={data:{test:""}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getDomainNamePayload({chainId:137,challenge:"",domain:"hello.eth"});expect(a).toEqual(r(new Error("[ContextModule] HttpTrustedNameDataSource: error getting domain payload")))}),it("should return a payload",async()=>{const e={data:{signedDescriptor:{data:"payload"}}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getDomainNamePayload({chainId:137,challenge:"challenge",domain:"hello.eth"});expect(a).toEqual(s("payload"))})}),describe("getTrustedNamePayload",()=>{it("should call axios with the correct url and ledger client version header",async()=>{const e=`context-module/${i.version}`,a=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(o,"request").mockImplementation(a),await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"5678",sources:["ens","crypto_asset_list"],types:["eoa"]}),expect(a).toHaveBeenCalledWith(expect.objectContaining({url:"https://nft.api.live.ledger.com/v2/names/ethereum/137/reverse/0x1234?types=eoa&sources=ens,crypto_asset_list&challenge=5678",headers:{[l]:e,[d]:n.originToken}}))}),it("should throw an error when axios throws an error",async()=>{vi.spyOn(o,"request").mockRejectedValue(new Error);const e=await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(e).toEqual(r(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name")))}),it("should return an error when no payload is returned",async()=>{const e={data:{test:""}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(a).toEqual(r(new Error("[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address 0x1234")))}),it("should return a payload",async()=>{const e={data:{signedDescriptor:{data:"payload"}}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(a).toEqual(s("payload"))}),it("should return a payload with a signature",async()=>{const e={data:{signedDescriptor:{data:"payload",signatures:{prod:"12345"}}}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(a).toEqual(s("payload153012345"))})})});
1
+ import o from"axios";import{Left as r,Right as s}from"purify-ts";import{LEDGER_CLIENT_VERSION_HEADER as l,LEDGER_ORIGIN_TOKEN_HEADER as d}from"../../shared/constant/HttpHeaders";import{HttpTrustedNameDataSource as c}from"../../trusted-name/data/HttpTrustedNameDataSource";import i from"../../../package.json";vi.mock("axios");const n={cal:{url:"https://crypto-assets-service.api.ledger.com/v1",mode:"prod",branch:"main"},metadataServiceDomain:{url:"https://nft.api.live.ledger.com"},originToken:"originToken"};describe("HttpTrustedNameDataSource",()=>{let t;beforeAll(()=>{t=new c(n),vi.clearAllMocks()}),describe("getDomainNamePayload",()=>{it("should call axios with the correct url and ledger client version header",async()=>{const e=`context-module/${i.version}`,a=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(o,"request").mockImplementation(a),await t.getDomainNamePayload({chainId:137,challenge:"9876",domain:"hello.eth"}),expect(a).toHaveBeenCalledWith(expect.objectContaining({url:"https://nft.api.live.ledger.com/v2/names/ethereum/137/forward/hello.eth?types=eoa&sources=ens&challenge=9876",headers:{[l]:e,[d]:n.originToken}}))}),it("should throw an error when axios throws an error",async()=>{vi.spyOn(o,"request").mockRejectedValue(new Error);const e=await t.getDomainNamePayload({chainId:137,challenge:"",domain:"hello.eth"});expect(e).toEqual(r(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name")))}),it("should return an error when no payload is returned",async()=>{const e={data:{test:""}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getDomainNamePayload({chainId:137,challenge:"",domain:"hello.eth"});expect(a).toEqual(r(new Error("[ContextModule] HttpTrustedNameDataSource: error getting domain payload")))}),it("should return a payload",async()=>{const e={data:{signedDescriptor:{data:"payload"}}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getDomainNamePayload({chainId:137,challenge:"challenge",domain:"hello.eth"});expect(a).toEqual(s("payload"))})}),describe("getTrustedNamePayload",()=>{it("should call axios with the correct url and ledger client version header",async()=>{const e=`context-module/${i.version}`,a=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(o,"request").mockImplementation(a),await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"5678",sources:["ens","crypto_asset_list"],types:["eoa"]}),expect(a).toHaveBeenCalledWith(expect.objectContaining({url:"https://nft.api.live.ledger.com/v2/names/ethereum/137/reverse/0x1234?types=eoa&sources=ens,crypto_asset_list&challenge=5678",headers:{[l]:e,[d]:n.originToken}}))}),it("should throw an error when axios throws an error",async()=>{vi.spyOn(o,"request").mockRejectedValue(new Error);const e=await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(e).toEqual(r(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name")))}),it("should return an error when no payload is returned",async()=>{const e={data:{test:""}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(a).toEqual(r(new Error("[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address 0x1234")))}),it("should return a payload",async()=>{const e={data:{signedDescriptor:{data:"payload"}}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(a).toEqual(s("payload"))}),it("should return a payload with a signature",async()=>{const e={data:{signedDescriptor:{data:"payload",signatures:{prod:"12345"}}}};vi.spyOn(o,"request").mockResolvedValue(e);const a=await t.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(a).toEqual(s("payload153012345"))})})});
2
2
  //# sourceMappingURL=HttpTrustedNameDataSource.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/trusted-name/data/HttpTrustedNameDataSource.test.ts"],
4
- "sourcesContent": ["import axios from \"axios\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport { HttpTrustedNameDataSource } from \"@/trusted-name/data/HttpTrustedNameDataSource\";\nimport { type TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\nvi.mock(\"axios\");\n\nconst config = {\n cal: {\n url: \"https://crypto-assets-service.api.ledger.com/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n metadataService: {\n url: \"https://nft.api.live.ledger.com/v2\",\n },\n originToken: \"originToken\",\n} as ContextModuleConfig;\ndescribe(\"HttpTrustedNameDataSource\", () => {\n let datasource: TrustedNameDataSource;\n\n beforeAll(() => {\n datasource = new HttpTrustedNameDataSource(config);\n vi.clearAllMocks();\n });\n\n describe(\"getDomainNamePayload\", () => {\n it(\"should call axios with the correct url and ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() => Promise.resolve({ data: [] }));\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"9876\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n url: `https://nft.api.live.ledger.com/v2/names/ethereum/137/forward/hello.eth?types=eoa&sources=ens&challenge=9876`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: version,\n [LEDGER_ORIGIN_TOKEN_HEADER]: config.originToken,\n },\n }),\n );\n });\n\n it(\"should throw an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error());\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name\",\n ),\n ),\n );\n });\n\n it(\"should return an error when no payload is returned\", async () => {\n // GIVEN\n const response = { data: { test: \"\" } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: error getting domain payload\",\n ),\n ),\n );\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const response = { data: { signedDescriptor: { data: \"payload\" } } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"challenge\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(Right(\"payload\"));\n });\n });\n\n describe(\"getTrustedNamePayload\", () => {\n it(\"should call axios with the correct url and ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() => Promise.resolve({ data: [] }));\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"5678\",\n sources: [\"ens\", \"crypto_asset_list\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n url: `https://nft.api.live.ledger.com/v2/names/ethereum/137/reverse/0x1234?types=eoa&sources=ens,crypto_asset_list&challenge=5678`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: version,\n [LEDGER_ORIGIN_TOKEN_HEADER]: config.originToken,\n },\n }),\n );\n });\n\n it(\"should throw an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error());\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name\",\n ),\n ),\n );\n });\n\n it(\"should return an error when no payload is returned\", async () => {\n // GIVEN\n const response = { data: { test: \"\" } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address 0x1234\",\n ),\n ),\n );\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const response = {\n data: {\n signedDescriptor: { data: \"payload\" },\n },\n };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(Right(\"payload\"));\n });\n\n it(\"should return a payload with a signature\", async () => {\n // GIVEN\n const response = {\n data: {\n signedDescriptor: { data: \"payload\", signatures: { prod: \"12345\" } },\n },\n };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa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CACH,CAAC,CACH,CAAC",
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport { HttpTrustedNameDataSource } from \"@/trusted-name/data/HttpTrustedNameDataSource\";\nimport { type TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\nvi.mock(\"axios\");\n\nconst config = {\n cal: {\n url: \"https://crypto-assets-service.api.ledger.com/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n metadataServiceDomain: {\n url: \"https://nft.api.live.ledger.com\",\n },\n originToken: \"originToken\",\n} as ContextModuleConfig;\ndescribe(\"HttpTrustedNameDataSource\", () => {\n let datasource: TrustedNameDataSource;\n\n beforeAll(() => {\n datasource = new HttpTrustedNameDataSource(config);\n vi.clearAllMocks();\n });\n\n describe(\"getDomainNamePayload\", () => {\n it(\"should call axios with the correct url and ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() => Promise.resolve({ data: [] }));\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"9876\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n url: `https://nft.api.live.ledger.com/v2/names/ethereum/137/forward/hello.eth?types=eoa&sources=ens&challenge=9876`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: version,\n [LEDGER_ORIGIN_TOKEN_HEADER]: config.originToken,\n },\n }),\n );\n });\n\n it(\"should throw an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error());\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name\",\n ),\n ),\n );\n });\n\n it(\"should return an error when no payload is returned\", async () => {\n // GIVEN\n const response = { data: { test: \"\" } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: error getting domain payload\",\n ),\n ),\n );\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const response = { data: { signedDescriptor: { data: \"payload\" } } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"challenge\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(Right(\"payload\"));\n });\n });\n\n describe(\"getTrustedNamePayload\", () => {\n it(\"should call axios with the correct url and ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() => Promise.resolve({ data: [] }));\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"5678\",\n sources: [\"ens\", \"crypto_asset_list\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n url: `https://nft.api.live.ledger.com/v2/names/ethereum/137/reverse/0x1234?types=eoa&sources=ens,crypto_asset_list&challenge=5678`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: version,\n [LEDGER_ORIGIN_TOKEN_HEADER]: config.originToken,\n },\n }),\n );\n });\n\n it(\"should throw an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error());\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name\",\n ),\n ),\n );\n });\n\n it(\"should return an error when no payload is returned\", async () => {\n // GIVEN\n const response = { data: { test: \"\" } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address 0x1234\",\n ),\n ),\n );\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const response = {\n data: {\n signedDescriptor: { data: \"payload\" },\n },\n };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(Right(\"payload\"));\n });\n\n it(\"should return a payload with a signature\", async () => {\n // GIVEN\n const response = {\n data: {\n signedDescriptor: { data: \"payload\", signatures: { prod: \"12345\" } },\n },\n };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(Right(\"payload153012345\"));\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAOA,MAAW,QAClB,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAG5B,OACE,gCAAAC,EACA,8BAAAC,MACK,gCACP,OAAS,6BAAAC,MAAiC,gDAE1C,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AAE,KAAM,CAAE,KAAM,EAAG,CAAE,EACtC,GAAG,MAAMZ,EAAO,SAAS,EAAE,kBAAkBY,CAAQ,EAGrD,MAAMD,EAAS,MAAMH,EAAW,sBAAsB,CACpD,QAAS,IACT,QAAS,SACT,UAAW,GACX,QAAS,CAAC,KAAK,EACf,MAAO,CAAC,KAAK,CACf,CAAC,EAGD,OAAOG,CAAM,EAAE,QACbV,EACE,IAAI,MACF,wFACF,CACF,CACF,CACF,CAAC,EAED,GAAG,0BAA2B,SAAY,CAExC,MAAMW,EAAW,CACf,KAAM,CACJ,iBAAkB,CAAE,KAAM,SAAU,CACtC,CACF,EACA,GAAG,MAAMZ,EAAO,SAAS,EAAE,kBAAkBY,CAAQ,EAGrD,MAAMD,EAAS,MAAMH,EAAW,sBAAsB,CACpD,QAAS,IACT,QAAS,SACT,UAAW,GACX,QAAS,CAAC,KAAK,EACf,MAAO,CAAC,KAAK,CACf,CAAC,EAGD,OAAOG,CAAM,EAAE,QAAQT,EAAM,SAAS,CAAC,CACzC,CAAC,EAED,GAAG,2CAA4C,SAAY,CAEzD,MAAMU,EAAW,CACf,KAAM,CACJ,iBAAkB,CAAE,KAAM,UAAW,WAAY,CAAE,KAAM,OAAQ,CAAE,CACrE,CACF,EACA,GAAG,MAAMZ,EAAO,SAAS,EAAE,kBAAkBY,CAAQ,EAGrD,MAAMD,EAAS,MAAMH,EAAW,sBAAsB,CACpD,QAAS,IACT,QAAS,SACT,UAAW,GACX,QAAS,CAAC,KAAK,EACf,MAAO,CAAC,KAAK,CACf,CAAC,EAGD,OAAOG,CAAM,EAAE,QAAQT,EAAM,kBAAkB,CAAC,CAClD,CAAC,CACH,CAAC,CACH,CAAC",
6
6
  "names": ["axios", "Left", "Right", "LEDGER_CLIENT_VERSION_HEADER", "LEDGER_ORIGIN_TOKEN_HEADER", "HttpTrustedNameDataSource", "PACKAGE", "config", "datasource", "version", "requestSpy", "result", "response"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{Left as l,Right as s}from"purify-ts";import{ClearSignContextType as n}from"../../shared/model/ClearSignContext";import{TrustedNameContextLoader as r}from"../../trusted-name/domain/TrustedNameContextLoader";describe("TrustedNameContextLoader",()=>{const o={getDomainNamePayload:vi.fn(),getTrustedNamePayload:vi.fn()};beforeEach(()=>{vi.restoreAllMocks(),vi.spyOn(o,"getDomainNamePayload").mockResolvedValue(s("payload"))}),describe("load function",async()=>{it("should return an empty array when no domain or registry",async()=>{const e={},t=new r(o),a=()=>t.load(e);await expect(a()).resolves.toEqual([])}),it("should return an error when domain > max length",async()=>{const e={domain:"maxlength-maxlength-maxlength-maxlength-maxlength-maxlength",challenge:"challenge"},a=await new r(o).load(e);expect(a).toEqual([{type:n.ERROR,error:new Error("[ContextModule] TrustedNameLoader: invalid domain")}])}),it("should return an error when domain is not valid",async()=>{const e={domain:"hello\u{1F44B}",challenge:"challenge"},a=await new r(o).load(e);expect(a).toEqual([{type:n.ERROR,error:new Error("[ContextModule] TrustedNameLoader: invalid domain")}])}),it("should return a payload",async()=>{const e={domain:"hello.eth",challenge:"challenge"},a=await new r(o).load(e);expect(a).toEqual([{type:n.TRUSTED_NAME,payload:"payload"}])}),it("should return an error when unable to fetch the datasource",async()=>{const e={domain:"hello.eth",challenge:"challenge"};vi.spyOn(o,"getDomainNamePayload").mockResolvedValue(l(new Error("error")));const a=await new r(o).load(e);expect(a).toEqual([{type:n.ERROR,error:new Error("error")}])}),it("should return an empty array when no challenge",async()=>{const e={domain:"hello.eth",challenge:void 0},a=await new r(o).load(e);expect(a).toEqual([])})}),describe("loadField function",()=>{it("should return an error when field type if not supported",async()=>{const e={type:n.TOKEN,chainId:7,address:"0x1234"},a=await new r(o).loadField(e);expect(a).toEqual(null)}),it("should return a payload",async()=>{const e={type:n.TRUSTED_NAME,chainId:7,address:"0x1234",challenge:"17",sources:["ens"],types:["eoa"]};vi.spyOn(o,"getTrustedNamePayload").mockResolvedValue(s("payload"));const a=await new r(o).loadField(e);expect(a).toEqual({type:n.TRUSTED_NAME,payload:"payload"})}),it("should return an error when unable to fetch the datasource",async()=>{const e={type:n.TRUSTED_NAME,chainId:7,address:"0x1234",challenge:"17",sources:["ens"],types:["eoa"]};vi.spyOn(o,"getTrustedNamePayload").mockResolvedValue(l(new Error("error")));const a=await new r(o).loadField(e);expect(a).toEqual({type:n.ERROR,error:new Error("error")})})})});
1
+ import{Left as l,Right as s}from"purify-ts";import{ClearSignContextType as n}from"../../shared/model/ClearSignContext";import{TrustedNameContextLoader as r}from"../../trusted-name/domain/TrustedNameContextLoader";describe("TrustedNameContextLoader",()=>{const o={getDomainNamePayload:vi.fn(),getTrustedNamePayload:vi.fn()};beforeEach(()=>{vi.restoreAllMocks(),vi.spyOn(o,"getDomainNamePayload").mockResolvedValue(s("payload"))}),describe("load function",()=>{it("should return an empty array when no domain or registry",async()=>{const e={},t=new r(o),a=()=>t.load(e);await expect(a()).resolves.toEqual([])}),it("should return an error when domain > max length",async()=>{const e={domain:"maxlength-maxlength-maxlength-maxlength-maxlength-maxlength",challenge:"challenge"},a=await new r(o).load(e);expect(a).toEqual([{type:n.ERROR,error:new Error("[ContextModule] TrustedNameLoader: invalid domain")}])}),it("should return an error when domain is not valid",async()=>{const e={domain:"hello\u{1F44B}",challenge:"challenge"},a=await new r(o).load(e);expect(a).toEqual([{type:n.ERROR,error:new Error("[ContextModule] TrustedNameLoader: invalid domain")}])}),it("should return a payload",async()=>{const e={domain:"hello.eth",challenge:"challenge"},a=await new r(o).load(e);expect(a).toEqual([{type:n.TRUSTED_NAME,payload:"payload"}])}),it("should return an error when unable to fetch the datasource",async()=>{const e={domain:"hello.eth",challenge:"challenge"};vi.spyOn(o,"getDomainNamePayload").mockResolvedValue(l(new Error("error")));const a=await new r(o).load(e);expect(a).toEqual([{type:n.ERROR,error:new Error("error")}])}),it("should return an empty array when no challenge",async()=>{const e={domain:"hello.eth",challenge:void 0},a=await new r(o).load(e);expect(a).toEqual([])})}),describe("loadField function",()=>{it("should return an error when field type if not supported",async()=>{const e={type:n.TOKEN,chainId:7,address:"0x1234"},a=await new r(o).loadField(e);expect(a).toEqual(null)}),it("should return a payload",async()=>{const e={type:n.TRUSTED_NAME,chainId:7,address:"0x1234",challenge:"17",sources:["ens"],types:["eoa"]};vi.spyOn(o,"getTrustedNamePayload").mockResolvedValue(s("payload"));const a=await new r(o).loadField(e);expect(a).toEqual({type:n.TRUSTED_NAME,payload:"payload"})}),it("should return an error when unable to fetch the datasource",async()=>{const e={type:n.TRUSTED_NAME,chainId:7,address:"0x1234",challenge:"17",sources:["ens"],types:["eoa"]};vi.spyOn(o,"getTrustedNamePayload").mockResolvedValue(l(new Error("error")));const a=await new r(o).loadField(e);expect(a).toEqual({type:n.ERROR,error:new Error("error")})})})});
2
2
  //# sourceMappingURL=TrustedNameContextLoader.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/trusted-name/domain/TrustedNameContextLoader.test.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"@/shared/model/TransactionContext\";\nimport { type TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport { TrustedNameContextLoader } from \"@/trusted-name/domain/TrustedNameContextLoader\";\n\ndescribe(\"TrustedNameContextLoader\", () => {\n const mockTrustedNameDataSource: TrustedNameDataSource = {\n getDomainNamePayload: vi.fn(),\n getTrustedNamePayload: vi.fn(),\n };\n\n beforeEach(() => {\n vi.restoreAllMocks();\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getDomainNamePayload\",\n ).mockResolvedValue(Right(\"payload\"));\n });\n\n describe(\"load function\", async () => {\n it(\"should return an empty array when no domain or registry\", async () => {\n const transaction = {} as TransactionContext;\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const promise = () => loader.load(transaction);\n\n await expect(promise()).resolves.toEqual([]);\n });\n\n it(\"should return an error when domain > max length\", async () => {\n const transaction = {\n domain: \"maxlength-maxlength-maxlength-maxlength-maxlength-maxlength\",\n challenge: \"challenge\",\n } as TransactionContext;\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ]);\n });\n\n it(\"should return an error when domain is not valid\", async () => {\n const transaction = {\n domain: \"hello\uD83D\uDC4B\",\n challenge: \"challenge\",\n } as TransactionContext;\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ]);\n });\n\n it(\"should return a payload\", async () => {\n const transaction = {\n domain: \"hello.eth\",\n challenge: \"challenge\",\n } as TransactionContext;\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.TRUSTED_NAME,\n payload: \"payload\",\n },\n ]);\n });\n\n it(\"should return an error when unable to fetch the datasource\", async () => {\n // GIVEN\n const transaction = {\n domain: \"hello.eth\",\n challenge: \"challenge\",\n } as TransactionContext;\n\n // WHEN\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getDomainNamePayload\",\n ).mockResolvedValue(Left(new Error(\"error\")));\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n { type: ClearSignContextType.ERROR, error: new Error(\"error\") },\n ]);\n });\n\n it(\"should return an empty array when no challenge\", async () => {\n // GIVEN\n const transaction = {\n domain: \"hello.eth\",\n challenge: undefined,\n } as TransactionContext;\n\n // WHEN\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n });\n\n describe(\"loadField function\", () => {\n it(\"should return an error when field type if not supported\", async () => {\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TOKEN,\n chainId: 7,\n address: \"0x1234\",\n };\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.loadField(field);\n\n expect(result).toEqual(null);\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TRUSTED_NAME,\n chainId: 7,\n address: \"0x1234\",\n challenge: \"17\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n };\n\n // WHEN\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(\"payload\"));\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: \"payload\",\n });\n });\n\n it(\"should return an error when unable to fetch the datasource\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TRUSTED_NAME,\n chainId: 7,\n address: \"0x1234\",\n challenge: \"17\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n };\n\n // WHEN\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Left(new Error(\"error\")));\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n });\n });\n });\n});\n"],
5
- "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAE5B,OAAS,wBAAAC,MAA4B,kCAMrC,OAAS,4BAAAC,MAAgC,iDAEzC,SAAS,2BAA4B,IAAM,CACzC,MAAMC,EAAmD,CACvD,qBAAsB,GAAG,GAAG,EAC5B,sBAAuB,GAAG,GAAG,CAC/B,EAEA,WAAW,IAAM,CACf,GAAG,gBAAgB,EACn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L,EAAyBC,CAAyB,EACzC,UAAUK,CAAK,EAG3C,OAAOD,CAAM,EAAE,QAAQ,CACrB,KAAMN,EAAqB,MAC3B,MAAO,IAAI,MAAM,OAAO,CAC1B,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"@/shared/model/TransactionContext\";\nimport { type TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport { TrustedNameContextLoader } from \"@/trusted-name/domain/TrustedNameContextLoader\";\n\ndescribe(\"TrustedNameContextLoader\", () => {\n const mockTrustedNameDataSource: TrustedNameDataSource = {\n getDomainNamePayload: vi.fn(),\n getTrustedNamePayload: vi.fn(),\n };\n\n beforeEach(() => {\n vi.restoreAllMocks();\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getDomainNamePayload\",\n ).mockResolvedValue(Right(\"payload\"));\n });\n\n describe(\"load function\", () => {\n it(\"should return an empty array when no domain or registry\", async () => {\n const transaction = {} as TransactionContext;\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const promise = () => loader.load(transaction);\n\n await expect(promise()).resolves.toEqual([]);\n });\n\n it(\"should return an error when domain > max length\", async () => {\n const transaction = {\n domain: \"maxlength-maxlength-maxlength-maxlength-maxlength-maxlength\",\n challenge: \"challenge\",\n } as TransactionContext;\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ]);\n });\n\n it(\"should return an error when domain is not valid\", async () => {\n const transaction = {\n domain: \"hello\uD83D\uDC4B\",\n challenge: \"challenge\",\n } as TransactionContext;\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ]);\n });\n\n it(\"should return a payload\", async () => {\n const transaction = {\n domain: \"hello.eth\",\n challenge: \"challenge\",\n } as TransactionContext;\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.TRUSTED_NAME,\n payload: \"payload\",\n },\n ]);\n });\n\n it(\"should return an error when unable to fetch the datasource\", async () => {\n // GIVEN\n const transaction = {\n domain: \"hello.eth\",\n challenge: \"challenge\",\n } as TransactionContext;\n\n // WHEN\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getDomainNamePayload\",\n ).mockResolvedValue(Left(new Error(\"error\")));\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n { type: ClearSignContextType.ERROR, error: new Error(\"error\") },\n ]);\n });\n\n it(\"should return an empty array when no challenge\", async () => {\n // GIVEN\n const transaction = {\n domain: \"hello.eth\",\n challenge: undefined,\n } as TransactionContext;\n\n // WHEN\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n });\n\n describe(\"loadField function\", () => {\n it(\"should return an error when field type if not supported\", async () => {\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TOKEN,\n chainId: 7,\n address: \"0x1234\",\n };\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.loadField(field);\n\n expect(result).toEqual(null);\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TRUSTED_NAME,\n chainId: 7,\n address: \"0x1234\",\n challenge: \"17\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n };\n\n // WHEN\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(\"payload\"));\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: \"payload\",\n });\n });\n\n it(\"should return an error when unable to fetch the datasource\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TRUSTED_NAME,\n chainId: 7,\n address: \"0x1234\",\n challenge: \"17\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n };\n\n // WHEN\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Left(new Error(\"error\")));\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n });\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAE5B,OAAS,wBAAAC,MAA4B,kCAMrC,OAAS,4BAAAC,MAAgC,iDAEzC,SAAS,2BAA4B,IAAM,CACzC,MAAMC,EAAmD,CACvD,qBAAsB,GAAG,GAAG,EAC5B,sBAAuB,GAAG,GAAG,CAC/B,EAEA,WAAW,IAAM,CACf,GAAG,gBAAgB,EACnB,GAAG,MACDA,EACA,sBACF,EAAE,kBAAkBH,EAAM,SAAS,CAAC,CACtC,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,GAAG,0DAA2D,SAAY,CACxE,MAAMI,EAAc,CAAC,EACfC,EAAS,IAAIH,EAAyBC,CAAyB,EAC/DG,EAAU,IAAMD,EAAO,KAAKD,CAAW,EAE7C,MAAM,OAAOE,EAAQ,CAAC,EAAE,SAAS,QAAQ,CAAC,CAAC,CAC7C,CAAC,EAED,GAAG,kDAAmD,SAAY,CAChE,MAAMF,EAAc,CAClB,OAAQ,8DACR,UAAW,WACb,EAGMG,EAAS,MADA,IAAIL,EAAyBC,CAAyB,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,MAAMC,EAAiC,CACrC,KAAMP,EAAqB,MAC3B,QAAS,EACT,QAAS,QACX,EAGMM,EAAS,MADA,IAAIL,EAAyBC,CAAyB,EACzC,UAAUK,CAAK,EAE3C,OAAOD,CAAM,EAAE,QAAQ,IAAI,CAC7B,CAAC,EAED,GAAG,0BAA2B,SAAY,CAExC,MAAMC,EAAiC,CACrC,KAAMP,EAAqB,aAC3B,QAAS,EACT,QAAS,SACT,UAAW,KACX,QAAS,CAAC,KAAK,EACf,MAAO,CAAC,KAAK,CACf,EAGA,GAAG,MACDE,EACA,uBACF,EAAE,kBAAkBH,EAAM,SAAS,CAAC,EAEpC,MAAMO,EAAS,MADA,IAAIL,EAAyBC,CAAyB,EACzC,UAAUK,CAAK,EAG3C,OAAOD,CAAM,EAAE,QAAQ,CACrB,KAAMN,EAAqB,aAC3B,QAAS,SACX,CAAC,CACH,CAAC,EAED,GAAG,6DAA8D,SAAY,CAE3E,MAAMO,EAAiC,CACrC,KAAMP,EAAqB,aAC3B,QAAS,EACT,QAAS,SACT,UAAW,KACX,QAAS,CAAC,KAAK,EACf,MAAO,CAAC,KAAK,CACf,EAGA,GAAG,MACDE,EACA,uBACF,EAAE,kBAAkBJ,EAAK,IAAI,MAAM,OAAO,CAAC,CAAC,EAE5C,MAAMQ,EAAS,MADA,IAAIL,EAAyBC,CAAyB,EACzC,UAAUK,CAAK,EAG3C,OAAOD,CAAM,EAAE,QAAQ,CACrB,KAAMN,EAAqB,MAC3B,MAAO,IAAI,MAAM,OAAO,CAC1B,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
6
  "names": ["Left", "Right", "ClearSignContextType", "TrustedNameContextLoader", "mockTrustedNameDataSource", "transaction", "loader", "promise", "result", "field"]
7
7
  }
@@ -1,2 +1,2 @@
1
- var P=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var g=(d,t,e,n)=>{for(var a=n>1?void 0:n?U(t,e):t,r=d.length-1,o;r>=0;r--)(o=d[r])&&(a=(n?o(t,e,a):o(a))||a);return n&&a&&P(t,e,a),a},u=(d,t)=>(e,n)=>t(e,n,d);import{bufferToHexaString as N,ByteArrayBuilder as E,hexaStringToBuffer as p,isHexaString as c}from"@ledgerhq/device-management-kit";import{Interface as I}from"ethers";import{inject as C,injectable as w}from"inversify";import{Maybe as x,Nothing as k}from"purify-ts";import{ClearSignContextType as S}from"../../shared/model/ClearSignContext";import{tokenTypes as H}from"../../token/di/tokenTypes";import{UNISWAP_PLUGIN_NAME as y,UNISWAP_PLUGIN_SIGNATURE as b}from"../../uniswap/constants/plugin";import{UNISWAP_COMMANDS as R,UNISWAP_EXECUTE_ABI as v,UNISWAP_EXECUTE_SELECTOR as D,UNISWAP_SWAP_COMMANDS as B,UNISWAP_UNIVERSAL_ROUTER_ADDRESS as M}from"../../uniswap/constants/uniswap";import{uniswapTypes as W}from"../../uniswap/di/uniswapTypes";let m=class{constructor(t,e){this.commandDecoderDataSource=t;this.tokenDataSource=e}async load(t){const{data:e,selector:n,chainId:a}=t;if(!c(e))return[];if(n!==D)return[];const r=this._buildUniswapPluginCommandData(),o=await this._extractClearSignContexts(e,a);return o.length>0?[r,...o]:[]}_buildUniswapPluginCommandData(){const t=new E().add8BitUIntToData(y.length).addAsciiStringToData(y).addBufferToData(p(M)).addBufferToData(p(D)).addBufferToData(p(b)).build();return{type:S.EXTERNAL_PLUGIN,payload:N(t).slice(2)}}async _extractClearSignContexts(t,e){try{const a=new I(v).parseTransaction({data:t}),r=a?.args[0],o=a?.args[1];if(!c(r)||!this._isHexaStringArray(o))return[];const f=this._extractCommands(r).orDefault([]);if(r.length===0||o.length!==f.length)return[];const l=f.reduce((i,s,A)=>{const T=o[A],h=this.commandDecoderDataSource.decode(s,T,e);return i.push([s,h]),i},[]);if(!this._isChainingSwapSupported(l))return[];const _=[...new Set(l.flatMap(([,i])=>i))];return(await Promise.all(_.map(i=>this.tokenDataSource.getTokenInfosPayload({address:i,chainId:e})))).map(i=>i.caseOf({Left:s=>({type:S.ERROR,error:s}),Right:s=>({type:S.TOKEN,payload:s})}))}catch{return[]}}_extractCommands(t){return x.fromNullable(t.slice(2).match(/../g)).map(e=>e.map(n=>`0x${n}`)).map(e=>e.map(n=>R[n])).chain(e=>e.every(n=>n!==void 0)?x.of(e):k)}_isChainingSwapSupported(t){let e,n;for(const[a,r]of t){if(!B.includes(a))continue;const o=a.slice(0,2);if(e&&(e!==r[0]||n!==o))return!1;e=r[r.length-1],n=o}return!0}_isHexaStringArray(t){return Array.isArray(t)&&t.every(e=>typeof e=="string"&&c(e))}};m=g([w(),u(0,C(W.CommandDecoderDataSource)),u(1,C(H.TokenDataSource))],m);export{m as UniswapContextLoader};
1
+ var P=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var g=(d,t,e,a)=>{for(var n=a>1?void 0:a?U(t,e):t,r=d.length-1,o;r>=0;r--)(o=d[r])&&(n=(a?o(t,e,n):o(n))||n);return a&&n&&P(t,e,n),n},u=(d,t)=>(e,a)=>t(e,a,d);import{bufferToHexaString as N,ByteArrayBuilder as E,hexaStringToBuffer as p,isHexaString as c}from"@ledgerhq/device-management-kit";import{Interface as I}from"ethers";import{inject as C,injectable as w}from"inversify";import{Maybe as x,Nothing as k}from"purify-ts";import{ClearSignContextType as S}from"../../shared/model/ClearSignContext";import{tokenTypes as H}from"../../token/di/tokenTypes";import{UNISWAP_PLUGIN_NAME as y,UNISWAP_PLUGIN_SIGNATURE as b}from"../../uniswap/constants/plugin";import{UNISWAP_COMMANDS as R,UNISWAP_EXECUTE_ABI as v,UNISWAP_EXECUTE_SELECTOR as D,UNISWAP_SWAP_COMMANDS as B,UNISWAP_UNIVERSAL_ROUTER_ADDRESS as M}from"../../uniswap/constants/uniswap";import{uniswapTypes as W}from"../../uniswap/di/uniswapTypes";let m=class{constructor(t,e){this.commandDecoderDataSource=t;this.tokenDataSource=e}async load(t){const{data:e,selector:a,chainId:n}=t;if(!c(e))return[];if(a!==D)return[];const r=this._buildUniswapPluginCommandData(),o=await this._extractClearSignContexts(e,n);return o.length>0?[r,...o]:[]}_buildUniswapPluginCommandData(){const t=new E().add8BitUIntToData(y.length).addAsciiStringToData(y).addBufferToData(p(M)).addBufferToData(p(D)).addBufferToData(p(b)).build();return{type:S.EXTERNAL_PLUGIN,payload:N(t,!1)}}async _extractClearSignContexts(t,e){try{const n=new I(v).parseTransaction({data:t}),r=n?.args[0],o=n?.args[1];if(!c(r)||!this._isHexaStringArray(o))return[];const f=this._extractCommands(r).orDefault([]);if(r.length===0||o.length!==f.length)return[];const l=f.reduce((i,s,A)=>{const T=o[A],h=this.commandDecoderDataSource.decode(s,T,e);return i.push([s,h]),i},[]);if(!this._isChainingSwapSupported(l))return[];const _=[...new Set(l.flatMap(([,i])=>i))];return(await Promise.all(_.map(i=>this.tokenDataSource.getTokenInfosPayload({address:i,chainId:e})))).map(i=>i.caseOf({Left:s=>({type:S.ERROR,error:s}),Right:s=>({type:S.TOKEN,payload:s})}))}catch{return[]}}_extractCommands(t){return x.fromNullable(t.slice(2).match(/../g)).map(e=>e.map(a=>`0x${a}`)).map(e=>e.map(a=>R[a])).chain(e=>e.every(a=>a!==void 0)?x.of(e):k)}_isChainingSwapSupported(t){let e,a;for(const[n,r]of t){if(!B.includes(n))continue;const o=n.slice(0,2);if(e&&(e!==r[0]||a!==o))return!1;e=r[r.length-1],a=o}return!0}_isHexaStringArray(t){return Array.isArray(t)&&t.every(e=>typeof e=="string"&&c(e))}};m=g([w(),u(0,C(W.CommandDecoderDataSource)),u(1,C(H.TokenDataSource))],m);export{m as UniswapContextLoader};
2
2
  //# sourceMappingURL=UniswapContextLoader.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/uniswap/domain/UniswapContextLoader.ts"],
4
- "sourcesContent": ["import {\n bufferToHexaString,\n ByteArrayBuilder,\n HexaString,\n hexaStringToBuffer,\n isHexaString,\n} from \"@ledgerhq/device-management-kit\";\nimport { Interface } from \"ethers\";\nimport { inject, injectable } from \"inversify\";\nimport { Maybe, Nothing } from \"purify-ts\";\n\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { TransactionContext } from \"@/shared/model/TransactionContext\";\nimport { type TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\nimport {\n UNISWAP_PLUGIN_NAME,\n UNISWAP_PLUGIN_SIGNATURE,\n} from \"@/uniswap/constants/plugin\";\nimport {\n UNISWAP_COMMANDS,\n UNISWAP_EXECUTE_ABI,\n UNISWAP_EXECUTE_SELECTOR,\n UNISWAP_SWAP_COMMANDS,\n UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n UniswapSupportedCommand,\n} from \"@/uniswap/constants/uniswap\";\nimport { type CommandDecoderDataSource } from \"@/uniswap/data/CommandDecoderDataSource\";\nimport { uniswapTypes } from \"@/uniswap/di/uniswapTypes\";\n\n@injectable()\nexport class UniswapContextLoader implements ContextLoader {\n constructor(\n @inject(uniswapTypes.CommandDecoderDataSource)\n private commandDecoderDataSource: CommandDecoderDataSource,\n @inject(tokenTypes.TokenDataSource)\n private tokenDataSource: TokenDataSource,\n ) {}\n\n async load(ctx: TransactionContext): Promise<ClearSignContext[]> {\n const { data, selector, chainId } = ctx;\n if (!isHexaString(data)) {\n return [];\n }\n\n if (selector !== UNISWAP_EXECUTE_SELECTOR) {\n return [];\n }\n\n const externalPluginContext = this._buildUniswapPluginCommandData();\n const tokenContexts = await this._extractClearSignContexts(data, chainId);\n\n if (tokenContexts.length > 0)\n return [externalPluginContext, ...tokenContexts];\n\n return [];\n }\n\n /**\n * Constructs the external plugin context for Uniswap external plugin command.\n *\n * @private\n * @returns {ClearSignContext} - The generated external plugin context.\n */\n private _buildUniswapPluginCommandData(): ClearSignContext {\n const buffer = new ByteArrayBuilder()\n .add8BitUIntToData(UNISWAP_PLUGIN_NAME.length)\n .addAsciiStringToData(UNISWAP_PLUGIN_NAME)\n .addBufferToData(hexaStringToBuffer(UNISWAP_UNIVERSAL_ROUTER_ADDRESS)!)\n .addBufferToData(hexaStringToBuffer(UNISWAP_EXECUTE_SELECTOR)!)\n .addBufferToData(hexaStringToBuffer(UNISWAP_PLUGIN_SIGNATURE)!)\n .build();\n\n return {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: bufferToHexaString(buffer).slice(2),\n };\n }\n\n /**\n * Extracts and decodes the clear sign contexts from a Uniswap calldata transaction.\n *\n * This function:\n * - Parses the calldata using the Uniswap `execute` function signature.\n * - Extracts and validates the `commands` and `inputs`.\n * - Decodes the commands and ensures they match the number of inputs.\n * - Extracts addresses used in the transaction and verifies if chaining swaps are supported.\n * - Fetches token information for unique addresses.\n * - Returns an array of `ClearSignContext` objects representing either token data or errors.\n *\n * @private\n * @param {HexaString} calldata - The raw calldata of the Uniswap transaction.\n * @param {number} chainId - The blockchain chain ID where the transaction is being executed.\n * @returns {Promise<ClearSignContext[]>} - A promise resolving to an array of clear sign contexts.\n */\n private async _extractClearSignContexts(\n calldata: HexaString,\n chainId: number,\n ): Promise<ClearSignContext[]> {\n try {\n const iface = new Interface(UNISWAP_EXECUTE_ABI);\n\n const tx = iface.parseTransaction({ data: calldata });\n const commands: unknown = tx?.args[0];\n const inputs: unknown = tx?.args[1];\n\n if (!isHexaString(commands) || !this._isHexaStringArray(inputs)) {\n return [];\n }\n\n const decodedCommands = this._extractCommands(commands).orDefault([]);\n if (commands.length === 0 || inputs.length !== decodedCommands.length) {\n // Invalid commands or inputs\n return [];\n }\n\n const addressesByCommand = decodedCommands.reduce(\n (acc, command, index) => {\n const input = inputs[index]!;\n const decoded: HexaString[] = this.commandDecoderDataSource.decode(\n command,\n input,\n chainId,\n );\n\n acc.push([command, decoded]);\n\n return acc;\n },\n [] as [UniswapSupportedCommand, HexaString[]][],\n );\n\n if (!this._isChainingSwapSupported(addressesByCommand)) {\n return [];\n }\n\n const uniqueAddresses = [\n ...new Set(addressesByCommand.flatMap(([, addresses]) => addresses)),\n ];\n\n const tokensPayload = await Promise.all(\n uniqueAddresses.map((address) =>\n this.tokenDataSource.getTokenInfosPayload({ address, chainId }),\n ),\n );\n\n return tokensPayload.map((either) =>\n either.caseOf<ClearSignContext>({\n Left: (error) => ({ type: ClearSignContextType.ERROR, error }),\n Right: (payload) => ({ type: ClearSignContextType.TOKEN, payload }),\n }),\n );\n } catch (_) {\n return [];\n }\n }\n\n /**\n * Extracts Uniswap-supported commands from a hexadecimal string.\n * Each command is represented by one byte (2 hex characters), and this function:\n * - Maps each command to a known Uniswap command.\n * - Returns `Nothing` if any extracted command is unsupported.\n *\n * @private\n * @param {HexaString} hex - A hexadecimal string representing commands.\n * @returns {Maybe<UniswapSupportedCommand[]>} - A `Maybe` containing an array of recognized commands, or `Nothing` if any command is unsupported.\n *\n * @example\n * // Valid command extraction\n * _extractCommands('0x0008');\n * // Returns: Just(['0x00', '0x08'])\n *\n * @example\n * // Contains an unsupported command (0x05 is not supported)\n * _extractCommands('0x0005');\n * // Returns: Nothing\n *\n * @example\n * // Empty or invalid input\n * _extractCommands('0x');\n * // Returns: Nothing\n */\n private _extractCommands(hex: HexaString): Maybe<UniswapSupportedCommand[]> {\n return Maybe.fromNullable(hex.slice(2).match(/../g))\n .map((bytes) => bytes.map((b) => `0x${b}` as HexaString))\n .map((hexBytes) => hexBytes.map((b) => UNISWAP_COMMANDS[b]))\n .chain((commands) =>\n commands.every((command) => command !== undefined)\n ? Maybe.of(commands as UniswapSupportedCommand[])\n : Nothing,\n );\n }\n\n /**\n * Checks if the provided swap commands can be chained together.\n * A valid chain requires that:\n * - The output asset of the previous swap matches the input asset of the next swap.\n * - The pool version remains consistent across swaps.\n *\n * @private\n * @param {Array<[UniswapSupportedCommand, HexaString[]]>} data - An array of tuples containing a swap command and associated addresses.\n * @returns {boolean} - Returns `true` if the swap commands form a valid chain, otherwise `false`.\n *\n * @example\n * // Valid chaining: same output/input asset and pool version\n * _isChainingSwapSupported([\n * ['0x08', ['0xABC', '0xDEF']],\n * ['0x08', ['0xDEF', '0x123']]\n * ]);\n * // Returns: true\n *\n * @example\n * // Invalid chaining: different pool versions\n * _isChainingSwapSupported([\n * ['0x08', ['0xABC', '0xDEF']],\n * ['0x01', ['0xDEF', '0x123']]\n * ]);\n * // Returns: false\n *\n * @example\n * // Invalid chaining: output does not match next input\n * _isChainingSwapSupported([\n * ['0x01A1', ['0xABC', '0xDEF']],\n * ['0x01B2', ['0xXYZ', '0x123']]\n * ]);\n * // Returns: false\n */\n private _isChainingSwapSupported(\n data: [UniswapSupportedCommand, HexaString[]][],\n ): boolean {\n let lastAsset: HexaString | undefined = undefined;\n let lastPoolVersion: string | undefined = undefined;\n\n for (const [command, addresses] of data) {\n if (!UNISWAP_SWAP_COMMANDS.includes(command)) continue; // Ignore non-swap commands\n\n const poolVersion = command.slice(0, 2);\n\n if (\n lastAsset &&\n (lastAsset !== addresses[0] || lastPoolVersion !== poolVersion)\n ) {\n // Invalid chaining, return empty array\n return false;\n }\n\n // update last asset and pool version\n lastAsset = addresses[addresses.length - 1];\n lastPoolVersion = poolVersion;\n }\n\n return true;\n }\n\n /**\n * Checks if a given value is an array of hexadecimal strings.\n *\n * @private\n * @param {unknown} array - The value to check.\n * @returns {array is HexaString[]} - `true` if the value is an array of hexadecimal strings, otherwise `false`.\n */\n private _isHexaStringArray(array: unknown): array is HexaString[] {\n return (\n Array.isArray(array) &&\n array.every((item) => typeof item === \"string\" && isHexaString(item))\n );\n }\n}\n"],
5
- "mappings": "iOAAA,OACE,sBAAAA,EACA,oBAAAC,EAEA,sBAAAC,EACA,gBAAAC,MACK,kCACP,OAAS,aAAAC,MAAiB,SAC1B,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAS,SAAAC,EAAO,WAAAC,MAAe,YAG/B,OAEE,wBAAAC,MACK,kCAGP,OAAS,cAAAC,MAAkB,wBAC3B,OACE,uBAAAC,EACA,4BAAAC,MACK,6BACP,OACE,oBAAAC,EACA,uB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SAE9C,MAAMoB,EAAcpB,EAAQ,MAAM,EAAG,CAAC,EAEtC,GACEiB,IACCA,IAAcZ,EAAU,CAAC,GAAKa,IAAoBE,GAGnD,MAAO,GAITH,EAAYZ,EAAUA,EAAU,OAAS,CAAC,EAC1Ca,EAAkBE,CACpB,CAEA,MAAO,EACT,CASQ,mBAAmBC,EAAuC,CAChE,OACE,MAAM,QAAQA,CAAK,GACnBA,EAAM,MAAOC,GAAS,OAAOA,GAAS,UAAY3C,EAAa2C,CAAI,CAAC,CAExE,CACF,EA5OalD,EAANmD,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAa,wBAAwB,GAE5CF,EAAA,EAAAC,EAAOE,EAAW,eAAe,IAJzBxD",
4
+ "sourcesContent": ["import {\n bufferToHexaString,\n ByteArrayBuilder,\n HexaString,\n hexaStringToBuffer,\n isHexaString,\n} from \"@ledgerhq/device-management-kit\";\nimport { Interface } from \"ethers\";\nimport { inject, injectable } from \"inversify\";\nimport { Maybe, Nothing } from \"purify-ts\";\n\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { TransactionContext } from \"@/shared/model/TransactionContext\";\nimport { type TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\nimport {\n UNISWAP_PLUGIN_NAME,\n UNISWAP_PLUGIN_SIGNATURE,\n} from \"@/uniswap/constants/plugin\";\nimport {\n UNISWAP_COMMANDS,\n UNISWAP_EXECUTE_ABI,\n UNISWAP_EXECUTE_SELECTOR,\n UNISWAP_SWAP_COMMANDS,\n UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n UniswapSupportedCommand,\n} from \"@/uniswap/constants/uniswap\";\nimport { type CommandDecoderDataSource } from \"@/uniswap/data/CommandDecoderDataSource\";\nimport { uniswapTypes } from \"@/uniswap/di/uniswapTypes\";\n\n@injectable()\nexport class UniswapContextLoader implements ContextLoader {\n constructor(\n @inject(uniswapTypes.CommandDecoderDataSource)\n private commandDecoderDataSource: CommandDecoderDataSource,\n @inject(tokenTypes.TokenDataSource)\n private tokenDataSource: TokenDataSource,\n ) {}\n\n async load(ctx: TransactionContext): Promise<ClearSignContext[]> {\n const { data, selector, chainId } = ctx;\n if (!isHexaString(data)) {\n return [];\n }\n\n if (selector !== UNISWAP_EXECUTE_SELECTOR) {\n return [];\n }\n\n const externalPluginContext = this._buildUniswapPluginCommandData();\n const tokenContexts = await this._extractClearSignContexts(data, chainId);\n\n if (tokenContexts.length > 0)\n return [externalPluginContext, ...tokenContexts];\n\n return [];\n }\n\n /**\n * Constructs the external plugin context for Uniswap external plugin command.\n *\n * @private\n * @returns {ClearSignContext} - The generated external plugin context.\n */\n private _buildUniswapPluginCommandData(): ClearSignContext {\n const buffer = new ByteArrayBuilder()\n .add8BitUIntToData(UNISWAP_PLUGIN_NAME.length)\n .addAsciiStringToData(UNISWAP_PLUGIN_NAME)\n .addBufferToData(hexaStringToBuffer(UNISWAP_UNIVERSAL_ROUTER_ADDRESS)!)\n .addBufferToData(hexaStringToBuffer(UNISWAP_EXECUTE_SELECTOR)!)\n .addBufferToData(hexaStringToBuffer(UNISWAP_PLUGIN_SIGNATURE)!)\n .build();\n\n return {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: bufferToHexaString(buffer, false),\n };\n }\n\n /**\n * Extracts and decodes the clear sign contexts from a Uniswap calldata transaction.\n *\n * This function:\n * - Parses the calldata using the Uniswap `execute` function signature.\n * - Extracts and validates the `commands` and `inputs`.\n * - Decodes the commands and ensures they match the number of inputs.\n * - Extracts addresses used in the transaction and verifies if chaining swaps are supported.\n * - Fetches token information for unique addresses.\n * - Returns an array of `ClearSignContext` objects representing either token data or errors.\n *\n * @private\n * @param {HexaString} calldata - The raw calldata of the Uniswap transaction.\n * @param {number} chainId - The blockchain chain ID where the transaction is being executed.\n * @returns {Promise<ClearSignContext[]>} - A promise resolving to an array of clear sign contexts.\n */\n private async _extractClearSignContexts(\n calldata: HexaString,\n chainId: number,\n ): Promise<ClearSignContext[]> {\n try {\n const iface = new Interface(UNISWAP_EXECUTE_ABI);\n\n const tx = iface.parseTransaction({ data: calldata });\n const commands: unknown = tx?.args[0];\n const inputs: unknown = tx?.args[1];\n\n if (!isHexaString(commands) || !this._isHexaStringArray(inputs)) {\n return [];\n }\n\n const decodedCommands = this._extractCommands(commands).orDefault([]);\n if (commands.length === 0 || inputs.length !== decodedCommands.length) {\n // Invalid commands or inputs\n return [];\n }\n\n const addressesByCommand = decodedCommands.reduce(\n (acc, command, index) => {\n const input = inputs[index]!;\n const decoded: HexaString[] = this.commandDecoderDataSource.decode(\n command,\n input,\n chainId,\n );\n\n acc.push([command, decoded]);\n\n return acc;\n },\n [] as [UniswapSupportedCommand, HexaString[]][],\n );\n\n if (!this._isChainingSwapSupported(addressesByCommand)) {\n return [];\n }\n\n const uniqueAddresses = [\n ...new Set(addressesByCommand.flatMap(([, addresses]) => addresses)),\n ];\n\n const tokensPayload = await Promise.all(\n uniqueAddresses.map((address) =>\n this.tokenDataSource.getTokenInfosPayload({ address, chainId }),\n ),\n );\n\n return tokensPayload.map((either) =>\n either.caseOf<ClearSignContext>({\n Left: (error) => ({ type: ClearSignContextType.ERROR, error }),\n Right: (payload) => ({ type: ClearSignContextType.TOKEN, payload }),\n }),\n );\n } catch (_) {\n return [];\n }\n }\n\n /**\n * Extracts Uniswap-supported commands from a hexadecimal string.\n * Each command is represented by one byte (2 hex characters), and this function:\n * - Maps each command to a known Uniswap command.\n * - Returns `Nothing` if any extracted command is unsupported.\n *\n * @private\n * @param {HexaString} hex - A hexadecimal string representing commands.\n * @returns {Maybe<UniswapSupportedCommand[]>} - A `Maybe` containing an array of recognized commands, or `Nothing` if any command is unsupported.\n *\n * @example\n * // Valid command extraction\n * _extractCommands('0x0008');\n * // Returns: Just(['0x00', '0x08'])\n *\n * @example\n * // Contains an unsupported command (0x05 is not supported)\n * _extractCommands('0x0005');\n * // Returns: Nothing\n *\n * @example\n * // Empty or invalid input\n * _extractCommands('0x');\n * // Returns: Nothing\n */\n private _extractCommands(hex: HexaString): Maybe<UniswapSupportedCommand[]> {\n return Maybe.fromNullable(hex.slice(2).match(/../g))\n .map((bytes) => bytes.map((b) => `0x${b}` as HexaString))\n .map((hexBytes) => hexBytes.map((b) => UNISWAP_COMMANDS[b]))\n .chain((commands) =>\n commands.every((command) => command !== undefined)\n ? Maybe.of(commands as UniswapSupportedCommand[])\n : Nothing,\n );\n }\n\n /**\n * Checks if the provided swap commands can be chained together.\n * A valid chain requires that:\n * - The output asset of the previous swap matches the input asset of the next swap.\n * - The pool version remains consistent across swaps.\n *\n * @private\n * @param {Array<[UniswapSupportedCommand, HexaString[]]>} data - An array of tuples containing a swap command and associated addresses.\n * @returns {boolean} - Returns `true` if the swap commands form a valid chain, otherwise `false`.\n *\n * @example\n * // Valid chaining: same output/input asset and pool version\n * _isChainingSwapSupported([\n * ['0x08', ['0xABC', '0xDEF']],\n * ['0x08', ['0xDEF', '0x123']]\n * ]);\n * // Returns: true\n *\n * @example\n * // Invalid chaining: different pool versions\n * _isChainingSwapSupported([\n * ['0x08', ['0xABC', '0xDEF']],\n * ['0x01', ['0xDEF', '0x123']]\n * ]);\n * // Returns: false\n *\n * @example\n * // Invalid chaining: output does not match next input\n * _isChainingSwapSupported([\n * ['0x01A1', ['0xABC', '0xDEF']],\n * ['0x01B2', ['0xXYZ', '0x123']]\n * ]);\n * // Returns: false\n */\n private _isChainingSwapSupported(\n data: [UniswapSupportedCommand, HexaString[]][],\n ): boolean {\n let lastAsset: HexaString | undefined = undefined;\n let lastPoolVersion: string | undefined = undefined;\n\n for (const [command, addresses] of data) {\n if (!UNISWAP_SWAP_COMMANDS.includes(command)) continue; // Ignore non-swap commands\n\n const poolVersion = command.slice(0, 2);\n\n if (\n lastAsset &&\n (lastAsset !== addresses[0] || lastPoolVersion !== poolVersion)\n ) {\n // Invalid chaining, return empty array\n return false;\n }\n\n // update last asset and pool version\n lastAsset = addresses[addresses.length - 1];\n lastPoolVersion = poolVersion;\n }\n\n return true;\n }\n\n /**\n * Checks if a given value is an array of hexadecimal strings.\n *\n * @private\n * @param {unknown} array - The value to check.\n * @returns {array is HexaString[]} - `true` if the value is an array of hexadecimal strings, otherwise `false`.\n */\n private _isHexaStringArray(array: unknown): array is HexaString[] {\n return (\n Array.isArray(array) &&\n array.every((item) => typeof item === \"string\" && isHexaString(item))\n );\n }\n}\n"],
5
+ "mappings": "iOAAA,OACE,sBAAAA,EACA,oBAAAC,EAEA,sBAAAC,EACA,gBAAAC,MACK,kCACP,OAAS,aAAAC,MAAiB,SAC1B,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAS,SAAAC,EAAO,WAAAC,MAAe,YAG/B,OAEE,wBAAAC,MACK,kCAGP,OAAS,cAAAC,MAAkB,wBAC3B,OACE,uBAAAC,EACA,4BAAAC,MACK,6BACP,OACE,oBAAAC,EACA,uBAAAC,EACA,4BAAAC,EACA,yBAAAC,EACA,oCAAAC,MAEK,8BAEP,OAAS,gBAAAC,MAAoB,4BAGtB,IAAMC,EAAN,KAAoD,CACzD,YAEUC,EAEAC,EACR,CAHQ,8BAAAD,EAEA,qBAAAC,CACP,CAEH,MAAM,KAAKC,EAAsD,CAC/D,KAAM,CAAE,KAAAC,EAAM,SAAAC,EAAU,QAAAC,CAAQ,EAAIH,EACpC,GAAI,CAACI,EAAaH,CAAI,EACpB,MAAO,CAAC,EAGV,GAAIC,IAAaG,EACf,MAAO,CAAC,EAGV,MAAMC,EAAwB,KAAK,+BAA+B,EAC5DC,EAAgB,MAAM,KAAK,0BAA0BN,EAAME,CAAO,EAExE,OAAII,EAAc,OAAS,EAClB,CAACD,EAAuB,GAAGC,CAAa,EAE1C,CAAC,CACV,CAQQ,gCAAmD,CACzD,MAAMC,EAAS,IAAIC,EAAiB,EACjC,kBAAkBC,EAAoB,MAAM,EAC5C,qBAAqBA,CAAmB,EACxC,gBAAg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AAAmB,CAAM,GAC5D,MAAQC,IAAa,CAAE,KAAMpB,EAAqB,MAAO,QAAAoB,CAAQ,EACnE,CAAC,CACH,CACF,MAAY,CACV,MAAO,CAAC,CACV,CACF,CA2BQ,iBAAiBC,EAAmD,CAC1E,OAAOC,EAAM,aAAaD,EAAI,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,EAChD,IAAKE,GAAUA,EAAM,IAAKC,GAAM,KAAKA,CAAC,EAAgB,CAAC,EACvD,IAAKC,GAAaA,EAAS,IAAKD,GAAME,EAAiBF,CAAC,CAAC,CAAC,EAC1D,MAAOlB,GACNA,EAAS,MAAOK,GAAYA,IAAY,MAAS,EAC7CW,EAAM,GAAGhB,CAAqC,EAC9CqB,CACN,CACJ,CAoCQ,yBACNxC,EACS,CACT,IAAIyC,EACAC,EAEJ,SAAW,CAAClB,EAASK,CAAS,IAAK7B,EAAM,CACvC,GAAI,CAAC2C,EAAsB,SAASnB,CAAO,EAAG,SAE9C,MAAMoB,EAAcpB,EAAQ,MAAM,EAAG,CAAC,EAEtC,GACEiB,IACCA,IAAcZ,EAAU,CAAC,GAAKa,IAAoBE,GAGnD,MAAO,GAITH,EAAYZ,EAAUA,EAAU,OAAS,CAAC,EAC1Ca,EAAkBE,CACpB,CAEA,MAAO,EACT,CASQ,mBAAmBC,EAAuC,CAChE,OACE,MAAM,QAAQA,CAAK,GACnBA,EAAM,MAAOC,GAAS,OAAOA,GAAS,UAAY3C,EAAa2C,CAAI,CAAC,CAExE,CACF,EA5OalD,EAANmD,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAa,wBAAwB,GAE5CF,EAAA,EAAAC,EAAOE,EAAW,eAAe,IAJzBxD",
6
6
  "names": ["bufferToHexaString", "ByteArrayBuilder", "hexaStringToBuffer", "isHexaString", "Interface", "inject", "injectable", "Maybe", "Nothing", "ClearSignContextType", "tokenTypes", "UNISWAP_PLUGIN_NAME", "UNISWAP_PLUGIN_SIGNATURE", "UNISWAP_COMMANDS", "UNISWAP_EXECUTE_ABI", "UNISWAP_EXECUTE_SELECTOR", "UNISWAP_SWAP_COMMANDS", "UNISWAP_UNIVERSAL_ROUTER_ADDRESS", "uniswapTypes", "UniswapContextLoader", "commandDecoderDataSource", "tokenDataSource", "ctx", "data", "selector", "chainId", "isHexaString", "UNISWAP_EXECUTE_SELECTOR", "externalPluginContext", "tokenContexts", "buffer", "ByteArrayBuilder", "UNISWAP_PLUGIN_NAME", "hexaStringToBuffer", "UNISWAP_UNIVERSAL_ROUTER_ADDRESS", "UNISWAP_PLUGIN_SIGNATURE", "ClearSignContextType", "bufferToHexaString", "calldata", "tx", "Interface", "UNISWAP_EXECUTE_ABI", "commands", "inputs", "decodedCommands", "addressesByCommand", "acc", "command", "index", "input", "decoded", "uniqueAddresses", "addresses", "address", "either", "error", "payload", "hex", "Maybe", "bytes", "b", "hexBytes", "UNISWAP_COMMANDS", "Nothing", "lastAsset", "lastPoolVersion", "UNISWAP_SWAP_COMMANDS", "poolVersion", "array", "item", "__decorateClass", "injectable", "__decorateParam", "inject", "uniswapTypes", "tokenTypes"]
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DefaultContextModule.d.ts","sourceRoot":"","sources":["../../../src/DefaultContextModule.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AAC1F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAIxE,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAM9E,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,oBAAoB,EACrB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AACxF,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC7B,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EAAE,KAAK,8BAA8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20
20
  web3checks: ContextModuleWeb3ChecksConfig;
21
- metadataService: ContextModuleMetadataServiceConfig;
21
+ metadataServiceDomain: ContextModuleMetadataServiceConfig;
22
22
  defaultLoaders: boolean;
23
23
  customLoaders: ContextLoader[];
24
24
  customTypedDataLoader?: TypedDataContextLoader;
@@ -1 +1 @@
1
- {"version":3,"file":"ContextModuleConfig.d.ts","sourceRoot":"","sources":["../../../../../src/config/model/ContextModuleConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAEzF,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,MAAM,CAAC;AACnD,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAE9D,MAAM,MAAM,sBAAsB,GAAG;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,oBAAoB,CAAC;IAC3B,MAAM,EAAE,sBAAsB,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,kCAAkC,GAAG;IAC/C,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,EAAE,sBAAsB,CAAC;IAC5B,UAAU,EAAE,6BAA6B,CAAC;IAC1C,eAAe,EAAE,kCAAkC,CAAC;IACpD,cAAc,EAAE,OAAO,CAAC;IACxB,aAAa,EAAE,aAAa,EAAE,CAAC;IAC/B,qBAAqB,CAAC,EAAE,sBAAsB,CAAC;IAC/C,qBAAqB,CAAC,EAAE,sBAAsB,CAAC;IAC/C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version":3,"file":"di.d.ts","sourceRoot":"","sources":["../../../src/di.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAY9E,KAAK,iBAAiB,GAAG;IACvB,MAAM,EAAE,mBAAmB,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,YAAY,iBAAiB,cAkB1D,CAAC"}
1
+ {"version":3,"file":"di.d.ts","sourceRoot":"","sources":["../../../src/di.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAa9E,KAAK,iBAAiB,GAAG;IACvB,MAAM,EAAE,mBAAmB,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,YAAY,iBAAiB,cAmB1D,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { type Either } from "purify-ts";
2
+ import { type DynamicNetworkConfiguration } from "../../dynamic-network/model/DynamicNetworkConfiguration";
3
+ export interface DynamicNetworkDataSource {
4
+ getDynamicNetworkConfiguration(chainId: number): Promise<Either<Error, DynamicNetworkConfiguration>>;
5
+ }
6
+ //# sourceMappingURL=DynamicNetworkDataSource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DynamicNetworkDataSource.d.ts","sourceRoot":"","sources":["../../../../../src/dynamic-network/data/DynamicNetworkDataSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,qDAAqD,CAAC;AAEvG,MAAM,WAAW,wBAAwB;IACvC,8BAA8B,CAC5B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,2BAA2B,CAAC,CAAC,CAAC;CACxD"}