@ledgerhq/context-module 0.0.0-signer-eth-plugin-fix-20250331141239 → 0.0.0-transactionInspector-resolutionObj-20250916071327

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 (414) hide show
  1. package/README.md +17 -5
  2. package/lib/cjs/package.json +12 -12
  3. package/lib/cjs/src/ContextModule.js +1 -1
  4. package/lib/cjs/src/ContextModule.js.map +1 -1
  5. package/lib/cjs/src/ContextModuleBuilder.js +1 -1
  6. package/lib/cjs/src/ContextModuleBuilder.js.map +3 -3
  7. package/lib/cjs/src/ContextModuleBuilder.test.js +1 -1
  8. package/lib/cjs/src/ContextModuleBuilder.test.js.map +3 -3
  9. package/lib/cjs/src/DefaultContextModule.js +1 -1
  10. package/lib/cjs/src/DefaultContextModule.js.map +3 -3
  11. package/lib/cjs/src/DefaultContextModule.test.js +1 -1
  12. package/lib/cjs/src/DefaultContextModule.test.js.map +2 -2
  13. package/lib/cjs/src/config/di/configModuleFactory.js +1 -1
  14. package/lib/cjs/src/config/di/configModuleFactory.js.map +3 -3
  15. package/lib/cjs/src/config/di/configTypes.js +1 -1
  16. package/lib/cjs/src/config/di/configTypes.js.map +2 -2
  17. package/lib/cjs/src/config/model/ContextModuleBuildArgs.js +2 -0
  18. package/lib/cjs/src/config/model/ContextModuleBuildArgs.js.map +7 -0
  19. package/lib/cjs/src/config/model/ContextModuleConfig.js +1 -1
  20. package/lib/cjs/src/config/model/ContextModuleConfig.js.map +1 -1
  21. package/lib/cjs/src/di.js +1 -1
  22. package/lib/cjs/src/di.js.map +3 -3
  23. package/lib/cjs/src/dynamic-network/data/DynamicNetworkDataSource.js +2 -0
  24. package/lib/cjs/src/dynamic-network/data/DynamicNetworkDataSource.js.map +7 -0
  25. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.js +2 -0
  26. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.js.map +7 -0
  27. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js +2 -0
  28. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js.map +7 -0
  29. package/lib/cjs/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.js +2 -0
  30. package/lib/cjs/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.js.map +7 -0
  31. package/lib/cjs/src/dynamic-network/di/dynamicNetworkModuleFactory.js +2 -0
  32. package/lib/cjs/src/dynamic-network/di/dynamicNetworkModuleFactory.js.map +7 -0
  33. package/lib/cjs/src/dynamic-network/di/dynamicNetworkTypes.js +2 -0
  34. package/lib/cjs/src/dynamic-network/di/dynamicNetworkTypes.js.map +7 -0
  35. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.js +2 -0
  36. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +7 -0
  37. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js +2 -0
  38. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +7 -0
  39. package/lib/cjs/src/dynamic-network/model/DynamicNetworkConfiguration.js +2 -0
  40. package/lib/cjs/src/dynamic-network/model/DynamicNetworkConfiguration.js.map +7 -0
  41. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js +1 -1
  42. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js.map +3 -3
  43. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js +1 -1
  44. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +3 -3
  45. package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js +1 -1
  46. package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js.map +3 -3
  47. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js +1 -1
  48. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js.map +3 -3
  49. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
  50. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +3 -3
  51. package/lib/cjs/src/index.js +1 -1
  52. package/lib/cjs/src/index.js.map +2 -2
  53. package/lib/cjs/src/nft/data/HttpNftDataSource.js +1 -1
  54. package/lib/cjs/src/nft/data/HttpNftDataSource.js.map +3 -3
  55. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js +1 -1
  56. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js.map +3 -3
  57. package/lib/cjs/src/nft/di/nftModuleFactory.js +1 -1
  58. package/lib/cjs/src/nft/di/nftModuleFactory.js.map +3 -3
  59. package/lib/cjs/src/nft/domain/NftContextLoader.js +1 -1
  60. package/lib/cjs/src/nft/domain/NftContextLoader.js.map +3 -3
  61. package/lib/cjs/src/nft/domain/NftContextLoader.test.js +1 -1
  62. package/lib/cjs/src/nft/domain/NftContextLoader.test.js.map +2 -2
  63. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.js +1 -1
  64. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.js.map +3 -3
  65. package/lib/cjs/src/pki/di/pkiModuleFactory.js +1 -1
  66. package/lib/cjs/src/pki/di/pkiModuleFactory.js.map +3 -3
  67. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.js.map +2 -2
  68. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js +1 -1
  69. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +3 -3
  70. package/lib/cjs/src/shared/constant/HttpHeaders.js +2 -0
  71. package/lib/cjs/src/shared/constant/HttpHeaders.js.map +7 -0
  72. package/lib/cjs/src/shared/model/ClearSignContext.js +1 -1
  73. package/lib/cjs/src/shared/model/ClearSignContext.js.map +2 -2
  74. package/lib/cjs/src/shared/model/SolanaTransactionContext.js +2 -0
  75. package/lib/cjs/src/shared/model/SolanaTransactionContext.js.map +7 -0
  76. package/lib/cjs/src/shared/model/TransactionSubset.js +1 -1
  77. package/lib/cjs/src/shared/model/TransactionSubset.js.map +1 -1
  78. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js +2 -0
  79. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +7 -0
  80. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +2 -0
  81. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +7 -0
  82. package/lib/cjs/src/solana/data/SolanaDataSource.js +2 -0
  83. package/lib/cjs/src/solana/data/SolanaDataSource.js.map +7 -0
  84. package/lib/cjs/src/solana/di/SolanaContextModuleFactory.js +2 -0
  85. package/lib/cjs/src/solana/di/SolanaContextModuleFactory.js.map +7 -0
  86. package/lib/cjs/src/solana/di/solanaContextTypes.js +2 -0
  87. package/lib/cjs/src/solana/di/solanaContextTypes.js.map +7 -0
  88. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.js +2 -0
  89. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.js.map +7 -0
  90. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.test.js +2 -0
  91. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.test.js.map +7 -0
  92. package/lib/cjs/src/solana/domain/SolanaContextLoader.js +2 -0
  93. package/lib/cjs/src/solana/domain/SolanaContextLoader.js.map +7 -0
  94. package/lib/cjs/src/solana/domain/solanaContextTypes.js +2 -0
  95. package/lib/cjs/src/solana/domain/solanaContextTypes.js.map +7 -0
  96. package/lib/cjs/src/token/data/HttpTokenDataSource.js +1 -1
  97. package/lib/cjs/src/token/data/HttpTokenDataSource.js.map +3 -3
  98. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js +1 -1
  99. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js.map +3 -3
  100. package/lib/cjs/src/token/di/tokenModuleFactory.js +1 -1
  101. package/lib/cjs/src/token/di/tokenModuleFactory.js.map +3 -3
  102. package/lib/cjs/src/token/domain/TokenContextLoader.js +1 -1
  103. package/lib/cjs/src/token/domain/TokenContextLoader.js.map +3 -3
  104. package/lib/cjs/src/token/domain/TokenContextLoader.test.js +1 -1
  105. package/lib/cjs/src/token/domain/TokenContextLoader.test.js.map +2 -2
  106. package/lib/cjs/src/transaction/data/HttpProxyDataSource.js +2 -0
  107. package/lib/cjs/src/transaction/data/HttpProxyDataSource.js.map +7 -0
  108. package/lib/cjs/src/transaction/data/HttpProxyDataSource.test.js +2 -0
  109. package/lib/cjs/src/transaction/data/HttpProxyDataSource.test.js.map +7 -0
  110. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js +1 -1
  111. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js.map +3 -3
  112. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js +1 -1
  113. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js.map +3 -3
  114. package/lib/cjs/src/transaction/data/{CalldataDto.js.map → dto/CalldataDto.js.map} +1 -1
  115. package/lib/cjs/src/transaction/data/dto/ProxyDelegateCallDto.js +2 -0
  116. package/lib/cjs/src/transaction/data/dto/ProxyDelegateCallDto.js.map +7 -0
  117. package/lib/cjs/src/transaction/data/dto/ProxyImplementationAddressDto.js +2 -0
  118. package/lib/cjs/src/transaction/data/dto/ProxyImplementationAddressDto.js.map +7 -0
  119. package/lib/cjs/src/transaction/di/transactionModuleFactory.js +1 -1
  120. package/lib/cjs/src/transaction/di/transactionModuleFactory.js.map +3 -3
  121. package/lib/cjs/src/transaction/di/transactionTypes.js +1 -1
  122. package/lib/cjs/src/transaction/di/transactionTypes.js.map +2 -2
  123. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js +1 -1
  124. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js.map +3 -3
  125. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js +1 -1
  126. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js.map +3 -3
  127. package/lib/cjs/src/transaction/model/ProxyDelegateCall.js +2 -0
  128. package/lib/cjs/src/transaction/model/ProxyDelegateCall.js.map +7 -0
  129. package/lib/cjs/src/transaction/model/ProxyImplementationAddress.js +2 -0
  130. package/lib/cjs/src/transaction/model/ProxyImplementationAddress.js.map +7 -0
  131. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
  132. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js.map +3 -3
  133. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  134. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +3 -3
  135. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js +1 -1
  136. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js.map +3 -3
  137. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
  138. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js.map +3 -3
  139. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
  140. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +2 -2
  141. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
  142. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js.map +3 -3
  143. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  144. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
  145. package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js +1 -1
  146. package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js.map +3 -3
  147. package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js +1 -1
  148. package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js.map +3 -3
  149. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js +1 -1
  150. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js.map +3 -3
  151. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
  152. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js.map +2 -2
  153. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.js +1 -1
  154. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.js.map +3 -3
  155. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.test.js +1 -1
  156. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.test.js.map +3 -3
  157. package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js +1 -1
  158. package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js.map +3 -3
  159. package/lib/esm/package.json +12 -12
  160. package/lib/esm/src/ContextModuleBuilder.js +1 -1
  161. package/lib/esm/src/ContextModuleBuilder.js.map +3 -3
  162. package/lib/esm/src/ContextModuleBuilder.test.js +1 -1
  163. package/lib/esm/src/ContextModuleBuilder.test.js.map +3 -3
  164. package/lib/esm/src/DefaultContextModule.js +1 -1
  165. package/lib/esm/src/DefaultContextModule.js.map +3 -3
  166. package/lib/esm/src/DefaultContextModule.test.js +1 -1
  167. package/lib/esm/src/DefaultContextModule.test.js.map +2 -2
  168. package/lib/esm/src/config/di/configModuleFactory.js +1 -1
  169. package/lib/esm/src/config/di/configModuleFactory.js.map +3 -3
  170. package/lib/esm/src/config/di/configTypes.js +1 -1
  171. package/lib/esm/src/config/di/configTypes.js.map +2 -2
  172. package/lib/esm/src/config/model/ContextModuleBuildArgs.js +1 -0
  173. package/lib/esm/src/di.js +1 -1
  174. package/lib/esm/src/di.js.map +3 -3
  175. package/lib/esm/src/dynamic-network/data/DynamicNetworkDataSource.js +1 -0
  176. package/lib/esm/src/dynamic-network/data/DynamicNetworkDataSource.js.map +7 -0
  177. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.js +2 -0
  178. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.js.map +7 -0
  179. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js +2 -0
  180. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js.map +7 -0
  181. package/lib/esm/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.js +1 -0
  182. package/lib/esm/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.js.map +7 -0
  183. package/lib/esm/src/dynamic-network/di/dynamicNetworkModuleFactory.js +2 -0
  184. package/lib/esm/src/dynamic-network/di/dynamicNetworkModuleFactory.js.map +7 -0
  185. package/lib/esm/src/dynamic-network/di/dynamicNetworkTypes.js +2 -0
  186. package/lib/esm/src/dynamic-network/di/dynamicNetworkTypes.js.map +7 -0
  187. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js +2 -0
  188. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +7 -0
  189. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js +2 -0
  190. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +7 -0
  191. package/lib/esm/src/dynamic-network/model/DynamicNetworkConfiguration.js +1 -0
  192. package/lib/esm/src/dynamic-network/model/DynamicNetworkConfiguration.js.map +7 -0
  193. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js +1 -1
  194. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js.map +3 -3
  195. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js +1 -1
  196. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +3 -3
  197. package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js +1 -1
  198. package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js.map +3 -3
  199. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js +1 -1
  200. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js.map +3 -3
  201. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
  202. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +3 -3
  203. package/lib/esm/src/index.js +1 -1
  204. package/lib/esm/src/index.js.map +2 -2
  205. package/lib/esm/src/nft/data/HttpNftDataSource.js +1 -1
  206. package/lib/esm/src/nft/data/HttpNftDataSource.js.map +3 -3
  207. package/lib/esm/src/nft/data/HttpNftDataSource.test.js +1 -1
  208. package/lib/esm/src/nft/data/HttpNftDataSource.test.js.map +3 -3
  209. package/lib/esm/src/nft/di/nftModuleFactory.js +1 -1
  210. package/lib/esm/src/nft/di/nftModuleFactory.js.map +3 -3
  211. package/lib/esm/src/nft/domain/NftContextLoader.js +1 -1
  212. package/lib/esm/src/nft/domain/NftContextLoader.js.map +3 -3
  213. package/lib/esm/src/nft/domain/NftContextLoader.test.js +1 -1
  214. package/lib/esm/src/nft/domain/NftContextLoader.test.js.map +2 -2
  215. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.js +1 -1
  216. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.js.map +3 -3
  217. package/lib/esm/src/pki/di/pkiModuleFactory.js +1 -1
  218. package/lib/esm/src/pki/di/pkiModuleFactory.js.map +3 -3
  219. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.js.map +2 -2
  220. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js +1 -1
  221. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +3 -3
  222. package/lib/esm/src/shared/constant/HttpHeaders.js +2 -0
  223. package/lib/esm/src/shared/constant/HttpHeaders.js.map +7 -0
  224. package/lib/esm/src/shared/model/ClearSignContext.js +1 -1
  225. package/lib/esm/src/shared/model/ClearSignContext.js.map +2 -2
  226. package/lib/esm/src/shared/model/SolanaTransactionContext.js +1 -0
  227. package/lib/esm/src/shared/model/SolanaTransactionContext.js.map +7 -0
  228. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js +2 -0
  229. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +7 -0
  230. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +2 -0
  231. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +7 -0
  232. package/lib/esm/src/solana/data/SolanaDataSource.js +1 -0
  233. package/lib/esm/src/solana/data/SolanaDataSource.js.map +7 -0
  234. package/lib/esm/src/solana/di/SolanaContextModuleFactory.js +2 -0
  235. package/lib/esm/src/solana/di/SolanaContextModuleFactory.js.map +7 -0
  236. package/lib/esm/src/solana/di/solanaContextTypes.js +2 -0
  237. package/lib/esm/src/solana/di/solanaContextTypes.js.map +7 -0
  238. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.js +2 -0
  239. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.js.map +7 -0
  240. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.test.js +2 -0
  241. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.test.js.map +7 -0
  242. package/lib/esm/src/solana/domain/SolanaContextLoader.js +1 -0
  243. package/lib/esm/src/solana/domain/SolanaContextLoader.js.map +7 -0
  244. package/lib/esm/src/solana/domain/solanaContextTypes.js +1 -0
  245. package/lib/esm/src/solana/domain/solanaContextTypes.js.map +7 -0
  246. package/lib/esm/src/token/data/HttpTokenDataSource.js +1 -1
  247. package/lib/esm/src/token/data/HttpTokenDataSource.js.map +3 -3
  248. package/lib/esm/src/token/data/HttpTokenDataSource.test.js +1 -1
  249. package/lib/esm/src/token/data/HttpTokenDataSource.test.js.map +3 -3
  250. package/lib/esm/src/token/di/tokenModuleFactory.js +1 -1
  251. package/lib/esm/src/token/di/tokenModuleFactory.js.map +3 -3
  252. package/lib/esm/src/token/domain/TokenContextLoader.js +1 -1
  253. package/lib/esm/src/token/domain/TokenContextLoader.js.map +3 -3
  254. package/lib/esm/src/token/domain/TokenContextLoader.test.js +1 -1
  255. package/lib/esm/src/token/domain/TokenContextLoader.test.js.map +2 -2
  256. package/lib/esm/src/transaction/data/HttpProxyDataSource.js +2 -0
  257. package/lib/esm/src/transaction/data/HttpProxyDataSource.js.map +7 -0
  258. package/lib/esm/src/transaction/data/HttpProxyDataSource.test.js +2 -0
  259. package/lib/esm/src/transaction/data/HttpProxyDataSource.test.js.map +7 -0
  260. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js +1 -1
  261. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js.map +3 -3
  262. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js +1 -1
  263. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js.map +3 -3
  264. package/lib/esm/src/transaction/data/dto/CalldataDto.js.map +7 -0
  265. package/lib/esm/src/transaction/data/dto/ProxyDelegateCallDto.js +1 -0
  266. package/lib/esm/src/transaction/data/dto/ProxyDelegateCallDto.js.map +7 -0
  267. package/lib/esm/src/transaction/data/dto/ProxyImplementationAddressDto.js +1 -0
  268. package/lib/esm/src/transaction/data/dto/ProxyImplementationAddressDto.js.map +7 -0
  269. package/lib/esm/src/transaction/di/transactionModuleFactory.js +1 -1
  270. package/lib/esm/src/transaction/di/transactionModuleFactory.js.map +3 -3
  271. package/lib/esm/src/transaction/di/transactionTypes.js +1 -1
  272. package/lib/esm/src/transaction/di/transactionTypes.js.map +2 -2
  273. package/lib/esm/src/transaction/domain/TransactionContextLoader.js +1 -1
  274. package/lib/esm/src/transaction/domain/TransactionContextLoader.js.map +3 -3
  275. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js +1 -1
  276. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js.map +3 -3
  277. package/lib/esm/src/transaction/model/ProxyDelegateCall.js +1 -0
  278. package/lib/esm/src/transaction/model/ProxyDelegateCall.js.map +7 -0
  279. package/lib/esm/src/transaction/model/ProxyImplementationAddress.js +1 -0
  280. package/lib/esm/src/transaction/model/ProxyImplementationAddress.js.map +7 -0
  281. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
  282. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js.map +3 -3
  283. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  284. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +3 -3
  285. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js +1 -1
  286. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js.map +3 -3
  287. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
  288. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js.map +3 -3
  289. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
  290. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +2 -2
  291. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
  292. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js.map +3 -3
  293. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  294. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
  295. package/lib/esm/src/typed-data/di/typedDataModuleFactory.js +1 -1
  296. package/lib/esm/src/typed-data/di/typedDataModuleFactory.js.map +3 -3
  297. package/lib/esm/src/uniswap/di/uniswapModuleFactory.js +1 -1
  298. package/lib/esm/src/uniswap/di/uniswapModuleFactory.js.map +3 -3
  299. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js +1 -1
  300. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js.map +3 -3
  301. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
  302. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js.map +2 -2
  303. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.js +1 -1
  304. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.js.map +3 -3
  305. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.test.js +1 -1
  306. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.test.js.map +3 -3
  307. package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js +1 -1
  308. package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js.map +3 -3
  309. package/lib/types/src/ContextModule.d.ts +3 -0
  310. package/lib/types/src/ContextModule.d.ts.map +1 -1
  311. package/lib/types/src/ContextModuleBuilder.d.ts +22 -4
  312. package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -1
  313. package/lib/types/src/DefaultContextModule.d.ts +5 -0
  314. package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
  315. package/lib/types/src/config/di/configModuleFactory.d.ts.map +1 -1
  316. package/lib/types/src/config/di/configTypes.d.ts +1 -0
  317. package/lib/types/src/config/di/configTypes.d.ts.map +1 -1
  318. package/lib/types/src/config/model/ContextModuleBuildArgs.d.ts +4 -0
  319. package/lib/types/src/config/model/ContextModuleBuildArgs.d.ts.map +1 -0
  320. package/lib/types/src/config/model/ContextModuleConfig.d.ts +7 -0
  321. package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -1
  322. package/lib/types/src/di.d.ts.map +1 -1
  323. package/lib/types/src/dynamic-network/data/DynamicNetworkDataSource.d.ts +6 -0
  324. package/lib/types/src/dynamic-network/data/DynamicNetworkDataSource.d.ts.map +1 -0
  325. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.d.ts +13 -0
  326. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.d.ts.map +1 -0
  327. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.d.ts +2 -0
  328. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.d.ts.map +1 -0
  329. package/lib/types/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.d.ts +14 -0
  330. package/lib/types/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.d.ts.map +1 -0
  331. package/lib/types/src/dynamic-network/di/dynamicNetworkModuleFactory.d.ts +3 -0
  332. package/lib/types/src/dynamic-network/di/dynamicNetworkModuleFactory.d.ts.map +1 -0
  333. package/lib/types/src/dynamic-network/di/dynamicNetworkTypes.d.ts +5 -0
  334. package/lib/types/src/dynamic-network/di/dynamicNetworkTypes.d.ts.map +1 -0
  335. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts +15 -0
  336. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts.map +1 -0
  337. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.test.d.ts +2 -0
  338. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.test.d.ts.map +1 -0
  339. package/lib/types/src/dynamic-network/model/DynamicNetworkConfiguration.d.ts +16 -0
  340. package/lib/types/src/dynamic-network/model/DynamicNetworkConfiguration.d.ts.map +1 -0
  341. package/lib/types/src/external-plugin/data/HttpExternalPluginDataSource.d.ts.map +1 -1
  342. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.d.ts +1 -1
  343. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.d.ts.map +1 -1
  344. package/lib/types/src/index.d.ts +2 -0
  345. package/lib/types/src/index.d.ts.map +1 -1
  346. package/lib/types/src/nft/data/HttpNftDataSource.d.ts +3 -0
  347. package/lib/types/src/nft/data/HttpNftDataSource.d.ts.map +1 -1
  348. package/lib/types/src/nft/domain/NftContextLoader.d.ts +1 -1
  349. package/lib/types/src/nft/domain/NftContextLoader.d.ts.map +1 -1
  350. package/lib/types/src/pki/data/HttpPkiCertificateDataSource.d.ts.map +1 -1
  351. package/lib/types/src/pki/domain/DefaultPkiCertificateLoader.d.ts.map +1 -1
  352. package/lib/types/src/shared/constant/HttpHeaders.d.ts +3 -0
  353. package/lib/types/src/shared/constant/HttpHeaders.d.ts.map +1 -0
  354. package/lib/types/src/shared/model/ClearSignContext.d.ts +3 -0
  355. package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -1
  356. package/lib/types/src/shared/model/SolanaTransactionContext.d.ts +11 -0
  357. package/lib/types/src/shared/model/SolanaTransactionContext.d.ts.map +1 -0
  358. package/lib/types/src/shared/model/TransactionSubset.d.ts +3 -3
  359. package/lib/types/src/shared/model/TransactionSubset.d.ts.map +1 -1
  360. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.d.ts +13 -0
  361. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.d.ts.map +1 -0
  362. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.test.d.ts +2 -0
  363. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.test.d.ts.map +1 -0
  364. package/lib/types/src/solana/data/SolanaDataSource.d.ts +12 -0
  365. package/lib/types/src/solana/data/SolanaDataSource.d.ts.map +1 -0
  366. package/lib/types/src/solana/di/SolanaContextModuleFactory.d.ts +3 -0
  367. package/lib/types/src/solana/di/SolanaContextModuleFactory.d.ts.map +1 -0
  368. package/lib/types/src/solana/di/solanaContextTypes.d.ts +5 -0
  369. package/lib/types/src/solana/di/solanaContextTypes.d.ts.map +1 -0
  370. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.d.ts +11 -0
  371. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.d.ts.map +1 -0
  372. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.test.d.ts +2 -0
  373. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.test.d.ts.map +1 -0
  374. package/lib/types/src/solana/domain/SolanaContextLoader.d.ts +5 -0
  375. package/lib/types/src/solana/domain/SolanaContextLoader.d.ts.map +1 -0
  376. package/lib/types/src/solana/domain/solanaContextTypes.d.ts +27 -0
  377. package/lib/types/src/solana/domain/solanaContextTypes.d.ts.map +1 -0
  378. package/lib/types/src/token/data/HttpTokenDataSource.d.ts.map +1 -1
  379. package/lib/types/src/token/domain/TokenContextLoader.d.ts +1 -1
  380. package/lib/types/src/token/domain/TokenContextLoader.d.ts.map +1 -1
  381. package/lib/types/src/transaction/data/HttpProxyDataSource.d.ts +33 -0
  382. package/lib/types/src/transaction/data/HttpProxyDataSource.d.ts.map +1 -0
  383. package/lib/types/src/transaction/data/HttpProxyDataSource.test.d.ts +2 -0
  384. package/lib/types/src/transaction/data/HttpProxyDataSource.test.d.ts.map +1 -0
  385. package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts.map +1 -1
  386. package/lib/types/src/transaction/data/dto/CalldataDto.d.ts.map +1 -0
  387. package/lib/types/src/transaction/data/dto/ProxyDelegateCallDto.d.ts +5 -0
  388. package/lib/types/src/transaction/data/dto/ProxyDelegateCallDto.d.ts.map +1 -0
  389. package/lib/types/src/transaction/data/dto/ProxyImplementationAddressDto.d.ts +6 -0
  390. package/lib/types/src/transaction/data/dto/ProxyImplementationAddressDto.d.ts.map +1 -0
  391. package/lib/types/src/transaction/di/transactionModuleFactory.d.ts.map +1 -1
  392. package/lib/types/src/transaction/di/transactionTypes.d.ts +1 -0
  393. package/lib/types/src/transaction/di/transactionTypes.d.ts.map +1 -1
  394. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts +4 -2
  395. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts.map +1 -1
  396. package/lib/types/src/transaction/model/ProxyDelegateCall.d.ts +5 -0
  397. package/lib/types/src/transaction/model/ProxyDelegateCall.d.ts.map +1 -0
  398. package/lib/types/src/transaction/model/ProxyImplementationAddress.d.ts +4 -0
  399. package/lib/types/src/transaction/model/ProxyImplementationAddress.d.ts.map +1 -0
  400. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts.map +1 -1
  401. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts +1 -1
  402. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts.map +1 -1
  403. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts.map +1 -1
  404. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts.map +1 -1
  405. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts +1 -1
  406. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts.map +1 -1
  407. package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.d.ts.map +1 -1
  408. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  409. package/package.json +14 -14
  410. package/lib/types/src/transaction/data/CalldataDto.d.ts.map +0 -1
  411. /package/lib/cjs/src/transaction/data/{CalldataDto.js → dto/CalldataDto.js} +0 -0
  412. /package/lib/esm/src/{transaction/data/CalldataDto.js.map → config/model/ContextModuleBuildArgs.js.map} +0 -0
  413. /package/lib/esm/src/transaction/data/{CalldataDto.js → dto/CalldataDto.js} +0 -0
  414. /package/lib/types/src/transaction/data/{CalldataDto.d.ts → dto/CalldataDto.d.ts} +0 -0
