@ledgerhq/context-module 1.6.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (533) hide show
  1. package/lib/cjs/package.json +2 -2
  2. package/lib/cjs/src/ContextModule.js +1 -1
  3. package/lib/cjs/src/ContextModule.js.map +1 -1
  4. package/lib/cjs/src/ContextModuleBuilder.js +1 -1
  5. package/lib/cjs/src/ContextModuleBuilder.js.map +3 -3
  6. package/lib/cjs/src/ContextModuleBuilder.test.js +1 -1
  7. package/lib/cjs/src/ContextModuleBuilder.test.js.map +3 -3
  8. package/lib/cjs/src/DefaultContextModule.js +1 -1
  9. package/lib/cjs/src/DefaultContextModule.js.map +3 -3
  10. package/lib/cjs/src/DefaultContextModule.test.js +1 -1
  11. package/lib/cjs/src/DefaultContextModule.test.js.map +3 -3
  12. package/lib/cjs/src/calldata/data/CalldataDescriptorDataSource.js +2 -0
  13. package/lib/cjs/src/calldata/data/CalldataDescriptorDataSource.js.map +7 -0
  14. package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.js +2 -0
  15. package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.js.map +7 -0
  16. package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.test.js +2 -0
  17. package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.test.js.map +7 -0
  18. package/lib/cjs/src/calldata/data/dto/CalldataDto.js +2 -0
  19. package/lib/cjs/src/calldata/data/dto/CalldataDto.js.map +7 -0
  20. package/lib/cjs/src/calldata/di/calldataModuleFactory.js +2 -0
  21. package/lib/cjs/src/calldata/di/calldataModuleFactory.js.map +7 -0
  22. package/lib/cjs/src/calldata/di/calldataTypes.js +2 -0
  23. package/lib/cjs/src/calldata/di/calldataTypes.js.map +7 -0
  24. package/lib/cjs/src/calldata/domain/CalldataContextLoader.js +2 -0
  25. package/lib/cjs/src/calldata/domain/CalldataContextLoader.js.map +7 -0
  26. package/lib/cjs/src/calldata/domain/CalldataContextLoader.test.js +2 -0
  27. package/lib/cjs/src/calldata/domain/CalldataContextLoader.test.js.map +7 -0
  28. package/lib/cjs/src/config/model/ContextModuleConfig.js +1 -1
  29. package/lib/cjs/src/config/model/ContextModuleConfig.js.map +1 -1
  30. package/lib/cjs/src/di.js +1 -1
  31. package/lib/cjs/src/di.js.map +3 -3
  32. package/lib/cjs/src/dynamic-network/data/DynamicNetworkDataSource.js +2 -0
  33. package/lib/cjs/src/dynamic-network/data/DynamicNetworkDataSource.js.map +7 -0
  34. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.js +2 -0
  35. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.js.map +7 -0
  36. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js +2 -0
  37. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js.map +7 -0
  38. package/lib/cjs/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.js +2 -0
  39. package/lib/cjs/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.js.map +7 -0
  40. package/lib/cjs/src/dynamic-network/di/dynamicNetworkModuleFactory.js +2 -0
  41. package/lib/cjs/src/dynamic-network/di/dynamicNetworkModuleFactory.js.map +7 -0
  42. package/lib/cjs/src/dynamic-network/di/dynamicNetworkTypes.js +2 -0
  43. package/lib/cjs/src/dynamic-network/di/dynamicNetworkTypes.js.map +7 -0
  44. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.js +2 -0
  45. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +7 -0
  46. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js +2 -0
  47. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +7 -0
  48. package/lib/cjs/src/dynamic-network/model/DynamicNetworkConfiguration.js +2 -0
  49. package/lib/cjs/src/dynamic-network/model/DynamicNetworkConfiguration.js.map +7 -0
  50. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js +1 -1
  51. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js.map +3 -3
  52. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
  53. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +3 -3
  54. package/lib/cjs/src/index.js +1 -1
  55. package/lib/cjs/src/index.js.map +2 -2
  56. package/lib/cjs/src/nft/data/HttpNftDataSource.js +1 -1
  57. package/lib/cjs/src/nft/data/HttpNftDataSource.js.map +2 -2
  58. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js +1 -1
  59. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js.map +2 -2
  60. package/lib/cjs/src/nft/di/nftModuleFactory.js +1 -1
  61. package/lib/cjs/src/nft/di/nftModuleFactory.js.map +3 -3
  62. package/lib/cjs/src/nft/di/nftTypes.js +1 -1
  63. package/lib/cjs/src/nft/di/nftTypes.js.map +2 -2
  64. package/lib/cjs/src/nft/domain/NftContextFieldLoader.js +2 -0
  65. package/lib/cjs/src/nft/domain/NftContextFieldLoader.js.map +7 -0
  66. package/lib/cjs/src/nft/domain/NftContextFieldLoader.test.js +2 -0
  67. package/lib/cjs/src/nft/domain/NftContextFieldLoader.test.js.map +7 -0
  68. package/lib/cjs/src/nft/domain/NftContextLoader.js +1 -1
  69. package/lib/cjs/src/nft/domain/NftContextLoader.js.map +3 -3
  70. package/lib/cjs/src/nft/domain/NftContextLoader.test.js +1 -1
  71. package/lib/cjs/src/nft/domain/NftContextLoader.test.js.map +3 -3
  72. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.js +1 -1
  73. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.js.map +3 -3
  74. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js +1 -1
  75. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +3 -3
  76. package/lib/cjs/src/pki/model/PkiCertificateInfo.js +1 -1
  77. package/lib/cjs/src/pki/model/PkiCertificateInfo.js.map +1 -1
  78. package/lib/cjs/src/proxy/data/HttpProxyDataSource.js +2 -0
  79. package/lib/cjs/src/proxy/data/HttpProxyDataSource.js.map +7 -0
  80. package/lib/cjs/src/proxy/data/HttpProxyDataSource.test.js +2 -0
  81. package/lib/cjs/src/proxy/data/HttpProxyDataSource.test.js.map +7 -0
  82. package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.js +2 -0
  83. package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.js.map +7 -0
  84. package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.test.js +2 -0
  85. package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.test.js.map +7 -0
  86. package/lib/cjs/src/proxy/data/ProxyDataSource.js +2 -0
  87. package/lib/cjs/src/proxy/data/ProxyDataSource.js.map +7 -0
  88. package/lib/cjs/src/proxy/data/dto/ProxyDelegateCallDto.js +2 -0
  89. package/lib/cjs/src/proxy/data/dto/ProxyDelegateCallDto.js.map +7 -0
  90. package/lib/cjs/src/{transaction → proxy}/data/dto/ProxyImplementationAddressDto.js.map +1 -1
  91. package/lib/cjs/src/proxy/data/dto/SafeProxyImplementationAddressDto.js +2 -0
  92. package/lib/cjs/src/proxy/data/dto/SafeProxyImplementationAddressDto.js.map +7 -0
  93. package/lib/cjs/src/proxy/di/proxyModuleFactory.js +2 -0
  94. package/lib/cjs/src/proxy/di/proxyModuleFactory.js.map +7 -0
  95. package/lib/cjs/src/proxy/di/proxyModuleFactory.test.js +2 -0
  96. package/lib/cjs/src/proxy/di/proxyModuleFactory.test.js.map +7 -0
  97. package/lib/cjs/src/proxy/di/proxyTypes.js +2 -0
  98. package/lib/cjs/src/proxy/di/proxyTypes.js.map +7 -0
  99. package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.js +2 -0
  100. package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.js.map +7 -0
  101. package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.test.js +2 -0
  102. package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.test.js.map +7 -0
  103. package/lib/cjs/src/proxy/model/ProxyDelegateCall.js +2 -0
  104. package/lib/cjs/src/proxy/model/ProxyDelegateCall.js.map +7 -0
  105. package/lib/cjs/src/shared/domain/ContextFieldLoader.js +2 -0
  106. package/lib/cjs/src/shared/domain/ContextFieldLoader.js.map +7 -0
  107. package/lib/cjs/src/shared/domain/ContextLoader.js +1 -1
  108. package/lib/cjs/src/shared/domain/ContextLoader.js.map +1 -1
  109. package/lib/cjs/src/shared/model/ClearSignContext.js +1 -1
  110. package/lib/cjs/src/shared/model/ClearSignContext.js.map +3 -3
  111. package/lib/cjs/src/shared/model/TransactionSubset.js +1 -1
  112. package/lib/cjs/src/shared/model/TransactionSubset.js.map +1 -1
  113. package/lib/cjs/src/shared/model/TypedDataClearSignContext.js +1 -1
  114. package/lib/cjs/src/shared/model/TypedDataClearSignContext.js.map +3 -3
  115. package/lib/cjs/src/shared/model/TypedDataContext.js +1 -1
  116. package/lib/cjs/src/shared/model/TypedDataContext.js.map +1 -1
  117. package/lib/cjs/src/shared/utils/KeyUsageMapper.js +1 -1
  118. package/lib/cjs/src/shared/utils/KeyUsageMapper.js.map +2 -2
  119. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js +1 -1
  120. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +2 -2
  121. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +1 -1
  122. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +2 -2
  123. package/lib/cjs/src/token/di/tokenModuleFactory.js +1 -1
  124. package/lib/cjs/src/token/di/tokenModuleFactory.js.map +3 -3
  125. package/lib/cjs/src/token/di/tokenTypes.js +1 -1
  126. package/lib/cjs/src/token/di/tokenTypes.js.map +2 -2
  127. package/lib/cjs/src/token/domain/TokenContextFieldLoader.js +2 -0
  128. package/lib/cjs/src/token/domain/TokenContextFieldLoader.js.map +7 -0
  129. package/lib/cjs/src/token/domain/TokenContextFieldLoader.test.js +2 -0
  130. package/lib/cjs/src/token/domain/TokenContextFieldLoader.test.js.map +7 -0
  131. package/lib/cjs/src/token/domain/TokenContextLoader.js +1 -1
  132. package/lib/cjs/src/token/domain/TokenContextLoader.js.map +3 -3
  133. package/lib/cjs/src/token/domain/TokenContextLoader.test.js +1 -1
  134. package/lib/cjs/src/token/domain/TokenContextLoader.test.js.map +3 -3
  135. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
  136. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js.map +3 -3
  137. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  138. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +2 -2
  139. package/lib/cjs/src/trusted-name/data/TrustedNameDataSource.js +1 -1
  140. package/lib/cjs/src/trusted-name/data/TrustedNameDataSource.js.map +1 -1
  141. package/lib/cjs/src/trusted-name/data/TrustedNameDto.js +1 -1
  142. package/lib/cjs/src/trusted-name/data/TrustedNameDto.js.map +1 -1
  143. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js +1 -1
  144. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js.map +3 -3
  145. package/lib/cjs/src/trusted-name/di/trustedNameTypes.js +1 -1
  146. package/lib/cjs/src/trusted-name/di/trustedNameTypes.js.map +2 -2
  147. package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.js +2 -0
  148. package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.js.map +7 -0
  149. package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js +2 -0
  150. package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js.map +7 -0
  151. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
  152. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js.map +3 -3
  153. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
  154. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +3 -3
  155. package/lib/cjs/src/typed-data/data/FiltersDto.js +1 -1
  156. package/lib/cjs/src/typed-data/data/FiltersDto.js.map +1 -1
  157. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
  158. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js.map +3 -3
  159. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  160. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
  161. package/lib/cjs/src/typed-data/data/TypedDataDataSource.js +1 -1
  162. package/lib/cjs/src/typed-data/data/TypedDataDataSource.js.map +1 -1
  163. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js +1 -1
  164. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +3 -3
  165. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
  166. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +3 -3
  167. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js +1 -1
  168. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js.map +3 -3
  169. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
  170. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js.map +3 -3
  171. package/lib/esm/package.json +2 -2
  172. package/lib/esm/src/ContextModuleBuilder.js +1 -1
  173. package/lib/esm/src/ContextModuleBuilder.js.map +3 -3
  174. package/lib/esm/src/ContextModuleBuilder.test.js +1 -1
  175. package/lib/esm/src/ContextModuleBuilder.test.js.map +3 -3
  176. package/lib/esm/src/DefaultContextModule.js +1 -1
  177. package/lib/esm/src/DefaultContextModule.js.map +3 -3
  178. package/lib/esm/src/DefaultContextModule.test.js +1 -1
  179. package/lib/esm/src/DefaultContextModule.test.js.map +3 -3
  180. package/lib/esm/src/calldata/data/CalldataDescriptorDataSource.js +1 -0
  181. package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.js +2 -0
  182. package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.js.map +7 -0
  183. package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.test.js +2 -0
  184. package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.test.js.map +7 -0
  185. package/lib/esm/src/calldata/di/calldataModuleFactory.js +2 -0
  186. package/lib/esm/src/calldata/di/calldataModuleFactory.js.map +7 -0
  187. package/lib/esm/src/calldata/di/calldataTypes.js +2 -0
  188. package/lib/esm/src/calldata/di/calldataTypes.js.map +7 -0
  189. package/lib/esm/src/calldata/domain/CalldataContextLoader.js +2 -0
  190. package/lib/esm/src/calldata/domain/CalldataContextLoader.js.map +7 -0
  191. package/lib/esm/src/calldata/domain/CalldataContextLoader.test.js +2 -0
  192. package/lib/esm/src/calldata/domain/CalldataContextLoader.test.js.map +7 -0
  193. package/lib/esm/src/di.js +1 -1
  194. package/lib/esm/src/di.js.map +3 -3
  195. package/lib/esm/src/dynamic-network/data/DynamicNetworkDataSource.js +1 -0
  196. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.js +2 -0
  197. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.js.map +7 -0
  198. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js +2 -0
  199. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js.map +7 -0
  200. package/lib/esm/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.js +1 -0
  201. package/lib/esm/src/dynamic-network/di/dynamicNetworkModuleFactory.js +2 -0
  202. package/lib/esm/src/dynamic-network/di/dynamicNetworkModuleFactory.js.map +7 -0
  203. package/lib/esm/src/dynamic-network/di/dynamicNetworkTypes.js +2 -0
  204. package/lib/esm/src/dynamic-network/di/dynamicNetworkTypes.js.map +7 -0
  205. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js +2 -0
  206. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +7 -0
  207. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js +2 -0
  208. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +7 -0
  209. package/lib/esm/src/dynamic-network/model/DynamicNetworkConfiguration.js +1 -0
  210. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js +1 -1
  211. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js.map +3 -3
  212. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
  213. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +3 -3
  214. package/lib/esm/src/index.js +1 -1
  215. package/lib/esm/src/index.js.map +2 -2
  216. package/lib/esm/src/nft/data/HttpNftDataSource.js +1 -1
  217. package/lib/esm/src/nft/data/HttpNftDataSource.js.map +2 -2
  218. package/lib/esm/src/nft/data/HttpNftDataSource.test.js +1 -1
  219. package/lib/esm/src/nft/data/HttpNftDataSource.test.js.map +2 -2
  220. package/lib/esm/src/nft/di/nftModuleFactory.js +1 -1
  221. package/lib/esm/src/nft/di/nftModuleFactory.js.map +3 -3
  222. package/lib/esm/src/nft/di/nftTypes.js +1 -1
  223. package/lib/esm/src/nft/di/nftTypes.js.map +2 -2
  224. package/lib/esm/src/nft/domain/NftContextFieldLoader.js +2 -0
  225. package/lib/esm/src/nft/domain/NftContextFieldLoader.js.map +7 -0
  226. package/lib/esm/src/nft/domain/NftContextFieldLoader.test.js +2 -0
  227. package/lib/esm/src/nft/domain/NftContextFieldLoader.test.js.map +7 -0
  228. package/lib/esm/src/nft/domain/NftContextLoader.js +1 -1
  229. package/lib/esm/src/nft/domain/NftContextLoader.js.map +3 -3
  230. package/lib/esm/src/nft/domain/NftContextLoader.test.js +1 -1
  231. package/lib/esm/src/nft/domain/NftContextLoader.test.js.map +3 -3
  232. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.js +1 -1
  233. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.js.map +3 -3
  234. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js +1 -1
  235. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +3 -3
  236. package/lib/esm/src/proxy/data/HttpProxyDataSource.js +2 -0
  237. package/lib/esm/src/proxy/data/HttpProxyDataSource.js.map +7 -0
  238. package/lib/esm/src/proxy/data/HttpProxyDataSource.test.js +2 -0
  239. package/lib/esm/src/proxy/data/HttpProxyDataSource.test.js.map +7 -0
  240. package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.js +2 -0
  241. package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.js.map +7 -0
  242. package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.test.js +2 -0
  243. package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.test.js.map +7 -0
  244. package/lib/esm/src/proxy/data/ProxyDataSource.js +1 -0
  245. package/lib/esm/src/proxy/data/dto/ProxyImplementationAddressDto.js.map +7 -0
  246. package/lib/esm/src/proxy/data/dto/SafeProxyImplementationAddressDto.js +1 -0
  247. package/lib/esm/src/proxy/data/dto/SafeProxyImplementationAddressDto.js.map +7 -0
  248. package/lib/esm/src/proxy/di/proxyModuleFactory.js +2 -0
  249. package/lib/esm/src/proxy/di/proxyModuleFactory.js.map +7 -0
  250. package/lib/esm/src/proxy/di/proxyModuleFactory.test.js +2 -0
  251. package/lib/esm/src/proxy/di/proxyModuleFactory.test.js.map +7 -0
  252. package/lib/esm/src/proxy/di/proxyTypes.js +2 -0
  253. package/lib/esm/src/proxy/di/proxyTypes.js.map +7 -0
  254. package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.js +2 -0
  255. package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.js.map +7 -0
  256. package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.test.js +2 -0
  257. package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.test.js.map +7 -0
  258. package/lib/esm/src/proxy/model/ProxyDelegateCall.js.map +7 -0
  259. package/lib/esm/src/shared/domain/ContextFieldLoader.js +1 -0
  260. package/lib/esm/src/shared/domain/ContextFieldLoader.js.map +7 -0
  261. package/lib/esm/src/shared/model/ClearSignContext.js +1 -1
  262. package/lib/esm/src/shared/model/ClearSignContext.js.map +3 -3
  263. package/lib/esm/src/shared/model/TypedDataClearSignContext.js +1 -1
  264. package/lib/esm/src/shared/model/TypedDataClearSignContext.js.map +3 -3
  265. package/lib/esm/src/shared/utils/KeyUsageMapper.js +1 -1
  266. package/lib/esm/src/shared/utils/KeyUsageMapper.js.map +2 -2
  267. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js +1 -1
  268. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +2 -2
  269. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +1 -1
  270. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +2 -2
  271. package/lib/esm/src/token/di/tokenModuleFactory.js +1 -1
  272. package/lib/esm/src/token/di/tokenModuleFactory.js.map +3 -3
  273. package/lib/esm/src/token/di/tokenTypes.js +1 -1
  274. package/lib/esm/src/token/di/tokenTypes.js.map +2 -2
  275. package/lib/esm/src/token/domain/TokenContextFieldLoader.js +2 -0
  276. package/lib/esm/src/token/domain/TokenContextFieldLoader.js.map +7 -0
  277. package/lib/esm/src/token/domain/TokenContextFieldLoader.test.js +2 -0
  278. package/lib/esm/src/token/domain/TokenContextFieldLoader.test.js.map +7 -0
  279. package/lib/esm/src/token/domain/TokenContextLoader.js +1 -1
  280. package/lib/esm/src/token/domain/TokenContextLoader.js.map +3 -3
  281. package/lib/esm/src/token/domain/TokenContextLoader.test.js +1 -1
  282. package/lib/esm/src/token/domain/TokenContextLoader.test.js.map +3 -3
  283. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
  284. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js.map +3 -3
  285. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  286. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +2 -2
  287. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js +1 -1
  288. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js.map +3 -3
  289. package/lib/esm/src/trusted-name/di/trustedNameTypes.js +1 -1
  290. package/lib/esm/src/trusted-name/di/trustedNameTypes.js.map +2 -2
  291. package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.js +2 -0
  292. package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.js.map +7 -0
  293. package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js +2 -0
  294. package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js.map +7 -0
  295. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
  296. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js.map +3 -3
  297. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
  298. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +3 -3
  299. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
  300. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js.map +3 -3
  301. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  302. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
  303. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js +1 -1
  304. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +3 -3
  305. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
  306. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +3 -3
  307. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js +1 -1
  308. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js.map +3 -3
  309. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
  310. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js.map +3 -3
  311. package/lib/types/src/ContextModule.d.ts +3 -4
  312. package/lib/types/src/ContextModule.d.ts.map +1 -1
  313. package/lib/types/src/ContextModuleBuilder.d.ts +8 -1
  314. package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -1
  315. package/lib/types/src/DefaultContextModule.d.ts +4 -3
  316. package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
  317. package/lib/types/src/{transaction/data/TransactionDataSource.d.ts → calldata/data/CalldataDescriptorDataSource.d.ts} +4 -4
  318. package/lib/types/src/calldata/data/CalldataDescriptorDataSource.d.ts.map +1 -0
  319. package/lib/types/src/{transaction/data/HttpTransactionDataSource.d.ts → calldata/data/HttpCalldataDescriptorDataSource.d.ts} +6 -5
  320. package/lib/types/src/calldata/data/HttpCalldataDescriptorDataSource.d.ts.map +1 -0
  321. package/lib/types/src/calldata/data/HttpCalldataDescriptorDataSource.test.d.ts +2 -0
  322. package/lib/types/src/calldata/data/HttpCalldataDescriptorDataSource.test.d.ts.map +1 -0
  323. package/lib/types/src/{transaction → calldata}/data/dto/CalldataDto.d.ts +10 -1
  324. package/lib/types/src/calldata/data/dto/CalldataDto.d.ts.map +1 -0
  325. package/lib/types/src/calldata/di/calldataModuleFactory.d.ts +3 -0
  326. package/lib/types/src/calldata/di/calldataModuleFactory.d.ts.map +1 -0
  327. package/lib/types/src/calldata/di/calldataTypes.d.ts +6 -0
  328. package/lib/types/src/calldata/di/calldataTypes.d.ts.map +1 -0
  329. package/lib/types/src/calldata/domain/CalldataContextLoader.d.ts +23 -0
  330. package/lib/types/src/calldata/domain/CalldataContextLoader.d.ts.map +1 -0
  331. package/lib/types/src/calldata/domain/CalldataContextLoader.test.d.ts +2 -0
  332. package/lib/types/src/calldata/domain/CalldataContextLoader.test.d.ts.map +1 -0
  333. package/lib/types/src/config/model/ContextModuleConfig.d.ts +8 -1
  334. package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -1
  335. package/lib/types/src/di.d.ts.map +1 -1
  336. package/lib/types/src/dynamic-network/data/DynamicNetworkDataSource.d.ts +6 -0
  337. package/lib/types/src/dynamic-network/data/DynamicNetworkDataSource.d.ts.map +1 -0
  338. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.d.ts +13 -0
  339. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.d.ts.map +1 -0
  340. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.d.ts +2 -0
  341. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.d.ts.map +1 -0
  342. package/lib/types/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.d.ts +14 -0
  343. package/lib/types/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.d.ts.map +1 -0
  344. package/lib/types/src/dynamic-network/di/dynamicNetworkModuleFactory.d.ts +3 -0
  345. package/lib/types/src/dynamic-network/di/dynamicNetworkModuleFactory.d.ts.map +1 -0
  346. package/lib/types/src/dynamic-network/di/dynamicNetworkTypes.d.ts +5 -0
  347. package/lib/types/src/dynamic-network/di/dynamicNetworkTypes.d.ts.map +1 -0
  348. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts +19 -0
  349. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts.map +1 -0
  350. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.test.d.ts +2 -0
  351. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.test.d.ts.map +1 -0
  352. package/lib/types/src/dynamic-network/model/DynamicNetworkConfiguration.d.ts +16 -0
  353. package/lib/types/src/dynamic-network/model/DynamicNetworkConfiguration.d.ts.map +1 -0
  354. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.d.ts +11 -4
  355. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.d.ts.map +1 -1
  356. package/lib/types/src/index.d.ts +42 -1
  357. package/lib/types/src/index.d.ts.map +1 -1
  358. package/lib/types/src/nft/di/nftModuleFactory.d.ts.map +1 -1
  359. package/lib/types/src/nft/di/nftTypes.d.ts +1 -0
  360. package/lib/types/src/nft/di/nftTypes.d.ts.map +1 -1
  361. package/lib/types/src/nft/domain/NftContextFieldLoader.d.ts +15 -0
  362. package/lib/types/src/nft/domain/NftContextFieldLoader.d.ts.map +1 -0
  363. package/lib/types/src/nft/domain/NftContextFieldLoader.test.d.ts +2 -0
  364. package/lib/types/src/nft/domain/NftContextFieldLoader.test.d.ts.map +1 -0
  365. package/lib/types/src/nft/domain/NftContextLoader.d.ts +10 -5
  366. package/lib/types/src/nft/domain/NftContextLoader.d.ts.map +1 -1
  367. package/lib/types/src/pki/domain/DefaultPkiCertificateLoader.d.ts.map +1 -1
  368. package/lib/types/src/pki/model/PkiCertificateInfo.d.ts +1 -2
  369. package/lib/types/src/pki/model/PkiCertificateInfo.d.ts.map +1 -1
  370. package/lib/types/src/proxy/data/HttpProxyDataSource.d.ts +13 -0
  371. package/lib/types/src/proxy/data/HttpProxyDataSource.d.ts.map +1 -0
  372. package/lib/types/src/proxy/data/HttpProxyDataSource.test.d.ts.map +1 -0
  373. package/lib/types/src/proxy/data/HttpSafeProxyDataSource.d.ts +13 -0
  374. package/lib/types/src/proxy/data/HttpSafeProxyDataSource.d.ts.map +1 -0
  375. package/lib/types/src/proxy/data/HttpSafeProxyDataSource.test.d.ts +2 -0
  376. package/lib/types/src/proxy/data/HttpSafeProxyDataSource.test.d.ts.map +1 -0
  377. package/lib/types/src/proxy/data/ProxyDataSource.d.ts +17 -0
  378. package/lib/types/src/proxy/data/ProxyDataSource.d.ts.map +1 -0
  379. package/lib/types/src/proxy/data/dto/ProxyDelegateCallDto.d.ts +5 -0
  380. package/lib/types/src/proxy/data/dto/ProxyDelegateCallDto.d.ts.map +1 -0
  381. package/lib/types/src/proxy/data/dto/ProxyImplementationAddressDto.d.ts.map +1 -0
  382. package/lib/types/src/proxy/data/dto/SafeProxyImplementationAddressDto.d.ts +10 -0
  383. package/lib/types/src/proxy/data/dto/SafeProxyImplementationAddressDto.d.ts.map +1 -0
  384. package/lib/types/src/proxy/di/proxyModuleFactory.d.ts +4 -0
  385. package/lib/types/src/proxy/di/proxyModuleFactory.d.ts.map +1 -0
  386. package/lib/types/src/proxy/di/proxyModuleFactory.test.d.ts +2 -0
  387. package/lib/types/src/proxy/di/proxyModuleFactory.test.d.ts.map +1 -0
  388. package/lib/types/src/proxy/di/proxyTypes.d.ts +5 -0
  389. package/lib/types/src/proxy/di/proxyTypes.d.ts.map +1 -0
  390. package/lib/types/src/proxy/domain/ProxyContextFieldLoader.d.ts +21 -0
  391. package/lib/types/src/proxy/domain/ProxyContextFieldLoader.d.ts.map +1 -0
  392. package/lib/types/src/proxy/domain/ProxyContextFieldLoader.test.d.ts +2 -0
  393. package/lib/types/src/proxy/domain/ProxyContextFieldLoader.test.d.ts.map +1 -0
  394. package/lib/types/src/proxy/model/ProxyDelegateCall.d.ts +7 -0
  395. package/lib/types/src/proxy/model/ProxyDelegateCall.d.ts.map +1 -0
  396. package/lib/types/src/shared/domain/ContextFieldLoader.d.ts +15 -0
  397. package/lib/types/src/shared/domain/ContextFieldLoader.d.ts.map +1 -0
  398. package/lib/types/src/shared/domain/ContextLoader.d.ts +13 -5
  399. package/lib/types/src/shared/domain/ContextLoader.d.ts.map +1 -1
  400. package/lib/types/src/shared/model/ClearSignContext.d.ts +29 -8
  401. package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -1
  402. package/lib/types/src/shared/model/TransactionSubset.d.ts +1 -0
  403. package/lib/types/src/shared/model/TransactionSubset.d.ts.map +1 -1
  404. package/lib/types/src/shared/model/TypedDataClearSignContext.d.ts +33 -1
  405. package/lib/types/src/shared/model/TypedDataClearSignContext.d.ts.map +1 -1
  406. package/lib/types/src/shared/model/TypedDataContext.d.ts +3 -0
  407. package/lib/types/src/shared/model/TypedDataContext.d.ts.map +1 -1
  408. package/lib/types/src/shared/utils/KeyUsageMapper.d.ts +1 -2
  409. package/lib/types/src/shared/utils/KeyUsageMapper.d.ts.map +1 -1
  410. package/lib/types/src/token/di/tokenModuleFactory.d.ts.map +1 -1
  411. package/lib/types/src/token/di/tokenTypes.d.ts +1 -0
  412. package/lib/types/src/token/di/tokenTypes.d.ts.map +1 -1
  413. package/lib/types/src/token/domain/TokenContextFieldLoader.d.ts +14 -0
  414. package/lib/types/src/token/domain/TokenContextFieldLoader.d.ts.map +1 -0
  415. package/lib/types/src/token/domain/TokenContextFieldLoader.test.d.ts +2 -0
  416. package/lib/types/src/token/domain/TokenContextFieldLoader.test.d.ts.map +1 -0
  417. package/lib/types/src/token/domain/TokenContextLoader.d.ts +10 -5
  418. package/lib/types/src/token/domain/TokenContextLoader.d.ts.map +1 -1
  419. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts +7 -3
  420. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts.map +1 -1
  421. package/lib/types/src/trusted-name/data/TrustedNameDataSource.d.ts +7 -2
  422. package/lib/types/src/trusted-name/data/TrustedNameDataSource.d.ts.map +1 -1
  423. package/lib/types/src/trusted-name/data/TrustedNameDto.d.ts +4 -5
  424. package/lib/types/src/trusted-name/data/TrustedNameDto.d.ts.map +1 -1
  425. package/lib/types/src/trusted-name/di/trustedNameModuleFactory.d.ts.map +1 -1
  426. package/lib/types/src/trusted-name/di/trustedNameTypes.d.ts +1 -0
  427. package/lib/types/src/trusted-name/di/trustedNameTypes.d.ts.map +1 -1
  428. package/lib/types/src/trusted-name/domain/TrustedNameContextFieldLoader.d.ts +22 -0
  429. package/lib/types/src/trusted-name/domain/TrustedNameContextFieldLoader.d.ts.map +1 -0
  430. package/lib/types/src/trusted-name/domain/TrustedNameContextFieldLoader.test.d.ts +2 -0
  431. package/lib/types/src/trusted-name/domain/TrustedNameContextFieldLoader.test.d.ts.map +1 -0
  432. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts +14 -6
  433. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts.map +1 -1
  434. package/lib/types/src/typed-data/data/FiltersDto.d.ts +32 -2
  435. package/lib/types/src/typed-data/data/FiltersDto.d.ts.map +1 -1
  436. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts +3 -0
  437. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts.map +1 -1
  438. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts +1 -0
  439. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts.map +1 -1
  440. package/lib/types/src/typed-data/data/TypedDataDataSource.d.ts +2 -1
  441. package/lib/types/src/typed-data/data/TypedDataDataSource.d.ts.map +1 -1
  442. package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts +12 -1
  443. package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts.map +1 -1
  444. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts +11 -4
  445. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts.map +1 -1
  446. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  447. package/package.json +3 -3
  448. package/lib/cjs/src/shared/model/TransactionContext.js +0 -2
  449. package/lib/cjs/src/shared/model/TransactionContext.js.map +0 -7
  450. package/lib/cjs/src/transaction/data/HttpProxyDataSource.js +0 -2
  451. package/lib/cjs/src/transaction/data/HttpProxyDataSource.js.map +0 -7
  452. package/lib/cjs/src/transaction/data/HttpProxyDataSource.test.js +0 -2
  453. package/lib/cjs/src/transaction/data/HttpProxyDataSource.test.js.map +0 -7
  454. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js +0 -2
  455. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js.map +0 -7
  456. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js +0 -2
  457. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js.map +0 -7
  458. package/lib/cjs/src/transaction/data/TransactionDataSource.js +0 -2
  459. package/lib/cjs/src/transaction/data/TransactionDataSource.js.map +0 -7
  460. package/lib/cjs/src/transaction/data/dto/CalldataDto.js +0 -2
  461. package/lib/cjs/src/transaction/data/dto/CalldataDto.js.map +0 -7
  462. package/lib/cjs/src/transaction/data/dto/ProxyDelegateCallDto.js +0 -2
  463. package/lib/cjs/src/transaction/data/dto/ProxyDelegateCallDto.js.map +0 -7
  464. package/lib/cjs/src/transaction/di/transactionModuleFactory.js +0 -2
  465. package/lib/cjs/src/transaction/di/transactionModuleFactory.js.map +0 -7
  466. package/lib/cjs/src/transaction/di/transactionTypes.js +0 -2
  467. package/lib/cjs/src/transaction/di/transactionTypes.js.map +0 -7
  468. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js +0 -2
  469. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js.map +0 -7
  470. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js +0 -2
  471. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js.map +0 -7
  472. package/lib/cjs/src/transaction/model/ProxyDelegateCall.js +0 -2
  473. package/lib/cjs/src/transaction/model/ProxyDelegateCall.js.map +0 -7
  474. package/lib/cjs/src/transaction/model/ProxyImplementationAddress.js +0 -2
  475. package/lib/cjs/src/transaction/model/ProxyImplementationAddress.js.map +0 -7
  476. package/lib/esm/src/shared/model/TransactionContext.js +0 -1
  477. package/lib/esm/src/transaction/data/HttpProxyDataSource.js +0 -2
  478. package/lib/esm/src/transaction/data/HttpProxyDataSource.js.map +0 -7
  479. package/lib/esm/src/transaction/data/HttpProxyDataSource.test.js +0 -2
  480. package/lib/esm/src/transaction/data/HttpProxyDataSource.test.js.map +0 -7
  481. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js +0 -2
  482. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js.map +0 -7
  483. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js +0 -2
  484. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js.map +0 -7
  485. package/lib/esm/src/transaction/data/TransactionDataSource.js +0 -1
  486. package/lib/esm/src/transaction/di/transactionModuleFactory.js +0 -2
  487. package/lib/esm/src/transaction/di/transactionModuleFactory.js.map +0 -7
  488. package/lib/esm/src/transaction/di/transactionTypes.js +0 -2
  489. package/lib/esm/src/transaction/di/transactionTypes.js.map +0 -7
  490. package/lib/esm/src/transaction/domain/TransactionContextLoader.js +0 -2
  491. package/lib/esm/src/transaction/domain/TransactionContextLoader.js.map +0 -7
  492. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js +0 -2
  493. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js.map +0 -7
  494. package/lib/esm/src/transaction/model/ProxyImplementationAddress.js +0 -1
  495. package/lib/types/src/shared/model/TransactionContext.d.ts +0 -21
  496. package/lib/types/src/shared/model/TransactionContext.d.ts.map +0 -1
  497. package/lib/types/src/transaction/data/HttpProxyDataSource.d.ts +0 -32
  498. package/lib/types/src/transaction/data/HttpProxyDataSource.d.ts.map +0 -1
  499. package/lib/types/src/transaction/data/HttpProxyDataSource.test.d.ts.map +0 -1
  500. package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts.map +0 -1
  501. package/lib/types/src/transaction/data/HttpTransactionDataSource.test.d.ts +0 -2
  502. package/lib/types/src/transaction/data/HttpTransactionDataSource.test.d.ts.map +0 -1
  503. package/lib/types/src/transaction/data/TransactionDataSource.d.ts.map +0 -1
  504. package/lib/types/src/transaction/data/dto/CalldataDto.d.ts.map +0 -1
  505. package/lib/types/src/transaction/data/dto/ProxyDelegateCallDto.d.ts +0 -5
  506. package/lib/types/src/transaction/data/dto/ProxyDelegateCallDto.d.ts.map +0 -1
  507. package/lib/types/src/transaction/data/dto/ProxyImplementationAddressDto.d.ts.map +0 -1
  508. package/lib/types/src/transaction/di/transactionModuleFactory.d.ts +0 -3
  509. package/lib/types/src/transaction/di/transactionModuleFactory.d.ts.map +0 -1
  510. package/lib/types/src/transaction/di/transactionTypes.d.ts +0 -6
  511. package/lib/types/src/transaction/di/transactionTypes.d.ts.map +0 -1
  512. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts +0 -10
  513. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts.map +0 -1
  514. package/lib/types/src/transaction/domain/TransactionContextLoader.test.d.ts +0 -2
  515. package/lib/types/src/transaction/domain/TransactionContextLoader.test.d.ts.map +0 -1
  516. package/lib/types/src/transaction/model/ProxyDelegateCall.d.ts +0 -5
  517. package/lib/types/src/transaction/model/ProxyDelegateCall.d.ts.map +0 -1
  518. package/lib/types/src/transaction/model/ProxyImplementationAddress.d.ts +0 -4
  519. package/lib/types/src/transaction/model/ProxyImplementationAddress.d.ts.map +0 -1
  520. /package/lib/cjs/src/{transaction → proxy}/data/dto/ProxyImplementationAddressDto.js +0 -0
  521. /package/lib/esm/src/{shared/model/TransactionContext.js.map → calldata/data/CalldataDescriptorDataSource.js.map} +0 -0
  522. /package/lib/esm/src/{transaction → calldata}/data/dto/CalldataDto.js +0 -0
  523. /package/lib/esm/src/{transaction → calldata}/data/dto/CalldataDto.js.map +0 -0
  524. /package/lib/esm/src/{transaction/data/TransactionDataSource.js.map → dynamic-network/data/DynamicNetworkDataSource.js.map} +0 -0
  525. /package/lib/esm/src/{transaction/data/dto/ProxyDelegateCallDto.js.map → dynamic-network/data/dto/DynamicNetworkApiResponseDto.js.map} +0 -0
  526. /package/lib/esm/src/{transaction/data/dto/ProxyImplementationAddressDto.js.map → dynamic-network/model/DynamicNetworkConfiguration.js.map} +0 -0
  527. /package/lib/esm/src/{transaction/model/ProxyDelegateCall.js.map → proxy/data/ProxyDataSource.js.map} +0 -0
  528. /package/lib/esm/src/{transaction → proxy}/data/dto/ProxyDelegateCallDto.js +0 -0
  529. /package/lib/esm/src/{transaction/model/ProxyImplementationAddress.js.map → proxy/data/dto/ProxyDelegateCallDto.js.map} +0 -0
  530. /package/lib/esm/src/{transaction → proxy}/data/dto/ProxyImplementationAddressDto.js +0 -0
  531. /package/lib/esm/src/{transaction → proxy}/model/ProxyDelegateCall.js +0 -0
  532. /package/lib/types/src/{transaction → proxy}/data/HttpProxyDataSource.test.d.ts +0 -0
  533. /package/lib/types/src/{transaction → proxy}/data/dto/ProxyImplementationAddressDto.d.ts +0 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/calldata/domain/CalldataContextLoader.test.ts"],