@@ -1,2 +1,2 @@
1
- "use strict";var a=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var c=(o,t)=>{for(var e in t)a(o,e,{get:t[e],enumerable:!0})},f=(o,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of u(t))!T.call(o,r)&&r!==e&&a(o,r,{get:()=>t[r],enumerable:!(n=k(t,r))||n.enumerable});return o};var s=o=>f(a({},"__esModule",{value:!0}),o);var C={};c(C,{tokenModuleFactory:()=>x});module.exports=s(C);var i=require("inversify"),p=require("../../token/data/HttpTokenDataSource"),m=require("../../token/di/tokenTypes"),d=require("../../token/domain/TokenContextLoader");const x=()=>new i.ContainerModule((o,t,e,n)=>{o(m.tokenTypes.TokenDataSource).to(p.HttpTokenDataSource),o(m.tokenTypes.TokenContextLoader).to(d.TokenContextLoader)});0&&(module.exports={tokenModuleFactory});
1
+ "use strict";var n=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var u=(o,t)=>{for(var r in t)n(o,r,{get:t[r],enumerable:!0})},d=(o,t,r,m)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of f(t))!i.call(o,e)&&e!==r&&n(o,e,{get:()=>t[e],enumerable:!(m=c(t,e))||m.enumerable});return o};var x=o=>d(n({},"__esModule",{value:!0}),o);var l={};u(l,{tokenModuleFactory:()=>C});module.exports=x(l);var p=require("inversify"),k=require("../../token/data/HttpTokenDataSource"),a=require("../../token/di/tokenTypes"),T=require("../../token/domain/TokenContextLoader");const C=()=>new p.ContainerModule(({bind:o})=>{o(a.tokenTypes.TokenDataSource).to(k.HttpTokenDataSource),o(a.tokenTypes.TokenContextLoader).to(T.TokenContextLoader)});0&&(module.exports={tokenModuleFactory});
2
2
  //# sourceMappingURL=tokenModuleFactory.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/token/di/tokenModuleFactory.ts"],
4
- "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpTokenDataSource } from \"@/token/data/HttpTokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\nimport { TokenContextLoader } from \"@/token/domain/TokenContextLoader\";\n\nexport const tokenModuleFactory = () =>\n new ContainerModule((bind, _unbind, _isBound, _rebind) => {\n bind(tokenTypes.TokenDataSource).to(HttpTokenDataSource);\n bind(tokenTypes.TokenContextLoader).to(TokenContextLoader);\n });\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,qBAEhCC,EAAoC,4CACpCC,EAA2B,iCAC3BC,EAAmC,6CAE5B,MAAML,EAAqB,IAChC,IAAI,kBAAgB,CAACM,EAAMC,EAASC,EAAUC,IAAY,CACxDH,EAAK,aAAW,eAAe,EAAE,GAAG,qBAAmB,EACvDA,EAAK,aAAW,kBAAkB,EAAE,GAAG,oBAAkB,CAC3D,CAAC",
6
- "names": ["tokenModuleFactory_exports", "__export", "tokenModuleFactory", "__toCommonJS", "import_inversify", "import_HttpTokenDataSource", "import_tokenTypes", "import_TokenContextLoader", "bind", "_unbind", "_isBound", "_rebind"]
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpTokenDataSource } from \"@/token/data/HttpTokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\nimport { TokenContextLoader } from \"@/token/domain/TokenContextLoader\";\n\nexport const tokenModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(tokenTypes.TokenDataSource).to(HttpTokenDataSource);\n bind(tokenTypes.TokenContextLoader).to(TokenContextLoader);\n });\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,qBAEhCC,EAAoC,4CACpCC,EAA2B,iCAC3BC,EAAmC,6CAE5B,MAAML,EAAqB,IAChC,IAAI,kBAAgB,CAAC,CAAE,KAAAM,CAAK,IAAM,CAChCA,EAAK,aAAW,eAAe,EAAE,GAAG,qBAAmB,EACvDA,EAAK,aAAW,kBAAkB,EAAE,GAAG,oBAAkB,CAC3D,CAAC",
6
+ "names": ["tokenModuleFactory_exports", "__export", "tokenModuleFactory", "__toCommonJS", "import_inversify", "import_HttpTokenDataSource", "import_tokenTypes", "import_TokenContextLoader", "bind"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var s=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var C=(o,e)=>{for(var t in e)s(o,t,{get:e[t],enumerable:!0})},T=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of f(e))!g.call(o,a)&&a!==t&&s(o,a,{get:()=>e[a],enumerable:!(r=u(e,a))||r.enumerable});return o};var h=o=>T(s({},"__esModule",{value:!0}),o),S=(o,e,t,r)=>{for(var a=r>1?void 0:r?u(e,t):e,c=o.length-1,p;c>=0;c--)(p=o[c])&&(a=(r?p(e,t,a):p(a))||a);return r&&a&&s(e,t,a),a},x=(o,e)=>(t,r)=>e(t,r,o);var I={};C(I,{ERC20_SUPPORTED_SELECTORS:()=>d,TokenContextLoader:()=>i});module.exports=h(I);var m=require("@ledgerhq/device-management-kit"),l=require("inversify"),n=require("../../shared/model/ClearSignContext"),y=require("../../token/di/tokenTypes");var d=(t=>(t.Approve="0x095ea7b3",t.Transfer="0xa9059cbb",t))(d||{});const O=Object.values(d);let i=class{_dataSource;constructor(e){this._dataSource=e}async load(e){if(!e.to||!e.data||e.data==="0x")return[];const t=e.data.slice(0,10);return(0,m.isHexaString)(t)?this.isSelectorSupported(t)?[(await this._dataSource.getTokenInfosPayload({address:e.to,chainId:e.chainId})).caseOf({Left:a=>({type:n.ClearSignContextType.ERROR,error:a}),Right:a=>({type:n.ClearSignContextType.TOKEN,payload:a})})]:[]:[{type:n.ClearSignContextType.ERROR,error:new Error("Invalid selector")}]}async loadField(e){return e.type!==n.ClearSignContextType.TOKEN?null:(await this._dataSource.getTokenInfosPayload({address:e.address,chainId:e.chainId})).caseOf({Left:r=>({type:n.ClearSignContextType.ERROR,error:r}),Right:r=>({type:n.ClearSignContextType.TOKEN,payload:r})})}isSelectorSupported(e){return Object.values(O).includes(e)}};i=S([(0,l.injectable)(),x(0,(0,l.inject)(y.tokenTypes.TokenDataSource))],i);0&&(module.exports={ERC20_SUPPORTED_SELECTORS,TokenContextLoader});
1
+ "use strict";var l=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var C=(o,t)=>{for(var e in t)l(o,e,{get:t[e],enumerable:!0})},T=(o,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of f(t))!g.call(o,r)&&r!==e&&l(o,r,{get:()=>t[r],enumerable:!(a=u(t,r))||a.enumerable});return o};var h=o=>T(l({},"__esModule",{value:!0}),o),S=(o,t,e,a)=>{for(var r=a>1?void 0:a?u(t,e):t,c=o.length-1,n;c>=0;c--)(n=o[c])&&(r=(a?n(t,e,r):n(r))||r);return a&&r&&l(t,e,r),r},m=(o,t)=>(e,a)=>t(e,a,o);var R={};C(R,{ERC20_SUPPORTED_SELECTORS:()=>d,TokenContextLoader:()=>s});module.exports=h(R);var x=require("@ledgerhq/device-management-kit"),p=require("inversify"),i=require("../../shared/model/ClearSignContext"),y=require("../../token/di/tokenTypes");var d=(e=>(e.Approve="0x095ea7b3",e.Transfer="0xa9059cbb",e))(d||{});const O=Object.values(d);let s=class{_dataSource;constructor(t){this._dataSource=t}async load(t){const{to:e,selector:a,chainId:r}=t;return e?(0,x.isHexaString)(a)?this.isSelectorSupported(a)?[(await this._dataSource.getTokenInfosPayload({address:e,chainId:r})).caseOf({Left:n=>({type:i.ClearSignContextType.ERROR,error:n}),Right:n=>({type:i.ClearSignContextType.TOKEN,payload:n})})]:[]:[{type:i.ClearSignContextType.ERROR,error:new Error("Invalid selector")}]:[]}async loadField(t){return t.type!==i.ClearSignContextType.TOKEN?null:(await this._dataSource.getTokenInfosPayload({address:t.address,chainId:t.chainId})).caseOf({Left:a=>({type:i.ClearSignContextType.ERROR,error:a}),Right:a=>({type:i.ClearSignContextType.TOKEN,payload:a})})}isSelectorSupported(t){return Object.values(O).includes(t)}};s=S([(0,p.injectable)(),m(0,(0,p.inject)(y.tokenTypes.TokenDataSource))],s);0&&(module.exports={ERC20_SUPPORTED_SELECTORS,TokenContextLoader});
2
2
  //# sourceMappingURL=TokenContextLoader.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/token/domain/TokenContextLoader.ts"],