4
+ "sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport type { CalldataDescriptorDataSource } from \"@/calldata/data/CalldataDescriptorDataSource\";\nimport {\n type CalldataContextInput,\n CalldataContextLoader,\n} from \"@/calldata/domain/CalldataContextLoader\";\nimport type { ProxyDataSource } from \"@/proxy/data/ProxyDataSource\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\n\ndescribe(\"CalldataContextLoader\", () => {\n const getProxyImplementationAddress = vi.fn();\n const getDappDescriptorsMock = vi.fn();\n const getTokenDescriptorsMock = vi.fn();\n const mockDappDataSource: CalldataDescriptorDataSource = {\n getCalldataDescriptors: getDappDescriptorsMock,\n };\n const mockTokenDataSource: CalldataDescriptorDataSource = {\n getCalldataDescriptors: getTokenDescriptorsMock,\n };\n const mockProxyDatasource: ProxyDataSource = {\n getProxyImplementationAddress: getProxyImplementationAddress,\n };\n const loader = new CalldataContextLoader(\n mockDappDataSource,\n mockTokenDataSource,\n mockProxyDatasource,\n );\n const SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.TRANSACTION_INFO,\n ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n ClearSignContextType.PROXY_INFO,\n ClearSignContextType.ENUM,\n ];\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"canHandle function\", () => {\n const validInput: CalldataContextInput = {\n to: \"0x1234567890123456789012345678901234567890\",\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n chainId: 1,\n deviceModelId: DeviceModelId.NANO_X,\n };\n\n it(\"should return true for valid input\", () => {\n expect(loader.canHandle(validInput, SUPPORTED_TYPES)).toBe(true);\n });\n\n it(\"should return false for invalid expected type\", () => {\n expect(loader.canHandle(validInput, [ClearSignContextType.TOKEN])).toBe(\n false,\n );\n expect(loader.canHandle(validInput, [ClearSignContextType.NFT])).toBe(\n false,\n );\n expect(\n loader.canHandle(validInput, [ClearSignContextType.PROXY_INFO]),\n ).toBe(false);\n expect(loader.canHandle(validInput, [ClearSignContextType.ENUM])).toBe(\n false,\n );\n expect(\n loader.canHandle(validInput, [ClearSignContextType.TRANSACTION_INFO]),\n ).toBe(false);\n });\n\n it.each([\n [null, \"null input\"],\n [undefined, \"undefined input\"],\n [{}, \"empty object\"],\n [\"string\", \"string input\"],\n [123, \"number input\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, SUPPORTED_TYPES)).toBe(false);\n });\n\n it.each([\n [{ ...validInput, to: undefined }, \"missing to\"],\n [{ ...validInput, data: undefined }, \"missing data\"],\n [{ ...validInput, selector: undefined }, \"missing selector\"],\n [{ ...validInput, chainId: undefined }, \"missing chainId\"],\n [{ ...validInput, deviceModelId: undefined }, \"missing deviceModelId\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, SUPPORTED_TYPES)).toBe(false);\n });\n\n it.each([\n [{ ...validInput, to: \"invalid-hex\" }, \"invalid to hex\"],\n [{ ...validInput, to: \"0x\" }, \"empty to hex\"],\n [{ ...validInput, data: \"invalid-hex\" }, \"invalid data hex\"],\n [{ ...validInput, selector: \"invalid-hex\" }, \"invalid selector hex\"],\n [{ ...validInput, selector: \"0x\" }, \"empty selector hex\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, SUPPORTED_TYPES)).toBe(false);\n });\n\n it.each([\n [{ ...validInput, chainId: \"1\" }, \"string chainId\"],\n [{ ...validInput, chainId: null }, \"null chainId\"],\n [\n { ...validInput, deviceModelId: DeviceModelId.NANO_S },\n \"deviceModelId is NANO_S\",\n ],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, SUPPORTED_TYPES)).toBe(false);\n });\n });\n\n it(\"should return an error if data source fails\", async () => {\n // GIVEN\n getProxyImplementationAddress.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n getDappDescriptorsMock.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n const input = {\n to: \"0x1234567890123456789012345678901234567890\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n deviceModelId: DeviceModelId.NANO_X,\n } as CalldataContextInput;\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(getDappDescriptorsMock).toHaveBeenCalledWith({\n address: \"0x1234567890123456789012345678901234567890\",\n chainId: 3,\n selector: \"0xaf68b302\",\n deviceModelId: DeviceModelId.NANO_X,\n });\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] CalldataContextLoader: No calldata contexts found\",\n ),\n },\n ]);\n });\n\n it(\"should return the contexts on success\", async () => {\n // GIVEN\n getDappDescriptorsMock.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 getProxyImplementationAddress.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n const input = {\n to: \"0x1234567890123456789012345678901234567890\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n deviceModelId: DeviceModelId.NANO_X,\n } as CalldataContextInput;\n\n // WHEN\n const result = await loader.load(input);\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 getDappDescriptorsMock.mockResolvedValueOnce(Right([])); // No transaction descriptors found for the first call\n getDappDescriptorsMock.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 getProxyImplementationAddress.mockResolvedValue(\n Right({\n implementationAddress: \"0x1234567890abcdef\",\n signedDescriptor: \"0x1234567890abcdef\",\n }),\n );\n const input = {\n to: \"0x1234567890123456789012345678901234567890\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n deviceModelId: DeviceModelId.NANO_X,\n } as CalldataContextInput;\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.PROXY_INFO,\n payload: \"0x\",\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 an error when proxy delegate call succeeds but transaction descriptors for resolved address fail\", async () => {\n // GIVEN\n getDappDescriptorsMock.mockResolvedValueOnce(Right([])); // No transaction descriptors found for the first call\n getDappDescriptorsMock.mockResolvedValueOnce(\n Left(new Error(\"data source error\")),\n ); // Second call fails\n getProxyImplementationAddress.mockResolvedValue(\n Right({\n implementationAddress: \"0xResolvedAddress\",\n signedDescriptor: \"0x1234567890abcdef\",\n }),\n );\n const input = {\n to: \"0x1234567890123456789012345678901234567890\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n deviceModelId: DeviceModelId.NANO_X,\n } as CalldataContextInput;\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(getDappDescriptorsMock).toHaveBeenCalledTimes(2);\n expect(getDappDescriptorsMock).toHaveBeenNthCalledWith(2, {\n address: \"0xResolvedAddress\",\n chainId: 3,\n selector: \"0xaf68b302\",\n deviceModelId: DeviceModelId.NANO_X,\n });\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] CalldataContextLoader: No calldata contexts found\",\n ),\n },\n ]);\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,iBAAAA,MAAqB,kCAC9B,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAG5B,OAEE,yBAAAC,MACK,0CAEP,OAAS,wBAAAC,MAA4B,kCAErC,SAAS,wBAAyB,IAAM,CACtC,MAAMC,EAAgC,GAAG,GAAG,EACtCC,EAAyB,GAAG,GAAG,EAC/BC,EAA0B,GAAG,GAAG,EAChCC,EAAmD,CACvD,uBAAwBF,CAC1B,EACMG,EAAoD,CACxD,uBAAwBF,CAC1B,EACMG,EAAuC,CAC3C,8BAA+BL,CACjC,EACMM,EAAS,IAAIR,EACjBK,EACAC,EACAC,CACF,EACME,EAA0C,CAC9CR,EAAqB,iBACrBA,EAAqB,8BACrBA,EAAqB,WACrBA,EAAqB,IACvB,EAEA,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,SAAS,qBAAsB,IAAM,CACnC,MAAMS,EAAmC,CACvC,GAAI,6CACJ,KAAM,yEACN,SAAU,aACV,QAAS,EACT,cAAeb,EAAc,MAC/B,EAEA,GAAG,qCAAsC,IAAM,CAC7C,OAAOW,EAAO,UAAUE,EAAYD,CAAe,CAAC,EAAE,KAAK,EAAI,CACjE,CAAC,EAED,GAAG,gDAAiD,IAAM,CACxD,OAAOD,EAAO,UAAUE,EAAY,CAACT,EAAqB,KAAK,CAAC,CAAC,EAAE,KACjE,EACF,E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B,EAAS,MAAML,EAAO,KAAKG,CAAK,EAGtC,OAAOR,CAAsB,EAAE,sBAAsB,CAAC,EACtD,OAAOA,CAAsB,EAAE,wBAAwB,EAAG,CACxD,QAAS,oBACT,QAAS,EACT,SAAU,aACV,cAAeN,EAAc,MAC/B,CAAC,EACD,OAAOgB,CAAM,EAAE,QAAQ,CACrB,CACE,KAAMZ,EAAqB,MAC3B,MAAO,IAAI,MACT,mEACF,CACF,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["DeviceModelId", "Left", "Right", "CalldataContextLoader", "ClearSignContextType", "getProxyImplementationAddress", "getDappDescriptorsMock", "getTokenDescriptorsMock", "mockDappDataSource", "mockTokenDataSource", "mockProxyDatasource", "loader", "SUPPORTED_TYPES", "validInput", "input", "_description", "result"]
7
+ }
package/lib/esm/src/di.js CHANGED
@@ -1,2 +1,2 @@
1
- import{Container as t}from"inversify";import{configModuleFactory as e}from"./config/di/configModuleFactory";import{externalPluginModuleFactory as n}from"./external-plugin/di/externalPluginModuleFactory";import{nftModuleFactory as a}from"./nft/di/nftModuleFactory";import{nanoPkiModuleFactory as m}from"./pki/di/pkiModuleFactory";import{solanaContextModuleFactory as i}from"./solana/di/SolanaContextModuleFactory";import{tokenModuleFactory as c}from"./token/di/tokenModuleFactory";import{transactionModuleFactory as f}from"./transaction/di/transactionModuleFactory";import{trustedNameModuleFactory as p}from"./trusted-name/di/trustedNameModuleFactory";import{typedDataModuleFactory as l}from"./typed-data/di/typedDataModuleFactory";import{uniswapModuleFactory as u}from"./uniswap/di/uniswapModuleFactory";import{web3CheckModuleFactory as d}from"./web3-check/di/web3CheckModuleFactory";const h=({config:r})=>{const o=new t;return o.loadSync(e(r),n(),a(),c(),f(),p(),l(),m(),u(),d(),i()),o};export{h as makeContainer};
1
+ import{Container as t}from"inversify";import{calldataModuleFactory as e}from"./calldata/di/calldataModuleFactory";import{configModuleFactory as a}from"./config/di/configModuleFactory";import{dynamicNetworkModuleFactory as m}from"./dynamic-network/di/dynamicNetworkModuleFactory";import{externalPluginModuleFactory as n}from"./external-plugin/di/externalPluginModuleFactory";import{nftModuleFactory as i}from"./nft/di/nftModuleFactory";import{nanoPkiModuleFactory as c}from"./pki/di/pkiModuleFactory";import{proxyModuleFactory as l}from"./proxy/di/proxyModuleFactory";import{solanaContextModuleFactory as p}from"./solana/di/SolanaContextModuleFactory";import{tokenModuleFactory as d}from"./token/di/tokenModuleFactory";import{trustedNameModuleFactory as f}from"./trusted-name/di/trustedNameModuleFactory";import{typedDataModuleFactory as u}from"./typed-data/di/typedDataModuleFactory";import{uniswapModuleFactory as y}from"./uniswap/di/uniswapModuleFactory";import{web3CheckModuleFactory as M}from"./web3-check/di/web3CheckModuleFactory";const j=({config:o})=>{const r=new t;return r.loadSync(a(o),n(),m(),i(),l(o),d(),e(),f(),u(),c(),y(),M(),p()),r};export{j as makeContainer};
2
2
  //# sourceMappingURL=di.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/di.ts"],
4
- "sourcesContent": ["import { Container } from \"inversify\";\n\nimport { configModuleFactory } from \"@/config/di/configModuleFactory\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { externalPluginModuleFactory } from \"@/external-plugin/di/externalPluginModuleFactory\";\nimport { nftModuleFactory } from \"@/nft/di/nftModuleFactory\";\nimport { nanoPkiModuleFactory } from \"@/pki/di/pkiModuleFactory\";\nimport { solanaContextModuleFactory } from \"@/solana/di/SolanaContextModuleFactory\";\nimport { tokenModuleFactory } from \"@/token/di/tokenModuleFactory\";\nimport { transactionModuleFactory } from \"@/transaction/di/transactionModuleFactory\";\nimport { trustedNameModuleFactory } from \"@/trusted-name/di/trustedNameModuleFactory\";\nimport { typedDataModuleFactory } from \"@/typed-data/di/typedDataModuleFactory\";\nimport { uniswapModuleFactory } from \"@/uniswap/di/uniswapModuleFactory\";\nimport { web3CheckModuleFactory } from \"@/web3-check/di/web3CheckModuleFactory\";\n\ntype MakeContainerArgs = {\n config: ContextModuleConfig;\n};\n\nexport const makeContainer = ({ config }: MakeContainerArgs) => {\n const container = new Container();\n\n container.loadSync(\n configModuleFactory(config),\n externalPluginModuleFactory(),\n nftModuleFactory(),\n tokenModuleFactory(),\n transactionModuleFactory(),\n trustedNameModuleFactory(),\n typedDataModuleFactory(),\n nanoPkiModuleFactory(),\n uniswapModuleFactory(),\n web3CheckModuleFactory(),\n solanaContextModuleFactory(),\n );\n\n return container;\n};\n"],
5
- "mappings": "AAAA,OAAS,aAAAA,MAAiB,YAE1B,OAAS,uBAAAC,MAA2B,kCAEpC,OAAS,+BAAAC,MAAmC,mDAC5C,OAAS,oBAAAC,MAAwB,4BACjC,OAAS,wBAAAC,MAA4B,4BACrC,OAAS,8BAAAC,MAAkC,yCAC3C,OAAS,sBAAAC,MAA0B,gCACnC,OAAS,4BAAAC,MAAgC,4CACzC,OAAS,4BAAAC,MAAgC,6CACzC,OAAS,0BAAAC,MAA8B,yCACvC,OAAS,wBAAAC,MAA4B,oCACrC,OAAS,0BAAAC,MAA8B,yCAMhC,MAAMC,EAAgB,CAAC,CAAE,OAAAC,CAAO,IAAyB,CAC9D,MAAMC,EAAY,IAAId,EAEtB,OAAAc,EAAU,SACRb,EAAoBY,CAAM,EAC1BX,EAA4B,EAC5BC,EAAiB,EACjBG,EAAmB,EACnBC,EAAyB,EACzBC,EAAyB,EACzBC,EAAuB,EACvBL,EAAqB,EACrBM,EAAqB,EACrBC,EAAuB,EACvBN,EAA2B,CAC7B,EAEOS,CACT",
6
- "names": ["Container", "configModuleFactory", "externalPluginModuleFactory", "nftModuleFactory", "nanoPkiModuleFactory", "solanaContextModuleFactory", "tokenModuleFactory", "transactionModuleFactory", "trustedNameModuleFactory", "typedDataModuleFactory", "uniswapModuleFactory", "web3CheckModuleFactory", "makeContainer", "config", "container"]
4
+ "sourcesContent": ["import { Container } from \"inversify\";\n\nimport { calldataModuleFactory } from \"@/calldata/di/calldataModuleFactory\";\nimport { configModuleFactory } from \"@/config/di/configModuleFactory\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { dynamicNetworkModuleFactory } from \"@/dynamic-network/di/dynamicNetworkModuleFactory\";\nimport { externalPluginModuleFactory } from \"@/external-plugin/di/externalPluginModuleFactory\";\nimport { nftModuleFactory } from \"@/nft/di/nftModuleFactory\";\nimport { nanoPkiModuleFactory } from \"@/pki/di/pkiModuleFactory\";\nimport { proxyModuleFactory } from \"@/proxy/di/proxyModuleFactory\";\nimport { solanaContextModuleFactory } from \"@/solana/di/SolanaContextModuleFactory\";\nimport { tokenModuleFactory } from \"@/token/di/tokenModuleFactory\";\nimport { trustedNameModuleFactory } from \"@/trusted-name/di/trustedNameModuleFactory\";\nimport { typedDataModuleFactory } from \"@/typed-data/di/typedDataModuleFactory\";\nimport { uniswapModuleFactory } from \"@/uniswap/di/uniswapModuleFactory\";\nimport { web3CheckModuleFactory } from \"@/web3-check/di/web3CheckModuleFactory\";\n\ntype MakeContainerArgs = {\n config: ContextModuleConfig;\n};\n\nexport const makeContainer = ({ config }: MakeContainerArgs) => {\n const container = new Container();\n\n container.loadSync(\n configModuleFactory(config),\n externalPluginModuleFactory(),\n dynamicNetworkModuleFactory(),\n nftModuleFactory(),\n proxyModuleFactory(config),\n tokenModuleFactory(),\n calldataModuleFactory(),\n trustedNameModuleFactory(),\n typedDataModuleFactory(),\n nanoPkiModuleFactory(),\n uniswapModuleFactory(),\n web3CheckModuleFactory(),\n solanaContextModuleFactory(),\n );\n\n return container;\n};\n"],
5
+ "mappings": "AAAA,OAAS,aAAAA,MAAiB,YAE1B,OAAS,yBAAAC,MAA6B,sCACtC,OAAS,uBAAAC,MAA2B,kCAEpC,OAAS,+BAAAC,MAAmC,mDAC5C,OAAS,+BAAAC,MAAmC,mDAC5C,OAAS,oBAAAC,MAAwB,4BACjC,OAAS,wBAAAC,MAA4B,4BACrC,OAAS,sBAAAC,MAA0B,gCACnC,OAAS,8BAAAC,MAAkC,yCAC3C,OAAS,sBAAAC,MAA0B,gCACnC,OAAS,4BAAAC,MAAgC,6CACzC,OAAS,0BAAAC,MAA8B,yCACvC,OAAS,wBAAAC,MAA4B,oCACrC,OAAS,0BAAAC,MAA8B,yCAMhC,MAAMC,EAAgB,CAAC,CAAE,OAAAC,CAAO,IAAyB,CAC9D,MAAMC,EAAY,IAAIhB,EAEtB,OAAAgB,EAAU,SACRd,EAAoBa,CAAM,EAC1BX,EAA4B,EAC5BD,EAA4B,EAC5BE,EAAiB,EACjBE,EAAmBQ,CAAM,EACzBN,EAAmB,EACnBR,EAAsB,EACtBS,EAAyB,EACzBC,EAAuB,EACvBL,EAAqB,EACrBM,EAAqB,EACrBC,EAAuB,EACvBL,EAA2B,CAC7B,EAEOQ,CACT",
6
+ "names": ["Container", "calldataModuleFactory", "configModuleFactory", "dynamicNetworkModuleFactory", "externalPluginModuleFactory", "nftModuleFactory", "nanoPkiModuleFactory", "proxyModuleFactory", "solanaContextModuleFactory", "tokenModuleFactory", "trustedNameModuleFactory", "typedDataModuleFactory", "uniswapModuleFactory", "web3CheckModuleFactory", "makeContainer", "config", "container"]
7
7
  }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=DynamicNetworkDataSource.js.map