4
- "sourcesContent": ["import { HexaString, isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport {\n TransactionContext,\n TransactionFieldContext,\n} from \"@/shared/model/TransactionContext\";\nimport type { TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\n\nexport enum ERC20_SUPPORTED_SELECTORS {\n Approve = \"0x095ea7b3\",\n Transfer = \"0xa9059cbb\",\n}\n\nconst SUPPORTED_SELECTORS: HexaString[] = Object.values(\n ERC20_SUPPORTED_SELECTORS,\n);\n\n@injectable()\nexport class TokenContextLoader implements ContextLoader {\n private _dataSource: TokenDataSource;\n\n constructor(@inject(tokenTypes.TokenDataSource) dataSource: TokenDataSource) {\n this._dataSource = dataSource;\n }\n\n async load(transaction: TransactionContext): Promise<ClearSignContext[]> {\n if (!transaction.to || !transaction.data || transaction.data === \"0x\") {\n return [];\n }\n\n const selector = transaction.data.slice(0, 10);\n\n if (!isHexaString(selector)) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ];\n }\n\n if (!this.isSelectorSupported(selector)) {\n return [];\n }\n\n const payload = await this._dataSource.getTokenInfosPayload({\n address: transaction.to,\n chainId: transaction.chainId,\n });\n\n return [\n payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TOKEN,\n payload: value,\n }),\n }),\n ];\n }\n\n async loadField(\n field: TransactionFieldContext,\n ): Promise<ClearSignContext | null> {\n if (field.type !== ClearSignContextType.TOKEN) {\n return null;\n }\n const payload = await this._dataSource.getTokenInfosPayload({\n address: field.address,\n chainId: field.chainId,\n });\n return payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TOKEN,\n payload: value,\n }),\n });\n }\n\n private isSelectorSupported(selector: HexaString) {\n return Object.values(SUPPORTED_SELECTORS).includes(selector);\n }\n}\n"],
5
- "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,EAAA,uBAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAAyC,2CACzCC,EAAmC,qBAGnCC,EAGO,2CAMPC,EAA2B,iCAEpB,IAAKC,OACVA,EAAA,QAAU,aACVA,EAAA,SAAW,aAFDA,OAAA,IAKZ,MAAMC,EAAoC,OAAO,OAC/CD,CACF,EAGO,IAAME,EAAN,KAAkD,CAC/C,YAER,YAAgDC,EAA6B,CAC3E,KAAK,YAAcA,CACrB,CAEA,MAAM,KAAKC,EAA8D,CACvE,GAAI,CAACA,EAAY,IAAM,CAACA,EAAY,MAAQA,EAAY,OAAS,KAC/D,MAAO,CAAC,EAGV,MAAMC,EAAWD,EAAY,KAAK,MAAM,EAAG,EAAE,EAE7C,SAAK,gBAAaC,CAAQ,EASrB,KAAK,oBAAoBA,CAAQ,EAS/B,EALS,MAAM,KAAK,YAAY,qBAAqB,CAC1D,QAASD,EAAY,GACrB,QAASA,EAAY,OACvB,CAAC,GAGS,OAAO,CACb,KAAOE,IAA6B,CAClC,KAAM,uBAAqB,MAC3B,MAAAA,CACF,GACA,MAAQC,IAA6B,CACnC,KAAM,uBAAqB,MAC3B,QAASA,CACX,EACF,CAAC,CACH,EAnBS,CAAC,EATD,CACL,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,kBAAkB,CACrC,CACF,CAwBJ,CAEA,MAAM,UACJC,EACkC,CAClC,OAAIA,EAAM,OAAS,uBAAqB,MAC/B,MAEO,MAAM,KAAK,YAAY,qBAAqB,CAC1D,QAASA,EAAM,QACf,QAASA,EAAM,OACjB,CAAC,GACc,OAAO,CACpB,KAAOF,IAA6B,CAClC,KAAM,uBAAqB,MAC3B,MAAAA,CACF,GACA,MAAQC,IAA6B,CACnC,KAAM,uBAAqB,MAC3B,QAASA,CACX,EACF,CAAC,CACH,CAEQ,oBAAoBF,EAAsB,CAChD,OAAO,OAAO,OAAOJ,CAAmB,EAAE,SAASI,CAAQ,CAC7D,CACF,EAvEaH,EAANO,EAAA,IADN,cAAW,EAIGC,EAAA,eAAO,aAAW,eAAe,IAHnCR",
6
- "names": ["TokenContextLoader_exports", "__export", "ERC20_SUPPORTED_SELECTORS", "TokenContextLoader", "__toCommonJS", "import_device_management_kit", "import_inversify", "import_ClearSignContext", "import_tokenTypes", "ERC20_SUPPORTED_SELECTORS", "SUPPORTED_SELECTORS", "TokenContextLoader", "dataSource", "transaction", "selector", "error", "value", "field", "__decorateClass", "__decorateParam"]
4
+ "sourcesContent": ["import { HexaString, isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport {\n TransactionContext,\n TransactionFieldContext,\n} from \"@/shared/model/TransactionContext\";\nimport type { TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\n\nexport enum ERC20_SUPPORTED_SELECTORS {\n Approve = \"0x095ea7b3\",\n Transfer = \"0xa9059cbb\",\n}\n\nconst SUPPORTED_SELECTORS: HexaString[] = Object.values(\n ERC20_SUPPORTED_SELECTORS,\n);\n\n@injectable()\nexport class TokenContextLoader implements ContextLoader {\n private _dataSource: TokenDataSource;\n\n constructor(@inject(tokenTypes.TokenDataSource) dataSource: TokenDataSource) {\n this._dataSource = dataSource;\n }\n\n async load(ctx: TransactionContext): Promise<ClearSignContext[]> {\n const { to, selector, chainId } = ctx;\n if (!to) {\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 if (!this.isSelectorSupported(selector)) {\n return [];\n }\n\n const payload = await this._dataSource.getTokenInfosPayload({\n address: to,\n chainId,\n });\n\n return [\n payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TOKEN,\n payload: value,\n }),\n }),\n ];\n }\n\n async loadField(\n field: TransactionFieldContext,\n ): Promise<ClearSignContext | null> {\n if (field.type !== ClearSignContextType.TOKEN) {\n return null;\n }\n const payload = await this._dataSource.getTokenInfosPayload({\n address: field.address,\n chainId: field.chainId,\n });\n return payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TOKEN,\n payload: value,\n }),\n });\n }\n\n private isSelectorSupported(selector: HexaString) {\n return Object.values(SUPPORTED_SELECTORS).includes(selector);\n }\n}\n"],
5
+ "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,EAAA,uBAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAAyC,2CACzCC,EAAmC,qBAGnCC,EAGO,2CAMPC,EAA2B,iCAEpB,IAAKC,OACVA,EAAA,QAAU,aACVA,EAAA,SAAW,aAFDA,OAAA,IAKZ,MAAMC,EAAoC,OAAO,OAC/CD,CACF,EAGO,IAAME,EAAN,KAAkD,CAC/C,YAER,YAAgDC,EAA6B,CAC3E,KAAK,YAAcA,CACrB,CAEA,MAAM,KAAKC,EAAsD,CAC/D,KAAM,CAAE,GAAAC,EAAI,SAAAC,EAAU,QAAAC,CAAQ,EAAIH,EAClC,OAAKC,KAIA,gBAAaC,CAAQ,EASrB,KAAK,oBAAoBA,CAAQ,EAS/B,EALS,MAAM,KAAK,YAAY,qBAAqB,CAC1D,QAASD,EACT,QAAAE,CACF,CAAC,GAGS,OAAO,CACb,KAAOC,IAA6B,CAClC,KAAM,uBAAqB,MAC3B,MAAAA,CACF,GACA,MAAQC,IAA6B,CACnC,KAAM,uBAAqB,MAC3B,QAASA,CACX,EACF,CAAC,CACH,EAnBS,CAAC,EATD,CACL,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,kBAAkB,CACrC,CACF,EATO,CAAC,CAiCZ,CAEA,MAAM,UACJC,EACkC,CAClC,OAAIA,EAAM,OAAS,uBAAqB,MAC/B,MAEO,MAAM,KAAK,YAAY,qBAAqB,CAC1D,QAASA,EAAM,QACf,QAASA,EAAM,OACjB,CAAC,GACc,OAAO,CACpB,KAAOF,IAA6B,CAClC,KAAM,uBAAqB,MAC3B,MAAAA,CACF,GACA,MAAQC,IAA6B,CACnC,KAAM,uBAAqB,MAC3B,QAASA,CACX,EACF,CAAC,CACH,CAEQ,oBAAoBH,EAAsB,CAChD,OAAO,OAAO,OAAOL,CAAmB,EAAE,SAASK,CAAQ,CAC7D,CACF,EAtEaJ,EAANS,EAAA,IADN,cAAW,EAIGC,EAAA,eAAO,aAAW,eAAe,IAHnCV",
6
+ "names": ["TokenContextLoader_exports", "__export", "ERC20_SUPPORTED_SELECTORS", "TokenContextLoader", "__toCommonJS", "import_device_management_kit", "import_inversify", "import_ClearSignContext", "import_tokenTypes", "ERC20_SUPPORTED_SELECTORS", "SUPPORTED_SELECTORS", "TokenContextLoader", "dataSource", "ctx", "to", "selector", "chainId", "error", "value", "field", "__decorateClass", "__decorateParam"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var n=require("purify-ts"),o=require("../../shared/model/ClearSignContext"),s=require("../../token/domain/TokenContextLoader");describe("TokenContextLoader",()=>{const r={getTokenInfosPayload:vi.fn()},e=new s.TokenContextLoader(r);beforeEach(()=>{vi.restoreAllMocks(),vi.spyOn(r,"getTokenInfosPayload").mockImplementation(({address:t})=>Promise.resolve((0,n.Right)(`payload-${t}`)))}),describe("load function",()=>{it("should return an empty array if transaction dest is undefined",async()=>{const t={to:void 0,data:"0x01"},a=await e.load(t);expect(a).toEqual([])}),it("should return an empty array if transaction data is undefined",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:void 0},a=await e.load(t);expect(a).toEqual([])}),it("should return an empty array if transaction data is empty",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x"},a=await e.load(t);expect(a).toEqual([])}),it("should return an empty array if the selector is not supported",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x095ea7b20000000000000"},a=await e.load(t);expect(a).toEqual([])}),it("should return an error when transaction data is not a valid hex string",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"notahexstring"},a=await e.load(t);expect(a).toEqual([{type:o.ClearSignContextType.ERROR,error:new Error("Invalid selector")}])}),it("should return an error when datasource returns an error",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x095ea7b30000000000",chainId:1};vi.spyOn(r,"getTokenInfosPayload").mockResolvedValue((0,n.Left)(new Error("error")));const a=await e.load(t);expect(a).toEqual([{type:o.ClearSignContextType.ERROR,error:new Error("error")}])}),it("should return a correct response",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x095ea7b30000000000",chainId:1},a=await e.load(t);expect(a).toEqual([{type:o.ClearSignContextType.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"}])})}),describe("loadField function",()=>{it("should return an error when field type if not supported",async()=>{const t={type:o.ClearSignContextType.NFT,chainId:7,address:"0x1234"},a=await e.loadField(t);expect(a).toEqual(null)}),it("should return a payload",async()=>{const t={type:o.ClearSignContextType.TOKEN,chainId:7,address:"0x1234"};vi.spyOn(r,"getTokenInfosPayload").mockResolvedValue((0,n.Right)("payload"));const a=await e.loadField(t);expect(a).toEqual({type:o.ClearSignContextType.TOKEN,payload:"payload"})}),it("should return an error when unable to fetch the datasource",async()=>{const t={type:o.ClearSignContextType.TOKEN,chainId:7,address:"0x1234"};vi.spyOn(r,"getTokenInfosPayload").mockResolvedValue((0,n.Left)(new Error("error")));const a=await e.loadField(t);expect(a).toEqual({type:o.ClearSignContextType.ERROR,error:new Error("error")})})})});
1
+ "use strict";var n=require("purify-ts"),t=require("../../shared/model/ClearSignContext"),s=require("../../token/domain/TokenContextLoader");describe("TokenContextLoader",()=>{const r={getTokenInfosPayload:vi.fn()},a=new s.TokenContextLoader(r);beforeEach(()=>{vi.restoreAllMocks(),vi.spyOn(r,"getTokenInfosPayload").mockImplementation(({address:e})=>Promise.resolve((0,n.Right)(`payload-${e}`)))}),describe("load function",()=>{it("should return an empty array if transaction dest is undefined",async()=>{const e={to:void 0},o=await a.load(e);expect(o).toEqual([])}),it("should return an error when datasource returns an error",async()=>{const e={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",chainId:1,selector:"0x095ea7b3"};vi.spyOn(r,"getTokenInfosPayload").mockResolvedValue((0,n.Left)(new Error("error")));const o=await a.load(e);expect(o).toEqual([{type:t.ClearSignContextType.ERROR,error:new Error("error")}])}),it("should return a correct response",async()=>{const e={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",chainId:1,selector:"0x095ea7b3"},o=await a.load(e);expect(o).toEqual([{type:t.ClearSignContextType.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"}])})}),describe("loadField function",()=>{it("should return an error when field type if not supported",async()=>{const e={type:t.ClearSignContextType.NFT,chainId:7,address:"0x1234"},o=await a.loadField(e);expect(o).toEqual(null)}),it("should return a payload",async()=>{const e={type:t.ClearSignContextType.TOKEN,chainId:7,address:"0x1234"};vi.spyOn(r,"getTokenInfosPayload").mockResolvedValue((0,n.Right)("payload"));const o=await a.loadField(e);expect(o).toEqual({type:t.ClearSignContextType.TOKEN,payload:"payload"})}),it("should return an error when unable to fetch the datasource",async()=>{const e={type:t.ClearSignContextType.TOKEN,chainId:7,address:"0x1234"};vi.spyOn(r,"getTokenInfosPayload").mockResolvedValue((0,n.Left)(new Error("error")));const o=await a.loadField(e);expect(o).toEqual({type:t.ClearSignContextType.ERROR,error:new Error("error")})})})});
2
2
  //# sourceMappingURL=TokenContextLoader.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/token/domain/TokenContextLoader.test.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"@/shared/model/TransactionContext\";\nimport { type TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { TokenContextLoader } from \"@/token/domain/TokenContextLoader\";\n\ndescribe(\"TokenContextLoader\", () => {\n const mockTokenDataSource: TokenDataSource = {\n getTokenInfosPayload: vi.fn(),\n };\n const loader = new TokenContextLoader(mockTokenDataSource);\n\n beforeEach(() => {\n vi.restoreAllMocks();\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockImplementation(\n ({ address }) => Promise.resolve(Right(`payload-${address}`)),\n );\n });\n\n describe(\"load function\", () => {\n it(\"should return an empty array if transaction dest is undefined\", async () => {\n // GIVEN\n const transaction = { to: undefined, data: \"0x01\" } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if transaction data is undefined\", async () => {\n // GIVEN\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: undefined,\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if transaction data is empty\", async () => {\n // GIVEN\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if the selector is not supported\", async () => {\n // GIVEN\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x095ea7b20000000000000\",\n } as unknown as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an error when transaction data is not a valid hex string\", async () => {\n // GIVEN\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"notahexstring\",\n } as unknown as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ]);\n });\n\n it(\"should return an error when datasource returns an error\", async () => {\n // GIVEN\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x095ea7b30000000000\",\n chainId: 1,\n } as TransactionContext;\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(new Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n { type: ClearSignContextType.ERROR, error: new Error(\"error\") },\n ]);\n });\n\n it(\"should return a correct response\", async () => {\n // GIVEN\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x095ea7b30000000000\",\n chainId: 1,\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n ]);\n });\n });\n\n describe(\"loadField function\", () => {\n it(\"should return an error when field type if not supported\", async () => {\n const field: TransactionFieldContext = {\n type: ClearSignContextType.NFT,\n chainId: 7,\n address: \"0x1234\",\n };\n\n const result = await loader.loadField(field);\n\n expect(result).toEqual(null);\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TOKEN,\n chainId: 7,\n address: \"0x1234\",\n };\n\n // WHEN\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Right(\"payload\"),\n );\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.TOKEN,\n payload: \"payload\",\n });\n });\n\n it(\"should return an error when unable to fetch the datasource\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TOKEN,\n chainId: 7,\n address: \"0x1234\",\n };\n\n // WHEN\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(new Error(\"error\")),\n );\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n });\n });\n });\n});\n"],
5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AAM,uBAAqB,MAC3B,QAAS,EACT,QAAS,QACX,EAGA,GAAG,MAAML,EAAqB,sBAAsB,EAAE,qBACpD,QAAK,IAAI,MAAM,OAAO,CAAC,CACzB,EACA,MAAMI,EAAS,MAAMH,EAAO,UAAUI,CAAK,EAG3C,OAAOD,CAAM,EAAE,QAAQ,CACrB,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,OAAO,CAC1B,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"@/shared/model/TransactionContext\";\nimport { type TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { TokenContextLoader } from \"@/token/domain/TokenContextLoader\";\n\ndescribe(\"TokenContextLoader\", () => {\n const mockTokenDataSource: TokenDataSource = {\n getTokenInfosPayload: vi.fn(),\n };\n const loader = new TokenContextLoader(mockTokenDataSource);\n\n beforeEach(() => {\n vi.restoreAllMocks();\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockImplementation(\n ({ address }) => Promise.resolve(Right(`payload-${address}`)),\n );\n });\n\n describe(\"load function\", () => {\n it(\"should return an empty array if transaction dest is undefined\", async () => {\n // GIVEN\n const transaction = { to: undefined } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an error when datasource returns an error\", async () => {\n // GIVEN\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n chainId: 1,\n selector: \"0x095ea7b3\",\n } as TransactionContext;\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(new Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n { type: ClearSignContextType.ERROR, error: new Error(\"error\") },\n ]);\n });\n\n it(\"should return a correct response\", async () => {\n // GIVEN\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n chainId: 1,\n selector: \"0x095ea7b3\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n ]);\n });\n });\n\n describe(\"loadField function\", () => {\n it(\"should return an error when field type if not supported\", async () => {\n const field: TransactionFieldContext = {\n type: ClearSignContextType.NFT,\n chainId: 7,\n address: \"0x1234\",\n };\n\n const result = await loader.loadField(field);\n\n expect(result).toEqual(null);\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TOKEN,\n chainId: 7,\n address: \"0x1234\",\n };\n\n // WHEN\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Right(\"payload\"),\n );\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.TOKEN,\n payload: \"payload\",\n });\n });\n\n it(\"should return an error when unable to fetch the datasource\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TOKEN,\n chainId: 7,\n address: \"0x1234\",\n };\n\n // WHEN\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(new Error(\"error\")),\n );\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n });\n });\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAA4B,qBAE5BC,EAAqC,2CAMrCC,EAAmC,6CAEnC,SAAS,qBAAsB,IAAM,CACnC,MAAMC,EAAuC,CAC3C,qBAAsB,GAAG,GAAG,CAC9B,EACMC,EAAS,IAAI,qBAAmBD,CAAmB,EAEzD,WAAW,IAAM,CACf,GAAG,gBAAgB,EACnB,GAAG,MAAMA,E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AAE,qBACpD,SAAM,SAAS,CACjB,EACA,MAAMI,EAAS,MAAMH,EAAO,UAAUI,CAAK,EAG3C,OAAOD,CAAM,EAAE,QAAQ,CACrB,KAAM,uBAAqB,MAC3B,QAAS,SACX,CAAC,CACH,CAAC,EAED,GAAG,6DAA8D,SAAY,CAE3E,MAAMC,EAAiC,CACrC,KAAM,uBAAqB,MAC3B,QAAS,EACT,QAAS,QACX,EAGA,GAAG,MAAML,EAAqB,sBAAsB,EAAE,qBACpD,QAAK,IAAI,MAAM,OAAO,CAAC,CACzB,EACA,MAAMI,EAAS,MAAMH,EAAO,UAAUI,CAAK,EAG3C,OAAOD,CAAM,EAAE,QAAQ,CACrB,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,OAAO,CAC1B,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
6
  "names": ["import_purify_ts", "import_ClearSignContext", "import_TokenContextLoader", "mockTokenDataSource", "loader", "address", "transaction", "result", "field"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ "use strict";var E=Object.create;var l=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty;var I=(t,e)=>{for(var r in e)l(t,r,{get:e[r],enumerable:!0})},g=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of C(e))!A.call(t,n)&&n!==r&&l(t,n,{get:()=>e[n],enumerable:!(o=c(e,n))||o.enumerable});return t};var P=(t,e,r)=>(r=t!=null?E(h(t)):{},g(e||!t||!t.__esModule?l(r,"default",{value:t,enumerable:!0}):r,t)),$=t=>g(l({},"__esModule",{value:!0}),t),f=(t,e,r,o)=>{for(var n=o>1?void 0:o?c(e,r):e,i=t.length-1,d;i>=0;i--)(d=t[i])&&(n=(o?d(e,r,n):d(n))||n);return o&&n&&l(e,r,n),n},D=(t,e)=>(r,o)=>e(r,o,t);var G={};I(G,{HttpProxyDataSource:()=>m});module.exports=$(G);var y=P(require("axios")),p=require("inversify"),a=require("purify-ts"),u=require("../../config/di/configTypes"),s=require("../../shared/constant/HttpHeaders"),x=P(require("../../../package.json"));let m=class{constructor(e){this.config=e}async getProxyDelegateCall({proxyAddress:e,calldata:r,chainId:o,challenge:n}){let i;try{i=(await y.default.request({method:"POST",url:`${this.config.metadataServiceDomain.url}/v2/ethereum/${o}/contract/proxy/delegate`,headers:{[s.LEDGER_CLIENT_VERSION_HEADER]:`context-module/${x.default.version}`,[s.LEDGER_ORIGIN_TOKEN_HEADER]:this.config.originToken},data:{proxy:e,data:r,challenge:n}})).data}catch{return(0,a.Left)(new Error("[ContextModule] HttpProxyDataSource: Failed to fetch delegate proxy"))}return i?this.isProxyDelegateCallDto(i)?(0,a.Right)({delegateAddresses:i.addresses,signedDescriptor:i.signedDescriptor}):(0,a.Left)(new Error(`[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${e} on chain ${o}`)):(0,a.Left)(new Error(`[ContextModule] HttpProxyDataSource: No data received for proxy ${e} on chain ${o}`))}async getProxyImplementationAddress({proxyAddress:e,chainId:r}){let o;try{o=(await y.default.request({method:"GET",url:`${this.config.metadataServiceDomain.url}/v2/ethereum/${r}/contract/proxy/${e}`,headers:{[s.LEDGER_CLIENT_VERSION_HEADER]:`context-module/${x.default.version}`,[s.LEDGER_ORIGIN_TOKEN_HEADER]:this.config.originToken}})).data}catch{return(0,a.Left)(new Error("[ContextModule] HttpProxyDataSource: Failed to fetch implementation address"))}return o?this.isProxyImplementationAddressDto(o)?(0,a.Right)({implementationAddress:o.implementationAddress}):(0,a.Left)(new Error(`[ContextModule] HttpProxyDataSource: Invalid proxy implementation address response format for proxy ${e} on chain ${r}`)):(0,a.Left)(new Error(`[ContextModule] HttpProxyDataSource: No data received for proxy ${e} on chain ${r}`))}isProxyDelegateCallDto(e){return typeof e=="object"&&e!==null&&"addresses"in e&&"signedDescriptor"in e&&Array.isArray(e.addresses)&&e.addresses.every(r=>typeof r=="string")&&typeof e.signedDescriptor=="string"}isProxyImplementationAddressDto(e){return typeof e=="object"&&e!==null&&"proxyAddress"in e&&"implementationAddress"in e&&"standard"in e&&typeof e.proxyAddress=="string"&&typeof e.implementationAddress=="string"&&typeof e.standard=="string"&&e.standard.length>0}};m=f([(0,p.injectable)(),D(0,(0,p.inject)(u.configTypes.Config))],m);0&&(module.exports={HttpProxyDataSource});
2
+ //# sourceMappingURL=HttpProxyDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/transaction/data/HttpProxyDataSource.ts"],
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport { type ProxyDelegateCall } from \"@/transaction/model/ProxyDelegateCall\";\nimport { type ProxyImplementationAddress } from \"@/transaction/model/ProxyImplementationAddress\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { type ProxyDelegateCallDto } from \"./dto/ProxyDelegateCallDto\";\nimport { type ProxyImplementationAddressDto } from \"./dto/ProxyImplementationAddressDto\";\n\nexport type GetProxyDelegateCallParam = {\n proxyAddress: string;\n calldata: string;\n chainId: number;\n challenge: string;\n};\n\nexport type GetProxyImplementationAddressParam = {\n proxyAddress: string;\n chainId: number;\n};\n\nexport interface ProxyDataSource {\n getProxyDelegateCall(\n params: GetProxyDelegateCallParam,\n ): Promise<Either<Error, ProxyDelegateCall>>;\n getProxyImplementationAddress(\n params: GetProxyImplementationAddressParam,\n ): Promise<Either<Error, ProxyImplementationAddress>>;\n}\n\n@injectable()\nexport class HttpProxyDataSource implements ProxyDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n public async getProxyDelegateCall({\n proxyAddress,\n calldata,\n chainId,\n challenge,\n }: GetProxyDelegateCallParam): Promise<Either<Error, ProxyDelegateCall>> {\n let dto: ProxyDelegateCallDto | undefined;\n try {\n const response = await axios.request<ProxyDelegateCallDto>({\n method: \"POST\",\n url: `${this.config.metadataServiceDomain.url}/v2/ethereum/${chainId}/contract/proxy/delegate`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n data: {\n proxy: proxyAddress,\n data: calldata,\n challenge,\n },\n });\n dto = response.data;\n } catch (_error) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: Failed to fetch delegate proxy`,\n ),\n );\n }\n\n if (!dto) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: No data received for proxy ${proxyAddress} on chain ${chainId}`,\n ),\n );\n }\n\n if (!this.isProxyDelegateCallDto(dto)) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${proxyAddress} on chain ${chainId}`,\n ),\n );\n }\n\n return Right({\n delegateAddresses: dto.addresses,\n signedDescriptor: dto.signedDescriptor,\n });\n }\n\n public async getProxyImplementationAddress({\n proxyAddress,\n chainId,\n }: GetProxyImplementationAddressParam): Promise<\n Either<Error, ProxyImplementationAddress>\n > {\n let dto: ProxyImplementationAddressDto | undefined;\n try {\n const response = await axios.request<ProxyImplementationAddressDto>({\n method: \"GET\",\n url: `${this.config.metadataServiceDomain.url}/v2/ethereum/${chainId}/contract/proxy/${proxyAddress}`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n });\n dto = response.data;\n } catch (_error) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: Failed to fetch implementation address`,\n ),\n );\n }\n\n if (!dto) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: No data received for proxy ${proxyAddress} on chain ${chainId}`,\n ),\n );\n }\n\n if (!this.isProxyImplementationAddressDto(dto)) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: Invalid proxy implementation address response format for proxy ${proxyAddress} on chain ${chainId}`,\n ),\n );\n }\n\n return Right({ implementationAddress: dto.implementationAddress });\n }\n\n /**\n * Type guard to validate ProxyDelegateCallDto\n */\n private isProxyDelegateCallDto(\n value: unknown,\n ): value is ProxyDelegateCallDto {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"addresses\" in value &&\n \"signedDescriptor\" in value &&\n Array.isArray(value.addresses) &&\n value.addresses.every((address) => typeof address === \"string\") &&\n typeof value.signedDescriptor === \"string\"\n );\n }\n\n /**\n * Type guard to validate ProxyImplementationAddressDto\n */\n private isProxyImplementationAddressDto(\n value: unknown,\n ): value is ProxyImplementationAddressDto {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"proxyAddress\" in value &&\n \"implementationAddress\" in value &&\n \"standard\" in value &&\n typeof value.proxyAddress === \"string\" &&\n typeof value.implementationAddress === \"string\" &&\n typeof value.standard === \"string\" &&\n value.standard.length > 0\n );\n }\n}\n"],
5
+ "mappings": "qtBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkB,oBAClBC,EAAmC,qBACnCC,EAAoC,qBAEpCC,EAA4B,mCAE5BC,EAGO,yCAGPC,EAAoB,iCA2Bb,IAAMC,EAAN,KAAqD,CAC1D,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CAEH,MAAa,qBAAqB,CAChC,aAAAC,EACA,SAAAC,EACA,QAAAC,EACA,UAAAC,CACF,EAAyE,CACvE,IAAIC,EACJ,GAAI,CAcFA,GAbiB,MAAM,EAAAC,QAAM,QAA8B,CACzD,OAAQ,OACR,IAAK,GAAG,KAAK,OAAO,sBAAsB,GAAG,gBAAgBH,CAAO,2BACpE,QA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,OAAOA,GAAY,QAAQ,GAC9D,OAAOD,EAAM,kBAAqB,QAEtC,CAKQ,gCACNA,EACwC,CACxC,OACE,OAAOA,GAAU,UACjBA,IAAU,MACV,iBAAkBA,GAClB,0BAA2BA,GAC3B,aAAcA,GACd,OAAOA,EAAM,cAAiB,UAC9B,OAAOA,EAAM,uBAA0B,UACvC,OAAOA,EAAM,UAAa,UAC1BA,EAAM,SAAS,OAAS,CAE5B,CACF,EAxIaT,EAANW,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,cAAY,MAAM,IAFjBZ",
6
+ "names": ["HttpProxyDataSource_exports", "__export", "HttpProxyDataSource", "__toCommonJS", "import_axios", "import_inversify", "import_purify_ts", "import_configTypes", "import_HttpHeaders", "import_package", "HttpProxyDataSource", "config", "proxyAddress", "calldata", "chainId", "challenge", "dto", "axios", "PACKAGE", "value", "address", "__decorateClass", "__decorateParam"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var f=Object.create;var m=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var C=(o,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let d of g(t))!P.call(o,d)&&d!==r&&m(o,d,{get:()=>t[d],enumerable:!(s=h(t,d))||s.enumerable});return o};var x=(o,t,r)=>(r=o!=null?f(v(o)):{},C(t||!o||!o.__esModule?m(r,"default",{value:o,enumerable:!0}):r,o));var a=x(require("axios")),n=require("purify-ts"),c=require("../../shared/constant/HttpHeaders"),p=x(require("../../../package.json")),u=require("./HttpProxyDataSource");vi.mock("axios");describe("HttpProxyDataSource",()=>{const o={web3checks:{url:"web3checksUrl"},originToken:"originToken"};let t;const r={proxyAddress:"0x72CBdEaAdddD14Ec95b92995933CeC69566650f0",calldata:"0x6a76120200000000000000000000000072cbdeaadddd14ec95b92995933cec69566650f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000440d582f13000000000000000000000000cfa7eae32032bf431aed95532142a9c2b35715d40000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041000000000000000000000000a0766b65a4f7b1da79a1af79ac695456efa2864400000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000",chainId:1,challenge:"0x1234567890abcdef"},s={proxyAddress:"0xee6a57ec80ea46401049e92587e52f5ec1c24785",chainId:1},d={addresses:["0xd9db270c1b5e3bd161e8c8503c55ceabee709552"],signedDescriptor:"0x1234567890abcdef"},y={implementationAddress:"0x91ae842a5ffd8d12023116943e72a606179294f3"},l={implementationAddress:"0x91ae842a5ffd8d12023116943e72a606179294f3",proxyAddress:"0xee6a57ec80ea46401049e92587e52f5ec1c24785",standard:"proxy"};beforeEach(()=>{vi.clearAllMocks(),t=new u.HttpProxyDataSource({metadataServiceDomain:{url:"https://nft.api.live.ledger.com"},originToken:"originToken"})}),describe("getDelegateProxy",()=>{it("should call axios with the ledger client version header",async()=>{const e=`context-module/${p.default.version}`,i=vi.fn(()=>Promise.resolve({data:d}));vi.spyOn(a.default,"request").mockImplementation(i),await t.getProxyDelegateCall(r),expect(i).toHaveBeenCalledWith(expect.objectContaining({headers:{[c.LEDGER_CLIENT_VERSION_HEADER]:e,[c.LEDGER_ORIGIN_TOKEN_HEADER]:o.originToken}}))}),it("should return the delegate proxy response on success",async()=>{vi.spyOn(a.default,"request").mockResolvedValue({data:d});const e=await t.getProxyDelegateCall(r);expect(e).toEqual((0,n.Right)({delegateAddresses:["0xd9db270c1b5e3bd161e8c8503c55ceabee709552"],signedDescriptor:"0x1234567890abcdef"}))}),it("should return an error when axios throws an error",async()=>{vi.spyOn(a.default,"request").mockRejectedValue(new Error("fail"));const e=await t.getProxyDelegateCall(r);expect(e).toEqual((0,n.Left)(new Error("[ContextModule] HttpProxyDataSource: Failed to fetch delegate proxy")))}),it("should return an error if response shape is invalid",async()=>{vi.spyOn(a.default,"request").mockResolvedValue({data:{foo:"bar"}});const e=await t.getProxyDelegateCall(r);expect(e).toEqual((0,n.Left)(new Error("[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy 0x72CBdEaAdddD14Ec95b92995933CeC69566650f0 on chain 1")))}),it("should use the provided chainId in the URL",async()=>{const e=vi.fn(()=>Promise.resolve({data:d}));vi.spyOn(a.default,"request").mockImplementation(e);const i={proxyAddress:"0x72CBdEaAdddD14Ec95b92995933CeC69566650f0",calldata:"0x6a76120200000000000000000000000072cbdeaadddd14ec95b92995933cec69566650f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000440d582f13000000000000000000000000cfa7eae32032bf431aed95532142a9c2b35715d40000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041000000000000000000000000a0766b65a4f7b1da79a1af79ac695456efa2864400000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000",chainId:137,challenge:"0x1234567890abcdef"};await t.getProxyDelegateCall(i),expect(e).toHaveBeenCalledWith(expect.objectContaining({method:"POST",url:"https://nft.api.live.ledger.com/v2/ethereum/137/contract/proxy/delegate"}))}),it("should return an error if no dto is returned from the api",async()=>{vi.spyOn(a.default,"request").mockResolvedValue({data:void 0});const e=await t.getProxyDelegateCall(r);expect(e).toEqual((0,n.Left)(new Error("[ContextModule] HttpProxyDataSource: No data received for proxy 0x72CBdEaAdddD14Ec95b92995933CeC69566650f0 on chain 1")))})}),describe("getImplementAddress",()=>{it("should call axios with the ledger client version header",async()=>{const e=`context-module/${p.default.version}`,i=vi.fn(()=>Promise.resolve({data:l}));vi.spyOn(a.default,"request").mockImplementation(i),await t.getProxyImplementationAddress(s),expect(i).toHaveBeenCalledWith(expect.objectContaining({headers:{[c.LEDGER_CLIENT_VERSION_HEADER]:e,[c.LEDGER_ORIGIN_TOKEN_HEADER]:o.originToken}}))}),it("should make a GET request to the correct URL",async()=>{const e=vi.fn(()=>Promise.resolve({data:l}));vi.spyOn(a.default,"request").mockImplementation(e),await t.getProxyImplementationAddress(s),expect(e).toHaveBeenCalledWith(expect.objectContaining({method:"GET",url:"https://nft.api.live.ledger.com/v2/ethereum/1/contract/proxy/0xee6a57ec80ea46401049e92587e52f5ec1c24785"}))}),it("should use the provided chainId in the URL",async()=>{const e=vi.fn(()=>Promise.resolve({data:l}));vi.spyOn(a.default,"request").mockImplementation(e);const i={proxyAddress:"0xee6a57ec80ea46401049e92587e52f5ec1c24785",chainId:137};await t.getProxyImplementationAddress(i),expect(e).toHaveBeenCalledWith(expect.objectContaining({method:"GET",url:"https://nft.api.live.ledger.com/v2/ethereum/137/contract/proxy/0xee6a57ec80ea46401049e92587e52f5ec1c24785"}))}),it("should return the implementation address response on success",async()=>{vi.spyOn(a.default,"request").mockResolvedValue({data:l});const e=await t.getProxyImplementationAddress(s);expect(e).toEqual((0,n.Right)(y))}),it("should return an error when axios throws an error",async()=>{vi.spyOn(a.default,"request").mockRejectedValue(new Error("network error"));const e=await t.getProxyImplementationAddress(s);expect(e).toEqual((0,n.Left)(new Error("[ContextModule] HttpProxyDataSource: Failed to fetch implementation address")))}),it("should return an error if response shape is invalid",async()=>{vi.spyOn(a.default,"request").mockResolvedValue({data:{invalid:"data"}});const e=await t.getProxyImplementationAddress(s);expect(e).toEqual((0,n.Left)(new Error("[ContextModule] HttpProxyDataSource: Invalid proxy implementation address response format for proxy 0xee6a57ec80ea46401049e92587e52f5ec1c24785 on chain 1")))}),it("should return an error if no dto is returned from the api",async()=>{vi.spyOn(a.default,"request").mockResolvedValue({data:void 0});const e=await t.getProxyImplementationAddress(s);expect(e).toEqual((0,n.Left)(new Error("[ContextModule] HttpProxyDataSource: No data received for proxy 0xee6a57ec80ea46401049e92587e52f5ec1c24785 on chain 1")))})})});
2
+ //# sourceMappingURL=HttpProxyDataSource.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/transaction/data/HttpProxyDataSource.test.ts"],
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport type { ProxyImplementationAddress } from \"@/transaction/model/ProxyImplementationAddress\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { type ProxyDelegateCallDto } from \"./dto/ProxyDelegateCallDto\";\nimport { type ProxyImplementationAddressDto } from \"./dto/ProxyImplementationAddressDto\";\nimport type {\n GetProxyDelegateCallParam,\n GetProxyImplementationAddressParam,\n ProxyDataSource,\n} from \"./HttpProxyDataSource\";\nimport { HttpProxyDataSource } from \"./HttpProxyDataSource\";\n\nvi.mock(\"axios\");\n\ndescribe(\"HttpProxyDataSource\", () => {\n const config = {\n web3checks: {\n url: \"web3checksUrl\",\n },\n originToken: \"originToken\",\n } as ContextModuleConfig;\n\n let datasource: ProxyDataSource;\n const defaultParams: GetProxyDelegateCallParam = {\n proxyAddress: \"0x72CBdEaAdddD14Ec95b92995933CeC69566650f0\",\n calldata:\n \"0x6a76120200000000000000000000000072cbdeaadddd14ec95b92995933cec69566650f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000440d582f13000000000000000000000000cfa7eae32032bf431aed95532142a9c2b35715d40000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041000000000000000000000000a0766b65a4f7b1da79a1af79ac695456efa2864400000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000\",\n chainId: 1,\n challenge: \"0x1234567890abcdef\",\n };\n const defaultImplementAddressParams: GetProxyImplementationAddressParam = {\n proxyAddress: \"0xee6a57ec80ea46401049e92587e52f5ec1c24785\",\n chainId: 1,\n };\n const delegateProxyResponse: ProxyDelegateCallDto = {\n addresses: [\"0xd9db270c1b5e3bd161e8c8503c55ceabee709552\"],\n signedDescriptor: \"0x1234567890abcdef\",\n };\n const implementationAddressResponse: ProxyImplementationAddress = {\n implementationAddress: \"0x91ae842a5ffd8d12023116943e72a606179294f3\",\n };\n const implementationAddressDto: ProxyImplementationAddressDto = {\n implementationAddress: \"0x91ae842a5ffd8d12023116943e72a606179294f3\",\n proxyAddress: \"0xee6a57ec80ea46401049e92587e52f5ec1c24785\",\n standard: \"proxy\",\n };\n\n beforeEach(() => {\n vi.clearAllMocks();\n datasource = new HttpProxyDataSource({\n metadataServiceDomain: {\n url: \"https://nft.api.live.ledger.com\",\n },\n originToken: \"originToken\",\n } as ContextModuleConfig);\n });\n\n describe(\"getDelegateProxy\", () => {\n it(\"should call axios with the ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() =>\n Promise.resolve({ data: delegateProxyResponse }),\n );\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getProxyDelegateCall(defaultParams);\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: version,\n [LEDGER_ORIGIN_TOKEN_HEADER]: config.originToken,\n },\n }),\n );\n });\n\n it(\"should return the delegate proxy response on success\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: delegateProxyResponse,\n });\n\n // WHEN\n const result = await datasource.getProxyDelegateCall(defaultParams);\n\n // THEN\n expect(result).toEqual(\n Right({\n delegateAddresses: [\"0xd9db270c1b5e3bd161e8c8503c55ceabee709552\"],\n signedDescriptor: \"0x1234567890abcdef\",\n }),\n );\n });\n\n it(\"should return an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"fail\"));\n\n // WHEN\n const result = await datasource.getProxyDelegateCall(defaultParams);\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: Failed to fetch delegate proxy\",\n ),\n ),\n );\n });\n\n it(\"should return an error if response shape is invalid\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: { foo: \"bar\" } });\n\n // WHEN\n const result = await datasource.getProxyDelegateCall(defaultParams);\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy 0x72CBdEaAdddD14Ec95b92995933CeC69566650f0 on chain 1\",\n ),\n ),\n );\n });\n\n it(\"should use the provided chainId in the URL\", async () => {\n // GIVEN\n const requestSpy = vi.fn(() =>\n Promise.resolve({ data: delegateProxyResponse }),\n );\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n const paramsWithDifferentChainId: GetProxyDelegateCallParam = {\n proxyAddress: \"0x72CBdEaAdddD14Ec95b92995933CeC69566650f0\",\n calldata:\n \"0x6a76120200000000000000000000000072cbdeaadddd14ec95b92995933cec69566650f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000440d582f13000000000000000000000000cfa7eae32032bf431aed95532142a9c2b35715d40000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041000000000000000000000000a0766b65a4f7b1da79a1af79ac695456efa2864400000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000\",\n chainId: 137, // Polygon\n challenge: \"0x1234567890abcdef\",\n };\n\n // WHEN\n await datasource.getProxyDelegateCall(paramsWithDifferentChainId);\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n method: \"POST\",\n url: \"https://nft.api.live.ledger.com/v2/ethereum/137/contract/proxy/delegate\",\n }),\n );\n });\n\n it(\"should return an error if no dto is returned from the api\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: undefined,\n });\n\n // WHEN\n const result = await datasource.getProxyDelegateCall(defaultParams);\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: No data received for proxy 0x72CBdEaAdddD14Ec95b92995933CeC69566650f0 on chain 1\",\n ),\n ),\n );\n });\n });\n\n describe(\"getImplementAddress\", () => {\n it(\"should call axios with the ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() =>\n Promise.resolve({ data: implementationAddressDto }),\n );\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: version,\n [LEDGER_ORIGIN_TOKEN_HEADER]: config.originToken,\n },\n }),\n );\n });\n\n it(\"should make a GET request to the correct URL\", async () => {\n // GIVEN\n const requestSpy = vi.fn(() =>\n Promise.resolve({ data: implementationAddressDto }),\n );\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n method: \"GET\",\n url: \"https://nft.api.live.ledger.com/v2/ethereum/1/contract/proxy/0xee6a57ec80ea46401049e92587e52f5ec1c24785\",\n }),\n );\n });\n\n it(\"should use the provided chainId in the URL\", async () => {\n // GIVEN\n const requestSpy = vi.fn(() =>\n Promise.resolve({ data: implementationAddressDto }),\n );\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n const paramsWithDifferentChainId: GetProxyImplementationAddressParam = {\n proxyAddress: \"0xee6a57ec80ea46401049e92587e52f5ec1c24785\",\n chainId: 137, // Polygon\n };\n\n // WHEN\n await datasource.getProxyImplementationAddress(\n paramsWithDifferentChainId,\n );\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n method: \"GET\",\n url: \"https://nft.api.live.ledger.com/v2/ethereum/137/contract/proxy/0xee6a57ec80ea46401049e92587e52f5ec1c24785\",\n }),\n );\n });\n\n it(\"should return the implementation address response on success\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: implementationAddressDto,\n });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(result).toEqual(Right(implementationAddressResponse));\n });\n\n it(\"should return an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"network error\"));\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: Failed to fetch implementation address\",\n ),\n ),\n );\n });\n\n it(\"should return an error if response shape is invalid\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: { invalid: \"data\" },\n });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: Invalid proxy implementation address response format for proxy 0xee6a57ec80ea46401049e92587e52f5ec1c24785 on chain 1\",\n ),\n ),\n );\n });\n\n it(\"should return an error if no dto is returned from the api\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: undefined,\n });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: No data received for proxy 0xee6a57ec80ea46401049e92587e52f5ec1c24785 on chain 1\",\n ),\n ),\n );\n });\n });\n});\n"],
5
+ "mappings": "wdAAA,IAAAA,EAAkB,oBAClBC,EAA4B,qBAG5BC,EAGO,yCAEPC,EAAoB,iCASpBC,EAAoC,iCAEpC,GAAG,KAAK,OAAO,EAEf,SAAS,sBAAuB,IAAM,CACpC,MAAMC,EAAS,CACb,WAAY,CACV,IAAK,eACP,EACA,YAAa,aACf,EAEA,IAAIC,EACJ,MAAMC,EAA2C,CAC/C,aAAc,6CACd,SACE,0oCACF,QAAS,EACT,UAAW,oBACb,EACMC,EAAoE,CACxE,aAAc,6CACd,QAAS,CACX,EACMC,EAA8C,CAClD,UAAW,CAAC,4CAA4C,EACxD,iBAAkB,oBACpB,EACMC,EAA4D,CAChE,sBAAuB,4CACzB,EACMC,EAA0D,CAC9D,sBAAuB,6CACvB,aAAc,6CACd,SAAU,OACZ,EAEA,WAAW,IAAM,CACf,GAAG,cAAc,EACjBL,EA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MACR,CAAC,EAGD,MAAMC,EAAS,MAAMV,EAAW,8BAC9BE,CACF,EAGA,OAAOQ,CAAM,EAAE,WACb,QACE,IAAI,MACF,uHACF,CACF,CACF,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_axios", "import_purify_ts", "import_HttpHeaders", "import_package", "import_HttpProxyDataSource", "config", "datasource", "defaultParams", "defaultImplementAddressParams", "delegateProxyResponse", "implementationAddressResponse", "implementationAddressDto", "version", "PACKAGE", "requestSpy", "axios", "result", "paramsWithDifferentChainId"]
7
+ }
@@ -1,2 +1,2 @@
1
- "use strict";var L=Object.create;var c=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var G=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var K=(i,e)=>{for(var t in e)c(i,t,{get:e[t],enumerable:!0})},E=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of j(e))!w.call(i,o)&&o!==t&&c(i,o,{get:()=>e[o],enumerable:!(r=g(e,o))||r.enumerable});return i};var D=(i,e,t)=>(t=i!=null?L(G(i)):{},E(e||!i||!i.__esModule?c(t,"default",{value:i,enumerable:!0}):t,i)),$=i=>E(c({},"__esModule",{value:!0}),i),V=(i,e,t,r)=>{for(var o=r>1?void 0:r?g(e,t):e,a=i.length-1,n;a>=0;a--)(n=i[a])&&(o=(r?n(e,t,o):n(o))||o);return r&&o&&c(e,t,o),o},C=(i,e)=>(t,r)=>e(t,r,i);var B={};K(B,{HttpTransactionDataSource:()=>y});module.exports=$(B);var A=D(require("axios")),f=require("inversify"),l=require("purify-ts"),b=require("../../config/di/configTypes"),v=require("../../pki/di/pkiTypes"),N=require("../../pki/model/KeyId"),P=require("../../pki/model/KeyUsage"),s=require("../../shared/model/ClearSignContext"),d=require("../../shared/model/SignatureTags"),m=require("../../shared/utils/HexStringUtils"),_=D(require("../../../package.json"));let y=class{constructor(e,t){this.config=e;this._certificateLoader=t}async getTransactionDescriptors({chainId:e,address:t,selector:r,deviceModelId:o}){let a;try{a=(await A.default.request({method:"GET",url:`${this.config.cal.url}/dapps`,params:{output:"descriptors_calldata",chain_id:e,contracts:t,ref:`branch:${this.config.cal.branch}`},headers:{"X-Ledger-Client-Version":`context-module/${_.default.version}`}})).data}catch(n){return(0,l.Left)(new Error(`[ContextModule] HttpTransactionDataSource: Failed to fetch transaction informations: ${n}`))}if(!Array.isArray(a))return(0,l.Left)(new Error("[ContextModule] HttpTransactionDataSource: Response is not an array"));if(a.length===0)return(0,l.Left)(new Error(`[ContextModule] HttpTransactionDataSource: No data for contract ${t} and selector ${r}`));for(const n of a){t=t.toLowerCase(),r=`0x${r.slice(2).toLowerCase()}`;const p=n.descriptors_calldata?.[t]?.[r];if(!p||!this.isCalldataDescriptorV1(p,this.config.cal.mode))continue;const S=p.transaction_info.descriptor.data,M=p.transaction_info.descriptor.signatures[this.config.cal.mode],I={targetDevice:o,keyUsage:P.KeyUsage.Calldata,keyId:N.KeyId.CalCalldataKey},h=await this._certificateLoader.loadCertificate(I),x={type:s.ClearSignContextType.TRANSACTION_INFO,payload:m.HexStringUtils.appendSignatureToPayload(S,M,d.INFO_SIGNATURE_TAG),certificate:h},T=[];for(const[u,O]of Object.entries(p.enums))for(const[F,{data:U,signatures:k}]of Object.entries(O))T.push({type:s.ClearSignContextType.ENUM,id:Number(u),value:Number(F),payload:m.HexStringUtils.appendSignatureToPayload(U,k[this.config.cal.mode],d.INFO_SIGNATURE_TAG),certificate:h});const R=p.fields.map(u=>({type:s.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:u.descriptor,reference:this.getReference(u.param)}));return(0,l.Right)([x,...T,...R])}return(0,l.Left)(new Error(`[ContextModule] HttpTransactionDataSource: Invalid response for contract ${t} and selector ${r}`))}getReference(e){if(e.type==="TOKEN_AMOUNT"&&e.token!==void 0&&e.token.type==="path")return{type:s.ClearSignContextType.TOKEN,valuePath:this.toGenericPath(e.token.binary_path)};if(e.type==="TOKEN_AMOUNT"&&e.token!==void 0&&e.token.type==="constant")return{type:s.ClearSignContextType.TOKEN,value:e.token.value};if(e.type==="NFT"&&e.collection.type==="path")return{type:s.ClearSignContextType.NFT,valuePath:this.toGenericPath(e.collection.binary_path)};if(e.type==="NFT"&&e.collection.type==="constant")return{type:s.ClearSignContextType.NFT,value:e.collection.value};if(e.type==="TRUSTED_NAME"&&e.value.type==="path")return{type:s.ClearSignContextType.TRUSTED_NAME,valuePath:this.toGenericPath(e.value.binary_path),types:e.types,sources:e.sources};if(e.type==="ENUM"&&e.value.type==="path")return{type:s.ClearSignContextType.ENUM,valuePath:this.toGenericPath(e.value.binary_path),id:e.id}}toGenericPath(e){return e.type==="CONTAINER"?e.value:e.elements.map(t=>{if(t.type==="ARRAY"){const{weight:r,...o}=t;return{itemSize:r,...o}}else if(t.type==="LEAF"){const{leaf_type:r,...o}=t;return{leafType:r,...o}}return t})}isCalldataDescriptorV1(e,t){return typeof e=="object"&&e.type==="calldata"&&e.version==="v1"&&this.isTransactionInfoV1(e.transaction_info,t)&&this.isEnumV1(e.enums,t)&&Array.isArray(e.fields)&&e.fields.every(r=>this.isFieldV1(r))}isTransactionInfoV1(e,t){return typeof e=="object"&&typeof e.descriptor=="object"&&typeof e.descriptor.data=="string"&&typeof e.descriptor.signatures=="object"&&typeof e.descriptor.signatures[t]=="string"}isEnumV1(e,t){return typeof e=="object"&&Object.entries(e).every(([r,o])=>typeof r=="string"&&typeof o=="object"&&Object.entries(o).every(([a,n])=>typeof a=="string"&&typeof n=="object"&&typeof n.data=="string"&&n.signatures!==void 0&&this.isCalldataSignatures(n.signatures,t)))}isCalldataSignatures(e,t){return typeof e=="object"&&typeof e[t]=="string"}isFieldV1(e){return typeof e=="object"&&typeof e.descriptor=="string"&&typeof e.param=="object"&&typeof e.param.value=="object"&&this.isDescriptorValueV1(e.param.value)&&(e.param.type==="RAW"||e.param.type==="AMOUNT"||e.param.type==="DATETIME"||e.param.type==="DURATION"||e.param.type==="UNIT"||e.param.type==="ENUM"||e.param.type==="NFT"&&this.isDescriptorValueV1(e.param.collection)||e.param.type==="TOKEN_AMOUNT"&&(e.param.token===void 0||this.isDescriptorValueV1(e.param.token))||e.param.type==="TRUSTED_NAME"&&Array.isArray(e.param.types)&&Array.isArray(e.param.sources)&&e.param.types.every(t=>typeof t=="string")&&e.param.sources.every(t=>typeof t=="string"))}isDescriptorValueV1(e){return typeof e=="object"&&typeof e.type_family=="string"&&["UINT","INT","UFIXED","FIXED","ADDRESS","BOOL","BYTES","STRING"].includes(e.type_family)&&(typeof e.type_size>"u"||typeof e.type_size=="number")&&(e.type==="path"&&this.isCalldataDescriptorValueBinaryPathV1(e)||e.type==="constant"&&this.isCalldataDescriptorValueConstantV1(e))}isCalldataDescriptorValueConstantV1(e){return typeof e=="object"&&e.type==="constant"&&typeof e.value=="string"}isCalldataDescriptorValueBinaryPathV1(e){return typeof e=="object"&&(e.type==="path"&&e.binary_path.type==="CONTAINER"&&["FROM","TO","VALUE"].includes(e.binary_path.value)||e.binary_path.type==="DATA"&&Array.isArray(e.binary_path.elements)&&e.binary_path.elements.every(t=>this.isPathElementV1(t)))}isPathElementV1(e){return typeof e=="object"&&(e.type==="REF"||e.type==="TUPLE"&&typeof e.offset=="number"||e.type==="ARRAY"&&typeof e.weight=="number"&&(typeof e.start>"u"||typeof e.start=="number")&&(typeof e.end>"u"||typeof e.end=="number")||e.type==="LEAF"&&typeof e.leaf_type=="string"&&["ARRAY_LEAF","TUPLE_LEAF","STATIC_LEAF","DYNAMIC_LEAF"].includes(e.leaf_type)||e.type==="SLICE"&&(typeof e.start>"u"||typeof e.start=="number")&&(typeof e.end>"u"||typeof e.end=="number"))}};y=V([(0,f.injectable)(),C(0,(0,f.inject)(b.configTypes.Config)),C(1,(0,f.inject)(v.pkiTypes.PkiCertificateLoader))],y);0&&(module.exports={HttpTransactionDataSource});
1
+ "use strict";var j=Object.create;var c=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var $=(i,e)=>{for(var t in e)c(i,t,{get:e[t],enumerable:!0})},D=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of G(e))!K.call(i,o)&&o!==t&&c(i,o,{get:()=>e[o],enumerable:!(r=g(e,o))||r.enumerable});return i};var V=(i,e,t)=>(t=i!=null?j(w(i)):{},D(e||!i||!i.__esModule?c(t,"default",{value:i,enumerable:!0}):t,i)),B=i=>D(c({},"__esModule",{value:!0}),i),A=(i,e,t,r)=>{for(var o=r>1?void 0:r?g(e,t):e,a=i.length-1,n;a>=0;a--)(n=i[a])&&(o=(r?n(e,t,o):n(o))||o);return r&&o&&c(e,t,o),o},d=(i,e)=>(t,r)=>e(t,r,i);var Y={};$(Y,{HttpTransactionDataSource:()=>y});module.exports=B(Y);var _=V(require("axios")),f=require("inversify"),l=require("purify-ts"),N=require("../../config/di/configTypes"),b=require("../../pki/di/pkiTypes"),v=require("../../pki/model/KeyId"),P=require("../../pki/model/KeyUsage"),C=require("../../shared/constant/HttpHeaders"),s=require("../../shared/model/ClearSignContext"),m=require("../../shared/model/SignatureTags"),h=require("../../shared/utils/HexStringUtils"),S=V(require("../../../package.json"));let y=class{constructor(e,t){this.config=e;this._certificateLoader=t}async getTransactionDescriptors({chainId:e,address:t,selector:r,deviceModelId:o}){let a;try{a=(await _.default.request({method:"GET",url:`${this.config.cal.url}/dapps`,params:{output:"descriptors_calldata",chain_id:e,contracts:t,ref:`branch:${this.config.cal.branch}`},headers:{[C.LEDGER_CLIENT_VERSION_HEADER]:`context-module/${S.default.version}`,[C.LEDGER_ORIGIN_TOKEN_HEADER]:this.config.originToken}})).data}catch(n){return(0,l.Left)(new Error(`[ContextModule] HttpTransactionDataSource: Failed to fetch transaction informations: ${n}`))}if(!Array.isArray(a))return(0,l.Left)(new Error("[ContextModule] HttpTransactionDataSource: Response is not an array"));if(a.length===0)return(0,l.Left)(new Error(`[ContextModule] HttpTransactionDataSource: No data for contract ${t} and selector ${r}`));for(const n of a){t=t.toLowerCase(),r=`0x${r.slice(2).toLowerCase()}`;const p=n.descriptors_calldata?.[t]?.[r];if(!p||!this.isCalldataDescriptorV1(p,this.config.cal.mode))continue;const I=p.transaction_info.descriptor.data,M=p.transaction_info.descriptor.signatures[this.config.cal.mode],R={targetDevice:o,keyUsage:P.KeyUsage.Calldata,keyId:v.KeyId.CalCalldataKey},E=await this._certificateLoader.loadCertificate(R),O={type:s.ClearSignContextType.TRANSACTION_INFO,payload:h.HexStringUtils.appendSignatureToPayload(I,M,m.INFO_SIGNATURE_TAG),certificate:E},T=[];for(const[u,F]of Object.entries(p.enums))for(const[L,{data:k,signatures:U}]of Object.entries(F))T.push({type:s.ClearSignContextType.ENUM,id:Number(u),value:Number(L),payload:h.HexStringUtils.appendSignatureToPayload(k,U[this.config.cal.mode],m.INFO_SIGNATURE_TAG),certificate:E});const x=p.fields.map(u=>({type:s.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:u.descriptor,reference:this.getReference(u.param)}));return(0,l.Right)([O,...T,...x])}return(0,l.Left)(new Error(`[ContextModule] HttpTransactionDataSource: Invalid response for contract ${t} and selector ${r}`))}getReference(e){if(e.type==="TOKEN_AMOUNT"&&e.token!==void 0&&e.token.type==="path")return{type:s.ClearSignContextType.TOKEN,valuePath:this.toGenericPath(e.token.binary_path)};if(e.type==="TOKEN_AMOUNT"&&e.token!==void 0&&e.token.type==="constant")return{type:s.ClearSignContextType.TOKEN,value:e.token.value};if(e.type==="NFT"&&e.collection.type==="path")return{type:s.ClearSignContextType.NFT,valuePath:this.toGenericPath(e.collection.binary_path)};if(e.type==="NFT"&&e.collection.type==="constant")return{type:s.ClearSignContextType.NFT,value:e.collection.value};if(e.type==="TRUSTED_NAME"&&e.value.type==="path")return{type:s.ClearSignContextType.TRUSTED_NAME,valuePath:this.toGenericPath(e.value.binary_path),types:e.types,sources:e.sources};if(e.type==="ENUM"&&e.value.type==="path")return{type:s.ClearSignContextType.ENUM,valuePath:this.toGenericPath(e.value.binary_path),id:e.id}}toGenericPath(e){return e.type==="CONTAINER"?e.value:e.elements.map(t=>{if(t.type==="ARRAY"){const{weight:r,...o}=t;return{itemSize:r,...o}}else if(t.type==="LEAF"){const{leaf_type:r,...o}=t;return{leafType:r,...o}}return t})}isCalldataDescriptorV1(e,t){return typeof e=="object"&&e.type==="calldata"&&e.version==="v1"&&this.isTransactionInfoV1(e.transaction_info,t)&&this.isEnumV1(e.enums,t)&&Array.isArray(e.fields)&&e.fields.every(r=>this.isFieldV1(r))}isTransactionInfoV1(e,t){return typeof e=="object"&&typeof e.descriptor=="object"&&typeof e.descriptor.data=="string"&&typeof e.descriptor.signatures=="object"&&typeof e.descriptor.signatures[t]=="string"}isEnumV1(e,t){return typeof e=="object"&&Object.entries(e).every(([r,o])=>typeof r=="string"&&typeof o=="object"&&Object.entries(o).every(([a,n])=>typeof a=="string"&&typeof n=="object"&&typeof n.data=="string"&&n.signatures!==void 0&&this.isCalldataSignatures(n.signatures,t)))}isCalldataSignatures(e,t){return typeof e=="object"&&typeof e[t]=="string"}isFieldV1(e){return typeof e=="object"&&typeof e.descriptor=="string"&&typeof e.param=="object"&&typeof e.param.value=="object"&&this.isDescriptorValueV1(e.param.value)&&(e.param.type==="RAW"||e.param.type==="AMOUNT"||e.param.type==="DATETIME"||e.param.type==="DURATION"||e.param.type==="UNIT"||e.param.type==="ENUM"||e.param.type==="NFT"&&this.isDescriptorValueV1(e.param.collection)||e.param.type==="TOKEN_AMOUNT"&&(e.param.token===void 0||this.isDescriptorValueV1(e.param.token))||e.param.type==="TRUSTED_NAME"&&Array.isArray(e.param.types)&&Array.isArray(e.param.sources)&&e.param.types.every(t=>typeof t=="string")&&e.param.sources.every(t=>typeof t=="string"))}isDescriptorValueV1(e){return typeof e=="object"&&typeof e.type_family=="string"&&["UINT","INT","UFIXED","FIXED","ADDRESS","BOOL","BYTES","STRING"].includes(e.type_family)&&(typeof e.type_size>"u"||typeof e.type_size=="number")&&(e.type==="path"&&this.isCalldataDescriptorValueBinaryPathV1(e)||e.type==="constant"&&this.isCalldataDescriptorValueConstantV1(e))}isCalldataDescriptorValueConstantV1(e){return typeof e=="object"&&e.type==="constant"&&typeof e.value=="string"}isCalldataDescriptorValueBinaryPathV1(e){return typeof e=="object"&&(e.type==="path"&&e.binary_path.type==="CONTAINER"&&["FROM","TO","VALUE"].includes(e.binary_path.value)||e.binary_path.type==="DATA"&&Array.isArray(e.binary_path.elements)&&e.binary_path.elements.every(t=>this.isPathElementV1(t)))}isPathElementV1(e){return typeof e=="object"&&(e.type==="REF"||e.type==="TUPLE"&&typeof e.offset=="number"||e.type==="ARRAY"&&typeof e.weight=="number"&&(typeof e.start>"u"||typeof e.start=="number")&&(typeof e.end>"u"||typeof e.end=="number")||e.type==="LEAF"&&typeof e.leaf_type=="string"&&["ARRAY_LEAF","TUPLE_LEAF","STATIC_LEAF","DYNAMIC_LEAF"].includes(e.leaf_type)||e.type==="SLICE"&&(typeof e.start>"u"||typeof e.start=="number")&&(typeof e.end>"u"||typeof e.end=="number"))}};y=A([(0,f.injectable)(),d(0,(0,f.inject)(N.configTypes.Config)),d(1,(0,f.inject)(b.pkiTypes.PkiCertificateLoader))],y);0&&(module.exports={HttpTransactionDataSource});
2
2
  //# sourceMappingURL=HttpTransactionDataSource.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/transaction/data/HttpTransactionDataSource.ts"],
4
- "sourcesContent": ["import axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport {\n type ContextModuleCalMode,\n type ContextModuleConfig,\n} from \"@/config/model/ContextModuleConfig\";\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport { PkiCertificateInfo } from \"@/pki/model/PkiCertificateInfo\";\nimport {\n ClearSignContextReference,\n ClearSignContextSuccess,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { GenericPath } from \"@/shared/model/GenericPath\";\nimport { INFO_SIGNATURE_TAG } from \"@/shared/model/SignatureTags\";\nimport { HexStringUtils } from \"@/shared/utils/HexStringUtils\";\nimport PACKAGE from \"@root/package.json\";\n\nimport {\n CalldataDescriptor,\n CalldataDescriptorContainerPathV1,\n CalldataDescriptorParam,\n CalldataDescriptorPathElementsV1,\n CalldataDescriptorPathElementV1,\n CalldataDescriptorV1,\n CalldataDescriptorValueBinaryPathV1,\n CalldataDescriptorValueConstantV1,\n CalldataDescriptorValueV1,\n CalldataDto,\n CalldataEnumV1,\n CalldataFieldV1,\n CalldataSignatures,\n CalldataTransactionDescriptor,\n CalldataTransactionInfoV1,\n} from \"./CalldataDto\";\nimport {\n GetTransactionDescriptorsParams,\n TransactionDataSource,\n} from \"./TransactionDataSource\";\n\n@injectable()\nexport class HttpTransactionDataSource implements TransactionDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly _certificateLoader: PkiCertificateLoader,\n ) {}\n\n public async getTransactionDescriptors({\n chainId,\n address,\n selector,\n deviceModelId,\n }: GetTransactionDescriptorsParams): Promise<\n Either<Error, ClearSignContextSuccess[]>\n > {\n let dto: CalldataDto[] | undefined;\n try {\n const response = await axios.request<CalldataDto[]>({\n method: \"GET\",\n url: `${this.config.cal.url}/dapps`,\n params: {\n output: \"descriptors_calldata\",\n chain_id: chainId,\n contracts: address,\n ref: `branch:${this.config.cal.branch}`,\n },\n headers: {\n \"X-Ledger-Client-Version\": `context-module/${PACKAGE.version}`,\n },\n });\n dto = response.data;\n } catch (error) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Failed to fetch transaction informations: ${error}`,\n ),\n );\n }\n\n if (!Array.isArray(dto)) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Response is not an array`,\n ),\n );\n }\n\n if (dto.length === 0) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: No data for contract ${address} and selector ${selector}`,\n ),\n );\n }\n\n for (const calldata of dto) {\n // Normalize the address and selector\n address = address.toLowerCase();\n selector = `0x${selector.slice(2).toLowerCase()}`;\n const calldataDescriptor =\n calldata.descriptors_calldata?.[address]?.[selector];\n\n if (\n !calldataDescriptor ||\n !this.isCalldataDescriptorV1(calldataDescriptor, this.config.cal.mode)\n ) {\n continue;\n }\n\n const infoData = calldataDescriptor.transaction_info.descriptor.data;\n const infoSignature =\n calldataDescriptor.transaction_info.descriptor.signatures[\n this.config.cal.mode\n ];\n\n const certificateInfos: PkiCertificateInfo = {\n targetDevice: deviceModelId,\n keyUsage: KeyUsage.Calldata,\n keyId: KeyId.CalCalldataKey,\n };\n const certificate: PkiCertificate | undefined =\n await this._certificateLoader.loadCertificate(certificateInfos);\n\n const info: ClearSignContextSuccess = {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: HexStringUtils.appendSignatureToPayload(\n infoData,\n infoSignature,\n INFO_SIGNATURE_TAG,\n ),\n certificate,\n };\n\n const enums: ClearSignContextSuccess[] = [];\n for (const [id, values] of Object.entries(calldataDescriptor.enums)) {\n for (const [\n value,\n { data, signatures },\n ] of Object.entries<CalldataTransactionDescriptor>(values)) {\n enums.push({\n type: ClearSignContextType.ENUM,\n id: Number(id),\n value: Number(value),\n payload: HexStringUtils.appendSignatureToPayload(\n data,\n signatures[this.config.cal.mode]!,\n INFO_SIGNATURE_TAG,\n ),\n certificate,\n });\n }\n }\n\n const fields: ClearSignContextSuccess[] = calldataDescriptor.fields.map(\n (field) => ({\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: field.descriptor,\n reference: this.getReference(field.param),\n }),\n );\n return Right([info, ...enums, ...fields]);\n }\n\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Invalid response for contract ${address} and selector ${selector}`,\n ),\n );\n }\n\n private getReference(\n param: CalldataDescriptorParam,\n ): ClearSignContextReference | undefined {\n if (\n param.type === \"TOKEN_AMOUNT\" &&\n param.token !== undefined &&\n param.token.type === \"path\"\n ) {\n return {\n type: ClearSignContextType.TOKEN,\n valuePath: this.toGenericPath(param.token.binary_path),\n };\n } else if (\n param.type === \"TOKEN_AMOUNT\" &&\n param.token !== undefined &&\n param.token.type === \"constant\"\n ) {\n return {\n type: ClearSignContextType.TOKEN,\n value: param.token.value,\n };\n } else if (param.type === \"NFT\" && param.collection.type === \"path\") {\n return {\n type: ClearSignContextType.NFT,\n valuePath: this.toGenericPath(param.collection.binary_path),\n };\n } else if (param.type === \"NFT\" && param.collection.type === \"constant\") {\n return {\n type: ClearSignContextType.NFT,\n value: param.collection.value,\n };\n } else if (param.type === \"TRUSTED_NAME\" && param.value.type === \"path\") {\n return {\n type: ClearSignContextType.TRUSTED_NAME,\n valuePath: this.toGenericPath(param.value.binary_path),\n types: param.types,\n sources: param.sources,\n };\n } else if (param.type === \"ENUM\" && param.value.type === \"path\") {\n return {\n type: ClearSignContextType.ENUM,\n valuePath: this.toGenericPath(param.value.binary_path),\n id: param.id,\n };\n }\n return undefined;\n }\n\n private toGenericPath(\n path: CalldataDescriptorContainerPathV1 | CalldataDescriptorPathElementsV1,\n ): GenericPath {\n if (path.type === \"CONTAINER\") {\n return path.value;\n }\n return path.elements.map((element) => {\n if (element.type === \"ARRAY\") {\n const { weight: itemSize, ...rest } = element;\n return {\n itemSize,\n ...rest,\n };\n } else if (element.type === \"LEAF\") {\n const { leaf_type: leafType, ...rest } = element;\n return {\n leafType,\n ...rest,\n };\n }\n return element;\n });\n }\n\n private isCalldataDescriptorV1(\n data: CalldataDescriptor,\n mode: ContextModuleCalMode,\n ): data is CalldataDescriptorV1 & {\n transaction_info: {\n descriptor: {\n signatures: { [key in ContextModuleCalMode]: string };\n };\n };\n } {\n return (\n typeof data === \"object\" &&\n data.type === \"calldata\" &&\n data.version === \"v1\" &&\n this.isTransactionInfoV1(data.transaction_info, mode) &&\n this.isEnumV1(data.enums, mode) &&\n Array.isArray(data.fields) &&\n data.fields.every((f) => this.isFieldV1(f))\n );\n }\n\n private isTransactionInfoV1(\n data: CalldataTransactionInfoV1,\n mode: ContextModuleCalMode,\n ): data is CalldataTransactionInfoV1 & {\n descriptor: {\n signatures: { [key in ContextModuleCalMode]: string };\n };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.descriptor === \"object\" &&\n typeof data.descriptor.data === \"string\" &&\n typeof data.descriptor.signatures === \"object\" &&\n typeof data.descriptor.signatures[mode] === \"string\"\n );\n }\n\n private isEnumV1(\n calldata: CalldataEnumV1,\n mode: ContextModuleCalMode,\n ): calldata is CalldataEnumV1 {\n return (\n typeof calldata === \"object\" &&\n Object.entries(calldata).every(\n ([id, values]) =>\n typeof id === \"string\" &&\n typeof values === \"object\" &&\n Object.entries<CalldataTransactionDescriptor>(values).every(\n ([value, obj]) =>\n typeof value === \"string\" &&\n typeof obj === \"object\" &&\n typeof obj.data === \"string\" &&\n obj.signatures !== undefined &&\n this.isCalldataSignatures(obj.signatures, mode),\n ),\n )\n );\n }\n\n private isCalldataSignatures(\n data: CalldataSignatures,\n mode: ContextModuleCalMode,\n ): data is CalldataSignatures & { [key in ContextModuleCalMode]: string } {\n return typeof data === \"object\" && typeof data[mode] === \"string\";\n }\n\n private isFieldV1(data: CalldataFieldV1): boolean {\n return (\n typeof data === \"object\" &&\n typeof data.descriptor === \"string\" &&\n typeof data.param === \"object\" &&\n typeof data.param.value === \"object\" &&\n this.isDescriptorValueV1(data.param.value) &&\n (data.param.type === \"RAW\" ||\n data.param.type === \"AMOUNT\" ||\n data.param.type === \"DATETIME\" ||\n data.param.type === \"DURATION\" ||\n data.param.type === \"UNIT\" ||\n data.param.type === \"ENUM\" ||\n (data.param.type === \"NFT\" &&\n this.isDescriptorValueV1(data.param.collection)) ||\n (data.param.type === \"TOKEN_AMOUNT\" &&\n (data.param.token === undefined ||\n this.isDescriptorValueV1(data.param.token))) ||\n (data.param.type === \"TRUSTED_NAME\" &&\n Array.isArray(data.param.types) &&\n Array.isArray(data.param.sources) &&\n data.param.types.every((t) => typeof t === \"string\") &&\n data.param.sources.every((t) => typeof t === \"string\")))\n );\n }\n\n private isDescriptorValueV1(data: CalldataDescriptorValueV1): boolean {\n return (\n typeof data === \"object\" &&\n typeof data.type_family === \"string\" &&\n [\n \"UINT\",\n \"INT\",\n \"UFIXED\",\n \"FIXED\",\n \"ADDRESS\",\n \"BOOL\",\n \"BYTES\",\n \"STRING\",\n ].includes(data.type_family) &&\n (typeof data.type_size === \"undefined\" ||\n typeof data.type_size === \"number\") &&\n ((data.type === \"path\" &&\n this.isCalldataDescriptorValueBinaryPathV1(data)) ||\n (data.type === \"constant\" &&\n this.isCalldataDescriptorValueConstantV1(data)))\n );\n }\n\n private isCalldataDescriptorValueConstantV1(\n data: CalldataDescriptorValueConstantV1,\n ): boolean {\n return (\n typeof data === \"object\" &&\n data.type === \"constant\" &&\n typeof data.value === \"string\"\n );\n }\n\n private isCalldataDescriptorValueBinaryPathV1(\n data: CalldataDescriptorValueBinaryPathV1,\n ): boolean {\n return (\n typeof data === \"object\" &&\n ((data.type === \"path\" &&\n data.binary_path.type === \"CONTAINER\" &&\n [\"FROM\", \"TO\", \"VALUE\"].includes(data.binary_path.value)) ||\n (data.binary_path.type === \"DATA\" &&\n Array.isArray(data.binary_path.elements) &&\n data.binary_path.elements.every((e) => this.isPathElementV1(e))))\n );\n }\n\n private isPathElementV1(data: CalldataDescriptorPathElementV1): boolean {\n return (\n typeof data === \"object\" &&\n (data.type === \"REF\" ||\n (data.type === \"TUPLE\" && typeof data.offset === \"number\") ||\n (data.type === \"ARRAY\" &&\n typeof data.weight === \"number\" &&\n (typeof data.start === \"undefined\" ||\n typeof data.start === \"number\") &&\n (typeof data.end === \"undefined\" || typeof data.end === \"number\")) ||\n (data.type === \"LEAF\" &&\n typeof data.leaf_type === \"string\" &&\n [\"ARRAY_LEAF\", \"TUPLE_LEAF\", \"STATIC_LEAF\", \"DYNAMIC_LEAF\"].includes(\n data.leaf_type,\n )) ||\n (data.type === \"SLICE\" &&\n (typeof data.start === \"undefined\" ||\n typeof data.start === \"number\") &&\n (typeof data.end === \"undefined\" || typeof data.end === \"number\")))\n );\n }\n}\n"],
5
- "mappings": "qtBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkB,oBAClBC,EAAmC,qBACnCC,EAAoC,qBAEpCC,EAA4B,mCAK5BC,EAAyB,6BAEzBC,EAAsB,6BACtBC,EAAyB,gCAGzBC,EAIO,2CAEPC,EAAmC,wCACnCC,EAA+B,yCAC/BC,EAAoB,iCAyBb,IAAMC,EAAN,KAAiE,CACtE,YAC+CC,EAE5BC,EACjB,CAH6C,YAAAD,EAE5B,wBAAAC,CAChB,CAEH,MAAa,0BAA0B,CACrC,QAAAC,EACA,QAAAC,EACA,SAAAC,EACA,cAAAC,CACF,EAEE,CACA,IAAIC,EACJ,GAAI,CAcFA,GAbiB,MAAM,EAAAC,QAAM,QAAuB,CAClD,OAAQ,MACR,IAAK,GAAG,KAAK,OAAO,IAAI,GAAG,SAC3B,OAAQ,CACN,OAAQ,uBACR,SAAUL,EACV,UAAWC,EACX,IAAK,UAAU,KAAK,OAAO,IAAI,MAAM,EACvC,EACA,QAAS,CACP,0BAA2B,kBAAkB,EAAAK,QAAQ,OAAO,EAC9D,CACF,CAAC,GACc,IACjB,OAASC,EAAO,CACd,SAAO,QACL,IAAI,MACF,wFAAwFA,CAAK,EAC/F,CACF,CACF,CAEA,GAAI,CAAC,MAAM,QAAQH,CAAG,EACpB,SAAO,QACL,IAAI,MACF,qEACF,CACF,EAGF,GAAIA,EAAI,SAAW,EACjB,SAAO,QACL,IAAI,MACF,mEAAmEH,CAAO,iBAA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AAK,QAAW,WACtB,OAAOA,EAAK,MAAU,KACrB,OAAOA,EAAK,OAAU,YACvB,OAAOA,EAAK,IAAQ,KAAe,OAAOA,EAAK,KAAQ,WACzDA,EAAK,OAAS,QACb,OAAOA,EAAK,WAAc,UAC1B,CAAC,aAAc,aAAc,cAAe,cAAc,EAAE,SAC1DA,EAAK,SACP,GACDA,EAAK,OAAS,UACZ,OAAOA,EAAK,MAAU,KACrB,OAAOA,EAAK,OAAU,YACvB,OAAOA,EAAK,IAAQ,KAAe,OAAOA,EAAK,KAAQ,UAEhE,CACF,EA3WatB,EAANoC,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,cAAY,MAAM,GACzBA,EAAA,eAAO,WAAS,oBAAoB,IAH5BrC",
6
- "names": ["HttpTransactionDataSource_exports", "__export", "HttpTransactionDataSource", "__toCommonJS", "import_axios", "import_inversify", "import_purify_ts", "import_configTypes", "import_pkiTypes", "import_KeyId", "import_KeyUsage", "import_ClearSignContext", "import_SignatureTags", "import_HexStringUtils", "import_package", "HttpTransactionDataSource", "config", "_certificateLoader", "chainId", "address", "selector", "deviceModelId", "dto", "axios", "PACKAGE", "error", "calldata", "calldataDescriptor", "infoData", "infoSignature", "certificateInfos", "certificate", "info", "enums", "id", "values", "value", "data", "signatures", "fields", "field", "param", "path", "element", "itemSize", "rest", "leafType", "mode", "f", "obj", "e", "__decorateClass", "__decorateParam"]
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport {\n type ContextModuleCalMode,\n type ContextModuleConfig,\n} from \"@/config/model/ContextModuleConfig\";\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport { PkiCertificateInfo } from \"@/pki/model/PkiCertificateInfo\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport {\n ClearSignContextReference,\n ClearSignContextSuccess,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { GenericPath } from \"@/shared/model/GenericPath\";\nimport { INFO_SIGNATURE_TAG } from \"@/shared/model/SignatureTags\";\nimport { HexStringUtils } from \"@/shared/utils/HexStringUtils\";\nimport PACKAGE from \"@root/package.json\";\n\nimport {\n CalldataDescriptor,\n CalldataDescriptorContainerPathV1,\n CalldataDescriptorParam,\n CalldataDescriptorPathElementsV1,\n CalldataDescriptorPathElementV1,\n CalldataDescriptorV1,\n CalldataDescriptorValueBinaryPathV1,\n CalldataDescriptorValueConstantV1,\n CalldataDescriptorValueV1,\n CalldataDto,\n CalldataEnumV1,\n CalldataFieldV1,\n CalldataSignatures,\n CalldataTransactionDescriptor,\n CalldataTransactionInfoV1,\n} from \"./dto/CalldataDto\";\nimport {\n GetTransactionDescriptorsParams,\n TransactionDataSource,\n} from \"./TransactionDataSource\";\n\n@injectable()\nexport class HttpTransactionDataSource implements TransactionDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly _certificateLoader: PkiCertificateLoader,\n ) {}\n\n public async getTransactionDescriptors({\n chainId,\n address,\n selector,\n deviceModelId,\n }: GetTransactionDescriptorsParams): Promise<\n Either<Error, ClearSignContextSuccess[]>\n > {\n let dto: CalldataDto[] | undefined;\n try {\n const response = await axios.request<CalldataDto[]>({\n method: \"GET\",\n url: `${this.config.cal.url}/dapps`,\n params: {\n output: \"descriptors_calldata\",\n chain_id: chainId,\n contracts: address,\n ref: `branch:${this.config.cal.branch}`,\n },\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n });\n dto = response.data;\n } catch (error) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Failed to fetch transaction informations: ${error}`,\n ),\n );\n }\n\n if (!Array.isArray(dto)) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Response is not an array`,\n ),\n );\n }\n\n if (dto.length === 0) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: No data for contract ${address} and selector ${selector}`,\n ),\n );\n }\n\n for (const calldata of dto) {\n // Normalize the address and selector\n address = address.toLowerCase();\n selector = `0x${selector.slice(2).toLowerCase()}`;\n const calldataDescriptor =\n calldata.descriptors_calldata?.[address]?.[selector];\n\n if (\n !calldataDescriptor ||\n !this.isCalldataDescriptorV1(calldataDescriptor, this.config.cal.mode)\n ) {\n continue;\n }\n\n const infoData = calldataDescriptor.transaction_info.descriptor.data;\n const infoSignature =\n calldataDescriptor.transaction_info.descriptor.signatures[\n this.config.cal.mode\n ];\n\n const certificateInfos: PkiCertificateInfo = {\n targetDevice: deviceModelId,\n keyUsage: KeyUsage.Calldata,\n keyId: KeyId.CalCalldataKey,\n };\n const certificate: PkiCertificate | undefined =\n await this._certificateLoader.loadCertificate(certificateInfos);\n\n const info: ClearSignContextSuccess = {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: HexStringUtils.appendSignatureToPayload(\n infoData,\n infoSignature,\n INFO_SIGNATURE_TAG,\n ),\n certificate,\n };\n\n const enums: ClearSignContextSuccess[] = [];\n for (const [id, values] of Object.entries(calldataDescriptor.enums)) {\n for (const [\n value,\n { data, signatures },\n ] of Object.entries<CalldataTransactionDescriptor>(values)) {\n enums.push({\n type: ClearSignContextType.ENUM,\n id: Number(id),\n value: Number(value),\n payload: HexStringUtils.appendSignatureToPayload(\n data,\n signatures[this.config.cal.mode]!,\n INFO_SIGNATURE_TAG,\n ),\n certificate,\n });\n }\n }\n\n const fields: ClearSignContextSuccess[] = calldataDescriptor.fields.map(\n (field) => ({\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: field.descriptor,\n reference: this.getReference(field.param),\n }),\n );\n return Right([info, ...enums, ...fields]);\n }\n\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Invalid response for contract ${address} and selector ${selector}`,\n ),\n );\n }\n\n private getReference(\n param: CalldataDescriptorParam,\n ): ClearSignContextReference | undefined {\n if (\n param.type === \"TOKEN_AMOUNT\" &&\n param.token !== undefined &&\n param.token.type === \"path\"\n ) {\n return {\n type: ClearSignContextType.TOKEN,\n valuePath: this.toGenericPath(param.token.binary_path),\n };\n } else if (\n param.type === \"TOKEN_AMOUNT\" &&\n param.token !== undefined &&\n param.token.type === \"constant\"\n ) {\n return {\n type: ClearSignContextType.TOKEN,\n value: param.token.value,\n };\n } else if (param.type === \"NFT\" && param.collection.type === \"path\") {\n return {\n type: ClearSignContextType.NFT,\n valuePath: this.toGenericPath(param.collection.binary_path),\n };\n } else if (param.type === \"NFT\" && param.collection.type === \"constant\") {\n return {\n type: ClearSignContextType.NFT,\n value: param.collection.value,\n };\n } else if (param.type === \"TRUSTED_NAME\" && param.value.type === \"path\") {\n return {\n type: ClearSignContextType.TRUSTED_NAME,\n valuePath: this.toGenericPath(param.value.binary_path),\n types: param.types,\n sources: param.sources,\n };\n } else if (param.type === \"ENUM\" && param.value.type === \"path\") {\n return {\n type: ClearSignContextType.ENUM,\n valuePath: this.toGenericPath(param.value.binary_path),\n id: param.id,\n };\n }\n return undefined;\n }\n\n private toGenericPath(\n path: CalldataDescriptorContainerPathV1 | CalldataDescriptorPathElementsV1,\n ): GenericPath {\n if (path.type === \"CONTAINER\") {\n return path.value;\n }\n return path.elements.map((element) => {\n if (element.type === \"ARRAY\") {\n const { weight: itemSize, ...rest } = element;\n return {\n itemSize,\n ...rest,\n };\n } else if (element.type === \"LEAF\") {\n const { leaf_type: leafType, ...rest } = element;\n return {\n leafType,\n ...rest,\n };\n }\n return element;\n });\n }\n\n private isCalldataDescriptorV1(\n data: CalldataDescriptor,\n mode: ContextModuleCalMode,\n ): data is CalldataDescriptorV1 & {\n transaction_info: {\n descriptor: {\n signatures: { [_key in ContextModuleCalMode]: string };\n };\n };\n } {\n return (\n typeof data === \"object\" &&\n data.type === \"calldata\" &&\n data.version === \"v1\" &&\n this.isTransactionInfoV1(data.transaction_info, mode) &&\n this.isEnumV1(data.enums, mode) &&\n Array.isArray(data.fields) &&\n data.fields.every((f) => this.isFieldV1(f))\n );\n }\n\n private isTransactionInfoV1(\n data: CalldataTransactionInfoV1,\n mode: ContextModuleCalMode,\n ): data is CalldataTransactionInfoV1 & {\n descriptor: {\n signatures: { [_key in ContextModuleCalMode]: string };\n };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.descriptor === \"object\" &&\n typeof data.descriptor.data === \"string\" &&\n typeof data.descriptor.signatures === \"object\" &&\n typeof data.descriptor.signatures[mode] === \"string\"\n );\n }\n\n private isEnumV1(\n calldata: CalldataEnumV1,\n mode: ContextModuleCalMode,\n ): calldata is CalldataEnumV1 {\n return (\n typeof calldata === \"object\" &&\n Object.entries(calldata).every(\n ([id, values]) =>\n typeof id === \"string\" &&\n typeof values === \"object\" &&\n Object.entries<CalldataTransactionDescriptor>(values).every(\n ([value, obj]) =>\n typeof value === \"string\" &&\n typeof obj === \"object\" &&\n typeof obj.data === \"string\" &&\n obj.signatures !== undefined &&\n this.isCalldataSignatures(obj.signatures, mode),\n ),\n )\n );\n }\n\n private isCalldataSignatures(\n data: CalldataSignatures,\n mode: ContextModuleCalMode,\n ): data is CalldataSignatures & { [_key in ContextModuleCalMode]: string } {\n return typeof data === \"object\" && typeof data[mode] === \"string\";\n }\n\n private isFieldV1(data: CalldataFieldV1): boolean {\n return (\n typeof data === \"object\" &&\n typeof data.descriptor === \"string\" &&\n typeof data.param === \"object\" &&\n typeof data.param.value === \"object\" &&\n this.isDescriptorValueV1(data.param.value) &&\n (data.param.type === \"RAW\" ||\n data.param.type === \"AMOUNT\" ||\n data.param.type === \"DATETIME\" ||\n data.param.type === \"DURATION\" ||\n data.param.type === \"UNIT\" ||\n data.param.type === \"ENUM\" ||\n (data.param.type === \"NFT\" &&\n this.isDescriptorValueV1(data.param.collection)) ||\n (data.param.type === \"TOKEN_AMOUNT\" &&\n (data.param.token === undefined ||\n this.isDescriptorValueV1(data.param.token))) ||\n (data.param.type === \"TRUSTED_NAME\" &&\n Array.isArray(data.param.types) &&\n Array.isArray(data.param.sources) &&\n data.param.types.every((t) => typeof t === \"string\") &&\n data.param.sources.every((t) => typeof t === \"string\")))\n );\n }\n\n private isDescriptorValueV1(data: CalldataDescriptorValueV1): boolean {\n return (\n typeof data === \"object\" &&\n typeof data.type_family === \"string\" &&\n [\n \"UINT\",\n \"INT\",\n \"UFIXED\",\n \"FIXED\",\n \"ADDRESS\",\n \"BOOL\",\n \"BYTES\",\n \"STRING\",\n ].includes(data.type_family) &&\n (typeof data.type_size === \"undefined\" ||\n typeof data.type_size === \"number\") &&\n ((data.type === \"path\" &&\n this.isCalldataDescriptorValueBinaryPathV1(data)) ||\n (data.type === \"constant\" &&\n this.isCalldataDescriptorValueConstantV1(data)))\n );\n }\n\n private isCalldataDescriptorValueConstantV1(\n data: CalldataDescriptorValueConstantV1,\n ): boolean {\n return (\n typeof data === \"object\" &&\n data.type === \"constant\" &&\n typeof data.value === \"string\"\n );\n }\n\n private isCalldataDescriptorValueBinaryPathV1(\n data: CalldataDescriptorValueBinaryPathV1,\n ): boolean {\n return (\n typeof data === \"object\" &&\n ((data.type === \"path\" &&\n data.binary_path.type === \"CONTAINER\" &&\n [\"FROM\", \"TO\", \"VALUE\"].includes(data.binary_path.value)) ||\n (data.binary_path.type === \"DATA\" &&\n Array.isArray(data.binary_path.elements) &&\n data.binary_path.elements.every((e) => this.isPathElementV1(e))))\n );\n }\n\n private isPathElementV1(data: CalldataDescriptorPathElementV1): boolean {\n return (\n typeof data === \"object\" &&\n (data.type === \"REF\" ||\n (data.type === \"TUPLE\" && typeof data.offset === \"number\") ||\n (data.type === \"ARRAY\" &&\n typeof data.weight === \"number\" &&\n (typeof data.start === \"undefined\" ||\n typeof data.start === \"number\") &&\n (typeof data.end === \"undefined\" || typeof data.end === \"number\")) ||\n (data.type === \"LEAF\" &&\n typeof data.leaf_type === \"string\" &&\n [\"ARRAY_LEAF\", \"TUPLE_LEAF\", \"STATIC_LEAF\", \"DYNAMIC_LEAF\"].includes(\n data.leaf_type,\n )) ||\n (data.type === \"SLICE\" &&\n (typeof data.start === \"undefined\" ||\n typeof data.start === \"number\") &&\n (typeof data.end === \"undefined\" || typeof data.end === \"number\")))\n );\n }\n}\n"],
5
+ "mappings": "qtBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkB,oBAClBC,EAAmC,qBACnCC,EAAoC,qBAEpCC,EAA4B,mCAK5BC,EAAyB,6BAEzBC,EAAsB,6BACtBC,EAAyB,gCAGzBC,EAGO,yCACPC,EAIO,2CAEPC,EAAmC,wCACnCC,EAA+B,yCAC/BC,EAAoB,iCAyBb,IAAMC,EAAN,KAAiE,CACtE,YAC+CC,EAE5BC,EACjB,CAH6C,YAAAD,EAE5B,wBAAAC,CAChB,CAEH,MAAa,0BAA0B,CACrC,QAAAC,EACA,QAAAC,EACA,SAAAC,EACA,cAAAC,CACF,EAEE,CACA,IAAIC,EACJ,GAAI,CAeFA,GAdiB,MAAM,EAAAC,QAAM,QAAuB,CAClD,OAAQ,MACR,IAAK,GAAG,KAAK,OAAO,IAAI,GAAG,SAC3B,OAAQ,CACN,OAAQ,uBACR,SAAUL,EACV,UAAWC,EACX,IAAK,UAAU,KAAK,OAAO,IAAI,MAAM,EACvC,EACA,QAAS,CACP,CAAC,8BAA4B,EAAG,kBAAkB,EAAAK,QAAQ,OAAO,GACjE,CAAC,4BAA0B,EAAG,KAAK,OAAO,WAC5C,CACF,CAAC,GACc,IACjB,OAASC,EAAO,CACd,SAAO,QACL,IAAI,MACF,wFAAwF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AK,gBAAgBA,CAAC,CAAC,EAEtE,CAEQ,gBAAgBb,EAAgD,CACtE,OACE,OAAOA,GAAS,WACfA,EAAK,OAAS,OACZA,EAAK,OAAS,SAAW,OAAOA,EAAK,QAAW,UAChDA,EAAK,OAAS,SACb,OAAOA,EAAK,QAAW,WACtB,OAAOA,EAAK,MAAU,KACrB,OAAOA,EAAK,OAAU,YACvB,OAAOA,EAAK,IAAQ,KAAe,OAAOA,EAAK,KAAQ,WACzDA,EAAK,OAAS,QACb,OAAOA,EAAK,WAAc,UAC1B,CAAC,aAAc,aAAc,cAAe,cAAc,EAAE,SAC1DA,EAAK,SACP,GACDA,EAAK,OAAS,UACZ,OAAOA,EAAK,MAAU,KACrB,OAAOA,EAAK,OAAU,YACvB,OAAOA,EAAK,IAAQ,KAAe,OAAOA,EAAK,KAAQ,UAEhE,CACF,EA5WatB,EAANoC,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,cAAY,MAAM,GACzBA,EAAA,eAAO,WAAS,oBAAoB,IAH5BrC",
6
+ "names": ["HttpTransactionDataSource_exports", "__export", "HttpTransactionDataSource", "__toCommonJS", "import_axios", "import_inversify", "import_purify_ts", "import_configTypes", "import_pkiTypes", "import_KeyId", "import_KeyUsage", "import_HttpHeaders", "import_ClearSignContext", "import_SignatureTags", "import_HexStringUtils", "import_package", "HttpTransactionDataSource", "config", "_certificateLoader", "chainId", "address", "selector", "deviceModelId", "dto", "axios", "PACKAGE", "error", "calldata", "calldataDescriptor", "infoData", "infoSignature", "certificateInfos", "certificate", "info", "enums", "id", "values", "value", "data", "signatures", "fields", "field", "param", "path", "element", "itemSize", "rest", "leafType", "mode", "f", "obj", "e", "__decorateClass", "__decorateParam"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var A=Object.create;var T=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var _=(t,d,f,l)=>{if(d&&typeof d=="object"||typeof d=="function")for(let p of O(d))!w.call(t,p)&&p!==f&&T(t,p,{get:()=>d[p],enumerable:!(l=F(d,p))||l.enumerable});return t};var D=(t,d,f)=>(f=t!=null?A(R(t)):{},_(d||!t||!t.__esModule?T(f,"default",{value:t,enumerable:!0}):f,t));var o=require("@ledgerhq/device-management-kit"),r=D(require("axios")),i=require("purify-ts"),h=require("../../transaction/data/HttpTransactionDataSource"),I=D(require("../../../package.json"));vi.mock("axios");describe("HttpTransactionDataSource",()=>{let t,d,f,l,p,m,b,y,u,v,x;const c={loadCertificate:vi.fn()};beforeAll(()=>{vi.clearAllMocks();const e={cal:{url:"https://crypto-assets-service.api.ledger.com/v1",mode:"test",branch:"main"}};t=new h.HttpTransactionDataSource(e,c),d={descriptor:{data:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c",signatures:{test:"3045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f"}}},f={0:{1:{data:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec0401000501010606737461626c65",signatures:{test:"3045022100862e724db664f5d94484928a6a5963268a22cd8178ad36e8c4ff13769ac5c27e0220079da2b6e86810156f6b5955b8190bc016c2fe813d27fcb878a9b99658546582"}},2:{data:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04010005010206087661726961626c65",signatures:{test:"3045022100b838ee3d597d6bad2533606cef7335f6c8a45b46d5717803e646777f6c8a6897022074f04b82c3dad8445bb6230ab762010c5fc6ee06198fd3e54752287cbf95c523"}}}},b=E("FROM","UFIXED","AMOUNT","06"),y=E("TO","FIXED","DATETIME","07"),u=E("TO","BOOL","UNIT","08"),v=E("VALUE","INT","DURATION","09"),l={param:{value:{type:"path",binary_path:{type:"DATA",elements:[{type:"TUPLE",offset:0},{type:"LEAF",leaf_type:"STATIC_LEAF"}]},type_family:"UINT",type_size:32},type:"TOKEN_AMOUNT",token:{type:"path",binary_path:{type:"DATA",elements:[{type:"ARRAY",start:0,end:5,weight:1},{type:"LEAF",leaf_type:"DYNAMIC_LEAF"}]},type_family:"ADDRESS",type_size:20}},descriptor:"0001000112416d6f756e7420746f20776974686472617702010203580001000115000100010101020120030a000100010200010401030215000100010105020114030a000100010200000401030420ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff05034d6178"},p={param:{value:{type:"path",binary_path:{type:"CONTAINER",value:"TO"},type_family:"STRING",type_size:20},type:"TRUSTED_NAME",types:["eoa"],sources:["ens","unstoppable_domain"]},descriptor:"000100010c546f20726563697069656e7402010803230001000115000100010105020114030a00010001020002040103020101030402030402"},m={param:{value:{type:"path",binary_path:{type:"DATA",elements:[{type:"ARRAY",weight:2},{type:"LEAF",leaf_type:"TUPLE_LEAF"},{type:"SLICE",end:2}]},type_family:"BYTES",type_size:20},collection:{type:"path",binary_path:{type:"DATA",elements:[{type:"REF"},{type:"LEAF",leaf_type:"ARRAY_LEAF"},{type:"SLICE",start:1}]},type_family:"INT",type_size:20},type:"NFT"},descriptor:"000100010c546f20726563697069656e7402010803230001000115000100010105020114"},x={param:{id:0,value:{type:"path",binary_path:{type:"DATA",elements:[]},type_family:"BYTES",type_size:20},type:"ENUM"},descriptor:"000100010c546f20726563697069656e7402010803230001000115000100010105020112"}});function E(e,a,n,C){return{param:{value:{type:"path",binary_path:{type:"CONTAINER",value:e},type_family:a,type_size:32},type:n},descriptor:C}}function s(e,a,n){return{descriptors_calldata:{"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9":{"0x69328dec":{type:"calldata",version:"v1",transaction_info:e,enums:a,fields:n}}}}}it("should call axios with the ledger client version header",async()=>{const e=`context-module/${I.default.version}`,a=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(r.default,"request").mockImplementation(a),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0),await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x0abc",selector:"0x01ff"}),expect(a).toHaveBeenCalledWith(expect.objectContaining({headers:{"X-Ledger-Client-Version":e}}))}),it("should return an error when axios throws an error",async()=>{vi.spyOn(r.default,"request").mockRejectedValue(new Error),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const e=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Failed to fetch transaction informations: Error")))}),it("should return an error when no payload is returned",async()=>{const e={data:{test:""}};vi.spyOn(r.default,"request").mockResolvedValue(e),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const a=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x0abc",selector:"0x01ff"});expect(a).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Response is not an array")))}),it("should return an error when an empty array is returned",async()=>{vi.spyOn(r.default,"request").mockResolvedValue({data:[]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const e=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: No data for contract 0x0abc and selector 0x01ff")))}),it("should return an error when selector is not found",async()=>{const e=s(d,f,[l]);vi.spyOn(r.default,"request").mockResolvedValue({data:[e]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const a=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x01fe"});expect(a).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x01fe")))}),it("Calldata with fields references and enums",async()=>{const e=s(d,f,[l,p,m,x]);vi.spyOn(r.default,"request").mockResolvedValue({data:[e]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const a=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80B7a3454c06bdac94a69ddc7a9",selector:"0x69328dEc"});expect(a.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{payload:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec0401000501010606737461626c6581ff473045022100862e724db664f5d94484928a6a5963268a22cd8178ad36e8c4ff13769ac5c27e0220079da2b6e86810156f6b5955b8190bc016c2fe813d27fcb878a9b99658546582",type:"enum",id:0,value:1},{payload:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04010005010206087661726961626c6581ff473045022100b838ee3d597d6bad2533606cef7335f6c8a45b46d5717803e646777f6c8a6897022074f04b82c3dad8445bb6230ab762010c5fc6ee06198fd3e54752287cbf95c523",type:"enum",id:0,value:2},{payload:l.descriptor,type:"transactionFieldDescription",reference:{type:"token",valuePath:[{type:"ARRAY",start:0,end:5,itemSize:1},{type:"LEAF",leafType:"DYNAMIC_LEAF"}]}},{payload:p.descriptor,type:"transactionFieldDescription",reference:{type:"trustedName",valuePath:"TO",types:["eoa"],sources:["ens","unstoppable_domain"]}},{payload:m.descriptor,type:"transactionFieldDescription",reference:{type:"nft",valuePath:[{type:"REF"},{type:"LEAF",leafType:"ARRAY_LEAF"},{type:"SLICE",start:1}]}},{payload:x.descriptor,type:"transactionFieldDescription",reference:{type:"enum",valuePath:[],id:0}}])}),it("Calldata with fields references and enums with certificates",async()=>{const e=s(d,f,[l,p,m,x]),a={keyUsageNumber:11,payload:new Uint8Array([1,2,3,4,21,4,5,6,7,8])};vi.spyOn(r.default,"request").mockResolvedValue({data:[e]}),vi.spyOn(c,"loadCertificate").mockResolvedValueOnce(a);const n=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80B7a3454c06bdac94a69ddc7a9",selector:"0x69328dEc"});expect(n.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo",certificate:a},{payload:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec0401000501010606737461626c6581ff473045022100862e724db664f5d94484928a6a5963268a22cd8178ad36e8c4ff13769ac5c27e0220079da2b6e86810156f6b5955b8190bc016c2fe813d27fcb878a9b99658546582",type:"enum",id:0,value:1,certificate:a},{payload:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04010005010206087661726961626c6581ff473045022100b838ee3d597d6bad2533606cef7335f6c8a45b46d5717803e646777f6c8a6897022074f04b82c3dad8445bb6230ab762010c5fc6ee06198fd3e54752287cbf95c523",type:"enum",id:0,value:2,certificate:a},{payload:l.descriptor,type:"transactionFieldDescription",reference:{type:"token",valuePath:[{type:"ARRAY",start:0,end:5,itemSize:1},{type:"LEAF",leafType:"DYNAMIC_LEAF"}]}},{payload:p.descriptor,type:"transactionFieldDescription",reference:{type:"trustedName",valuePath:"TO",types:["eoa"],sources:["ens","unstoppable_domain"]}},{payload:m.descriptor,type:"transactionFieldDescription",reference:{type:"nft",valuePath:[{type:"REF"},{type:"LEAF",leafType:"ARRAY_LEAF"},{type:"SLICE",start:1}]}},{payload:x.descriptor,type:"transactionFieldDescription",reference:{type:"enum",valuePath:[],id:0}}])}),it("Calldata without fields references",async()=>{const e=s(d,[],[b,y,u,v]);vi.spyOn(r.default,"request").mockResolvedValue({data:[e]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const a=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(a.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{type:"transactionFieldDescription",payload:b.descriptor},{type:"transactionFieldDescription",payload:y.descriptor},{type:"transactionFieldDescription",payload:u.descriptor},{type:"transactionFieldDescription",payload:v.descriptor}])}),it("Calldata on third array element",async()=>{const e=s(d,[],[b,y,u,v]);vi.spyOn(r.default,"request").mockResolvedValue({data:[{},{},e]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const a=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(a.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{type:"transactionFieldDescription",payload:b.descriptor},{type:"transactionFieldDescription",payload:y.descriptor},{type:"transactionFieldDescription",payload:u.descriptor},{type:"transactionFieldDescription",payload:v.descriptor}])}),it("Calldata without fields references and transaction info signature length % 2 different from 0",async()=>{const e={descriptor:{data:d.descriptor.data,signatures:{test:d.descriptor.signatures.test+"0"}}},a=s(e,[],[b,y,u,v]);vi.spyOn(r.default,"request").mockResolvedValue({data:[a]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const n=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(n.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff4803045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f0",type:"transactionInfo"},{type:"transactionFieldDescription",payload:b.descriptor},{type:"transactionFieldDescription",payload:y.descriptor},{type:"transactionFieldDescription",payload:u.descriptor},{type:"transactionFieldDescription",payload:v.descriptor}])}),it("Calldata with token fields references as constants",async()=>{const e={name:"Amount to exchange",param:{type:"TOKEN_AMOUNT",token:{raw:"0xae7ab96520de3a18e5e111b5eaab095312d7fe84",type:"constant",value:"0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84",version:1,type_size:20,type_family:"ADDRESS"},value:{type:"path",version:1,abi_path:{type:"data",absolute:!0,elements:[{type:"field",identifier:"_stETHAmount"}]},type_size:32,binary_path:{type:"DATA",version:1,elements:[{type:"TUPLE",offset:0},{type:"LEAF",leaf_type:"STATIC_LEAF"}]},type_family:"UINT"},version:1},version:1,descriptor:"0001010112416d6f756e7420746f2065786368616e6765020102033b0001010115000101010101020120030a00010101020000040103021f0001010101050201140514ae7ab96520de3a18e5e111b5eaab095312d7fe84"},a=s(d,[],[e]);vi.spyOn(r.default,"request").mockResolvedValue({data:[a]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const n=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(n.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{payload:e.descriptor,type:"transactionFieldDescription",reference:{type:"token",value:"0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84"}}])}),it("Calldata with collection fields references as constants",async()=>{const e={name:"Collection ID",param:{type:"NFT",collection:{raw:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",type:"constant",value:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",version:1,type_size:20,type_family:"ADDRESS"},value:{type:"path",version:1,abi_path:{type:"data",absolute:!0,elements:[{type:"field",identifier:"_collectionId"}]},type_size:20,binary_path:{type:"DATA",version:1,elements:[{type:"ARRAY",weight:2},{type:"LEAF",leaf_type:"TUPLE_LEAF"},{type:"SLICE",end:2}]},type_family:"BYTES"},version:1},version:1,descriptor:"0001010112416d6f756e7420746f2065786368616e6765020102033b0001010115000101010101020120030a00010101020000040103021f00010101010502011405147d2768de32b0b80b7a3454c06bdac94a69ddc7a9"},a=s(d,[],[e]);vi.spyOn(r.default,"request").mockResolvedValue({data:[a]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const n=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(n.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{payload:e.descriptor,type:"transactionFieldDescription",reference:{type:"nft",value:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9"}}])}),it("should return an error when calldata is not correctly formatted",async()=>{const e={descriptors_calldata:{"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9":{"0x69328dec":{type:"calldat",version:"v1",transaction_info:d,enums:f,fields:[l]}}}};vi.spyOn(r.default,"request").mockResolvedValue({data:[e]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const a=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(a).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when transactionInfo is not correctly formatted",async()=>{const e=s({descriptor:{data:"1234",signatures:{prod:"1234"}}},f,[l]);vi.spyOn(r.default,"request").mockResolvedValue({data:[e]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const a=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(a).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when enum is not correctly formatted",async()=>{const e=s(d,["badEnum"],[l]);vi.spyOn(r.default,"request").mockResolvedValue({data:[e]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const a=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(a).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when enum does not contain a signature",async()=>{const e=s(d,{0:{1:{data:"1234"}}},[l]);vi.spyOn(r.default,"request").mockResolvedValue({data:[e]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const a=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(a).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when enum contain the wrong signature",async()=>{const e=s(d,{0:{1:{data:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04010005010106067374626c65",signatures:{prod:"wrongSignature"}}}},[l]);vi.spyOn(r.default,"request").mockResolvedValue({data:[e]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const a=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(a).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when field is not correctly formatted",async()=>{const e=s(d,[],[{descriptor:3}]);vi.spyOn(r.default,"request").mockResolvedValue({data:[e]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const a=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(a).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when field value is not correctly formatted",async()=>{const a=s(d,[],[{param:{value:{binary_path:"TO",type_family:"UNKNOWN",type_size:20},type:"DATETIME"},descriptor:"000100010c546f20726563697069667"}]);vi.spyOn(r.default,"request").mockResolvedValue({data:[a]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const n=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(n).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when field container path is not correctly formatted",async()=>{const a=s(d,[],[{param:{value:{binary_path:"UNKNOWN",type_family:"ADDRESS",type_size:20},type:"DATETIME"},descriptor:"000100010c546f20726563697069667"}]);vi.spyOn(r.default,"request").mockResolvedValue({data:[a]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const n=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(n).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when field calldata path is not correctly formatted",async()=>{const a=s(d,[],[{param:{value:{binary_path:{elements:[{type:"UNKNOWN"}]},type_family:"ADDRESS",type_size:20},type:"DATETIME"},descriptor:"000100010c546f20726563697069667"}]);vi.spyOn(r.default,"request").mockResolvedValue({data:[a]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const n=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(n).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when field type is not correctly formatted",async()=>{const a=s(d,[],[{param:{value:{binary_path:"TO",type_family:"ADDRESS",type_size:20},type:"UNKNOWN"},descriptor:"000100010c546f20726563697069667"}]);vi.spyOn(r.default,"request").mockResolvedValue({data:[a]}),vi.spyOn(c,"loadCertificate").mockResolvedValue(void 0);const n=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(n).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))})});
1
+ "use strict";var F=Object.create;var I=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var V=(t,d,f,l)=>{if(d&&typeof d=="object"||typeof d=="function")for(let p of _(d))!k.call(t,p)&&p!==f&&I(t,p,{get:()=>d[p],enumerable:!(l=R(d,p))||l.enumerable});return t};var C=(t,d,f)=>(f=t!=null?F(w(t)):{},V(d||!t||!t.__esModule?I(f,"default",{value:t,enumerable:!0}):f,t));var o=require("@ledgerhq/device-management-kit"),c=C(require("axios")),i=require("purify-ts"),m=require("../../shared/constant/HttpHeaders"),O=require("../../transaction/data/HttpTransactionDataSource"),h=C(require("../../../package.json"));vi.mock("axios");const D={cal:{url:"https://crypto-assets-service.api.ledger.com/v1",mode:"test",branch:"main"},originToken:"originToken"};describe("HttpTransactionDataSource",()=>{let t,d,f,l,p,E,b,y,u,v,x;const r={loadCertificate:vi.fn()};beforeAll(()=>{vi.clearAllMocks(),t=new O.HttpTransactionDataSource(D,r),d={descriptor:{data:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c",signatures:{test:"3045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f"}}},f={0:{1:{data:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec0401000501010606737461626c65",signatures:{test:"3045022100862e724db664f5d94484928a6a5963268a22cd8178ad36e8c4ff13769ac5c27e0220079da2b6e86810156f6b5955b8190bc016c2fe813d27fcb878a9b99658546582"}},2:{data:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04010005010206087661726961626c65",signatures:{test:"3045022100b838ee3d597d6bad2533606cef7335f6c8a45b46d5717803e646777f6c8a6897022074f04b82c3dad8445bb6230ab762010c5fc6ee06198fd3e54752287cbf95c523"}}}},b=T("FROM","UFIXED","AMOUNT","06"),y=T("TO","FIXED","DATETIME","07"),u=T("TO","BOOL","UNIT","08"),v=T("VALUE","INT","DURATION","09"),l={param:{value:{type:"path",binary_path:{type:"DATA",elements:[{type:"TUPLE",offset:0},{type:"LEAF",leaf_type:"STATIC_LEAF"}]},type_family:"UINT",type_size:32},type:"TOKEN_AMOUNT",token:{type:"path",binary_path:{type:"DATA",elements:[{type:"ARRAY",start:0,end:5,weight:1},{type:"LEAF",leaf_type:"DYNAMIC_LEAF"}]},type_family:"ADDRESS",type_size:20}},descriptor:"0001000112416d6f756e7420746f20776974686472617702010203580001000115000100010101020120030a000100010200010401030215000100010105020114030a000100010200000401030420ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff05034d6178"},p={param:{value:{type:"path",binary_path:{type:"CONTAINER",value:"TO"},type_family:"STRING",type_size:20},type:"TRUSTED_NAME",types:["eoa"],sources:["ens","unstoppable_domain"]},descriptor:"000100010c546f20726563697069656e7402010803230001000115000100010105020114030a00010001020002040103020101030402030402"},E={param:{value:{type:"path",binary_path:{type:"DATA",elements:[{type:"ARRAY",weight:2},{type:"LEAF",leaf_type:"TUPLE_LEAF"},{type:"SLICE",end:2}]},type_family:"BYTES",type_size:20},collection:{type:"path",binary_path:{type:"DATA",elements:[{type:"REF"},{type:"LEAF",leaf_type:"ARRAY_LEAF"},{type:"SLICE",start:1}]},type_family:"INT",type_size:20},type:"NFT"},descriptor:"000100010c546f20726563697069656e7402010803230001000115000100010105020114"},x={param:{id:0,value:{type:"path",binary_path:{type:"DATA",elements:[]},type_family:"BYTES",type_size:20},type:"ENUM"},descriptor:"000100010c546f20726563697069656e7402010803230001000115000100010105020112"}});function T(a,e,n,A){return{param:{value:{type:"path",binary_path:{type:"CONTAINER",value:a},type_family:e,type_size:32},type:n},descriptor:A}}function s(a,e,n){return{descriptors_calldata:{"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9":{"0x69328dec":{type:"calldata",version:"v1",transaction_info:a,enums:e,fields:n}}}}}it("should call axios with the ledger client version header",async()=>{const a=`context-module/${h.default.version}`,e=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(c.default,"request").mockImplementation(e),vi.spyOn(r,"loadCertificate").mockResolvedValue(void 0),await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x0abc",selector:"0x01ff"}),expect(e).toHaveBeenCalledWith(expect.objectContaining({headers:{[m.LEDGER_CLIENT_VERSION_HEADER]:a,[m.LEDGER_ORIGIN_TOKEN_HEADER]:D.originToken}}))}),it("should return an error when axios throws an error",async()=>{vi.spyOn(c.default,"request").mockRejectedValue(new Error),vi.spyOn(r,"loadCertificate").mockResolvedValue(void 0);const a=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x0abc",selector:"0x01ff"});expect(a).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Failed to fetch transaction informations: Error")))}),it("should return an error when no payload is returned",async()=>{const a={data:{test:""}};vi.spyOn(c.default,"request").mockResolvedValue(a),vi.spyOn(r,"loadCertificate").mockResolvedValue(void 0);const e=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Response is not an array")))}),it("should return an error when an empty array is returned",async()=>{vi.spyOn(c.default,"request").mockResolvedValue({data:[]}),vi.spyOn(r,"loadCertificate").mockResolvedValue(void 0);const a=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x0abc",selector:"0x01ff"});expect(a).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: No data for contract 0x0abc and selector 0x01ff")))}),it("should return an error when selector is not found",async()=>{const a=s(d,f,[l]);vi.spyOn(c.default,"request").mockResolvedValue({data:[a]}),vi.spyOn(r,"loadCertificate").mockResolvedValue(void 0);const e=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x01fe"});expect(e).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x01fe")))}),it("Calldata with fields references and enums",async()=>{const a=s(d,f,[l,p,E,x]);vi.spyOn(c.default,"request").mockResolvedValue({data:[a]}),vi.spyOn(r,"loadCertificate").mockResolvedValue(void 0);const e=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80B7a3454c06bdac94a69ddc7a9",selector:"0x69328dEc"});expect(e.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{payload:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec0401000501010606737461626c6581ff473045022100862e724db664f5d94484928a6a5963268a22cd8178ad36e8c4ff13769ac5c27e0220079da2b6e86810156f6b5955b8190bc016c2fe813d27fcb878a9b99658546582",type:"enum",id:0,value:1},{payload:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04010005010206087661726961626c6581ff473045022100b838ee3d597d6bad2533606cef7335f6c8a45b46d5717803e646777f6c8a6897022074f04b82c3dad8445bb6230ab762010c5fc6ee06198fd3e54752287cbf95c523",type:"enum",id:0,value:2},{payload:l.descriptor,type:"transactionFieldDescription",reference:{type:"token",valuePath:[{type:"ARRAY",start:0,end:5,itemSize:1},{type:"LEAF",leafType:"DYNAMIC_LEAF"}]}},{payload:p.descriptor,type:"transactionFieldDescription",reference:{type:"trustedName",valuePath:"TO",types:["eoa"],sources:["ens","unstoppable_domain"]}},{payload:E.descriptor,type:"transactionFieldDescription",reference:{type:"nft",valuePath:[{type:"REF"},{type:"LEAF",leafType:"ARRAY_LEAF"},{type:"SLICE",start:1}]}},{payload:x.descriptor,type:"transactionFieldDescription",reference:{type:"enum",valuePath:[],id:0}}])}),it("Calldata with fields references and enums with certificates",async()=>{const a=s(d,f,[l,p,E,x]),e={keyUsageNumber:11,payload:new Uint8Array([1,2,3,4,21,4,5,6,7,8])};vi.spyOn(c.default,"request").mockResolvedValue({data:[a]}),vi.spyOn(r,"loadCertificate").mockResolvedValueOnce(e);const n=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80B7a3454c06bdac94a69ddc7a9",selector:"0x69328dEc"});expect(n.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo",certificate:e},{payload:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec0401000501010606737461626c6581ff473045022100862e724db664f5d94484928a6a5963268a22cd8178ad36e8c4ff13769ac5c27e0220079da2b6e86810156f6b5955b8190bc016c2fe813d27fcb878a9b99658546582",type:"enum",id:0,value:1,certificate:e},{payload:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04010005010206087661726961626c6581ff473045022100b838ee3d597d6bad2533606cef7335f6c8a45b46d5717803e646777f6c8a6897022074f04b82c3dad8445bb6230ab762010c5fc6ee06198fd3e54752287cbf95c523",type:"enum",id:0,value:2,certificate:e},{payload:l.descriptor,type:"transactionFieldDescription",reference:{type:"token",valuePath:[{type:"ARRAY",start:0,end:5,itemSize:1},{type:"LEAF",leafType:"DYNAMIC_LEAF"}]}},{payload:p.descriptor,type:"transactionFieldDescription",reference:{type:"trustedName",valuePath:"TO",types:["eoa"],sources:["ens","unstoppable_domain"]}},{payload:E.descriptor,type:"transactionFieldDescription",reference:{type:"nft",valuePath:[{type:"REF"},{type:"LEAF",leafType:"ARRAY_LEAF"},{type:"SLICE",start:1}]}},{payload:x.descriptor,type:"transactionFieldDescription",reference:{type:"enum",valuePath:[],id:0}}])}),it("Calldata without fields references",async()=>{const a=s(d,[],[b,y,u,v]);vi.spyOn(c.default,"request").mockResolvedValue({data:[a]}),vi.spyOn(r,"loadCertificate").mockResolvedValue(void 0);const e=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{type:"transactionFieldDescription",payload:b.descriptor},{type:"transactionFieldDescription",payload:y.descriptor},{type:"transactionFieldDescription",payload:u.descriptor},{type:"transactionFieldDescription",payload:v.descriptor}])}),it("Calldata on third array element",async()=>{const a=s(d,[],[b,y,u,v]);vi.spyOn(c.default,"request").mockResolvedValue({data:[{},{},a]}),vi.spyOn(r,"loadCertificate").mockResolvedValue(void 0);const e=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{type:"transactionFieldDescription",payload:b.descriptor},{type:"transactionFieldDescription",payload:y.descriptor},{type:"transactionFieldDescription",payload:u.descriptor},{type:"transactionFieldDescription",payload:v.descriptor}])}),it("Calldata without fields references and transaction info signature length % 2 different from 0",async()=>{const a={descriptor:{data:d.descriptor.data,signatures:{test:d.descriptor.signatures.test+"0"}}},e=s(a,[],[b,y,u,v]);vi.spyOn(c.default,"request").mockResolvedValue({data:[e]}),vi.spyOn(r,"loadCertificate").mockResolvedValue(void 0);const n=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(n.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff4803045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f0",type:"transactionInfo"},{type:"transactionFieldDescription",payload:b.descriptor},{type:"transactionFieldDescription",payload:y.descriptor},{type:"transactionFieldDescription",payload:u.descriptor},{type:"transactionFieldDescription",payload:v.descriptor}])}),it("Calldata with token fields references as constants",async()=>{const a={name:"Amount to exchange",param:{type:"TOKEN_AMOUNT",token:{raw:"0xae7ab96520de3a18e5e111b5eaab095312d7fe84",type:"constant",value:"0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84",version:1,type_size:20,type_family:"ADDRESS"},value:{type:"path",version:1,abi_path:{type:"data",absolute:!0,elements:[{type:"field",identifier:"_stETHAmount"}]},type_size:32,binary_path:{type:"DATA",version:1,elements:[{type:"TUPLE",offset:0},{type:"LEAF",leaf_type:"STATIC_LEAF"}]},type_family:"UINT"},version:1},version:1,descriptor:"0001010112416d6f756e7420746f2065786368616e6765020102033b0001010115000101010101020120030a00010101020000040103021f0001010101050201140514ae7ab96520de3a18e5e111b5eaab095312d7fe84"},e=s(d,[],[a]);vi.spyOn(c.default,"request").mockResolvedValue({data:[e]}),vi.spyOn(r,"loadCertificate").mockResolvedValue(void 0);const n=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(n.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{payload:a.descriptor,type:"transactionFieldDescription",reference:{type:"token",value:"0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84"}}])}),it("Calldata with collection fields references as constants",async()=>{const a={name:"Collection ID",param:{type:"NFT",collection:{raw:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",type:"constant",value:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",version:1,type_size:20,type_family:"ADDRESS"},value:{type:"path",version:1,abi_path:{type:"data",absolute:!0,elements:[{type:"field",identifier:"_collectionId"}]},type_size:20,binary_path:{type:"DATA",version:1,elements:[{type:"ARRAY",weight:2},{type:"LEAF",leaf_type:"TUPLE_LEAF"},{type:"SLICE",end:2}]},type_family:"BYTES"},version:1},version:1,descriptor:"0001010112416d6f756e7420746f2065786368616e6765020102033b0001010115000101010101020120030a00010101020000040103021f00010101010502011405147d2768de32b0b80b7a3454c06bdac94a69ddc7a9"},e=s(d,[],[a]);vi.spyOn(c.default,"request").mockResolvedValue({data:[e]}),vi.spyOn(r,"loadCertificate").mockResolvedValue(void 0);const n=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(n.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{payload:a.descriptor,type:"transactionFieldDescription",reference:{type:"nft",value:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9"}}])}),it("should return an error when calldata is not correctly formatted",async()=>{const a={descriptors_calldata:{"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9":{"0x69328dec":{type:"calldat",version:"v1",transaction_info:d,enums:f,fields:[l]}}}};vi.spyOn(c.default,"request").mockResolvedValue({data:[a]}),vi.spyOn(r,"loadCertificate").mockResolvedValue(void 0);const e=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when transactionInfo is not correctly formatted",async()=>{const a=s({descriptor:{data:"1234",signatures:{prod:"1234"}}},f,[l]);vi.spyOn(c.default,"request").mockResolvedValue({data:[a]}),vi.spyOn(r,"loadCertificate").mockResolvedValue(void 0);const e=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when enum is not correctly formatted",async()=>{const a=s(d,["badEnum"],[l]);vi.spyOn(c.default,"request").mockResolvedValue({data:[a]}),vi.spyOn(r,"loadCertificate").mockResolvedValue(void 0);const e=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when enum does not contain a signature",async()=>{const a=s(d,{0:{1:{data:"1234"}}},[l]);vi.spyOn(c.default,"request").mockResolvedValue({data:[a]}),vi.spyOn(r,"loadCertificate").mockResolvedValue(void 0);const e=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when enum contain the wrong signature",async()=>{const a=s(d,{0:{1:{data:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04010005010106067374626c65",signatures:{prod:"wrongSignature"}}}},[l]);vi.spyOn(c.default,"request").mockResolvedValue({data:[a]}),vi.spyOn(r,"loadCertificate").mockResolvedValue(void 0);const e=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when field is not correctly formatted",async()=>{const a=s(d,[],[{descriptor:3}]);vi.spyOn(c.default,"request").mockResolvedValue({data:[a]}),vi.spyOn(r,"loadCertificate").mockResolvedValue(void 0);const e=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when field value is not correctly formatted",async()=>{const e=s(d,[],[{param:{value:{binary_path:"TO",type_family:"UNKNOWN",type_size:20},type:"DATETIME"},descriptor:"000100010c546f20726563697069667"}]);vi.spyOn(c.default,"request").mockResolvedValue({data:[e]}),vi.spyOn(r,"loadCertificate").mockResolvedValue(void 0);const n=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(n).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when field container path is not correctly formatted",async()=>{const e=s(d,[],[{param:{value:{binary_path:"UNKNOWN",type_family:"ADDRESS",type_size:20},type:"DATETIME"},descriptor:"000100010c546f20726563697069667"}]);vi.spyOn(c.default,"request").mockResolvedValue({data:[e]}),vi.spyOn(r,"loadCertificate").mockResolvedValue(void 0);const n=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(n).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when field calldata path is not correctly formatted",async()=>{const e=s(d,[],[{param:{value:{binary_path:{elements:[{type:"UNKNOWN"}]},type_family:"ADDRESS",type_size:20},type:"DATETIME"},descriptor:"000100010c546f20726563697069667"}]);vi.spyOn(c.default,"request").mockResolvedValue({data:[e]}),vi.spyOn(r,"loadCertificate").mockResolvedValue(void 0);const n=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(n).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when field type is not correctly formatted",async()=>{const e=s(d,[],[{param:{value:{binary_path:"TO",type_family:"ADDRESS",type_size:20},type:"UNKNOWN"},descriptor:"000100010c546f20726563697069667"}]);vi.spyOn(c.default,"request").mockResolvedValue({data:[e]}),vi.spyOn(r,"loadCertificate").mockResolvedValue(void 0);const n=await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(n).toEqual((0,i.Left)(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should call axios with the correct headers",async()=>{vi.spyOn(c.default,"request").mockResolvedValueOnce({data:{}}),await t.getTransactionDescriptors({deviceModelId:o.DeviceModelId.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"}),expect(c.default.request).toHaveBeenCalledWith(expect.objectContaining({headers:{[m.LEDGER_CLIENT_VERSION_HEADER]:`context-module/${h.default.version}`,[m.LEDGER_ORIGIN_TOKEN_HEADER]:D.originToken}}))})});
2
2
  //# sourceMappingURL=HttpTransactionDataSource.test.js.map