@@ -0,0 +1,2 @@
1
+ var u=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var f=(n,o,r,e)=>{for(var t=e>1?void 0:e?m(o,r):o,i=n.length-1,a;i>=0;i--)(a=n[i])&&(t=(e?a(o,r,t):a(t))||t);return e&&t&&u(o,r,t),t},p=(n,o)=>(r,e)=>o(r,e,n);import d from"axios";import{inject as g,injectable as y}from"inversify";import{Left as c,Right as l}from"purify-ts";import{configTypes as D}from"../../config/di/configTypes";import{LEDGER_CLIENT_VERSION_HEADER as w}from"../../shared/constant/HttpHeaders";import k from"../../../package.json";let s=class{constructor(o){this.config=o}async getDynamicNetworkConfiguration(o){let r;try{r=(await d.get(`${this.config.cal.url}/networks?output=id,descriptors,icons&chain_id=${o}`,{headers:{[w]:`context-module/${k.version}`}})).data}catch(i){return c(i instanceof Error?i:new Error("Failed to fetch network configuration"))}const e=r?.[0];if(!e)return c(new Error(`Network configuration not found for chain ID: ${o}`));if(!this.isValidNetworkData(e))return c(new Error(`Invalid network configuration response for chain ID: ${o}`));const t=this.transformToNetworkConfiguration(e);return l(t)}isValidNetworkData(o){if(!o||typeof o!="object")return!1;const r=o;if(typeof r.id!="string"||!r.descriptors||typeof r.descriptors!="object")return!1;for(const e of Object.values(r.descriptors))if(!this.isValidDescriptor(e))return!1;return!(r.icons&&typeof r.icons!="object")}isValidDescriptor(o){if(!o||typeof o!="object")return!1;const r=o;if(typeof r.data!="string"||typeof r.descriptorType!="string"||typeof r.descriptorVersion!="string"||!r.signatures||typeof r.signatures!="object")return!1;const e=r.signatures;return!(typeof e.prod!="string"||typeof e.test!="string")}transformToNetworkConfiguration(o){const r=Object.entries(o.descriptors).reduce((e,[t,i])=>(e[t]={descriptorType:i.descriptorType,descriptorVersion:i.descriptorVersion,data:i.data,signatures:i.signatures,icon:o.icons?.[t]},e),{});return{id:o.id,descriptors:r}}};s=f([y(),p(0,g(D.Config))],s);export{s as HttpDynamicNetworkDataSource};
2
+ //# sourceMappingURL=HttpDynamicNetworkDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/dynamic-network/data/HttpDynamicNetworkDataSource.ts"],
4
+ "sourcesContent": ["import { type DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport 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 type DynamicNetworkConfiguration,\n type DynamicNetworkDescriptor,\n} from \"@/dynamic-network/model/DynamicNetworkConfiguration\";\nimport { LEDGER_CLIENT_VERSION_HEADER } from \"@/shared/constant/HttpHeaders\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { type DynamicNetworkApiResponseDto } from \"./dto/DynamicNetworkApiResponseDto\";\nimport { type DynamicNetworkDataSource } from \"./DynamicNetworkDataSource\";\n\n@injectable()\nexport class HttpDynamicNetworkDataSource implements DynamicNetworkDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n async getDynamicNetworkConfiguration(\n chainId: number,\n ): Promise<Either<Error, DynamicNetworkConfiguration>> {\n let response: DynamicNetworkApiResponseDto;\n\n try {\n const axiosResponse = await axios.get<DynamicNetworkApiResponseDto>(\n `${this.config.cal.url}/networks?output=id,descriptors,icons&chain_id=${chainId}`,\n {\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n },\n },\n );\n response = axiosResponse.data;\n } catch (error) {\n return Left(\n error instanceof Error\n ? error\n : new Error(\"Failed to fetch network configuration\"),\n );\n }\n\n const networkData = response?.[0];\n if (!networkData) {\n return Left(\n new Error(`Network configuration not found for chain ID: ${chainId}`),\n );\n }\n\n // Validate response structure\n if (!this.isValidNetworkData(networkData)) {\n return Left(\n new Error(\n `Invalid network configuration response for chain ID: ${chainId}`,\n ),\n );\n }\n\n const configuration = this.transformToNetworkConfiguration(networkData);\n return Right(configuration);\n }\n\n private isValidNetworkData(\n data: unknown,\n ): data is DynamicNetworkApiResponseDto[0] {\n if (!data || typeof data !== \"object\") {\n return false;\n }\n\n const obj = data as Record<string, unknown>;\n\n // Check required fields\n if (typeof obj[\"id\"] !== \"string\") {\n return false;\n }\n\n // Check descriptors structure\n if (!obj[\"descriptors\"] || typeof obj[\"descriptors\"] !== \"object\") {\n return false;\n }\n\n // Validate each descriptor\n for (const descriptor of Object.values(obj[\"descriptors\"])) {\n if (!this.isValidDescriptor(descriptor)) {\n return false;\n }\n }\n\n // Icons are optional but if present, should be an object\n if (obj[\"icons\"] && typeof obj[\"icons\"] !== \"object\") {\n return false;\n }\n\n return true;\n }\n\n private isValidDescriptor(\n descriptor: unknown,\n ): descriptor is DynamicNetworkApiResponseDto[0][\"descriptors\"][string] {\n if (!descriptor || typeof descriptor !== \"object\") {\n return false;\n }\n\n const desc = descriptor as Record<string, unknown>;\n\n // Check required descriptor fields\n if (\n typeof desc[\"data\"] !== \"string\" ||\n typeof desc[\"descriptorType\"] !== \"string\" ||\n typeof desc[\"descriptorVersion\"] !== \"string\"\n ) {\n return false;\n }\n\n // Check signatures structure\n if (!desc[\"signatures\"] || typeof desc[\"signatures\"] !== \"object\") {\n return false;\n }\n\n const signatures = desc[\"signatures\"] as Record<string, unknown>;\n if (\n typeof signatures[\"prod\"] !== \"string\" ||\n typeof signatures[\"test\"] !== \"string\"\n ) {\n return false;\n }\n\n return true;\n }\n\n private transformToNetworkConfiguration(\n networkData: DynamicNetworkApiResponseDto[0],\n ): DynamicNetworkConfiguration {\n const descriptors = Object.entries(networkData.descriptors).reduce(\n (acc, [deviceModel, descriptor]) => {\n acc[deviceModel as DeviceModelId] = {\n descriptorType: descriptor.descriptorType,\n descriptorVersion: descriptor.descriptorVersion,\n data: descriptor.data,\n signatures: descriptor.signatures,\n icon: networkData.icons?.[deviceModel],\n };\n return acc;\n },\n {} as Record<DeviceModelId, DynamicNetworkDescriptor>,\n );\n\n return {\n id: networkData.id,\n descriptors,\n };\n }\n}\n"],
5
+ "mappings": "iOACA,OAAOA,MAAW,QAClB,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAM5B,OAAS,gCAAAC,MAAoC,gCAC7C,OAAOC,MAAa,qBAMb,IAAMC,EAAN,KAAuE,CAC5E,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CAEH,MAAM,+BACJC,EACqD,CACrD,IAAIC,EAEJ,GAAI,CASFA,GARsB,MAAMC,EAAM,IAChC,GAAG,KAAK,OAAO,IAAI,GAAG,kDAAkDF,CAAO,GAC/E,CACE,QAAS,CACP,CAACG,CAA4B,EAA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AW,eAC3B,kBAAmBA,EAAW,kBAC9B,KAAMA,EAAW,KACjB,WAAYA,EAAW,WACvB,KAAML,EAAY,QAAQU,CAAW,CACvC,EACOD,GAET,CAAC,CACH,EAEA,MAAO,CACL,GAAIT,EAAY,GAChB,YAAAQ,CACF,CACF,CACF,EA1IajB,EAANoB,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,IAFjBxB",
6
+ "names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "HttpDynamicNetworkDataSource", "config", "chainId", "response", "axios", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "error", "Left", "networkData", "configuration", "Right", "data", "obj", "descriptor", "desc", "signatures", "descriptors", "acc", "deviceModel", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import a from"axios";import{Left as c,Right as u}from"purify-ts";import{beforeAll as g,beforeEach as p,describe as l,expect as o,it as i,vi as r}from"vitest";import{HttpDynamicNetworkDataSource as w}from"./HttpDynamicNetworkDataSource";r.mock("axios");l("HttpNetworkDataSource",()=>{let n;const f={cal:{url:"https://crypto-assets-service.api.ledger.com",mode:"prod",branch:"main"}},s={data:[{id:"ethereum",descriptors:{flex:{data:"0x010108020101510101230800000000000000895207506f6c79676f6e2403504f4c",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"3045022100c116b5470c266c2947b92aa9eadbe3da03305efc6b8fee041e04e8484a9834af022041d5b82b359614ea8dd94a542dfd87b0ae6f3b4a075aad9a53a030064ab42cd0",test:"3045022100f78bac5c9c3f2ceeea26680aaea17be61fce84ae7ec983a8194e68275f4fe5900220231afbe39fcec63edfea2b4e787a72d79ce53d6a4c408f24b5a116905a9082d3"}},stax:{data:"0x010108020101510101230800000000000000895207506f6c79676f6e2403504f4c53204aa5034d2fd4c46647d382aa64d0a03d06b185512bb7942390318bda18d0423a",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"3045022100cf42c039c16fc95dc97c09f15cdd93bed0e63ee45cf5c38c2b30bb8a3bc17f8d022053a96c9e51695c3c1c1a31f5cbf84bd6febadc97f4bb02bdc67cf3e24ad0c32d",test:"304402207e1e1b8f99b45c95b0cf1e90f46cf07e6a90f82c49ccdb6e2e95ab0c1e2f5a370220784e1fac16bb01c5d096733e1cbf067d616e4de659fda2c388f8c3502e7f7f80"}}}}]};g(()=>{n=new w(f)}),p(()=>{r.clearAllMocks()}),l("getNetworkConfiguration",()=>{i("should return network configuration successfully",async()=>{r.mocked(a.get).mockResolvedValue(s);const e=await n.getDynamicNetworkConfiguration(1);o(a.get).toHaveBeenCalledWith("https://crypto-assets-service.api.ledger.com/networks?output=id,descriptors,icons&chain_id=1",o.objectContaining({headers:o.any(Object)})),o(e).toEqual(u({id:"ethereum",descriptors:{flex:{data:"0x010108020101510101230800000000000000895207506f6c79676f6e2403504f4c",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"3045022100c116b5470c266c2947b92aa9eadbe3da03305efc6b8fee041e04e8484a9834af022041d5b82b359614ea8dd94a542dfd87b0ae6f3b4a075aad9a53a030064ab42cd0",test:"3045022100f78bac5c9c3f2ceeea26680aaea17be61fce84ae7ec983a8194e68275f4fe5900220231afbe39fcec63edfea2b4e787a72d79ce53d6a4c408f24b5a116905a9082d3"},icon:void 0},stax:{data:"0x010108020101510101230800000000000000895207506f6c79676f6e2403504f4c53204aa5034d2fd4c46647d382aa64d0a03d06b185512bb7942390318bda18d0423a",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"3045022100cf42c039c16fc95dc97c09f15cdd93bed0e63ee45cf5c38c2b30bb8a3bc17f8d022053a96c9e51695c3c1c1a31f5cbf84bd6febadc97f4bb02bdc67cf3e24ad0c32d",test:"304402207e1e1b8f99b45c95b0cf1e90f46cf07e6a90f82c49ccdb6e2e95ab0c1e2f5a370220784e1fac16bb01c5d096733e1cbf067d616e4de659fda2c388f8c3502e7f7f80"},icon:void 0}}}))}),i("should return error when network data is not found",async()=>{r.mocked(a.get).mockResolvedValue({data:[]});const e=await n.getDynamicNetworkConfiguration(1);o(e).toEqual(c(new Error("Network configuration not found for chain ID: 1")))}),i("should return error when network data is undefined",async()=>{r.mocked(a.get).mockResolvedValue({data:void 0});const e=await n.getDynamicNetworkConfiguration(1);o(e).toEqual(c(new Error("Network configuration not found for chain ID: 1")))}),i("should return error when axios throws an error",async()=>{r.mocked(a.get).mockRejectedValue(new Error("Network error"));const e=await n.getDynamicNetworkConfiguration(1);o(e).toEqual(c(new Error("Network error")))}),i("should return generic error when axios throws non-Error",async()=>{r.mocked(a.get).mockRejectedValue("String error");const e=await n.getDynamicNetworkConfiguration(1);o(e).toEqual(c(new Error("Failed to fetch network configuration")))}),i("should handle invalid data - missing id",async()=>{const e={data:[{descriptors:{}}]};r.mocked(a.get).mockResolvedValue(e);const t=await n.getDynamicNetworkConfiguration(1);o(t).toEqual(c(new Error("Invalid network configuration response for chain ID: 1")))}),i("should handle invalid data - missing descriptors",async()=>{const e={data:[{id:"ethereum"}]};r.mocked(a.get).mockResolvedValue(e);const t=await n.getDynamicNetworkConfiguration(1);o(t).toEqual(c(new Error("Invalid network configuration response for chain ID: 1")))}),i("should handle invalid descriptor - missing data field",async()=>{const e={data:[{id:"ethereum",descriptors:{flex:{descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"sig1",test:"sig2"}}}}]};r.mocked(a.get).mockResolvedValue(e);const t=await n.getDynamicNetworkConfiguration(1);o(t).toEqual(c(new Error("Invalid network configuration response for chain ID: 1")))}),i("should handle invalid descriptor - missing signatures",async()=>{const e={data:[{id:"ethereum",descriptors:{flex:{data:"0x0101",descriptorType:"network",descriptorVersion:"v1"}}}]};r.mocked(a.get).mockResolvedValue(e);const t=await n.getDynamicNetworkConfiguration(1);o(t).toEqual(c(new Error("Invalid network configuration response for chain ID: 1")))}),i("should handle invalid signatures - missing prod",async()=>{const e={data:[{id:"ethereum",descriptors:{flex:{data:"0x0101",descriptorType:"network",descriptorVersion:"v1",signatures:{test:"sig2"}}}}]};r.mocked(a.get).mockResolvedValue(e);const t=await n.getDynamicNetworkConfiguration(1);o(t).toEqual(c(new Error("Invalid network configuration response for chain ID: 1")))}),i("should include icons when available",async()=>{const e={data:[{id:"ethereum",descriptors:{flex:{data:"0x0101",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"sig1",test:"sig2"}},stax:{data:"0x0102",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"sig3",test:"sig4"}}},icons:{flex:"icon1",stax:"icon2"}}]};r.mocked(a.get).mockResolvedValue(e);const t=await n.getDynamicNetworkConfiguration(1);o(t.isRight()).toBe(!0);const d=t.unsafeCoerce();o(d.descriptors.flex.icon).toBe("icon1"),o(d.descriptors.stax.icon).toBe("icon2")}),i("should transform data correctly for Polygon chain ID",async()=>{r.mocked(a.get).mockResolvedValue(s);const e=await n.getDynamicNetworkConfiguration(137);o(a.get).toHaveBeenCalledWith("https://crypto-assets-service.api.ledger.com/networks?output=id,descriptors,icons&chain_id=137",o.objectContaining({headers:o.any(Object)})),o(e.isRight()).toBe(!0);const t=e.unsafeCoerce();o(Object.keys(t.descriptors)).toEqual(["flex","stax"])}),i("should handle invalid data - null data",async()=>{const e={data:[null]};r.mocked(a.get).mockResolvedValue(e);const t=await n.getDynamicNetworkConfiguration(1);o(t).toEqual(c(new Error("Network configuration not found for chain ID: 1")))}),i("should handle invalid data - non-object data",async()=>{const e={data:["string_instead_of_object"]};r.mocked(a.get).mockResolvedValue(e);const t=await n.getDynamicNetworkConfiguration(1);o(t).toEqual(c(new Error("Invalid network configuration response for chain ID: 1")))}),i("should handle invalid data - icons as string instead of object",async()=>{const e={data:[{id:"ethereum",descriptors:{flex:{data:"0x0101",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"sig1",test:"sig2"}}},icons:"should_be_object_not_string"}]};r.mocked(a.get).mockResolvedValue(e);const t=await n.getDynamicNetworkConfiguration(1);o(t).toEqual(c(new Error("Invalid network configuration response for chain ID: 1")))}),i("should handle invalid data - icons as number instead of object (line 93)",async()=>{const e={data:[{id:"ethereum",descriptors:{flex:{data:"0x0101",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"sig1",test:"sig2"}}},icons:123}]};r.mocked(a.get).mockResolvedValue(e);const t=await n.getDynamicNetworkConfiguration(1);o(t).toEqual(c(new Error("Invalid network configuration response for chain ID: 1")))}),i("should handle invalid descriptor - null descriptor (line 103)",async()=>{const e={data:[{id:"ethereum",descriptors:{flex:null}}]};r.mocked(a.get).mockResolvedValue(e);const t=await n.getDynamicNetworkConfiguration(1);o(t).toEqual(c(new Error("Invalid network configuration response for chain ID: 1")))}),i("should handle invalid descriptor - non-object descriptor (line 103)",async()=>{const e={data:[{id:"ethereum",descriptors:{flex:"should_be_object_not_string"}}]};r.mocked(a.get).mockResolvedValue(e);const t=await n.getDynamicNetworkConfiguration(1);o(t).toEqual(c(new Error("Invalid network configuration response for chain ID: 1")))})})});
2
+ //# sourceMappingURL=HttpDynamicNetworkDataSource.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/dynamic-network/data/HttpDynamicNetworkDataSource.test.ts"],
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { Left, Right } from \"purify-ts\";\nimport { beforeAll, beforeEach, describe, expect, it, vi } from \"vitest\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\n\nimport { HttpDynamicNetworkDataSource } from \"./HttpDynamicNetworkDataSource\";\n\nvi.mock(\"axios\");\n\ndescribe(\"HttpNetworkDataSource\", () => {\n let datasource: HttpDynamicNetworkDataSource;\n const mockConfig: ContextModuleConfig = {\n cal: {\n url: \"https://crypto-assets-service.api.ledger.com\",\n mode: \"prod\",\n branch: \"main\",\n },\n } as ContextModuleConfig;\n\n const mockNetworkResponse = {\n data: [\n {\n id: \"ethereum\",\n descriptors: {\n flex: {\n data: \"0x010108020101510101230800000000000000895207506f6c79676f6e2403504f4c\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"3045022100c116b5470c266c2947b92aa9eadbe3da03305efc6b8fee041e04e8484a9834af022041d5b82b359614ea8dd94a542dfd87b0ae6f3b4a075aad9a53a030064ab42cd0\",\n test: \"3045022100f78bac5c9c3f2ceeea26680aaea17be61fce84ae7ec983a8194e68275f4fe5900220231afbe39fcec63edfea2b4e787a72d79ce53d6a4c408f24b5a116905a9082d3\",\n },\n },\n stax: {\n data: \"0x010108020101510101230800000000000000895207506f6c79676f6e2403504f4c53204aa5034d2fd4c46647d382aa64d0a03d06b185512bb7942390318bda18d0423a\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"3045022100cf42c039c16fc95dc97c09f15cdd93bed0e63ee45cf5c38c2b30bb8a3bc17f8d022053a96c9e51695c3c1c1a31f5cbf84bd6febadc97f4bb02bdc67cf3e24ad0c32d\",\n test: \"304402207e1e1b8f99b45c95b0cf1e90f46cf07e6a90f82c49ccdb6e2e95ab0c1e2f5a370220784e1fac16bb01c5d096733e1cbf067d616e4de659fda2c388f8c3502e7f7f80\",\n },\n },\n },\n },\n ],\n };\n\n beforeAll(() => {\n datasource = new HttpDynamicNetworkDataSource(mockConfig);\n });\n\n beforeEach(() => {\n vi.clearAllMocks();\n });\n\n describe(\"getNetworkConfiguration\", () => {\n it(\"should return network configuration successfully\", async () => {\n vi.mocked(axios.get).mockResolvedValue(mockNetworkResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(axios.get).toHaveBeenCalledWith(\n \"https://crypto-assets-service.api.ledger.com/networks?output=id,descriptors,icons&chain_id=1\",\n expect.objectContaining({\n headers: expect.any(Object) as Record<string, string>,\n }),\n );\n\n expect(result).toEqual(\n Right({\n id: \"ethereum\",\n descriptors: {\n flex: {\n data: \"0x010108020101510101230800000000000000895207506f6c79676f6e2403504f4c\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"3045022100c116b5470c266c2947b92aa9eadbe3da03305efc6b8fee041e04e8484a9834af022041d5b82b359614ea8dd94a542dfd87b0ae6f3b4a075aad9a53a030064ab42cd0\",\n test: \"3045022100f78bac5c9c3f2ceeea26680aaea17be61fce84ae7ec983a8194e68275f4fe5900220231afbe39fcec63edfea2b4e787a72d79ce53d6a4c408f24b5a116905a9082d3\",\n },\n icon: undefined,\n },\n stax: {\n data: \"0x010108020101510101230800000000000000895207506f6c79676f6e2403504f4c53204aa5034d2fd4c46647d382aa64d0a03d06b185512bb7942390318bda18d0423a\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"3045022100cf42c039c16fc95dc97c09f15cdd93bed0e63ee45cf5c38c2b30bb8a3bc17f8d022053a96c9e51695c3c1c1a31f5cbf84bd6febadc97f4bb02bdc67cf3e24ad0c32d\",\n test: \"304402207e1e1b8f99b45c95b0cf1e90f46cf07e6a90f82c49ccdb6e2e95ab0c1e2f5a370220784e1fac16bb01c5d096733e1cbf067d616e4de659fda2c388f8c3502e7f7f80\",\n },\n icon: undefined,\n },\n },\n }),\n );\n });\n\n it(\"should return error when network data is not found\", async () => {\n vi.mocked(axios.get).mockResolvedValue({ data: [] });\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(new Error(\"Network configuration not found for chain ID: 1\")),\n );\n });\n\n it(\"should return error when network data is undefined\", async () => {\n vi.mocked(axios.get).mockResolvedValue({ data: undefined });\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(new Error(\"Network configuration not found for chain ID: 1\")),\n );\n });\n\n it(\"should return error when axios throws an error\", async () => {\n vi.mocked(axios.get).mockRejectedValue(new Error(\"Network error\"));\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(Left(new Error(\"Network error\")));\n });\n\n it(\"should return generic error when axios throws non-Error\", async () => {\n vi.mocked(axios.get).mockRejectedValue(\"String error\");\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(new Error(\"Failed to fetch network configuration\")),\n );\n });\n\n it(\"should handle invalid data - missing id\", async () => {\n const invalidResponse = {\n data: [\n {\n // Missing id\n descriptors: {},\n },\n ],\n };\n vi.mocked(axios.get).mockResolvedValue(invalidResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(\n new Error(\"Invalid network configuration response for chain ID: 1\"),\n ),\n );\n });\n\n it(\"should handle invalid data - missing descriptors\", async () => {\n const invalidResponse = {\n data: [\n {\n id: \"ethereum\",\n // Missing descriptors\n },\n ],\n };\n vi.mocked(axios.get).mockResolvedValue(invalidResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(\n new Error(\"Invalid network configuration response for chain ID: 1\"),\n ),\n );\n });\n\n it(\"should handle invalid descriptor - missing data field\", async () => {\n const invalidResponse = {\n data: [\n {\n id: \"ethereum\",\n descriptors: {\n flex: {\n // Missing data\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: { prod: \"sig1\", test: \"sig2\" },\n },\n },\n },\n ],\n };\n vi.mocked(axios.get).mockResolvedValue(invalidResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(\n new Error(\"Invalid network configuration response for chain ID: 1\"),\n ),\n );\n });\n\n it(\"should handle invalid descriptor - missing signatures\", async () => {\n const invalidResponse = {\n data: [\n {\n id: \"ethereum\",\n descriptors: {\n flex: {\n data: \"0x0101\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n // Missing signatures\n },\n },\n },\n ],\n };\n vi.mocked(axios.get).mockResolvedValue(invalidResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(\n new Error(\"Invalid network configuration response for chain ID: 1\"),\n ),\n );\n });\n\n it(\"should handle invalid signatures - missing prod\", async () => {\n const invalidResponse = {\n data: [\n {\n id: \"ethereum\",\n descriptors: {\n flex: {\n data: \"0x0101\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n // Missing prod\n test: \"sig2\",\n },\n },\n },\n },\n ],\n };\n vi.mocked(axios.get).mockResolvedValue(invalidResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(\n new Error(\"Invalid network configuration response for chain ID: 1\"),\n ),\n );\n });\n\n it(\"should include icons when available\", async () => {\n const responseWithIcons = {\n data: [\n {\n id: \"ethereum\",\n descriptors: {\n flex: {\n data: \"0x0101\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"sig1\",\n test: \"sig2\",\n },\n },\n stax: {\n data: \"0x0102\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"sig3\",\n test: \"sig4\",\n },\n },\n },\n icons: {\n flex: \"icon1\",\n stax: \"icon2\",\n },\n },\n ],\n };\n vi.mocked(axios.get).mockResolvedValue(responseWithIcons);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result.isRight()).toBe(true);\n const configuration = result.unsafeCoerce();\n expect(configuration.descriptors.flex.icon).toBe(\"icon1\");\n expect(configuration.descriptors.stax.icon).toBe(\"icon2\");\n });\n\n it(\"should transform data correctly for Polygon chain ID\", async () => {\n vi.mocked(axios.get).mockResolvedValue(mockNetworkResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(137);\n\n expect(axios.get).toHaveBeenCalledWith(\n \"https://crypto-assets-service.api.ledger.com/networks?output=id,descriptors,icons&chain_id=137\",\n expect.objectContaining({\n headers: expect.any(Object) as Record<string, string>,\n }),\n );\n\n expect(result.isRight()).toBe(true);\n const configuration = result.unsafeCoerce();\n expect(Object.keys(configuration.descriptors)).toEqual([\"flex\", \"stax\"]);\n });\n\n it(\"should handle invalid data - null data\", async () => {\n const invalidResponse = {\n data: [null],\n };\n vi.mocked(axios.get).mockResolvedValue(invalidResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(new Error(\"Network configuration not found for chain ID: 1\")),\n );\n });\n\n it(\"should handle invalid data - non-object data\", async () => {\n const invalidResponse = {\n data: [\"string_instead_of_object\"],\n };\n vi.mocked(axios.get).mockResolvedValue(invalidResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(\n new Error(\"Invalid network configuration response for chain ID: 1\"),\n ),\n );\n });\n\n it(\"should handle invalid data - icons as string instead of object\", async () => {\n const invalidResponse = {\n data: [\n {\n id: \"ethereum\",\n descriptors: {\n flex: {\n data: \"0x0101\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"sig1\",\n test: \"sig2\",\n },\n },\n },\n icons: \"should_be_object_not_string\",\n },\n ],\n };\n vi.mocked(axios.get).mockResolvedValue(invalidResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(\n new Error(\"Invalid network configuration response for chain ID: 1\"),\n ),\n );\n });\n\n it(\"should handle invalid data - icons as number instead of object (line 93)\", async () => {\n const invalidResponse = {\n data: [\n {\n id: \"ethereum\",\n descriptors: {\n flex: {\n data: \"0x0101\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"sig1\",\n test: \"sig2\",\n },\n },\n },\n icons: 123,\n },\n ],\n };\n vi.mocked(axios.get).mockResolvedValue(invalidResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(\n new Error(\"Invalid network configuration response for chain ID: 1\"),\n ),\n );\n });\n\n it(\"should handle invalid descriptor - null descriptor (line 103)\", async () => {\n const invalidResponse = {\n data: [\n {\n id: \"ethereum\",\n descriptors: {\n flex: null,\n },\n },\n ],\n };\n vi.mocked(axios.get).mockResolvedValue(invalidResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(\n new Error(\"Invalid network configuration response for chain ID: 1\"),\n ),\n );\n });\n\n it(\"should handle invalid descriptor - non-object descriptor (line 103)\", async () => {\n const invalidResponse = {\n data: [\n {\n id: \"ethereum\",\n descriptors: {\n flex: \"should_be_object_not_string\",\n },\n },\n ],\n };\n vi.mocked(axios.get).mockResolvedValue(invalidResponse);\n\n const result = await datasource.getDynamicNetworkConfiguration(1);\n\n expect(result).toEqual(\n Left(\n new Error(\"Invalid network configuration response for chain ID: 1\"),\n ),\n );\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAOA,MAAW,QAClB,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAC5B,OAAS,aAAAC,EAAW,cAAAC,EAAY,YAAAC,EAAU,UAAAC,EAAQ,MAAAC,EAAI,MAAAC,MAAU,SAIhE,OAAS,gCAAAC,MAAoC,iCAE7CD,EAAG,KAAK,OAAO,EAEfH,EAAS,wBAAyB,IAAM,CACtC,IAAIK,EACJ,MAAMC,EAAkC,CACtC,IAAK,CACH,IAAK,+CACL,KAAM,OACN,OAAQ,MACV,CACF,EAEMC,EAAsB,CAC1B,KAAM,CACJ,CACE,GAAI,WACJ,YAAa,CACX,KAAM,CACJ,KAAM,uEACN,eAAgB,UAChB,kBAAmB,KACnB,WAAY,CACV,KAAM,iJACN,KAAM,gJACR,CACF,EACA,KAAM,CACJ,KAAM,2IACN,eAAgB,UAChB,kBAAmB,KACnB,WAAY,CACV,KAAM,iJACN,KAAM,8IACR,CACF,CACF,CACF,CACF,CACF,EAEAT,EAAU,IAAM,CACdO,EAAa,IAAID,EAA6BE,CAAU,CAC1D,CAAC,EAEDP,EAAW,IAAM,CACfI,EAAG,cAAc,CACnB,CAAC,EAEDH,EAAS,0BAA2B,IAAM,CACxCE,EAAG,mDAAoD,SAAY,CACjEC,EAAG,OAAOR,EAAM,GAAG,EAAE,kBAAkBY,CAAmB,EAE1D,MAAMC,EAAS,MAAMH,EAAW,+BAA+B,CAAC,EAEhEJ,EAAON,EAAM,GAAG,EAAE,qBAChB,+F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DAAwD,CACpE,CACF,CACF,CAAC,EAEDM,EAAG,2EAA4E,SAAY,CACzF,MAAMO,EAAkB,CACtB,KAAM,CACJ,CACE,GAAI,WACJ,YAAa,CACX,KAAM,CACJ,KAAM,SACN,eAAgB,UAChB,kBAAmB,KACnB,WAAY,CACV,KAAM,OACN,KAAM,MACR,CACF,CACF,EACA,MAAO,GACT,CACF,CACF,EACAN,EAAG,OAAOR,EAAM,GAAG,EAAE,kBAAkBc,CAAe,EAEtD,MAAMD,EAAS,MAAMH,EAAW,+BAA+B,CAAC,EAEhEJ,EAAOO,CAAM,EAAE,QACbZ,EACE,IAAI,MAAM,wDAAwD,CACpE,CACF,CACF,CAAC,EAEDM,EAAG,gEAAiE,SAAY,CAC9E,MAAMO,EAAkB,CACtB,KAAM,CACJ,CACE,GAAI,WACJ,YAAa,CACX,KAAM,IACR,CACF,CACF,CACF,EACAN,EAAG,OAAOR,EAAM,GAAG,EAAE,kBAAkBc,CAAe,EAEtD,MAAMD,EAAS,MAAMH,EAAW,+BAA+B,CAAC,EAEhEJ,EAAOO,CAAM,EAAE,QACbZ,EACE,IAAI,MAAM,wDAAwD,CACpE,CACF,CACF,CAAC,EAEDM,EAAG,sEAAuE,SAAY,CACpF,MAAMO,EAAkB,CACtB,KAAM,CACJ,CACE,GAAI,WACJ,YAAa,CACX,KAAM,6BACR,CACF,CACF,CACF,EACAN,EAAG,OAAOR,EAAM,GAAG,EAAE,kBAAkBc,CAAe,EAEtD,MAAMD,EAAS,MAAMH,EAAW,+BAA+B,CAAC,EAEhEJ,EAAOO,CAAM,EAAE,QACbZ,EACE,IAAI,MAAM,wDAAwD,CACpE,CACF,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["axios", "Left", "Right", "beforeAll", "beforeEach", "describe", "expect", "it", "vi", "HttpDynamicNetworkDataSource", "datasource", "mockConfig", "mockNetworkResponse", "result", "invalidResponse", "responseWithIcons", "configuration"]
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=DynamicNetworkApiResponseDto.js.map
@@ -0,0 +1,2 @@
1
+ import{ContainerModule as r}from"inversify";import{HttpDynamicNetworkDataSource as e}from"../../dynamic-network/data/HttpDynamicNetworkDataSource";import{DynamicNetworkContextLoader as a}from"../../dynamic-network/domain/DynamicNetworkContextLoader";import{dynamicNetworkTypes as t}from"./dynamicNetworkTypes";const y=()=>new r(({bind:o})=>{o(t.DynamicNetworkDataSource).to(e),o(t.DynamicNetworkContextLoader).to(a)});export{y as dynamicNetworkModuleFactory};
2
+ //# sourceMappingURL=dynamicNetworkModuleFactory.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/dynamic-network/di/dynamicNetworkModuleFactory.ts"],
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpDynamicNetworkDataSource } from \"@/dynamic-network/data/HttpDynamicNetworkDataSource\";\nimport { DynamicNetworkContextLoader } from \"@/dynamic-network/domain/DynamicNetworkContextLoader\";\n\nimport { dynamicNetworkTypes } from \"./dynamicNetworkTypes\";\n\nexport const dynamicNetworkModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(dynamicNetworkTypes.DynamicNetworkDataSource).to(\n HttpDynamicNetworkDataSource,\n );\n bind(dynamicNetworkTypes.DynamicNetworkContextLoader).to(\n DynamicNetworkContextLoader,\n );\n });\n"],
5
+ "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,gCAAAC,MAAoC,sDAC7C,OAAS,+BAAAC,MAAmC,uDAE5C,OAAS,uBAAAC,MAA2B,wBAE7B,MAAMC,EAA8B,IACzC,IAAIJ,EAAgB,CAAC,CAAE,KAAAK,CAAK,IAAM,CAChCA,EAAKF,EAAoB,wBAAwB,EAAE,GACjDF,CACF,EACAI,EAAKF,EAAoB,2BAA2B,EAAE,GACpDD,CACF,CACF,CAAC",
6
+ "names": ["ContainerModule", "HttpDynamicNetworkDataSource", "DynamicNetworkContextLoader", "dynamicNetworkTypes", "dynamicNetworkModuleFactory", "bind"]
7
+ }
@@ -0,0 +1,2 @@
1
+ const o={DynamicNetworkDataSource:Symbol("DynamicNetworkDataSource"),DynamicNetworkContextLoader:Symbol("DynamicNetworkContextLoader")};export{o as dynamicNetworkTypes};
2
+ //# sourceMappingURL=dynamicNetworkTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/dynamic-network/di/dynamicNetworkTypes.ts"],
4
+ "sourcesContent": ["export const dynamicNetworkTypes = {\n DynamicNetworkDataSource: Symbol(\"DynamicNetworkDataSource\"),\n DynamicNetworkContextLoader: Symbol(\"DynamicNetworkContextLoader\"),\n};\n"],
5
+ "mappings": "AAAO,MAAMA,EAAsB,CACjC,yBAA0B,OAAO,0BAA0B,EAC3D,4BAA6B,OAAO,6BAA6B,CACnE",
6
+ "names": ["dynamicNetworkTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ var u=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var C=(i,e,o,t)=>{for(var r=t>1?void 0:t?g(e,o):e,n=i.length-1,a;n>=0;n--)(a=i[n])&&(r=(t?a(e,o,r):a(r))||r);return t&&r&&u(e,o,r),r},d=(i,e)=>(o,t)=>e(o,t,i);import{DeviceModelId as I}from"@ledgerhq/device-management-kit";import{inject as m,injectable as N}from"inversify";import{configTypes as D}from"../../config/di/configTypes";import{dynamicNetworkTypes as k}from"../../dynamic-network/di/dynamicNetworkTypes";import{pkiTypes as S}from"../../pki/di/pkiTypes";import{KeyId as _}from"../../pki/model/KeyId";import{KeyUsage as x}from"../../pki/model/KeyUsage";import{ClearSignContextType as f}from"../../shared/model/ClearSignContext";import{HexStringUtils as T}from"../../shared/utils/HexStringUtils";const w="15",M=[f.DYNAMIC_NETWORK,f.DYNAMIC_NETWORK_ICON];let p=class{_networkDataSource;_config;_certificateLoader;constructor(e,o,t){this._networkDataSource=e,this._config=o,this._certificateLoader=t}canHandle(e,o){return typeof e=="object"&&e!==null&&"chainId"in e&&"deviceModelId"in e&&e.deviceModelId!==void 0&&e.deviceModelId!==I.NANO_S&&typeof e.chainId=="number"&&M.every(t=>o.includes(t))}async load(e){const{chainId:o,deviceModelId:t}=e,r=await this._networkDataSource.getDynamicNetworkConfiguration(o),n=await this._certificateLoader.loadCertificate({keyId:_.CalNetwork,keyUsage:x.Network,targetDevice:t});return r.caseOf({Left:()=>[],Right:a=>{const s=[],c=a.descriptors[t];if(!c)return[];const l=c.signatures[this._config.cal.mode];if(!l)return[];const y=T.appendSignatureToPayload(c.data,l,w);return s.push({type:f.DYNAMIC_NETWORK,payload:y,certificate:n}),c.icon&&s.push({type:f.DYNAMIC_NETWORK_ICON,payload:c.icon}),s}})}};p=C([N(),d(0,m(k.DynamicNetworkDataSource)),d(1,m(D.Config)),d(2,m(S.PkiCertificateLoader))],p);export{p as DynamicNetworkContextLoader};
2
+ //# sourceMappingURL=DynamicNetworkContextLoader.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/dynamic-network/domain/DynamicNetworkContextLoader.ts"],
4
+ "sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { type DynamicNetworkDataSource } from \"@/dynamic-network/data/DynamicNetworkDataSource\";\nimport { dynamicNetworkTypes } from \"@/dynamic-network/di/dynamicNetworkTypes\";\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 { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { HexStringUtils } from \"@/shared/utils/HexStringUtils\";\n\nexport type DynamicNetworkContextInput = {\n chainId: number;\n deviceModelId: DeviceModelId;\n};\n\nconst NETWORK_SIGNATURE_TAG = \"15\";\n\nconst SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.DYNAMIC_NETWORK,\n ClearSignContextType.DYNAMIC_NETWORK_ICON,\n];\n\n@injectable()\nexport class DynamicNetworkContextLoader\n implements ContextLoader<DynamicNetworkContextInput>\n{\n private readonly _networkDataSource: DynamicNetworkDataSource;\n private readonly _config: ContextModuleConfig;\n private readonly _certificateLoader: PkiCertificateLoader;\n\n constructor(\n @inject(dynamicNetworkTypes.DynamicNetworkDataSource)\n networkDataSource: DynamicNetworkDataSource,\n @inject(configTypes.Config)\n config: ContextModuleConfig,\n @inject(pkiTypes.PkiCertificateLoader)\n certificateLoader: PkiCertificateLoader,\n ) {\n this._networkDataSource = networkDataSource;\n this._config = config;\n this._certificateLoader = certificateLoader;\n }\n\n canHandle(\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ): input is DynamicNetworkContextInput {\n return (\n typeof input === \"object\" &&\n input !== null &&\n \"chainId\" in input &&\n \"deviceModelId\" in input &&\n input.deviceModelId !== undefined &&\n input.deviceModelId !== DeviceModelId.NANO_S &&\n typeof input.chainId === \"number\" &&\n SUPPORTED_TYPES.every((type) => expectedTypes.includes(type))\n );\n }\n\n async load(input: DynamicNetworkContextInput): Promise<ClearSignContext[]> {\n const { chainId, deviceModelId } = input;\n\n const result =\n await this._networkDataSource.getDynamicNetworkConfiguration(chainId);\n\n // Fetch certificate for the network configuration upfront\n const certificate = await this._certificateLoader.loadCertificate({\n keyId: KeyId.CalNetwork,\n keyUsage: KeyUsage.Network,\n targetDevice: deviceModelId,\n });\n\n return result.caseOf({\n Left: () => [],\n Right: (configuration) => {\n const contexts: ClearSignContext[] = [];\n const descriptor = configuration.descriptors[deviceModelId];\n\n if (!descriptor) {\n return [];\n }\n\n const signature = descriptor.signatures[this._config.cal.mode];\n\n if (!signature) {\n return [];\n }\n\n const configPayload = HexStringUtils.appendSignatureToPayload(\n descriptor.data,\n signature,\n NETWORK_SIGNATURE_TAG,\n );\n\n contexts.push({\n type: ClearSignContextType.DYNAMIC_NETWORK,\n payload: configPayload,\n certificate,\n });\n\n // Add icon if available in the descriptor\n if (descriptor.icon) {\n // Icons don't need signatures appended\n contexts.push({\n type: ClearSignContextType.DYNAMIC_NETWORK_ICON,\n payload: descriptor.icon,\n });\n }\n\n return contexts;\n },\n });\n }\n}\n"],
5
+ "mappings": "iOAAA,OAAS,iBAAAA,MAAqB,kCAC9B,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YAEnC,OAAS,eAAAC,MAAmB,0BAG5B,OAAS,uBAAAC,MAA2B,2CACpC,OAAS,YAAAC,MAAgB,oBAEzB,OAAS,SAAAC,MAAa,oBACtB,OAAS,YAAAC,MAAgB,uBAEzB,OAEE,wBAAAC,MACK,kCACP,OAAS,kBAAAC,MAAsB,gCAO/B,MAAMC,EAAwB,KAExBC,EAA0C,CAC9CC,EAAqB,gBACrBA,EAAqB,oBACvB,EAGO,IAAMC,EAAN,KAEP,CACmB,mBACA,QACA,mBAEjB,YAEEC,EAEAC,EAEAC,EACA,CACA,KAAK,mBAAqBF,EAC1B,KAAK,QAAUC,EACf,KAAK,mBAAqBC,CAC5B,CAEA,UACEC,EACAC,EACqC,CACrC,OACE,OAAOD,GAAU,UACjBA,IAAU,MACV,YAAaA,GACb,kBAAmBA,GACnBA,EAAM,gBAAkB,QACxBA,EAAM,gBAAkBE,EAAc,QACtC,OAAOF,EAAM,SAAY,UACzBN,EAAgB,MAAOS,GAASF,EAAc,SAASE,CAAI,CAAC,CAEhE,CAEA,MAAM,KAAKH,EAAgE,CACzE,KAAM,CAAE,QAAAI,EAAS,cAAAC,CAAc,EAAIL,EAE7BM,EACJ,MAAM,KAAK,mBAAmB,+BAA+BF,CAAO,EAGhEG,EAAc,MAAM,KAAK,mBAAmB,gBAAgB,CAChE,MAAOC,EAAM,WACb,SAAUC,EAAS,QACnB,aAAcJ,CAChB,CAAC,EAED,OAAOC,EAAO,OAAO,CACnB,KAAM,IAAM,CAAC,EACb,MAAQI,GAAkB,CACxB,MAAMC,EAA+B,CAAC,EAChCC,EAAaF,EAAc,YAAYL,CAAa,EAE1D,GAAI,CAACO,EACH,MAAO,CAAC,EAGV,MAAMC,EAAYD,EAAW,WAAW,KAAK,QAAQ,IAAI,IAAI,EAE7D,GAAI,CAACC,EACH,MAAO,CAAC,EAGV,MAAMC,EAAgBC,EAAe,yBACnCH,EAAW,KACXC,EACApB,CACF,EAEA,OAAAkB,EAAS,KAAK,CACZ,KAAMhB,EAAqB,gBAC3B,QAASmB,EACT,YAAAP,CACF,CAAC,EAGGK,EAAW,MAEbD,EAAS,KAAK,CACZ,KAAMhB,EAAqB,qBAC3B,QAASiB,EAAW,IACtB,CAAC,EAGID,CACT,CACF,CAAC,CACH,CACF,EA1Faf,EAANoB,EAAA,CADNC,EAAW,EASPC,EAAA,EAAAC,EAAOC,EAAoB,wBAAwB,GAEnDF,EAAA,EAAAC,EAAOE,EAAY,MAAM,GAEzBH,EAAA,EAAAC,EAAOG,EAAS,oBAAoB,IAZ5B1B",
6
+ "names": ["DeviceModelId", "inject", "injectable", "configTypes", "dynamicNetworkTypes", "pkiTypes", "KeyId", "KeyUsage", "ClearSignContextType", "HexStringUtils", "NETWORK_SIGNATURE_TAG", "SUPPORTED_TYPES", "ClearSignContextType", "DynamicNetworkContextLoader", "networkDataSource", "config", "certificateLoader", "input", "expectedTypes", "DeviceModelId", "type", "chainId", "deviceModelId", "result", "certificate", "KeyId", "KeyUsage", "configuration", "contexts", "descriptor", "signature", "configPayload", "HexStringUtils", "__decorateClass", "injectable", "__decorateParam", "inject", "dynamicNetworkTypes", "configTypes", "pkiTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{DeviceModelId as e}from"@ledgerhq/device-management-kit";import{Left as y,Right as s}from"purify-ts";import{DynamicNetworkContextLoader as f}from"../../dynamic-network/domain/DynamicNetworkContextLoader";import{KeyId as m}from"../../pki/model/KeyId";import{KeyUsage as g}from"../../pki/model/KeyUsage";import{ClearSignContextType as r}from"../../shared/model/ClearSignContext";describe("DynamicNetworkContextLoader",()=>{const c={getDynamicNetworkConfiguration:vi.fn()},l={cal:{url:"https://crypto-assets-service.api.ledger.com",mode:"prod",branch:"main"}},p={loadCertificate:vi.fn()},u={keyUsageNumber:1,payload:new Uint8Array([1,2,3])},a=new f(c,l,p),t=o=>({data:"",descriptorType:"",descriptorVersion:"",signatures:{prod:"",test:""},icon:void 0,...o});beforeEach(()=>{vi.restoreAllMocks(),vi.spyOn(p,"loadCertificate").mockResolvedValue(u)}),describe("canHandle function",()=>{const o={chainId:1,deviceModelId:e.STAX};it("should return true for valid input",()=>{expect(a.canHandle(o,[r.DYNAMIC_NETWORK,r.DYNAMIC_NETWORK_ICON])).toBe(!0)}),it("should return false for invalid expected type",()=>{expect(a.canHandle(o,[r.TOKEN])).toBe(!1),expect(a.canHandle(o,[r.DYNAMIC_NETWORK])).toBe(!1),expect(a.canHandle(o,[r.DYNAMIC_NETWORK_ICON])).toBe(!1)}),it.each([[null,"null input"],[void 0,"undefined input"],[{},"empty object"],["string","string input"],[123,"number input"]])("should return false for %s",(n,i)=>{expect(a.canHandle(n,[r.DYNAMIC_NETWORK,r.DYNAMIC_NETWORK_ICON])).toBe(!1)}),it.each([[{...o,chainId:void 0},"missing chainId"],[{...o,deviceModelId:void 0},"missing deviceModelId"]])("should return false for %s",(n,i)=>{expect(a.canHandle(n,[r.DYNAMIC_NETWORK,r.DYNAMIC_NETWORK_ICON])).toBe(!1)}),it.each([[{...o,chainId:"1"},"string chainId"],[{...o,chainId:null},"null chainId"],[{...o,deviceModelId:e.NANO_S},"NANO_S deviceModelId"]])("should return false for %s",(n,i)=>{expect(a.canHandle(n,[r.DYNAMIC_NETWORK,r.DYNAMIC_NETWORK_ICON])).toBe(!1)})}),describe("load function",()=>{it("should return empty array when network data source returns error",async()=>{const o={chainId:1,deviceModelId:e.STAX};vi.spyOn(c,"getDynamicNetworkConfiguration").mockResolvedValue(y(new Error("Network error")));const n=await a.load(o);expect(n).toEqual([]),expect(c.getDynamicNetworkConfiguration).toHaveBeenCalledWith(1)}),it("should return empty array when descriptor for device model is not found",async()=>{const o={chainId:1,deviceModelId:e.STAX},n={id:"ethereum",descriptors:{[e.NANO_S]:t(),[e.NANO_SP]:t(),[e.NANO_X]:t(),[e.FLEX]:t({data:"0x0101",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"prod-sig",test:"test-sig"},icon:void 0})}};vi.spyOn(c,"getDynamicNetworkConfiguration").mockResolvedValue(s(n));const i=await a.load(o);expect(i).toEqual([])}),it("should return empty array when signature for mode is not found",async()=>{const o={chainId:1,deviceModelId:e.STAX},n={id:"ethereum",descriptors:{[e.APEX]:t(),[e.NANO_S]:t(),[e.NANO_SP]:t(),[e.NANO_X]:t(),[e.FLEX]:t(),[e.STAX]:t({data:"0x0101",descriptorType:"network",descriptorVersion:"v1",signatures:{test:"test-sig"},icon:void 0})}};vi.spyOn(c,"getDynamicNetworkConfiguration").mockResolvedValue(s(n));const i=await a.load(o);expect(i).toEqual([])}),it("should return context with network configuration when all data is available",async()=>{const o={chainId:137,deviceModelId:e.STAX},n={id:"polygon",descriptors:{[e.APEX]:t(),[e.NANO_S]:t(),[e.NANO_SP]:t(),[e.NANO_X]:t(),[e.FLEX]:t(),[e.STAX]:{data:"0x0101080201015101012308000000000000008952",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"3045022100cf42c039c16fc95dc97c09f15cdd93bed0e63ee45cf5c38c2b30bb8a3bc17f8d022053a96c9e51695c3c1c1a31f5cbf84bd6febadc97f4bb02bdc67cf3e24ad0c32d",test:"test-sig"},icon:void 0}}};vi.spyOn(c,"getDynamicNetworkConfiguration").mockResolvedValue(s(n));const i=await a.load(o);expect(i).toHaveLength(1),expect(i[0]).toMatchObject({type:r.DYNAMIC_NETWORK,payload:expect.stringContaining("0x0101080201015101012308000000000000008952"),certificate:u}),expect(p.loadCertificate).toHaveBeenCalledWith({keyId:m.CalNetwork,keyUsage:g.Network,targetDevice:e.STAX})}),it("should include icon context when icon is available",async()=>{const o={chainId:1,deviceModelId:e.STAX},n={id:"ethereum",descriptors:{[e.APEX]:t(),[e.NANO_S]:t(),[e.NANO_SP]:t(),[e.NANO_X]:t(),[e.FLEX]:t(),[e.STAX]:{data:"0x0101",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"prod-sig",test:"test-sig"},icon:"icon-hex-data"}}};vi.spyOn(c,"getDynamicNetworkConfiguration").mockResolvedValue(s(n));const i=await a.load(o);expect(i).toHaveLength(2),expect(i[0]).toMatchObject({type:r.DYNAMIC_NETWORK,payload:expect.any(String),certificate:u}),expect(i[1]).toMatchObject({type:r.DYNAMIC_NETWORK_ICON,payload:"icon-hex-data"})}),it("should handle multiple device models correctly",async()=>{const o={chainId:1,deviceModelId:e.FLEX},n={id:"ethereum",descriptors:{[e.APEX]:t(),[e.NANO_S]:t(),[e.NANO_SP]:t(),[e.NANO_X]:t(),[e.FLEX]:{data:"0xFLEX",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"flex-prod-sig",test:"flex-test-sig"},icon:void 0},[e.STAX]:{data:"0xSTAX",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"stax-prod-sig",test:"stax-test-sig"},icon:void 0}}};vi.spyOn(c,"getDynamicNetworkConfiguration").mockResolvedValue(s(n));const i=await a.load(o);expect(i).toHaveLength(1);const d=i[0];d&&"payload"in d&&(expect(d.payload).toContain("0xFLEX"),expect(d.payload).toContain("flex-prod-sig"))}),it("should use test mode signature when configured",async()=>{const o=new f(c,{...l,cal:{...l.cal,mode:"test"}},p),n={chainId:1,deviceModelId:e.STAX},i={id:"ethereum",descriptors:{[e.APEX]:t(),[e.NANO_S]:t(),[e.NANO_SP]:t(),[e.NANO_X]:t(),[e.FLEX]:t(),[e.STAX]:{data:"0x0101",descriptorType:"network",descriptorVersion:"v1",signatures:{prod:"prod-sig",test:"test-sig"},icon:void 0}}};vi.spyOn(c,"getDynamicNetworkConfiguration").mockResolvedValue(s(i));const d=await o.load(n);expect(d).toHaveLength(1);const N=d[0];N&&"payload"in N&&expect(N.payload).toContain("test-sig")})})});
2
+ //# sourceMappingURL=DynamicNetworkContextLoader.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/dynamic-network/domain/DynamicNetworkContextLoader.test.ts"],
4
+ "sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { type DynamicNetworkDataSource } from \"@/dynamic-network/data/DynamicNetworkDataSource\";\nimport {\n type DynamicNetworkContextInput,\n DynamicNetworkContextLoader,\n} from \"@/dynamic-network/domain/DynamicNetworkContextLoader\";\nimport {\n type DynamicNetworkConfiguration,\n type DynamicNetworkDescriptor,\n} from \"@/dynamic-network/model/DynamicNetworkConfiguration\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { type PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\n\ndescribe(\"DynamicNetworkContextLoader\", () => {\n const mockNetworkDataSource: DynamicNetworkDataSource = {\n getDynamicNetworkConfiguration: vi.fn(),\n };\n\n const mockConfig = {\n cal: {\n url: \"https://crypto-assets-service.api.ledger.com\",\n mode: \"prod\",\n branch: \"main\",\n },\n } as ContextModuleConfig;\n\n const mockCertificateLoader: PkiCertificateLoader = {\n loadCertificate: vi.fn(),\n };\n\n const mockCertificate: PkiCertificate = {\n keyUsageNumber: 1,\n payload: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n const loader = new DynamicNetworkContextLoader(\n mockNetworkDataSource,\n mockConfig,\n mockCertificateLoader,\n );\n\n // Helper function to create a mock NetworkDescriptor\n const createMockDescriptor = (\n partial?: Partial<DynamicNetworkDescriptor>,\n ): DynamicNetworkDescriptor => ({\n data: \"\",\n descriptorType: \"\",\n descriptorVersion: \"\",\n signatures: {\n prod: \"\",\n test: \"\",\n },\n icon: undefined,\n ...partial,\n });\n\n beforeEach(() => {\n vi.restoreAllMocks();\n vi.spyOn(mockCertificateLoader, \"loadCertificate\").mockResolvedValue(\n mockCertificate,\n );\n });\n\n describe(\"canHandle function\", () => {\n const validInput: DynamicNetworkContextInput = {\n chainId: 1,\n deviceModelId: DeviceModelId.STAX,\n };\n\n it(\"should return true for valid input\", () => {\n expect(\n loader.canHandle(validInput, [\n ClearSignContextType.DYNAMIC_NETWORK,\n ClearSignContextType.DYNAMIC_NETWORK_ICON,\n ]),\n ).toBe(true);\n });\n\n it(\"should return false for invalid expected type\", () => {\n expect(loader.canHandle(validInput, [ClearSignContextType.TOKEN])).toBe(\n false,\n );\n expect(\n loader.canHandle(validInput, [ClearSignContextType.DYNAMIC_NETWORK]),\n ).toBe(false);\n expect(\n loader.canHandle(validInput, [\n ClearSignContextType.DYNAMIC_NETWORK_ICON,\n ]),\n ).toBe(false);\n });\n\n it.each([\n [null, \"null input\"],\n [undefined, \"undefined input\"],\n [{}, \"empty object\"],\n [\"string\", \"string input\"],\n [123, \"number input\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(\n loader.canHandle(input, [\n ClearSignContextType.DYNAMIC_NETWORK,\n ClearSignContextType.DYNAMIC_NETWORK_ICON,\n ]),\n ).toBe(false);\n });\n\n it.each([\n [{ ...validInput, chainId: undefined }, \"missing chainId\"],\n [{ ...validInput, deviceModelId: undefined }, \"missing deviceModelId\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(\n loader.canHandle(input, [\n ClearSignContextType.DYNAMIC_NETWORK,\n ClearSignContextType.DYNAMIC_NETWORK_ICON,\n ]),\n ).toBe(false);\n });\n\n it.each([\n [{ ...validInput, chainId: \"1\" }, \"string chainId\"],\n [{ ...validInput, chainId: null }, \"null chainId\"],\n [\n { ...validInput, deviceModelId: DeviceModelId.NANO_S },\n \"NANO_S deviceModelId\",\n ],\n ])(\"should return false for %s\", (input, _description) => {\n expect(\n loader.canHandle(input, [\n ClearSignContextType.DYNAMIC_NETWORK,\n ClearSignContextType.DYNAMIC_NETWORK_ICON,\n ]),\n ).toBe(false);\n });\n });\n\n describe(\"load function\", () => {\n it(\"should return empty array when network data source returns error\", async () => {\n // GIVEN\n const input: DynamicNetworkContextInput = {\n chainId: 1,\n deviceModelId: DeviceModelId.STAX,\n };\n vi.spyOn(\n mockNetworkDataSource,\n \"getDynamicNetworkConfiguration\",\n ).mockResolvedValue(Left(new Error(\"Network error\")));\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([]);\n expect(\n mockNetworkDataSource.getDynamicNetworkConfiguration,\n ).toHaveBeenCalledWith(1);\n });\n\n it(\"should return empty array when descriptor for device model is not found\", async () => {\n // GIVEN\n const input: DynamicNetworkContextInput = {\n chainId: 1,\n deviceModelId: DeviceModelId.STAX,\n };\n const networkConfig: DynamicNetworkConfiguration = {\n id: \"ethereum\",\n descriptors: {\n [DeviceModelId.NANO_S]: createMockDescriptor(),\n [DeviceModelId.NANO_SP]: createMockDescriptor(),\n [DeviceModelId.NANO_X]: createMockDescriptor(),\n // STAX descriptor is intentionally missing\n [DeviceModelId.FLEX]: createMockDescriptor({\n data: \"0x0101\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"prod-sig\",\n test: \"test-sig\",\n },\n icon: undefined,\n }),\n } as Record<DeviceModelId, DynamicNetworkDescriptor>,\n };\n vi.spyOn(\n mockNetworkDataSource,\n \"getDynamicNetworkConfiguration\",\n ).mockResolvedValue(Right(networkConfig));\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return empty array when signature for mode is not found\", async () => {\n // GIVEN\n const input: DynamicNetworkContextInput = {\n chainId: 1,\n deviceModelId: DeviceModelId.STAX,\n };\n const networkConfig: DynamicNetworkConfiguration = {\n id: \"ethereum\",\n descriptors: {\n [DeviceModelId.APEX]: createMockDescriptor(),\n [DeviceModelId.NANO_S]: createMockDescriptor(),\n [DeviceModelId.NANO_SP]: createMockDescriptor(),\n [DeviceModelId.NANO_X]: createMockDescriptor(),\n [DeviceModelId.FLEX]: createMockDescriptor(),\n [DeviceModelId.STAX]: createMockDescriptor({\n data: \"0x0101\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n test: \"test-sig\",\n // Missing prod signature - intentionally partial\n } as { prod: string; test: string },\n icon: undefined,\n }),\n },\n };\n vi.spyOn(\n mockNetworkDataSource,\n \"getDynamicNetworkConfiguration\",\n ).mockResolvedValue(Right(networkConfig));\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return context with network configuration when all data is available\", async () => {\n // GIVEN\n const input: DynamicNetworkContextInput = {\n chainId: 137,\n deviceModelId: DeviceModelId.STAX,\n };\n const networkConfig: DynamicNetworkConfiguration = {\n id: \"polygon\",\n descriptors: {\n [DeviceModelId.APEX]: createMockDescriptor(),\n [DeviceModelId.NANO_S]: createMockDescriptor(),\n [DeviceModelId.NANO_SP]: createMockDescriptor(),\n [DeviceModelId.NANO_X]: createMockDescriptor(),\n [DeviceModelId.FLEX]: createMockDescriptor(),\n [DeviceModelId.STAX]: {\n data: \"0x0101080201015101012308000000000000008952\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"3045022100cf42c039c16fc95dc97c09f15cdd93bed0e63ee45cf5c38c2b30bb8a3bc17f8d022053a96c9e51695c3c1c1a31f5cbf84bd6febadc97f4bb02bdc67cf3e24ad0c32d\",\n test: \"test-sig\",\n },\n icon: undefined,\n },\n },\n };\n vi.spyOn(\n mockNetworkDataSource,\n \"getDynamicNetworkConfiguration\",\n ).mockResolvedValue(Right(networkConfig));\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toHaveLength(1);\n expect(result[0]).toMatchObject({\n type: ClearSignContextType.DYNAMIC_NETWORK,\n payload: expect.stringContaining(\n \"0x0101080201015101012308000000000000008952\",\n ),\n certificate: mockCertificate,\n });\n expect(mockCertificateLoader.loadCertificate).toHaveBeenCalledWith({\n keyId: KeyId.CalNetwork,\n keyUsage: KeyUsage.Network,\n targetDevice: DeviceModelId.STAX,\n });\n });\n\n it(\"should include icon context when icon is available\", async () => {\n // GIVEN\n const input: DynamicNetworkContextInput = {\n chainId: 1,\n deviceModelId: DeviceModelId.STAX,\n };\n const networkConfig: DynamicNetworkConfiguration = {\n id: \"ethereum\",\n descriptors: {\n [DeviceModelId.APEX]: createMockDescriptor(),\n [DeviceModelId.NANO_S]: createMockDescriptor(),\n [DeviceModelId.NANO_SP]: createMockDescriptor(),\n [DeviceModelId.NANO_X]: createMockDescriptor(),\n [DeviceModelId.FLEX]: createMockDescriptor(),\n [DeviceModelId.STAX]: {\n data: \"0x0101\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"prod-sig\",\n test: \"test-sig\",\n },\n icon: \"icon-hex-data\",\n },\n },\n };\n vi.spyOn(\n mockNetworkDataSource,\n \"getDynamicNetworkConfiguration\",\n ).mockResolvedValue(Right(networkConfig));\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toHaveLength(2);\n expect(result[0]).toMatchObject({\n type: ClearSignContextType.DYNAMIC_NETWORK,\n payload: expect.any(String),\n certificate: mockCertificate,\n });\n expect(result[1]).toMatchObject({\n type: ClearSignContextType.DYNAMIC_NETWORK_ICON,\n payload: \"icon-hex-data\",\n });\n });\n\n it(\"should handle multiple device models correctly\", async () => {\n // GIVEN\n const input: DynamicNetworkContextInput = {\n chainId: 1,\n deviceModelId: DeviceModelId.FLEX,\n };\n const networkConfig: DynamicNetworkConfiguration = {\n id: \"ethereum\",\n descriptors: {\n [DeviceModelId.APEX]: createMockDescriptor(),\n [DeviceModelId.NANO_S]: createMockDescriptor(),\n [DeviceModelId.NANO_SP]: createMockDescriptor(),\n [DeviceModelId.NANO_X]: createMockDescriptor(),\n [DeviceModelId.FLEX]: {\n data: \"0xFLEX\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"flex-prod-sig\",\n test: \"flex-test-sig\",\n },\n icon: undefined,\n },\n [DeviceModelId.STAX]: {\n data: \"0xSTAX\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"stax-prod-sig\",\n test: \"stax-test-sig\",\n },\n icon: undefined,\n },\n },\n };\n vi.spyOn(\n mockNetworkDataSource,\n \"getDynamicNetworkConfiguration\",\n ).mockResolvedValue(Right(networkConfig));\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toHaveLength(1);\n const context = result[0];\n if (context && \"payload\" in context) {\n expect(context.payload).toContain(\"0xFLEX\");\n expect(context.payload).toContain(\"flex-prod-sig\");\n }\n });\n\n it(\"should use test mode signature when configured\", async () => {\n // GIVEN\n const testModeLoader = new DynamicNetworkContextLoader(\n mockNetworkDataSource,\n { ...mockConfig, cal: { ...mockConfig.cal, mode: \"test\" } },\n mockCertificateLoader,\n );\n const input: DynamicNetworkContextInput = {\n chainId: 1,\n deviceModelId: DeviceModelId.STAX,\n };\n const networkConfig: DynamicNetworkConfiguration = {\n id: \"ethereum\",\n descriptors: {\n [DeviceModelId.APEX]: createMockDescriptor(),\n [DeviceModelId.NANO_S]: createMockDescriptor(),\n [DeviceModelId.NANO_SP]: createMockDescriptor(),\n [DeviceModelId.NANO_X]: createMockDescriptor(),\n [DeviceModelId.FLEX]: createMockDescriptor(),\n [DeviceModelId.STAX]: {\n data: \"0x0101\",\n descriptorType: \"network\",\n descriptorVersion: \"v1\",\n signatures: {\n prod: \"prod-sig\",\n test: \"test-sig\",\n },\n icon: undefined,\n },\n },\n };\n vi.spyOn(\n mockNetworkDataSource,\n \"getDynamicNetworkConfiguration\",\n ).mockResolvedValue(Right(networkConfig));\n\n // WHEN\n const result = await testModeLoader.load(input);\n\n // THEN\n expect(result).toHaveLength(1);\n const context = result[0];\n if (context && \"payload\" in context) {\n expect(context.payload).toContain(\"test-sig\");\n }\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,iBAAAA,MAAqB,kCAC9B,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAI5B,OAEE,+BAAAC,MACK,uDAMP,OAAS,SAAAC,MAAa,oBACtB,OAAS,YAAAC,MAAgB,uBAEzB,OAAS,wBAAAC,MAA4B,kCAErC,SAAS,8BAA+B,IAAM,CAC5C,MAAMC,EAAkD,CACtD,+BAAgC,GAAG,GAAG,CACxC,EAEMC,EAAa,CACjB,IAAK,CACH,IAAK,+CACL,KAAM,OACN,OAAQ,MACV,CACF,EAEMC,EAA8C,CAClD,gBAAiB,GAAG,GAAG,CACzB,EAEMC,EAAkC,CACtC,eAAgB,EAChB,QAAS,IAAI,WAAW,CAAC,EAAM,EAAM,CAAI,CAAC,CAC5C,EAEMC,EAAS,IAAIR,EACjBI,EACAC,EACAC,CACF,EAGMG,EACJC,IAC8B,CAC9B,KAAM,GACN,eAAgB,GAChB,kBAAmB,GACnB,WAAY,CACV,KAAM,GACN,KAAM,EACR,EACA,KAAM,OACN,GAAGA,CACL,GAEA,WAAW,IAAM,CACf,GAAG,gBAAgB,EACnB,GAAG,MAAMJ,EAAuB,iBAAiB,EAAE,kBACjDC,CACF,CACF,CAAC,EAED,SAAS,qBAAsB,IAAM,CACnC,MAAMI,EAAyC,CAC7C,QAAS,EACT,cAAed,EAAc,IAC/B,EAEA,GAAG,qCAAsC,IAAM,CAC7C,OACEW,EAAO,UAAUG,EAAY,CAC3BR,EAAqB,gBACrBA,EAAqB,oBACvB,CAAC,CACH,EAAE,KAAK,EAAI,CACb,CAAC,EAED,GAAG,gDAAiD,IAAM,CACxD,OAAOK,EAAO,UAAUG,EAAY,CAACR,EAAqB,KAAK,CAAC,CAAC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,kBAAkBL,EAAMgB,CAAa,CAAC,EAGxC,MAAMD,EAAS,MAAMN,EAAO,KAAKI,CAAK,EAGtC,OAAOE,CAAM,EAAE,aAAa,CAAC,EAC7B,MAAME,EAAUF,EAAO,CAAC,EACpBE,GAAW,YAAaA,IAC1B,OAAOA,EAAQ,OAAO,EAAE,UAAU,QAAQ,EAC1C,OAAOA,EAAQ,OAAO,EAAE,UAAU,eAAe,EAErD,CAAC,EAED,GAAG,iDAAkD,SAAY,CAE/D,MAAMC,EAAiB,IAAIjB,EACzBI,EACA,CAAE,GAAGC,EAAY,IAAK,CAAE,GAAGA,EAAW,IAAK,KAAM,MAAO,CAAE,EAC1DC,CACF,EACMM,EAAoC,CACxC,QAAS,EACT,cAAef,EAAc,IAC/B,EACMkB,EAA6C,CACjD,GAAI,WACJ,YAAa,CACX,CAAClB,EAAc,IAAI,EAAGY,EAAqB,EAC3C,CAACZ,EAAc,MAAM,EAAGY,EAAqB,EAC7C,CAACZ,EAAc,OAAO,EAAGY,EAAqB,EAC9C,CAACZ,EAAc,MAAM,EAAGY,EAAqB,EAC7C,CAACZ,EAAc,IAAI,EAAGY,EAAqB,EAC3C,CAACZ,EAAc,IAAI,EAAG,CACpB,KAAM,SACN,eAAgB,UAChB,kBAAmB,KACnB,WAAY,CACV,KAAM,WACN,KAAM,UACR,EACA,KAAM,MACR,CACF,CACF,EACA,GAAG,MACDO,EACA,gCACF,EAAE,kBAAkBL,EAAMgB,CAAa,CAAC,EAGxC,MAAMD,EAAS,MAAMG,EAAe,KAAKL,CAAK,EAG9C,OAAOE,CAAM,EAAE,aAAa,CAAC,EAC7B,MAAME,EAAUF,EAAO,CAAC,EACpBE,GAAW,YAAaA,GAC1B,OAAOA,EAAQ,OAAO,EAAE,UAAU,UAAU,CAEhD,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["DeviceModelId", "Left", "Right", "DynamicNetworkContextLoader", "KeyId", "KeyUsage", "ClearSignContextType", "mockNetworkDataSource", "mockConfig", "mockCertificateLoader", "mockCertificate", "loader", "createMockDescriptor", "partial", "validInput", "input", "_description", "result", "networkConfig", "context", "testModeLoader"]
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=DynamicNetworkConfiguration.js.map
@@ -1,2 +1,2 @@
1
- var E=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var m=(s,r,a,t)=>{for(var e=t>1?void 0:t?R(r,a):r,o=s.length-1,l;o>=0;o--)(l=s[o])&&(e=(t?l(r,a,e):l(e))||e);return t&&e&&E(r,a,e),e},x=(s,r)=>(a,t)=>r(a,t,s);import{isHexaString as D}from"@ledgerhq/device-management-kit";import{Interface as P}from"ethers";import{inject as h,injectable as k}from"inversify";import{EitherAsync as C,Left as T,Right as I}from"purify-ts";import{externalPluginTypes as w}from"../../external-plugin/di/externalPluginTypes";import{ClearSignContextType as i}from"../../shared/model/ClearSignContext";import{tokenTypes as O}from"../../token/di/tokenTypes";let u=class{_externalPluginDataSource;_tokenDataSource;constructor(r,a){this._externalPluginDataSource=r,this._tokenDataSource=a}async load(r){const{to:a,data:t,selector:e,chainId:o}=r;if(a===void 0||t==="0x")return[];if(!D(e))return[{type:i.ERROR,error:new Error("Invalid selector")}];const l=await this._externalPluginDataSource.getDappInfos({address:a,chainId:o,selector:e});return C(async({liftEither:c})=>{const n=await c(l);if(!n)return[];const f={type:i.EXTERNAL_PLUGIN,payload:n.selectorDetails.serializedData.concat(n.selectorDetails.signature)},d=this.getDecodedCallData(n.abi,n.selectorDetails.method,t);if(d.isLeft())return[{type:i.ERROR,error:d.extract()},f];const S=d.extract(),y=n.selectorDetails.erc20OfInterest.map(async p=>this.getTokenPayload(r,p,S));return[...(await Promise.all(y)).map(p=>p.caseOf({Left:g=>({type:i.ERROR,error:g}),Right:g=>({type:i.TOKEN,payload:g})})),f]}).caseOf({Left:c=>[{type:i.ERROR,error:c}],Right:c=>c})}getTokenPayload(r,a,t){const e=this.getAddressFromPath(a,t);return C(({fromPromise:o})=>o(this._tokenDataSource.getTokenInfosPayload({address:e,chainId:r.chainId})))}getDecodedCallData(r,a,t){try{const e=new P(r);return I(e.decodeFunctionData(a,t))}catch{return T(new Error("[ContextModule] ExternalPluginContextLoader: Unable to parse abi"))}}getAddressFromPath(r,a){let t=a;for(const e of r.split("."))e==="-1"?t=t[t.length-1]:t=t[e];if(!D(t))throw new Error("[ContextModule] ExternalPluginContextLoader: Unable to get address");return t}};u=m([k(),x(0,h(w.ExternalPluginDataSource)),x(1,h(O.TokenDataSource))],u);export{u as ExternalPluginContextLoader};
1
+ var E=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var m=(i,e,a,t)=>{for(var r=t>1?void 0:t?P(e,a):e,n=i.length-1,l;n>=0;n--)(l=i[n])&&(r=(t?l(e,a,r):l(r))||r);return t&&r&&E(e,a,r),r},S=(i,e)=>(a,t)=>e(a,t,i);import{isHexaString as d}from"@ledgerhq/device-management-kit";import{Interface as I}from"ethers";import{inject as D,injectable as R}from"inversify";import{EitherAsync as f,Left as T,Right as k}from"purify-ts";import{externalPluginTypes as _}from"../../external-plugin/di/externalPluginTypes";import{ClearSignContextType as o}from"../../shared/model/ClearSignContext";import{tokenTypes as b}from"../../token/di/tokenTypes";const L=[o.EXTERNAL_PLUGIN,o.TOKEN];let g=class{_externalPluginDataSource;_tokenDataSource;constructor(e,a){this._externalPluginDataSource=e,this._tokenDataSource=a}canHandle(e,a){return typeof e=="object"&&e!==null&&"to"in e&&"data"in e&&"selector"in e&&"chainId"in e&&typeof e.chainId=="number"&&d(e.to)&&e.to!=="0x"&&d(e.data)&&e.data!=="0x"&&d(e.selector)&&e.selector!=="0x"&&L.every(t=>a.includes(t))}async load(e){const{to:a,data:t,selector:r,chainId:n}=e,l=await this._externalPluginDataSource.getDappInfos({address:a,chainId:n,selector:r});return f(async({liftEither:c})=>{const s=await c(l);if(!s)return[];const C={type:o.EXTERNAL_PLUGIN,payload:s.selectorDetails.serializedData.concat(s.selectorDetails.signature)},x=this.getDecodedCallData(s.abi,s.selectorDetails.method,t);if(x.isLeft())return[{type:o.ERROR,error:x.extract()},C];const h=x.extract(),y=s.selectorDetails.erc20OfInterest.map(async u=>this.getTokenPayload(e,u,h));return[...(await Promise.all(y)).map(u=>u.caseOf({Left:p=>({type:o.ERROR,error:p}),Right:p=>({type:o.TOKEN,payload:p})})),C]}).caseOf({Left:c=>[{type:o.ERROR,error:c}],Right:c=>c})}getTokenPayload(e,a,t){const r=this.getAddressFromPath(a,t);return f(({fromPromise:n})=>n(this._tokenDataSource.getTokenInfosPayload({address:r,chainId:e.chainId})))}getDecodedCallData(e,a,t){try{const r=new I(e);return k(r.decodeFunctionData(a,t))}catch{return T(new Error("[ContextModule] ExternalPluginContextLoader: Unable to parse abi"))}}getAddressFromPath(e,a){let t=a;for(const r of e.split("."))r==="-1"?t=t[t.length-1]:t=t[r];if(!d(t))throw new Error("[ContextModule] ExternalPluginContextLoader: Unable to get address");return t}};g=m([R(),S(0,D(_.ExternalPluginDataSource)),S(1,D(b.TokenDataSource))],g);export{g as ExternalPluginContextLoader};
2
2
  //# sourceMappingURL=ExternalPluginContextLoader.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/external-plugin/domain/ExternalPluginContextLoader.ts"],
4
- "sourcesContent": ["import { HexaString, isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { ethers, Interface } from \"ethers\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, EitherAsync, Left, Right } from \"purify-ts\";\n\nimport type { ExternalPluginDataSource } from \"@/external-plugin/data/ExternalPluginDataSource\";\nimport { externalPluginTypes } from \"@/external-plugin/di/externalPluginTypes\";\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\";\n\n@injectable()\nexport class ExternalPluginContextLoader implements ContextLoader {\n private _externalPluginDataSource: ExternalPluginDataSource;\n private _tokenDataSource: TokenDataSource;\n\n constructor(\n @inject(externalPluginTypes.ExternalPluginDataSource)\n externalPluginDataSource: ExternalPluginDataSource,\n @inject(tokenTypes.TokenDataSource) tokenDataSource: TokenDataSource,\n ) {\n this._externalPluginDataSource = externalPluginDataSource;\n this._tokenDataSource = tokenDataSource;\n }\n\n async load(ctx: TransactionContext): Promise<ClearSignContext[]> {\n const { to, data, selector, chainId } = 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 eitherDappInfos = await this._externalPluginDataSource.getDappInfos({\n address: to,\n chainId,\n selector,\n });\n\n return EitherAsync<Error, ClearSignContext[]>(async ({ liftEither }) => {\n const dappInfos = await liftEither(eitherDappInfos);\n\n // if the dappInfos is null, return an empty array\n // this means that the selector is not a known selector\n if (!dappInfos) {\n return [];\n }\n\n const externalPluginContext: ClearSignContext = {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: dappInfos.selectorDetails.serializedData.concat(\n dappInfos.selectorDetails.signature,\n ),\n };\n\n const decodedCallData = this.getDecodedCallData(\n dappInfos.abi,\n dappInfos.selectorDetails.method,\n data,\n );\n\n // if the call data cannot be decoded, return the error\n // but also the externalPluginContext because it is still valid\n if (decodedCallData.isLeft()) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: decodedCallData.extract(),\n },\n externalPluginContext,\n ];\n }\n\n // decodedCallData is a Right so we can extract it safely\n const extractedDecodedCallData =\n decodedCallData.extract() as ethers.Result;\n\n // get the token payload for each erc20OfInterest\n // and return the payload or the error\n const promises = dappInfos.selectorDetails.erc20OfInterest.map(\n async (erc20Path) =>\n this.getTokenPayload(ctx, erc20Path, extractedDecodedCallData),\n );\n\n const tokensPayload = await Promise.all(promises);\n\n // map the payload or the error to a ClearSignContext\n const contexts: ClearSignContext[] = tokensPayload.map((eitherToken) =>\n eitherToken.caseOf<ClearSignContext>({\n Left: (error) => ({ type: ClearSignContextType.ERROR, error }),\n Right: (payload) => ({ type: ClearSignContextType.TOKEN, payload }),\n }),\n );\n\n return [...contexts, externalPluginContext];\n }).caseOf<ClearSignContext[]>({\n // parse all errors into ClearSignContext\n Left: (error) => [{ type: ClearSignContextType.ERROR, error }],\n Right: (contexts) => contexts,\n });\n }\n\n private getTokenPayload(\n ctx: TransactionContext,\n erc20Path: string,\n decodedCallData: ethers.Result,\n ) {\n const address = this.getAddressFromPath(erc20Path, decodedCallData);\n\n return EitherAsync<Error, string>(({ fromPromise }) =>\n fromPromise(\n this._tokenDataSource.getTokenInfosPayload({\n address,\n chainId: ctx.chainId,\n }),\n ),\n );\n }\n\n private getDecodedCallData(\n abi: object[],\n method: string,\n data: string,\n ): Either<Error, ethers.Result> {\n try {\n const contractInterface = new Interface(abi);\n return Right(contractInterface.decodeFunctionData(method, data));\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to parse abi\",\n ),\n );\n }\n }\n\n private getAddressFromPath(\n path: string,\n decodedCallData: ethers.Result,\n ): HexaString {\n // ethers.Result is a record string, any\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let value: any = decodedCallData;\n for (const key of path.split(\".\")) {\n // In Solidity, a struct cannot begin with a number\n // Additionally, when we use -1, it signifies the last element of the array.\n if (key === \"-1\") {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n value = value[value.length - 1];\n } else {\n // This access can throw a RangeError error in case of an invalid key\n // but is correctly caught by the liftEither above\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n value = value[key];\n }\n }\n\n if (!isHexaString(value)) {\n throw new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to get address\",\n );\n }\n\n return value;\n }\n}\n"],
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PzBvC",
6
- "names": ["isHexaString", "Interface", "inject", "injectable", "EitherAsync", "Left", "Right", "externalPluginTypes", "ClearSignContextType", "tokenTypes", "ExternalPluginContextLoader", "externalPluginDataSource", "tokenDataSource", "ctx", "to", "data", "selector", "chainId", "isHexaString", "ClearSignContextType", "eitherDappInfos", "EitherAsync", "liftEither", "dappInfos", "externalPluginContext", "decodedCallData", "extractedDecodedCallData", "promises", "erc20Path", "eitherToken", "error", "payload", "contexts", "address", "fromPromise", "abi", "method", "contractInterface", "Interface", "Right", "Left", "path", "value", "key", "__decorateClass", "injectable", "__decorateParam", "inject", "externalPluginTypes", "tokenTypes"]
4
+ "sourcesContent": ["import { HexaString, isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { ethers, Interface } from \"ethers\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, EitherAsync, Left, Right } from \"purify-ts\";\n\nimport type { ExternalPluginDataSource } from \"@/external-plugin/data/ExternalPluginDataSource\";\nimport { externalPluginTypes } from \"@/external-plugin/di/externalPluginTypes\";\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport type { TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\n\nexport type ExternalPluginContextInput = {\n to: HexaString;\n data: HexaString;\n selector: HexaString;\n chainId: number;\n};\n\nconst SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.EXTERNAL_PLUGIN,\n ClearSignContextType.TOKEN,\n];\n\n@injectable()\nexport class ExternalPluginContextLoader\n implements ContextLoader<ExternalPluginContextInput>\n{\n private _externalPluginDataSource: ExternalPluginDataSource;\n private _tokenDataSource: TokenDataSource;\n\n constructor(\n @inject(externalPluginTypes.ExternalPluginDataSource)\n externalPluginDataSource: ExternalPluginDataSource,\n @inject(tokenTypes.TokenDataSource) tokenDataSource: TokenDataSource,\n ) {\n this._externalPluginDataSource = externalPluginDataSource;\n this._tokenDataSource = tokenDataSource;\n }\n\n canHandle(\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ): input is ExternalPluginContextInput {\n return (\n typeof input === \"object\" &&\n input !== null &&\n \"to\" in input &&\n \"data\" in input &&\n \"selector\" in input &&\n \"chainId\" in input &&\n typeof input.chainId === \"number\" &&\n isHexaString(input.to) &&\n input.to !== \"0x\" &&\n isHexaString(input.data) &&\n input.data !== \"0x\" && // non empty data\n isHexaString(input.selector) &&\n input.selector !== \"0x\" &&\n SUPPORTED_TYPES.every((type) => expectedTypes.includes(type))\n );\n }\n\n async load(input: ExternalPluginContextInput): Promise<ClearSignContext[]> {\n const { to, data, selector, chainId } = input;\n\n const eitherDappInfos = await this._externalPluginDataSource.getDappInfos({\n address: to,\n chainId,\n selector,\n });\n\n return EitherAsync<Error, ClearSignContext[]>(async ({ liftEither }) => {\n const dappInfos = await liftEither(eitherDappInfos);\n\n // if the dappInfos is null, return an empty array\n // this means that the selector is not a known selector\n if (!dappInfos) {\n return [];\n }\n\n const externalPluginContext: ClearSignContext = {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: dappInfos.selectorDetails.serializedData.concat(\n dappInfos.selectorDetails.signature,\n ),\n };\n\n const decodedCallData = this.getDecodedCallData(\n dappInfos.abi,\n dappInfos.selectorDetails.method,\n data,\n );\n\n // if the call data cannot be decoded, return the error\n // but also the externalPluginContext because it is still valid\n if (decodedCallData.isLeft()) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: decodedCallData.extract(),\n },\n externalPluginContext,\n ];\n }\n\n // decodedCallData is a Right so we can extract it safely\n const extractedDecodedCallData =\n decodedCallData.extract() as ethers.Result;\n\n // get the token payload for each erc20OfInterest\n // and return the payload or the error\n const promises = dappInfos.selectorDetails.erc20OfInterest.map(\n async (erc20Path) =>\n this.getTokenPayload(input, erc20Path, extractedDecodedCallData),\n );\n\n const tokensPayload = await Promise.all(promises);\n\n // map the payload or the error to a ClearSignContext\n const contexts: ClearSignContext[] = tokensPayload.map((eitherToken) =>\n eitherToken.caseOf<ClearSignContext>({\n Left: (error) => ({ type: ClearSignContextType.ERROR, error }),\n Right: (payload) => ({ type: ClearSignContextType.TOKEN, payload }),\n }),\n );\n\n return [...contexts, externalPluginContext];\n }).caseOf<ClearSignContext[]>({\n // parse all errors into ClearSignContext\n Left: (error) => [{ type: ClearSignContextType.ERROR, error }],\n Right: (contexts) => contexts,\n });\n }\n\n private getTokenPayload(\n input: ExternalPluginContextInput,\n erc20Path: string,\n decodedCallData: ethers.Result,\n ) {\n const address = this.getAddressFromPath(erc20Path, decodedCallData);\n\n return EitherAsync<Error, string>(({ fromPromise }) =>\n fromPromise(\n this._tokenDataSource.getTokenInfosPayload({\n address,\n chainId: input.chainId,\n }),\n ),\n );\n }\n\n private getDecodedCallData(\n abi: object[],\n method: string,\n data: string,\n ): Either<Error, ethers.Result> {\n try {\n const contractInterface = new Interface(abi);\n return Right(contractInterface.decodeFunctionData(method, data));\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to parse abi\",\n ),\n );\n }\n }\n\n private getAddressFromPath(\n path: string,\n decodedCallData: ethers.Result,\n ): HexaString {\n // ethers.Result is a record string, any\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let value: any = decodedCallData;\n for (const key of path.split(\".\")) {\n // In Solidity, a struct cannot begin with a number\n // Additionally, when we use -1, it signifies the last element of the array.\n if (key === \"-1\") {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n value = value[value.length - 1];\n } else {\n // This access can throw a RangeError error in case of an invalid key\n // but is correctly caught by the liftEither above\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n value = value[key];\n }\n }\n\n if (!isHexaString(value)) {\n throw new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to get address\",\n );\n }\n\n return value;\n }\n}\n"],
5
+ "mappings": "iOAAA,OAA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CAAG,EAIrB,GAAI,CAAC7B,EAAa4B,CAAK,EACrB,MAAM,IAAI,MACR,oEACF,EAGF,OAAOA,CACT,CACF,EA5KajC,EAANmC,EAAA,CADNC,EAAW,EAQPC,EAAA,EAAAC,EAAOC,EAAoB,wBAAwB,GAEnDF,EAAA,EAAAC,EAAOE,EAAW,eAAe,IATzBxC",
6
+ "names": ["isHexaString", "Interface", "inject", "injectable", "EitherAsync", "Left", "Right", "externalPluginTypes", "ClearSignContextType", "tokenTypes", "SUPPORTED_TYPES", "ClearSignContextType", "ExternalPluginContextLoader", "externalPluginDataSource", "tokenDataSource", "input", "expectedTypes", "isHexaString", "type", "to", "data", "selector", "chainId", "eitherDappInfos", "EitherAsync", "liftEither", "dappInfos", "externalPluginContext", "decodedCallData", "extractedDecodedCallData", "promises", "erc20Path", "eitherToken", "error", "payload", "contexts", "address", "fromPromise", "abi", "method", "contractInterface", "Interface", "Right", "Left", "path", "value", "key", "__decorateClass", "injectable", "__decorateParam", "inject", "externalPluginTypes", "tokenTypes"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{Interface as m}from"ethers";import{Left as i,Right as c}from"purify-ts";import o from"@/external-plugin/__tests__/abi.json";import{ExternalPluginContextLoader as y}from"../../external-plugin/domain/ExternalPluginContextLoader";import{ClearSignContextType as t}from"../../shared/model/ClearSignContext";const p=({abi:d,selectorDetails:n})=>({abi:d,selectorDetails:{erc20OfInterest:[],method:"",plugin:"",serializedData:"123456",signature:"7890",...n}}),l=(d,n,s)=>{const a=new m(JSON.stringify(d)).encodeFunctionData(n,s);return{to:"0x0",data:a,selector:a.slice(0,10)}};describe("ExternalPluginContextLoader",()=>{const d={getTokenInfosPayload:vi.fn()},n={getDappInfos:vi.fn()},s=new y(n,d);beforeEach(()=>{vi.clearAllMocks(),vi.spyOn(d,"getTokenInfosPayload").mockImplementation(({address:e})=>Promise.resolve(c(`payload-${e}`)))}),describe("load function",async()=>{it("should return an empty array if no destination address is provided",async()=>{const e={},a=()=>s.load(e);await expect(a()).resolves.toEqual([])}),it("should return an empty array if no data provided",async()=>{const e={to:"0x0",data:"0x",selector:"0x0"},a=await s.load(e);expect(a).toEqual([])}),it("should return an empty array if no dapp info is povided",async()=>{const e=l(o,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(n,"getDappInfos").mockResolvedValue(c(void 0));const a=await s.load(e);expect(a).toEqual([])}),it("should return e plugin if no erc20OfInterest is provided",async()=>{const e=p({abi:o,selectorDetails:{erc20OfInterest:[],method:"singleParam"}}),a=l(o,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(n,"getDappInfos").mockResolvedValue(c(e));const r=await s.load(a);expect(r).toEqual([{type:t.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return a list of context responses when one erc20OfInterest is provided for a single parameter",async()=>{const e=p({abi:o,selectorDetails:{erc20OfInterest:["fromToken"],method:"singleParam"}}),a=l(o,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(n,"getDappInfos").mockResolvedValue(c(e));const r=await s.load(a);expect(r).toEqual(expect.arrayContaining([{type:t.EXTERNAL_PLUGIN,payload:"1234567890"},{type:t.TOKEN,payload:"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"}]))}),it("should return a context response with only set external plugin when one erc20OfInterest is provided for a single parameter but no payload is feched",async()=>{const e=p({abi:o,selectorDetails:{erc20OfInterest:["fromToken"],method:"singleParam"}}),a=l(o,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(n,"getDappInfos").mockResolvedValue(c(e)),vi.spyOn(d,"getTokenInfosPayload").mockResolvedValue(i(Error("error")));const r=await s.load(a);expect(r).toEqual([{type:t.ERROR,error:new Error("error")},{type:t.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return a list of context responses when two erc20OfInterest are provided for two parameters",async()=>{const e=p({abi:o,selectorDetails:{erc20OfInterest:["fromToken","toToken"],method:"multipleParams"}}),a=l(o,"multipleParams",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7"]);vi.spyOn(n,"getDappInfos").mockResolvedValue(c(e));const r=await s.load(a);expect(r).toEqual(expect.arrayContaining([{type:t.EXTERNAL_PLUGIN,payload:"1234567890"},{type:t.TOKEN,payload:"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{type:t.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"}]))}),it("should return a list of context responses when one erc20OfInterest is an array",async()=>{const e=p({abi:o,selectorDetails:{erc20OfInterest:["fromToken.0","fromToken.1","fromToken.2","fromToken.-1"],method:"arrayParam"}}),a=l(o,"arrayParam",[["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7","0xB8c77482e45F1F44dE1745F52C74426C631bDD52"]]);vi.spyOn(n,"getDappInfos").mockResolvedValue(c(e));const r=await s.load(a);expect(r).toEqual([{type:t.TOKEN,payload:"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{type:t.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"},{type:t.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"},{type:t.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"},{type:t.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return an error when a token datasource returns an error",async()=>{const e=p({abi:o,selectorDetails:{erc20OfInterest:["fromToken"],method:"singleParam"}}),a=l(o,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(n,"getDappInfos").mockResolvedValue(c(e)),vi.spyOn(d,"getTokenInfosPayload").mockResolvedValue(i(new Error("error")));const r=await s.load(a);expect(r).toEqual([{type:t.ERROR,error:new Error("error")},{type:t.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return an error when the abi is not conform",async()=>{const e=p({abi:[{fakeabi:"notworking"}],selectorDetails:{erc20OfInterest:["fromToken"],method:"singleParam"}}),a=l(o,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(n,"getDappInfos").mockResolvedValue(c(e));const r=await s.load(a);expect(r).toEqual([{type:t.ERROR,error:new Error("[ContextModule] ExternalPluginContextLoader: Unable to parse abi")},{type:t.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should throw an error when the erc20OfInterest doest not exist in the transaction",async()=>{const e=p({abi:o,selectorDetails:{erc20OfInterest:["notFound"],method:"singleParam"}}),a=l(o,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(n,"getDappInfos").mockResolvedValue(c(e));const r=await s.load(a);expect(r).toEqual([{type:t.ERROR,error:new Error("[ContextModule] ExternalPluginContextLoader: Unable to get address")}])}),it("should throw an error when an out-of-bounds element is present in erc20OfInterest",async()=>{const e=p({abi:o,selectorDetails:{erc20OfInterest:["fromToken.3"],method:"arrayParam"}}),a=l(o,"arrayParam",[["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7","0xB8c77482e45F1F44dE1745F52C74426C631bDD52"]]);vi.spyOn(n,"getDappInfos").mockResolvedValue(c(e));const r=await s.load(a);expect(r).toEqual([{type:t.ERROR,error:new RangeError("out of result range")}])}),it("should return a list of context responses when one erc20OfInterest is a complex struct",async()=>{const e=p({abi:o,selectorDetails:{erc20OfInterest:["complexStruct.address1","complexStruct.param1.param2.0.param3.addresses.0","complexStruct.param1.param2.0.param3.addresses.1","complexStruct.param1.param2.0.param3.addresses.-1","complexStruct.param1.param2.1.param3.addresses.0","complexStruct.param1.param2.-1.param3.addresses.0"],method:"complexStructParam"}}),a=l(o,"complexStructParam",[{address1:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",param1:{param2:[{param3:{addresses:["0xdAC17F958D2ee523a2206206994597C13D831ec7","0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE"]}},{param3:{addresses:["0xB8c77482e45F1F44dE1745F52C74426C631bDD52"]}}]}}]);vi.spyOn(n,"getDappInfos").mockResolvedValue(c(e));const r=await s.load(a);expect(r).toEqual([{type:t.TOKEN,payload:"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{type:t.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"},{type:t.TOKEN,payload:"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE"},{type:t.TOKEN,payload:"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE"},{type:t.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"},{type:t.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"},{type:t.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return an error when datasource return a Left",async()=>{const e=l(o,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(n,"getDappInfos").mockResolvedValue(i(new Error("error")));const a=await s.load(e);expect(a).toEqual([{type:t.ERROR,error:new Error("error")}])}),it("should return an error when transaction data is not a valid hex string",async()=>{const e={to:"0x0",data:"notAHexString"},a=await s.load(e);expect(a).toEqual([{type:t.ERROR,error:new Error("Invalid selector")}])})})});
1
+ import{Interface as u}from"ethers";import{Left as i,Right as c}from"purify-ts";import r from"@/external-plugin/__tests__/abi.json";import{ExternalPluginContextLoader as E}from"../../external-plugin/domain/ExternalPluginContextLoader";import{ClearSignContextType as a}from"../../shared/model/ClearSignContext";const d=({abi:p,selectorDetails:s})=>({abi:p,selectorDetails:{erc20OfInterest:[],method:"",plugin:"",serializedData:"123456",signature:"7890",...s}}),l=(p,s,n)=>{const t=new u(JSON.stringify(p)).encodeFunctionData(s,n);return{to:"0x0",data:t,selector:t.slice(0,10),chainId:1}};describe("ExternalPluginContextLoader",()=>{const p={getTokenInfosPayload:vi.fn()},s={getDappInfos:vi.fn()},n=new E(s,p);beforeEach(()=>{vi.clearAllMocks(),vi.spyOn(p,"getTokenInfosPayload").mockImplementation(({address:e})=>Promise.resolve(c(`payload-${e}`)))}),describe("canHandle function",()=>{const e={to:"0x1234567890123456789012345678901234567890",data:"0x095ea7b30000000000000000000000001234567890123456789012345678901234567890",selector:"0x095ea7b3",chainId:1};it("should return true for valid input",()=>{expect(n.canHandle(e,[a.EXTERNAL_PLUGIN,a.TOKEN])).toBe(!0)}),it("should return false for invalid expected type",()=>{expect(n.canHandle(e,[a.NFT])).toBe(!1),expect(n.canHandle(e,[a.TOKEN])).toBe(!1),expect(n.canHandle(e,[a.EXTERNAL_PLUGIN])).toBe(!1)}),it.each([[null,"null input"],[void 0,"undefined input"],[{},"empty object"],["string","string input"],[123,"number input"]])("should return false for %s",(t,o)=>{expect(n.canHandle(t,[a.EXTERNAL_PLUGIN,a.TOKEN])).toBe(!1)}),it.each([[{...e,to:void 0},"missing to"],[{...e,data:void 0},"missing data"],[{...e,selector:void 0},"missing selector"],[{...e,chainId:void 0},"missing chainId"]])("should return false for %s",(t,o)=>{expect(n.canHandle(t,[a.EXTERNAL_PLUGIN,a.TOKEN])).toBe(!1)}),it.each([[{...e,to:"invalid-hex"},"invalid to hex"],[{...e,to:"0x"},"empty to hex"],[{...e,data:"invalid-hex"},"invalid data hex"],[{...e,data:"0x"},"empty data (0x)"],[{...e,selector:"invalid-hex"},"invalid selector hex"],[{...e,selector:"0x"},"empty selector hex"]])("should return false for %s",(t,o)=>{expect(n.canHandle(t,[a.EXTERNAL_PLUGIN,a.TOKEN])).toBe(!1)}),it.each([[{...e,chainId:"1"},"string chainId"],[{...e,chainId:null},"null chainId"],[{...e,chainId:void 0},"undefined chainId"]])("should return false for %s",(t,o)=>{expect(n.canHandle(t,[a.EXTERNAL_PLUGIN,a.TOKEN])).toBe(!1)})}),describe("load function",()=>{it("should return an empty array if no dapp info is provided",async()=>{const e=l(r,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(c(void 0));const t=await n.load(e);expect(t).toEqual([])}),it("should return e plugin if no erc20OfInterest is provided",async()=>{const e=d({abi:r,selectorDetails:{erc20OfInterest:[],method:"singleParam"}}),t=l(r,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(c(e));const o=await n.load(t);expect(o).toEqual([{type:a.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return a list of context responses when one erc20OfInterest is provided for a single parameter",async()=>{const e=d({abi:r,selectorDetails:{erc20OfInterest:["fromToken"],method:"singleParam"}}),t=l(r,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(c(e));const o=await n.load(t);expect(o).toEqual(expect.arrayContaining([{type:a.EXTERNAL_PLUGIN,payload:"1234567890"},{type:a.TOKEN,payload:"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"}]))}),it("should return a context response with only set external plugin when one erc20OfInterest is provided for a single parameter but no payload is feched",async()=>{const e=d({abi:r,selectorDetails:{erc20OfInterest:["fromToken"],method:"singleParam"}}),t=l(r,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(c(e)),vi.spyOn(p,"getTokenInfosPayload").mockResolvedValue(i(Error("error")));const o=await n.load(t);expect(o).toEqual([{type:a.ERROR,error:new Error("error")},{type:a.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return a list of context responses when two erc20OfInterest are provided for two parameters",async()=>{const e=d({abi:r,selectorDetails:{erc20OfInterest:["fromToken","toToken"],method:"multipleParams"}}),t=l(r,"multipleParams",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(c(e));const o=await n.load(t);expect(o).toEqual(expect.arrayContaining([{type:a.EXTERNAL_PLUGIN,payload:"1234567890"},{type:a.TOKEN,payload:"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{type:a.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"}]))}),it("should return a list of context responses when one erc20OfInterest is an array",async()=>{const e=d({abi:r,selectorDetails:{erc20OfInterest:["fromToken.0","fromToken.1","fromToken.2","fromToken.-1"],method:"arrayParam"}}),t=l(r,"arrayParam",[["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7","0xB8c77482e45F1F44dE1745F52C74426C631bDD52"]]);vi.spyOn(s,"getDappInfos").mockResolvedValue(c(e));const o=await n.load(t);expect(o).toEqual([{type:a.TOKEN,payload:"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{type:a.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"},{type:a.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"},{type:a.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"},{type:a.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return an error when a token datasource returns an error",async()=>{const e=d({abi:r,selectorDetails:{erc20OfInterest:["fromToken"],method:"singleParam"}}),t=l(r,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(c(e)),vi.spyOn(p,"getTokenInfosPayload").mockResolvedValue(i(new Error("error")));const o=await n.load(t);expect(o).toEqual([{type:a.ERROR,error:new Error("error")},{type:a.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return an error when the abi is not conform",async()=>{const e=d({abi:[{fakeabi:"notworking"}],selectorDetails:{erc20OfInterest:["fromToken"],method:"singleParam"}}),t=l(r,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(c(e));const o=await n.load(t);expect(o).toEqual([{type:a.ERROR,error:new Error("[ContextModule] ExternalPluginContextLoader: Unable to parse abi")},{type:a.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should throw an error when the erc20OfInterest doest not exist in the transaction",async()=>{const e=d({abi:r,selectorDetails:{erc20OfInterest:["notFound"],method:"singleParam"}}),t=l(r,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(c(e));const o=await n.load(t);expect(o).toEqual([{type:a.ERROR,error:new Error("[ContextModule] ExternalPluginContextLoader: Unable to get address")}])}),it("should throw an error when an out-of-bounds element is present in erc20OfInterest",async()=>{const e=d({abi:r,selectorDetails:{erc20OfInterest:["fromToken.3"],method:"arrayParam"}}),t=l(r,"arrayParam",[["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7","0xB8c77482e45F1F44dE1745F52C74426C631bDD52"]]);vi.spyOn(s,"getDappInfos").mockResolvedValue(c(e));const o=await n.load(t);expect(o).toEqual([{type:a.ERROR,error:new RangeError("out of result range")}])}),it("should return a list of context responses when one erc20OfInterest is a complex struct",async()=>{const e=d({abi:r,selectorDetails:{erc20OfInterest:["complexStruct.address1","complexStruct.param1.param2.0.param3.addresses.0","complexStruct.param1.param2.0.param3.addresses.1","complexStruct.param1.param2.0.param3.addresses.-1","complexStruct.param1.param2.1.param3.addresses.0","complexStruct.param1.param2.-1.param3.addresses.0"],method:"complexStructParam"}}),t=l(r,"complexStructParam",[{address1:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",param1:{param2:[{param3:{addresses:["0xdAC17F958D2ee523a2206206994597C13D831ec7","0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE"]}},{param3:{addresses:["0xB8c77482e45F1F44dE1745F52C74426C631bDD52"]}}]}}]);vi.spyOn(s,"getDappInfos").mockResolvedValue(c(e));const o=await n.load(t);expect(o).toEqual([{type:a.TOKEN,payload:"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{type:a.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"},{type:a.TOKEN,payload:"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE"},{type:a.TOKEN,payload:"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE"},{type:a.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"},{type:a.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"},{type:a.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return an error when datasource return a Left",async()=>{const e=l(r,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(i(new Error("error")));const t=await n.load(e);expect(t).toEqual([{type:a.ERROR,error:new Error("error")}])})})});
2
2
  //# sourceMappingURL=ExternalPluginContextLoader.test.js.map