@ledgerhq/context-module 0.0.0-develop-20241011001048 → 0.0.0-develop-20250219001044

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 (753) hide show
  1. package/LICENSE.MD +202 -0
  2. package/README.md +4 -6
  3. package/lib/cjs/index.js +2 -20
  4. package/lib/cjs/index.js.map +7 -1
  5. package/lib/cjs/package.json +54 -59
  6. package/lib/cjs/src/ContextModule.js +2 -3
  7. package/lib/cjs/src/ContextModule.js.map +7 -1
  8. package/lib/cjs/src/ContextModuleBuilder.js +2 -87
  9. package/lib/cjs/src/ContextModuleBuilder.js.map +7 -1
  10. package/lib/cjs/src/ContextModuleBuilder.test.js +2 -0
  11. package/lib/cjs/src/ContextModuleBuilder.test.js.map +7 -0
  12. package/lib/cjs/src/DefaultContextModule.js +2 -21
  13. package/lib/cjs/src/DefaultContextModule.js.map +7 -1
  14. package/lib/cjs/src/DefaultContextModule.test.js +2 -0
  15. package/lib/cjs/src/DefaultContextModule.test.js.map +7 -0
  16. package/lib/cjs/src/config/di/configModuleFactory.js +2 -10
  17. package/lib/cjs/src/config/di/configModuleFactory.js.map +7 -1
  18. package/lib/cjs/src/config/di/configTypes.js +2 -7
  19. package/lib/cjs/src/config/di/configTypes.js.map +7 -1
  20. package/lib/cjs/src/config/model/ContextModuleConfig.js +2 -3
  21. package/lib/cjs/src/config/model/ContextModuleConfig.js.map +7 -1
  22. package/lib/cjs/src/di.js +2 -17
  23. package/lib/cjs/src/di.js.map +7 -1
  24. package/lib/cjs/src/external-plugin/data/DAppDto.js +2 -3
  25. package/lib/cjs/src/external-plugin/data/DAppDto.js.map +7 -1
  26. package/lib/cjs/src/external-plugin/data/ExternalPluginDataSource.js +2 -3
  27. package/lib/cjs/src/external-plugin/data/ExternalPluginDataSource.js.map +7 -1
  28. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js +2 -83
  29. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js.map +7 -1
  30. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js +2 -0
  31. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +7 -0
  32. package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js +2 -13
  33. package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js.map +7 -1
  34. package/lib/cjs/src/external-plugin/di/externalPluginTypes.js +2 -8
  35. package/lib/cjs/src/external-plugin/di/externalPluginTypes.js.map +7 -1
  36. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js +2 -136
  37. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js.map +7 -1
  38. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js +2 -0
  39. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +7 -0
  40. package/lib/cjs/src/external-plugin/model/DappInfos.js +2 -3
  41. package/lib/cjs/src/external-plugin/model/DappInfos.js.map +7 -1
  42. package/lib/cjs/src/external-plugin/model/SelectorDetails.js +2 -3
  43. package/lib/cjs/src/external-plugin/model/SelectorDetails.js.map +7 -1
  44. package/lib/cjs/src/index.js +2 -30
  45. package/lib/cjs/src/index.js.map +7 -1
  46. package/lib/cjs/src/nft/data/HttpNftDataSource.js +2 -57
  47. package/lib/cjs/src/nft/data/HttpNftDataSource.js.map +7 -1
  48. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js +2 -0
  49. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js.map +7 -0
  50. package/lib/cjs/src/nft/data/NftDataSource.js +2 -3
  51. package/lib/cjs/src/nft/data/NftDataSource.js.map +7 -1
  52. package/lib/cjs/src/nft/di/nftModuleFactory.js +2 -13
  53. package/lib/cjs/src/nft/di/nftModuleFactory.js.map +7 -1
  54. package/lib/cjs/src/nft/di/nftTypes.js +2 -8
  55. package/lib/cjs/src/nft/di/nftTypes.js.map +7 -1
  56. package/lib/cjs/src/nft/domain/NftContextLoader.js +2 -111
  57. package/lib/cjs/src/nft/domain/NftContextLoader.js.map +7 -1
  58. package/lib/cjs/src/nft/domain/NftContextLoader.test.js +2 -0
  59. package/lib/cjs/src/nft/domain/NftContextLoader.test.js.map +7 -0
  60. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.js +2 -0
  61. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.js.map +7 -0
  62. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.test.js +2 -0
  63. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.test.js.map +7 -0
  64. package/lib/cjs/src/pki/data/PkiCertificateDataSource.js +2 -0
  65. package/lib/cjs/src/pki/data/PkiCertificateDataSource.js.map +7 -0
  66. package/lib/cjs/src/pki/data/pkiDataSourceTypes.js +2 -0
  67. package/lib/cjs/src/pki/data/pkiDataSourceTypes.js.map +7 -0
  68. package/lib/cjs/src/pki/di/pkiModuleFactory.js +2 -0
  69. package/lib/cjs/src/pki/di/pkiModuleFactory.js.map +7 -0
  70. package/lib/cjs/src/pki/di/pkiTypes.js +2 -0
  71. package/lib/cjs/src/pki/di/pkiTypes.js.map +7 -0
  72. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.js +2 -0
  73. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.js.map +7 -0
  74. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js +2 -0
  75. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +7 -0
  76. package/lib/cjs/src/pki/domain/PkiCertificateLoader.js +2 -0
  77. package/lib/cjs/src/pki/domain/PkiCertificateLoader.js.map +7 -0
  78. package/lib/cjs/src/pki/model/KeyId.js +2 -0
  79. package/lib/cjs/src/pki/model/KeyId.js.map +7 -0
  80. package/lib/cjs/src/pki/model/KeyUsage.js +2 -0
  81. package/lib/cjs/src/pki/model/KeyUsage.js.map +7 -0
  82. package/lib/cjs/src/pki/model/PkiCertificate.js +2 -0
  83. package/lib/cjs/src/pki/model/PkiCertificate.js.map +7 -0
  84. package/lib/cjs/src/pki/model/PkiCertificateInfo.js +2 -0
  85. package/lib/cjs/src/pki/model/PkiCertificateInfo.js.map +7 -0
  86. package/lib/cjs/src/shared/domain/ContextLoader.js +2 -3
  87. package/lib/cjs/src/shared/domain/ContextLoader.js.map +7 -1
  88. package/lib/cjs/src/shared/model/ClearSignContext.js +2 -13
  89. package/lib/cjs/src/shared/model/ClearSignContext.js.map +7 -1
  90. package/lib/cjs/src/shared/model/GenericPath.js +2 -0
  91. package/lib/cjs/src/shared/model/GenericPath.js.map +7 -0
  92. package/lib/cjs/src/shared/model/SignatureTags.js +2 -0
  93. package/lib/cjs/src/shared/model/SignatureTags.js.map +7 -0
  94. package/lib/cjs/src/shared/model/TransactionContext.js +2 -3
  95. package/lib/cjs/src/shared/model/TransactionContext.js.map +7 -1
  96. package/lib/cjs/src/shared/model/TransactionSubset.js +2 -3
  97. package/lib/cjs/src/shared/model/TransactionSubset.js.map +7 -1
  98. package/lib/cjs/src/shared/model/TypedDataClearSignContext.js +2 -6
  99. package/lib/cjs/src/shared/model/TypedDataClearSignContext.js.map +7 -1
  100. package/lib/cjs/src/shared/model/TypedDataContext.js +2 -3
  101. package/lib/cjs/src/shared/model/TypedDataContext.js.map +7 -1
  102. package/lib/cjs/src/shared/utils/HexStringUtils.js +2 -15
  103. package/lib/cjs/src/shared/utils/HexStringUtils.js.map +7 -1
  104. package/lib/cjs/src/shared/utils/HexStringUtils.test.js +2 -0
  105. package/lib/cjs/src/shared/utils/HexStringUtils.test.js.map +7 -0
  106. package/lib/cjs/src/shared/utils/KeyUsageMapper.js +2 -0
  107. package/lib/cjs/src/shared/utils/KeyUsageMapper.js.map +7 -0
  108. package/lib/cjs/src/shared/utils/KeyUsageMapper.test.js +2 -0
  109. package/lib/cjs/src/shared/utils/KeyUsageMapper.test.js.map +7 -0
  110. package/lib/cjs/src/token/data/HttpTokenDataSource.js +2 -83
  111. package/lib/cjs/src/token/data/HttpTokenDataSource.js.map +7 -1
  112. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js +2 -0
  113. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js.map +7 -0
  114. package/lib/cjs/src/token/data/TokenDataSource.js +2 -3
  115. package/lib/cjs/src/token/data/TokenDataSource.js.map +7 -1
  116. package/lib/cjs/src/token/data/TokenDto.js +2 -3
  117. package/lib/cjs/src/token/data/TokenDto.js.map +7 -1
  118. package/lib/cjs/src/token/di/tokenModuleFactory.js +2 -13
  119. package/lib/cjs/src/token/di/tokenModuleFactory.js.map +7 -1
  120. package/lib/cjs/src/token/di/tokenTypes.js +2 -8
  121. package/lib/cjs/src/token/di/tokenTypes.js.map +7 -1
  122. package/lib/cjs/src/token/domain/TokenContextLoader.js +2 -74
  123. package/lib/cjs/src/token/domain/TokenContextLoader.js.map +7 -1
  124. package/lib/cjs/src/token/domain/TokenContextLoader.test.js +2 -0
  125. package/lib/cjs/src/token/domain/TokenContextLoader.test.js.map +7 -0
  126. package/lib/cjs/src/transaction/data/CalldataDto.js +2 -0
  127. package/lib/cjs/src/transaction/data/CalldataDto.js.map +7 -0
  128. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js +2 -0
  129. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js.map +7 -0
  130. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js +2 -0
  131. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js.map +7 -0
  132. package/lib/cjs/src/transaction/data/TransactionDataSource.js +2 -0
  133. package/lib/cjs/src/transaction/data/TransactionDataSource.js.map +7 -0
  134. package/lib/cjs/src/transaction/di/transactionModuleFactory.js +2 -0
  135. package/lib/cjs/src/transaction/di/transactionModuleFactory.js.map +7 -0
  136. package/lib/cjs/src/transaction/di/transactionTypes.js +2 -0
  137. package/lib/cjs/src/transaction/di/transactionTypes.js.map +7 -0
  138. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js +2 -0
  139. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js.map +7 -0
  140. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js +2 -0
  141. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js.map +7 -0
  142. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js +2 -0
  143. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js.map +7 -0
  144. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js +2 -0
  145. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +7 -0
  146. package/lib/cjs/src/trusted-name/data/TrustedNameDataSource.js +2 -0
  147. package/lib/cjs/src/trusted-name/data/TrustedNameDataSource.js.map +7 -0
  148. package/lib/cjs/src/trusted-name/data/TrustedNameDto.js +2 -0
  149. package/lib/cjs/src/trusted-name/data/TrustedNameDto.js.map +7 -0
  150. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js +2 -0
  151. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js.map +7 -0
  152. package/lib/cjs/src/trusted-name/di/trustedNameTypes.js +2 -0
  153. package/lib/cjs/src/trusted-name/di/trustedNameTypes.js.map +7 -0
  154. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js +2 -0
  155. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js.map +7 -0
  156. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js +2 -0
  157. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +7 -0
  158. package/lib/cjs/src/typed-data/data/FiltersDto.js +2 -3
  159. package/lib/cjs/src/typed-data/data/FiltersDto.js.map +7 -1
  160. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js +2 -163
  161. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js.map +7 -1
  162. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js +2 -0
  163. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js.map +7 -0
  164. package/lib/cjs/src/typed-data/data/TypedDataDataSource.js +2 -3
  165. package/lib/cjs/src/typed-data/data/TypedDataDataSource.js.map +7 -1
  166. package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js +2 -13
  167. package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js.map +7 -1
  168. package/lib/cjs/src/typed-data/di/typedDataTypes.js +2 -8
  169. package/lib/cjs/src/typed-data/di/typedDataTypes.js.map +7 -1
  170. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js +2 -127
  171. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +7 -1
  172. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +2 -0
  173. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +7 -0
  174. package/lib/cjs/src/typed-data/domain/TypedDataContextLoader.js +2 -3
  175. package/lib/cjs/src/typed-data/domain/TypedDataContextLoader.js.map +7 -1
  176. package/lib/cjs/src/uniswap/constants/plugin.js +2 -0
  177. package/lib/cjs/src/uniswap/constants/plugin.js.map +7 -0
  178. package/lib/cjs/src/uniswap/constants/uniswap.js +2 -0
  179. package/lib/cjs/src/uniswap/constants/uniswap.js.map +7 -0
  180. package/lib/cjs/src/uniswap/constants/weth.js +2 -0
  181. package/lib/cjs/src/uniswap/constants/weth.js.map +7 -0
  182. package/lib/cjs/src/uniswap/data/AbiDecoderDataSource.js +2 -0
  183. package/lib/cjs/src/uniswap/data/AbiDecoderDataSource.js.map +7 -0
  184. package/lib/cjs/src/uniswap/data/CommandDecoderDataSource.js +2 -0
  185. package/lib/cjs/src/uniswap/data/CommandDecoderDataSource.js.map +7 -0
  186. package/lib/cjs/src/uniswap/data/DefaultCommandDecoderDataSource.js +2 -0
  187. package/lib/cjs/src/uniswap/data/DefaultCommandDecoderDataSource.js.map +7 -0
  188. package/lib/cjs/src/uniswap/data/DefaultCommandDecoderDataSource.test.js +2 -0
  189. package/lib/cjs/src/uniswap/data/DefaultCommandDecoderDataSource.test.js.map +7 -0
  190. package/lib/cjs/src/uniswap/data/EthersAbiDecoderDataSource.js +2 -0
  191. package/lib/cjs/src/uniswap/data/EthersAbiDecoderDataSource.js.map +7 -0
  192. package/lib/cjs/src/uniswap/data/EthersAbiDecoderDataSource.test.js +2 -0
  193. package/lib/cjs/src/uniswap/data/EthersAbiDecoderDataSource.test.js.map +7 -0
  194. package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js +2 -0
  195. package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js.map +7 -0
  196. package/lib/cjs/src/uniswap/di/uniswapTypes.js +2 -0
  197. package/lib/cjs/src/uniswap/di/uniswapTypes.js.map +7 -0
  198. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js +2 -0
  199. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js.map +7 -0
  200. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js +2 -0
  201. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js.map +7 -0
  202. package/lib/esm/index.js +2 -4
  203. package/lib/esm/index.js.map +7 -1
  204. package/lib/esm/package.json +54 -59
  205. package/lib/esm/src/ContextModule.js +1 -2
  206. package/lib/esm/src/ContextModule.js.map +7 -1
  207. package/lib/esm/src/ContextModuleBuilder.js +2 -83
  208. package/lib/esm/src/ContextModuleBuilder.js.map +7 -1
  209. package/lib/esm/src/ContextModuleBuilder.test.js +2 -0
  210. package/lib/esm/src/ContextModuleBuilder.test.js.map +7 -0
  211. package/lib/esm/src/DefaultContextModule.js +2 -17
  212. package/lib/esm/src/DefaultContextModule.js.map +7 -1
  213. package/lib/esm/src/DefaultContextModule.test.js +2 -0
  214. package/lib/esm/src/DefaultContextModule.test.js.map +7 -0
  215. package/lib/esm/src/config/di/configModuleFactory.js +2 -6
  216. package/lib/esm/src/config/di/configModuleFactory.js.map +7 -1
  217. package/lib/esm/src/config/di/configTypes.js +2 -4
  218. package/lib/esm/src/config/di/configTypes.js.map +7 -1
  219. package/lib/esm/src/config/model/ContextModuleConfig.js +1 -2
  220. package/lib/esm/src/config/model/ContextModuleConfig.js.map +7 -1
  221. package/lib/esm/src/di.js +2 -13
  222. package/lib/esm/src/di.js.map +7 -1
  223. package/lib/esm/src/external-plugin/data/DAppDto.js +1 -2
  224. package/lib/esm/src/external-plugin/data/DAppDto.js.map +7 -1
  225. package/lib/esm/src/external-plugin/data/ExternalPluginDataSource.js +1 -2
  226. package/lib/esm/src/external-plugin/data/ExternalPluginDataSource.js.map +7 -1
  227. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js +2 -77
  228. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js.map +7 -1
  229. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js +2 -0
  230. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +7 -0
  231. package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js +2 -9
  232. package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js.map +7 -1
  233. package/lib/esm/src/external-plugin/di/externalPluginTypes.js +2 -5
  234. package/lib/esm/src/external-plugin/di/externalPluginTypes.js.map +7 -1
  235. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js +2 -133
  236. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js.map +7 -1
  237. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js +2 -0
  238. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +7 -0
  239. package/lib/esm/src/external-plugin/model/DappInfos.js +1 -2
  240. package/lib/esm/src/external-plugin/model/DappInfos.js.map +7 -1
  241. package/lib/esm/src/external-plugin/model/SelectorDetails.js +1 -2
  242. package/lib/esm/src/external-plugin/model/SelectorDetails.js.map +7 -1
  243. package/lib/esm/src/index.js +2 -14
  244. package/lib/esm/src/index.js.map +7 -1
  245. package/lib/esm/src/nft/data/HttpNftDataSource.js +2 -51
  246. package/lib/esm/src/nft/data/HttpNftDataSource.js.map +7 -1
  247. package/lib/esm/src/nft/data/HttpNftDataSource.test.js +2 -0
  248. package/lib/esm/src/nft/data/HttpNftDataSource.test.js.map +7 -0
  249. package/lib/esm/src/nft/data/NftDataSource.js +1 -2
  250. package/lib/esm/src/nft/data/NftDataSource.js.map +7 -1
  251. package/lib/esm/src/nft/di/nftModuleFactory.js +2 -9
  252. package/lib/esm/src/nft/di/nftModuleFactory.js.map +7 -1
  253. package/lib/esm/src/nft/di/nftTypes.js +2 -5
  254. package/lib/esm/src/nft/di/nftTypes.js.map +7 -1
  255. package/lib/esm/src/nft/domain/NftContextLoader.js +2 -108
  256. package/lib/esm/src/nft/domain/NftContextLoader.js.map +7 -1
  257. package/lib/esm/src/nft/domain/NftContextLoader.test.js +2 -0
  258. package/lib/esm/src/nft/domain/NftContextLoader.test.js.map +7 -0
  259. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.js +2 -0
  260. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.js.map +7 -0
  261. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.test.js +2 -0
  262. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.test.js.map +7 -0
  263. package/lib/esm/src/pki/data/PkiCertificateDataSource.js +1 -0
  264. package/lib/esm/src/pki/data/PkiCertificateDataSource.js.map +7 -0
  265. package/lib/esm/src/pki/data/pkiDataSourceTypes.js +1 -0
  266. package/lib/esm/src/pki/data/pkiDataSourceTypes.js.map +7 -0
  267. package/lib/esm/src/pki/di/pkiModuleFactory.js +2 -0
  268. package/lib/esm/src/pki/di/pkiModuleFactory.js.map +7 -0
  269. package/lib/esm/src/pki/di/pkiTypes.js +2 -0
  270. package/lib/esm/src/pki/di/pkiTypes.js.map +7 -0
  271. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.js +2 -0
  272. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.js.map +7 -0
  273. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js +2 -0
  274. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +7 -0
  275. package/lib/esm/src/pki/domain/PkiCertificateLoader.js +1 -0
  276. package/lib/esm/src/pki/domain/PkiCertificateLoader.js.map +7 -0
  277. package/lib/esm/src/pki/model/KeyId.js +2 -0
  278. package/lib/esm/src/pki/model/KeyId.js.map +7 -0
  279. package/lib/esm/src/pki/model/KeyUsage.js +2 -0
  280. package/lib/esm/src/pki/model/KeyUsage.js.map +7 -0
  281. package/lib/esm/src/pki/model/PkiCertificate.js +1 -0
  282. package/lib/esm/src/pki/model/PkiCertificate.js.map +7 -0
  283. package/lib/esm/src/pki/model/PkiCertificateInfo.js +1 -0
  284. package/lib/esm/src/pki/model/PkiCertificateInfo.js.map +7 -0
  285. package/lib/esm/src/shared/domain/ContextLoader.js +1 -2
  286. package/lib/esm/src/shared/domain/ContextLoader.js.map +7 -1
  287. package/lib/esm/src/shared/model/ClearSignContext.js +2 -10
  288. package/lib/esm/src/shared/model/ClearSignContext.js.map +7 -1
  289. package/lib/esm/src/shared/model/GenericPath.js +2 -0
  290. package/lib/esm/src/shared/model/GenericPath.js.map +7 -0
  291. package/lib/esm/src/shared/model/SignatureTags.js +2 -0
  292. package/lib/esm/src/shared/model/SignatureTags.js.map +7 -0
  293. package/lib/esm/src/shared/model/TransactionContext.js +1 -2
  294. package/lib/esm/src/shared/model/TransactionContext.js.map +7 -1
  295. package/lib/esm/src/shared/model/TransactionSubset.js +1 -2
  296. package/lib/esm/src/shared/model/TransactionSubset.js.map +7 -1
  297. package/lib/esm/src/shared/model/TypedDataClearSignContext.js +2 -3
  298. package/lib/esm/src/shared/model/TypedDataClearSignContext.js.map +7 -1
  299. package/lib/esm/src/shared/model/TypedDataContext.js +1 -2
  300. package/lib/esm/src/shared/model/TypedDataContext.js.map +7 -1
  301. package/lib/esm/src/shared/utils/HexStringUtils.js +2 -11
  302. package/lib/esm/src/shared/utils/HexStringUtils.js.map +7 -1
  303. package/lib/esm/src/shared/utils/HexStringUtils.test.js +2 -0
  304. package/lib/esm/src/shared/utils/HexStringUtils.test.js.map +7 -0
  305. package/lib/esm/src/shared/utils/KeyUsageMapper.js +2 -0
  306. package/lib/esm/src/shared/utils/KeyUsageMapper.js.map +7 -0
  307. package/lib/esm/src/shared/utils/KeyUsageMapper.test.js +2 -0
  308. package/lib/esm/src/shared/utils/KeyUsageMapper.test.js.map +7 -0
  309. package/lib/esm/src/token/data/HttpTokenDataSource.js +2 -77
  310. package/lib/esm/src/token/data/HttpTokenDataSource.js.map +7 -1
  311. package/lib/esm/src/token/data/HttpTokenDataSource.test.js +2 -0
  312. package/lib/esm/src/token/data/HttpTokenDataSource.test.js.map +7 -0
  313. package/lib/esm/src/token/data/TokenDataSource.js +1 -2
  314. package/lib/esm/src/token/data/TokenDataSource.js.map +7 -1
  315. package/lib/esm/src/token/data/TokenDto.js +1 -2
  316. package/lib/esm/src/token/data/TokenDto.js.map +7 -1
  317. package/lib/esm/src/token/di/tokenModuleFactory.js +2 -9
  318. package/lib/esm/src/token/di/tokenModuleFactory.js.map +7 -1
  319. package/lib/esm/src/token/di/tokenTypes.js +2 -5
  320. package/lib/esm/src/token/di/tokenTypes.js.map +7 -1
  321. package/lib/esm/src/token/domain/TokenContextLoader.js +2 -71
  322. package/lib/esm/src/token/domain/TokenContextLoader.js.map +7 -1
  323. package/lib/esm/src/token/domain/TokenContextLoader.test.js +2 -0
  324. package/lib/esm/src/token/domain/TokenContextLoader.test.js.map +7 -0
  325. package/lib/esm/src/transaction/data/CalldataDto.js +1 -0
  326. package/lib/esm/src/transaction/data/CalldataDto.js.map +7 -0
  327. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js +2 -0
  328. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js.map +7 -0
  329. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js +2 -0
  330. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js.map +7 -0
  331. package/lib/esm/src/transaction/data/TransactionDataSource.js +1 -0
  332. package/lib/esm/src/transaction/data/TransactionDataSource.js.map +7 -0
  333. package/lib/esm/src/transaction/di/transactionModuleFactory.js +2 -0
  334. package/lib/esm/src/transaction/di/transactionModuleFactory.js.map +7 -0
  335. package/lib/esm/src/transaction/di/transactionTypes.js +2 -0
  336. package/lib/esm/src/transaction/di/transactionTypes.js.map +7 -0
  337. package/lib/esm/src/transaction/domain/TransactionContextLoader.js +2 -0
  338. package/lib/esm/src/transaction/domain/TransactionContextLoader.js.map +7 -0
  339. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js +2 -0
  340. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js.map +7 -0
  341. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js +2 -0
  342. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js.map +7 -0
  343. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js +2 -0
  344. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +7 -0
  345. package/lib/esm/src/trusted-name/data/TrustedNameDataSource.js +1 -0
  346. package/lib/esm/src/trusted-name/data/TrustedNameDataSource.js.map +7 -0
  347. package/lib/esm/src/trusted-name/data/TrustedNameDto.js +1 -0
  348. package/lib/esm/src/trusted-name/data/TrustedNameDto.js.map +7 -0
  349. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js +2 -0
  350. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js.map +7 -0
  351. package/lib/esm/src/trusted-name/di/trustedNameTypes.js +2 -0
  352. package/lib/esm/src/trusted-name/di/trustedNameTypes.js.map +7 -0
  353. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js +2 -0
  354. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js.map +7 -0
  355. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js +2 -0
  356. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +7 -0
  357. package/lib/esm/src/typed-data/data/FiltersDto.js +1 -2
  358. package/lib/esm/src/typed-data/data/FiltersDto.js.map +7 -1
  359. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js +2 -157
  360. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js.map +7 -1
  361. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js +2 -0
  362. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js.map +7 -0
  363. package/lib/esm/src/typed-data/data/TypedDataDataSource.js +1 -2
  364. package/lib/esm/src/typed-data/data/TypedDataDataSource.js.map +7 -1
  365. package/lib/esm/src/typed-data/di/typedDataModuleFactory.js +2 -9
  366. package/lib/esm/src/typed-data/di/typedDataModuleFactory.js.map +7 -1
  367. package/lib/esm/src/typed-data/di/typedDataTypes.js +2 -5
  368. package/lib/esm/src/typed-data/di/typedDataTypes.js.map +7 -1
  369. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js +2 -124
  370. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +7 -1
  371. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +2 -0
  372. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +7 -0
  373. package/lib/esm/src/typed-data/domain/TypedDataContextLoader.js +1 -2
  374. package/lib/esm/src/typed-data/domain/TypedDataContextLoader.js.map +7 -1
  375. package/lib/esm/src/uniswap/constants/plugin.js +2 -0
  376. package/lib/esm/src/uniswap/constants/plugin.js.map +7 -0
  377. package/lib/esm/src/uniswap/constants/uniswap.js +2 -0
  378. package/lib/esm/src/uniswap/constants/uniswap.js.map +7 -0
  379. package/lib/esm/src/uniswap/constants/weth.js +2 -0
  380. package/lib/esm/src/uniswap/constants/weth.js.map +7 -0
  381. package/lib/esm/src/uniswap/data/AbiDecoderDataSource.js +1 -0
  382. package/lib/esm/src/uniswap/data/AbiDecoderDataSource.js.map +7 -0
  383. package/lib/esm/src/uniswap/data/CommandDecoderDataSource.js +1 -0
  384. package/lib/esm/src/uniswap/data/CommandDecoderDataSource.js.map +7 -0
  385. package/lib/esm/src/uniswap/data/DefaultCommandDecoderDataSource.js +2 -0
  386. package/lib/esm/src/uniswap/data/DefaultCommandDecoderDataSource.js.map +7 -0
  387. package/lib/esm/src/uniswap/data/DefaultCommandDecoderDataSource.test.js +2 -0
  388. package/lib/esm/src/uniswap/data/DefaultCommandDecoderDataSource.test.js.map +7 -0
  389. package/lib/esm/src/uniswap/data/EthersAbiDecoderDataSource.js +2 -0
  390. package/lib/esm/src/uniswap/data/EthersAbiDecoderDataSource.js.map +7 -0
  391. package/lib/esm/src/uniswap/data/EthersAbiDecoderDataSource.test.js +2 -0
  392. package/lib/esm/src/uniswap/data/EthersAbiDecoderDataSource.test.js.map +7 -0
  393. package/lib/esm/src/uniswap/di/uniswapModuleFactory.js +2 -0
  394. package/lib/esm/src/uniswap/di/uniswapModuleFactory.js.map +7 -0
  395. package/lib/esm/src/uniswap/di/uniswapTypes.js +2 -0
  396. package/lib/esm/src/uniswap/di/uniswapTypes.js.map +7 -0
  397. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js +2 -0
  398. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js.map +7 -0
  399. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js +2 -0
  400. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js.map +7 -0
  401. package/lib/{cjs → types}/src/ContextModule.d.ts +3 -2
  402. package/lib/types/src/ContextModule.d.ts.map +1 -0
  403. package/lib/{cjs → types}/src/ContextModuleBuilder.d.ts +9 -11
  404. package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -0
  405. package/lib/types/src/ContextModuleBuilder.test.d.ts +2 -0
  406. package/lib/types/src/ContextModuleBuilder.test.d.ts.map +1 -0
  407. package/lib/types/src/DefaultContextModule.d.ts +18 -0
  408. package/lib/types/src/DefaultContextModule.d.ts.map +1 -0
  409. package/lib/types/src/DefaultContextModule.test.d.ts +2 -0
  410. package/lib/types/src/DefaultContextModule.test.d.ts.map +1 -0
  411. package/lib/{cjs → types}/src/config/di/configModuleFactory.d.ts +1 -1
  412. package/lib/{cjs → types}/src/config/di/configModuleFactory.d.ts.map +1 -1
  413. package/lib/types/src/config/model/ContextModuleConfig.d.ts +16 -0
  414. package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -0
  415. package/lib/{cjs → types}/src/di.d.ts +1 -1
  416. package/lib/types/src/di.d.ts.map +1 -0
  417. package/lib/{cjs → types}/src/external-plugin/data/ExternalPluginDataSource.d.ts +3 -3
  418. package/lib/types/src/external-plugin/data/ExternalPluginDataSource.d.ts.map +1 -0
  419. package/lib/types/src/external-plugin/data/HttpExternalPluginDataSource.test.d.ts +2 -0
  420. package/lib/types/src/external-plugin/data/HttpExternalPluginDataSource.test.d.ts.map +1 -0
  421. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.test.d.ts +2 -0
  422. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.test.d.ts.map +1 -0
  423. package/lib/types/src/external-plugin/model/DappInfos.d.ts +6 -0
  424. package/lib/types/src/external-plugin/model/DappInfos.d.ts.map +1 -0
  425. package/lib/{cjs → types}/src/index.d.ts +8 -1
  426. package/lib/types/src/index.d.ts.map +1 -0
  427. package/lib/types/src/nft/data/HttpNftDataSource.test.d.ts +2 -0
  428. package/lib/types/src/nft/data/HttpNftDataSource.test.d.ts.map +1 -0
  429. package/lib/{cjs → types}/src/nft/data/NftDataSource.d.ts +1 -1
  430. package/lib/types/src/nft/data/NftDataSource.d.ts.map +1 -0
  431. package/lib/{cjs → types}/src/nft/domain/NftContextLoader.d.ts +2 -1
  432. package/lib/types/src/nft/domain/NftContextLoader.d.ts.map +1 -0
  433. package/lib/types/src/nft/domain/NftContextLoader.test.d.ts +2 -0
  434. package/lib/types/src/nft/domain/NftContextLoader.test.d.ts.map +1 -0
  435. package/lib/types/src/pki/data/HttpPkiCertificateDataSource.d.ts +12 -0
  436. package/lib/types/src/pki/data/HttpPkiCertificateDataSource.d.ts.map +1 -0
  437. package/lib/types/src/pki/data/HttpPkiCertificateDataSource.test.d.ts +2 -0
  438. package/lib/types/src/pki/data/HttpPkiCertificateDataSource.test.d.ts.map +1 -0
  439. package/lib/types/src/pki/data/PkiCertificateDataSource.d.ts +7 -0
  440. package/lib/types/src/pki/data/PkiCertificateDataSource.d.ts.map +1 -0
  441. package/lib/types/src/pki/data/pkiDataSourceTypes.d.ts +23 -0
  442. package/lib/types/src/pki/data/pkiDataSourceTypes.d.ts.map +1 -0
  443. package/lib/types/src/pki/di/pkiModuleFactory.d.ts +3 -0
  444. package/lib/types/src/pki/di/pkiModuleFactory.d.ts.map +1 -0
  445. package/lib/types/src/pki/di/pkiTypes.d.ts +5 -0
  446. package/lib/types/src/pki/di/pkiTypes.d.ts.map +1 -0
  447. package/lib/types/src/pki/domain/DefaultPkiCertificateLoader.d.ts +10 -0
  448. package/lib/types/src/pki/domain/DefaultPkiCertificateLoader.d.ts.map +1 -0
  449. package/lib/types/src/pki/domain/DefaultPkiCertificateLoader.test.d.ts +2 -0
  450. package/lib/types/src/pki/domain/DefaultPkiCertificateLoader.test.d.ts.map +1 -0
  451. package/lib/types/src/pki/domain/PkiCertificateLoader.d.ts +6 -0
  452. package/lib/types/src/pki/domain/PkiCertificateLoader.d.ts.map +1 -0
  453. package/lib/types/src/pki/model/KeyId.d.ts +14 -0
  454. package/lib/types/src/pki/model/KeyId.d.ts.map +1 -0
  455. package/lib/types/src/pki/model/KeyUsage.d.ts +15 -0
  456. package/lib/types/src/pki/model/KeyUsage.d.ts.map +1 -0
  457. package/lib/types/src/pki/model/PkiCertificate.d.ts +5 -0
  458. package/lib/types/src/pki/model/PkiCertificate.d.ts.map +1 -0
  459. package/lib/types/src/pki/model/PkiCertificateInfo.d.ts +7 -0
  460. package/lib/types/src/pki/model/PkiCertificateInfo.d.ts.map +1 -0
  461. package/lib/types/src/shared/domain/ContextLoader.d.ts +7 -0
  462. package/lib/types/src/shared/domain/ContextLoader.d.ts.map +1 -0
  463. package/lib/types/src/shared/model/ClearSignContext.d.ts +51 -0
  464. package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -0
  465. package/lib/types/src/shared/model/GenericPath.d.ts +105 -0
  466. package/lib/types/src/shared/model/GenericPath.d.ts.map +1 -0
  467. package/lib/types/src/shared/model/SignatureTags.d.ts +3 -0
  468. package/lib/types/src/shared/model/SignatureTags.d.ts.map +1 -0
  469. package/lib/types/src/shared/model/TransactionContext.d.ts +21 -0
  470. package/lib/types/src/shared/model/TransactionContext.d.ts.map +1 -0
  471. package/lib/types/src/shared/utils/HexStringUtils.d.ts +5 -0
  472. package/lib/{cjs → types}/src/shared/utils/HexStringUtils.d.ts.map +1 -1
  473. package/lib/types/src/shared/utils/HexStringUtils.test.d.ts +2 -0
  474. package/lib/types/src/shared/utils/HexStringUtils.test.d.ts.map +1 -0
  475. package/lib/types/src/shared/utils/KeyUsageMapper.d.ts +6 -0
  476. package/lib/types/src/shared/utils/KeyUsageMapper.d.ts.map +1 -0
  477. package/lib/types/src/shared/utils/KeyUsageMapper.test.d.ts +2 -0
  478. package/lib/types/src/shared/utils/KeyUsageMapper.test.d.ts.map +1 -0
  479. package/lib/{cjs → types}/src/token/data/HttpTokenDataSource.d.ts.map +1 -1
  480. package/lib/types/src/token/data/HttpTokenDataSource.test.d.ts +2 -0
  481. package/lib/types/src/token/data/HttpTokenDataSource.test.d.ts.map +1 -0
  482. package/lib/{cjs → types}/src/token/data/TokenDataSource.d.ts +1 -1
  483. package/lib/types/src/token/data/TokenDataSource.d.ts.map +1 -0
  484. package/lib/types/src/token/data/TokenDto.d.ts +16 -0
  485. package/lib/types/src/token/data/TokenDto.d.ts.map +1 -0
  486. package/lib/{cjs → types}/src/token/domain/TokenContextLoader.d.ts +2 -1
  487. package/lib/types/src/token/domain/TokenContextLoader.d.ts.map +1 -0
  488. package/lib/types/src/token/domain/TokenContextLoader.test.d.ts +2 -0
  489. package/lib/types/src/token/domain/TokenContextLoader.test.d.ts.map +1 -0
  490. package/lib/types/src/transaction/data/CalldataDto.d.ts +128 -0
  491. package/lib/types/src/transaction/data/CalldataDto.d.ts.map +1 -0
  492. package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts +23 -0
  493. package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts.map +1 -0
  494. package/lib/types/src/transaction/data/HttpTransactionDataSource.test.d.ts +2 -0
  495. package/lib/types/src/transaction/data/HttpTransactionDataSource.test.d.ts.map +1 -0
  496. package/lib/types/src/transaction/data/TransactionDataSource.d.ts +13 -0
  497. package/lib/types/src/transaction/data/TransactionDataSource.d.ts.map +1 -0
  498. package/lib/types/src/transaction/di/transactionModuleFactory.d.ts +3 -0
  499. package/lib/types/src/transaction/di/transactionModuleFactory.d.ts.map +1 -0
  500. package/lib/types/src/transaction/di/transactionTypes.d.ts +5 -0
  501. package/lib/types/src/transaction/di/transactionTypes.d.ts.map +1 -0
  502. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts +10 -0
  503. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts.map +1 -0
  504. package/lib/types/src/transaction/domain/TransactionContextLoader.test.d.ts +2 -0
  505. package/lib/types/src/transaction/domain/TransactionContextLoader.test.d.ts.map +1 -0
  506. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts +11 -0
  507. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts.map +1 -0
  508. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.test.d.ts +2 -0
  509. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.test.d.ts.map +1 -0
  510. package/lib/types/src/trusted-name/data/TrustedNameDataSource.d.ts +16 -0
  511. package/lib/types/src/trusted-name/data/TrustedNameDataSource.d.ts.map +1 -0
  512. package/lib/types/src/trusted-name/data/TrustedNameDto.d.ts +15 -0
  513. package/lib/types/src/trusted-name/data/TrustedNameDto.d.ts.map +1 -0
  514. package/lib/types/src/trusted-name/di/trustedNameModuleFactory.d.ts +3 -0
  515. package/lib/types/src/trusted-name/di/trustedNameModuleFactory.d.ts.map +1 -0
  516. package/lib/types/src/trusted-name/di/trustedNameTypes.d.ts +5 -0
  517. package/lib/types/src/trusted-name/di/trustedNameTypes.d.ts.map +1 -0
  518. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts +12 -0
  519. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts.map +1 -0
  520. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.test.d.ts +2 -0
  521. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.test.d.ts.map +1 -0
  522. package/lib/{cjs → types}/src/typed-data/data/FiltersDto.d.ts +3 -0
  523. package/lib/types/src/typed-data/data/FiltersDto.d.ts.map +1 -0
  524. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts.map +1 -0
  525. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts +3 -0
  526. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts.map +1 -0
  527. package/lib/{cjs → types}/src/typed-data/data/TypedDataDataSource.d.ts +3 -3
  528. package/lib/types/src/typed-data/data/TypedDataDataSource.d.ts.map +1 -0
  529. package/lib/{cjs → types}/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts.map +1 -1
  530. package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.test.d.ts +2 -0
  531. package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.test.d.ts.map +1 -0
  532. package/lib/types/src/uniswap/constants/plugin.d.ts +3 -0
  533. package/lib/types/src/uniswap/constants/plugin.d.ts.map +1 -0
  534. package/lib/types/src/uniswap/constants/uniswap.d.ts +21 -0
  535. package/lib/types/src/uniswap/constants/uniswap.d.ts.map +1 -0
  536. package/lib/types/src/uniswap/constants/weth.d.ts +20 -0
  537. package/lib/types/src/uniswap/constants/weth.d.ts.map +1 -0
  538. package/lib/types/src/uniswap/data/AbiDecoderDataSource.d.ts +5 -0
  539. package/lib/types/src/uniswap/data/AbiDecoderDataSource.d.ts.map +1 -0
  540. package/lib/types/src/uniswap/data/CommandDecoderDataSource.d.ts +6 -0
  541. package/lib/types/src/uniswap/data/CommandDecoderDataSource.d.ts.map +1 -0
  542. package/lib/types/src/uniswap/data/DefaultCommandDecoderDataSource.d.ts +14 -0
  543. package/lib/types/src/uniswap/data/DefaultCommandDecoderDataSource.d.ts.map +1 -0
  544. package/lib/types/src/uniswap/data/DefaultCommandDecoderDataSource.test.d.ts +2 -0
  545. package/lib/types/src/uniswap/data/DefaultCommandDecoderDataSource.test.d.ts.map +1 -0
  546. package/lib/types/src/uniswap/data/EthersAbiDecoderDataSource.d.ts +5 -0
  547. package/lib/types/src/uniswap/data/EthersAbiDecoderDataSource.d.ts.map +1 -0
  548. package/lib/types/src/uniswap/data/EthersAbiDecoderDataSource.test.d.ts +2 -0
  549. package/lib/types/src/uniswap/data/EthersAbiDecoderDataSource.test.d.ts.map +1 -0
  550. package/lib/types/src/uniswap/di/uniswapModuleFactory.d.ts +3 -0
  551. package/lib/types/src/uniswap/di/uniswapModuleFactory.d.ts.map +1 -0
  552. package/lib/types/src/uniswap/di/uniswapTypes.d.ts +6 -0
  553. package/lib/types/src/uniswap/di/uniswapTypes.d.ts.map +1 -0
  554. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts +105 -0
  555. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts.map +1 -0
  556. package/lib/types/src/uniswap/domain/UniswapContextLoader.test.d.ts +2 -0
  557. package/lib/types/src/uniswap/domain/UniswapContextLoader.test.d.ts.map +1 -0
  558. package/lib/types/tsconfig.prod.tsbuildinfo +1 -0
  559. package/package.json +25 -30
  560. package/lib/cjs/src/ContextModule.d.ts.map +0 -1
  561. package/lib/cjs/src/ContextModuleBuilder.d.ts.map +0 -1
  562. package/lib/cjs/src/DefaultContextModule.d.ts +0 -20
  563. package/lib/cjs/src/DefaultContextModule.d.ts.map +0 -1
  564. package/lib/cjs/src/config/model/ContextModuleConfig.d.ts +0 -9
  565. package/lib/cjs/src/config/model/ContextModuleConfig.d.ts.map +0 -1
  566. package/lib/cjs/src/di.d.ts.map +0 -1
  567. package/lib/cjs/src/external-plugin/data/ExternalPluginDataSource.d.ts.map +0 -1
  568. package/lib/cjs/src/external-plugin/model/DappInfos.d.ts +0 -6
  569. package/lib/cjs/src/external-plugin/model/DappInfos.d.ts.map +0 -1
  570. package/lib/cjs/src/forward-domain/data/ForwardDomainDataSource.d.ts +0 -9
  571. package/lib/cjs/src/forward-domain/data/ForwardDomainDataSource.d.ts.map +0 -1
  572. package/lib/cjs/src/forward-domain/data/ForwardDomainDataSource.js +0 -3
  573. package/lib/cjs/src/forward-domain/data/ForwardDomainDataSource.js.map +0 -1
  574. package/lib/cjs/src/forward-domain/data/HttpForwardDomainDataSource.d.ts +0 -6
  575. package/lib/cjs/src/forward-domain/data/HttpForwardDomainDataSource.d.ts.map +0 -1
  576. package/lib/cjs/src/forward-domain/data/HttpForwardDomainDataSource.js +0 -40
  577. package/lib/cjs/src/forward-domain/data/HttpForwardDomainDataSource.js.map +0 -1
  578. package/lib/cjs/src/forward-domain/di/forwardDomainModuleFactory.d.ts +0 -3
  579. package/lib/cjs/src/forward-domain/di/forwardDomainModuleFactory.d.ts.map +0 -1
  580. package/lib/cjs/src/forward-domain/di/forwardDomainModuleFactory.js +0 -13
  581. package/lib/cjs/src/forward-domain/di/forwardDomainModuleFactory.js.map +0 -1
  582. package/lib/cjs/src/forward-domain/di/forwardDomainTypes.d.ts +0 -5
  583. package/lib/cjs/src/forward-domain/di/forwardDomainTypes.d.ts.map +0 -1
  584. package/lib/cjs/src/forward-domain/di/forwardDomainTypes.js +0 -8
  585. package/lib/cjs/src/forward-domain/di/forwardDomainTypes.js.map +0 -1
  586. package/lib/cjs/src/forward-domain/domain/ForwardDomainContextLoader.d.ts +0 -11
  587. package/lib/cjs/src/forward-domain/domain/ForwardDomainContextLoader.d.ts.map +0 -1
  588. package/lib/cjs/src/forward-domain/domain/ForwardDomainContextLoader.js +0 -66
  589. package/lib/cjs/src/forward-domain/domain/ForwardDomainContextLoader.js.map +0 -1
  590. package/lib/cjs/src/index.d.ts.map +0 -1
  591. package/lib/cjs/src/nft/data/NftDataSource.d.ts.map +0 -1
  592. package/lib/cjs/src/nft/domain/NftContextLoader.d.ts.map +0 -1
  593. package/lib/cjs/src/shared/domain/ContextLoader.d.ts +0 -6
  594. package/lib/cjs/src/shared/domain/ContextLoader.d.ts.map +0 -1
  595. package/lib/cjs/src/shared/model/ClearSignContext.d.ts +0 -21
  596. package/lib/cjs/src/shared/model/ClearSignContext.d.ts.map +0 -1
  597. package/lib/cjs/src/shared/model/TransactionContext.d.ts +0 -6
  598. package/lib/cjs/src/shared/model/TransactionContext.d.ts.map +0 -1
  599. package/lib/cjs/src/shared/utils/HexStringUtils.d.ts +0 -4
  600. package/lib/cjs/src/token/data/TokenDataSource.d.ts.map +0 -1
  601. package/lib/cjs/src/token/data/TokenDto.d.ts +0 -6
  602. package/lib/cjs/src/token/data/TokenDto.d.ts.map +0 -1
  603. package/lib/cjs/src/token/domain/TokenContextLoader.d.ts.map +0 -1
  604. package/lib/cjs/src/typed-data/data/FiltersDto.d.ts.map +0 -1
  605. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.d.ts.map +0 -1
  606. package/lib/cjs/src/typed-data/data/TypedDataDataSource.d.ts.map +0 -1
  607. package/lib/cjs/tsconfig.cjs.tsbuildinfo +0 -1
  608. package/lib/esm/index.d.ts +0 -3
  609. package/lib/esm/index.d.ts.map +0 -1
  610. package/lib/esm/src/ContextModule.d.ts +0 -9
  611. package/lib/esm/src/ContextModule.d.ts.map +0 -1
  612. package/lib/esm/src/ContextModuleBuilder.d.ts +0 -45
  613. package/lib/esm/src/ContextModuleBuilder.d.ts.map +0 -1
  614. package/lib/esm/src/DefaultContextModule.d.ts +0 -20
  615. package/lib/esm/src/DefaultContextModule.d.ts.map +0 -1
  616. package/lib/esm/src/config/di/configModuleFactory.d.ts +0 -4
  617. package/lib/esm/src/config/di/configModuleFactory.d.ts.map +0 -1
  618. package/lib/esm/src/config/di/configTypes.d.ts +0 -4
  619. package/lib/esm/src/config/di/configTypes.d.ts.map +0 -1
  620. package/lib/esm/src/config/model/ContextModuleConfig.d.ts +0 -9
  621. package/lib/esm/src/config/model/ContextModuleConfig.d.ts.map +0 -1
  622. package/lib/esm/src/di.d.ts +0 -8
  623. package/lib/esm/src/di.d.ts.map +0 -1
  624. package/lib/esm/src/external-plugin/data/DAppDto.d.ts +0 -38
  625. package/lib/esm/src/external-plugin/data/DAppDto.d.ts.map +0 -1
  626. package/lib/esm/src/external-plugin/data/ExternalPluginDataSource.d.ts +0 -12
  627. package/lib/esm/src/external-plugin/data/ExternalPluginDataSource.d.ts.map +0 -1
  628. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.d.ts +0 -10
  629. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.d.ts.map +0 -1
  630. package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.d.ts +0 -3
  631. package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.d.ts.map +0 -1
  632. package/lib/esm/src/external-plugin/di/externalPluginTypes.d.ts +0 -5
  633. package/lib/esm/src/external-plugin/di/externalPluginTypes.d.ts.map +0 -1
  634. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.d.ts +0 -15
  635. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.d.ts.map +0 -1
  636. package/lib/esm/src/external-plugin/model/DappInfos.d.ts +0 -6
  637. package/lib/esm/src/external-plugin/model/DappInfos.d.ts.map +0 -1
  638. package/lib/esm/src/external-plugin/model/SelectorDetails.d.ts +0 -8
  639. package/lib/esm/src/external-plugin/model/SelectorDetails.d.ts.map +0 -1
  640. package/lib/esm/src/forward-domain/data/ForwardDomainDataSource.d.ts +0 -9
  641. package/lib/esm/src/forward-domain/data/ForwardDomainDataSource.d.ts.map +0 -1
  642. package/lib/esm/src/forward-domain/data/ForwardDomainDataSource.js +0 -2
  643. package/lib/esm/src/forward-domain/data/ForwardDomainDataSource.js.map +0 -1
  644. package/lib/esm/src/forward-domain/data/HttpForwardDomainDataSource.d.ts +0 -6
  645. package/lib/esm/src/forward-domain/data/HttpForwardDomainDataSource.d.ts.map +0 -1
  646. package/lib/esm/src/forward-domain/data/HttpForwardDomainDataSource.js +0 -34
  647. package/lib/esm/src/forward-domain/data/HttpForwardDomainDataSource.js.map +0 -1
  648. package/lib/esm/src/forward-domain/di/forwardDomainModuleFactory.d.ts +0 -3
  649. package/lib/esm/src/forward-domain/di/forwardDomainModuleFactory.d.ts.map +0 -1
  650. package/lib/esm/src/forward-domain/di/forwardDomainModuleFactory.js +0 -9
  651. package/lib/esm/src/forward-domain/di/forwardDomainModuleFactory.js.map +0 -1
  652. package/lib/esm/src/forward-domain/di/forwardDomainTypes.d.ts +0 -5
  653. package/lib/esm/src/forward-domain/di/forwardDomainTypes.d.ts.map +0 -1
  654. package/lib/esm/src/forward-domain/di/forwardDomainTypes.js +0 -5
  655. package/lib/esm/src/forward-domain/di/forwardDomainTypes.js.map +0 -1
  656. package/lib/esm/src/forward-domain/domain/ForwardDomainContextLoader.d.ts +0 -11
  657. package/lib/esm/src/forward-domain/domain/ForwardDomainContextLoader.d.ts.map +0 -1
  658. package/lib/esm/src/forward-domain/domain/ForwardDomainContextLoader.js +0 -63
  659. package/lib/esm/src/forward-domain/domain/ForwardDomainContextLoader.js.map +0 -1
  660. package/lib/esm/src/index.d.ts +0 -14
  661. package/lib/esm/src/index.d.ts.map +0 -1
  662. package/lib/esm/src/nft/data/HttpNftDataSource.d.ts +0 -7
  663. package/lib/esm/src/nft/data/HttpNftDataSource.d.ts.map +0 -1
  664. package/lib/esm/src/nft/data/NftDataSource.d.ts +0 -15
  665. package/lib/esm/src/nft/data/NftDataSource.d.ts.map +0 -1
  666. package/lib/esm/src/nft/di/nftModuleFactory.d.ts +0 -3
  667. package/lib/esm/src/nft/di/nftModuleFactory.d.ts.map +0 -1
  668. package/lib/esm/src/nft/di/nftTypes.d.ts +0 -5
  669. package/lib/esm/src/nft/di/nftTypes.d.ts.map +0 -1
  670. package/lib/esm/src/nft/domain/NftContextLoader.d.ts +0 -11
  671. package/lib/esm/src/nft/domain/NftContextLoader.d.ts.map +0 -1
  672. package/lib/esm/src/shared/domain/ContextLoader.d.ts +0 -6
  673. package/lib/esm/src/shared/domain/ContextLoader.d.ts.map +0 -1
  674. package/lib/esm/src/shared/model/ClearSignContext.d.ts +0 -21
  675. package/lib/esm/src/shared/model/ClearSignContext.d.ts.map +0 -1
  676. package/lib/esm/src/shared/model/TransactionContext.d.ts +0 -6
  677. package/lib/esm/src/shared/model/TransactionContext.d.ts.map +0 -1
  678. package/lib/esm/src/shared/model/TransactionSubset.d.ts +0 -6
  679. package/lib/esm/src/shared/model/TransactionSubset.d.ts.map +0 -1
  680. package/lib/esm/src/shared/model/TypedDataClearSignContext.d.ts +0 -33
  681. package/lib/esm/src/shared/model/TypedDataClearSignContext.d.ts.map +0 -1
  682. package/lib/esm/src/shared/model/TypedDataContext.d.ts +0 -16
  683. package/lib/esm/src/shared/model/TypedDataContext.d.ts.map +0 -1
  684. package/lib/esm/src/shared/utils/HexStringUtils.d.ts +0 -4
  685. package/lib/esm/src/shared/utils/HexStringUtils.d.ts.map +0 -1
  686. package/lib/esm/src/token/data/HttpTokenDataSource.d.ts +0 -9
  687. package/lib/esm/src/token/data/HttpTokenDataSource.d.ts.map +0 -1
  688. package/lib/esm/src/token/data/TokenDataSource.d.ts +0 -9
  689. package/lib/esm/src/token/data/TokenDataSource.d.ts.map +0 -1
  690. package/lib/esm/src/token/data/TokenDto.d.ts +0 -6
  691. package/lib/esm/src/token/data/TokenDto.d.ts.map +0 -1
  692. package/lib/esm/src/token/di/tokenModuleFactory.d.ts +0 -3
  693. package/lib/esm/src/token/di/tokenModuleFactory.d.ts.map +0 -1
  694. package/lib/esm/src/token/di/tokenTypes.d.ts +0 -5
  695. package/lib/esm/src/token/di/tokenTypes.d.ts.map +0 -1
  696. package/lib/esm/src/token/domain/TokenContextLoader.d.ts +0 -15
  697. package/lib/esm/src/token/domain/TokenContextLoader.d.ts.map +0 -1
  698. package/lib/esm/src/typed-data/data/FiltersDto.d.ts +0 -55
  699. package/lib/esm/src/typed-data/data/FiltersDto.d.ts.map +0 -1
  700. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.d.ts +0 -14
  701. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.d.ts.map +0 -1
  702. package/lib/esm/src/typed-data/data/TypedDataDataSource.d.ts +0 -17
  703. package/lib/esm/src/typed-data/data/TypedDataDataSource.d.ts.map +0 -1
  704. package/lib/esm/src/typed-data/di/typedDataModuleFactory.d.ts +0 -3
  705. package/lib/esm/src/typed-data/di/typedDataModuleFactory.d.ts.map +0 -1
  706. package/lib/esm/src/typed-data/di/typedDataTypes.d.ts +0 -5
  707. package/lib/esm/src/typed-data/di/typedDataTypes.d.ts.map +0 -1
  708. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts +0 -13
  709. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts.map +0 -1
  710. package/lib/esm/src/typed-data/domain/TypedDataContextLoader.d.ts +0 -6
  711. package/lib/esm/src/typed-data/domain/TypedDataContextLoader.d.ts.map +0 -1
  712. package/lib/esm/tsconfig.esm.tsbuildinfo +0 -1
  713. /package/lib/{cjs → types}/index.d.ts +0 -0
  714. /package/lib/{cjs → types}/index.d.ts.map +0 -0
  715. /package/lib/{cjs → types}/src/config/di/configTypes.d.ts +0 -0
  716. /package/lib/{cjs → types}/src/config/di/configTypes.d.ts.map +0 -0
  717. /package/lib/{cjs → types}/src/external-plugin/data/DAppDto.d.ts +0 -0
  718. /package/lib/{cjs → types}/src/external-plugin/data/DAppDto.d.ts.map +0 -0
  719. /package/lib/{cjs → types}/src/external-plugin/data/HttpExternalPluginDataSource.d.ts +0 -0
  720. /package/lib/{cjs → types}/src/external-plugin/data/HttpExternalPluginDataSource.d.ts.map +0 -0
  721. /package/lib/{cjs → types}/src/external-plugin/di/externalPluginModuleFactory.d.ts +0 -0
  722. /package/lib/{cjs → types}/src/external-plugin/di/externalPluginModuleFactory.d.ts.map +0 -0
  723. /package/lib/{cjs → types}/src/external-plugin/di/externalPluginTypes.d.ts +0 -0
  724. /package/lib/{cjs → types}/src/external-plugin/di/externalPluginTypes.d.ts.map +0 -0
  725. /package/lib/{cjs → types}/src/external-plugin/domain/ExternalPluginContextLoader.d.ts +0 -0
  726. /package/lib/{cjs → types}/src/external-plugin/domain/ExternalPluginContextLoader.d.ts.map +0 -0
  727. /package/lib/{cjs → types}/src/external-plugin/model/SelectorDetails.d.ts +0 -0
  728. /package/lib/{cjs → types}/src/external-plugin/model/SelectorDetails.d.ts.map +0 -0
  729. /package/lib/{cjs → types}/src/nft/data/HttpNftDataSource.d.ts +0 -0
  730. /package/lib/{cjs → types}/src/nft/data/HttpNftDataSource.d.ts.map +0 -0
  731. /package/lib/{cjs → types}/src/nft/di/nftModuleFactory.d.ts +0 -0
  732. /package/lib/{cjs → types}/src/nft/di/nftModuleFactory.d.ts.map +0 -0
  733. /package/lib/{cjs → types}/src/nft/di/nftTypes.d.ts +0 -0
  734. /package/lib/{cjs → types}/src/nft/di/nftTypes.d.ts.map +0 -0
  735. /package/lib/{cjs → types}/src/shared/model/TransactionSubset.d.ts +0 -0
  736. /package/lib/{cjs → types}/src/shared/model/TransactionSubset.d.ts.map +0 -0
  737. /package/lib/{cjs → types}/src/shared/model/TypedDataClearSignContext.d.ts +0 -0
  738. /package/lib/{cjs → types}/src/shared/model/TypedDataClearSignContext.d.ts.map +0 -0
  739. /package/lib/{cjs → types}/src/shared/model/TypedDataContext.d.ts +0 -0
  740. /package/lib/{cjs → types}/src/shared/model/TypedDataContext.d.ts.map +0 -0
  741. /package/lib/{cjs → types}/src/token/data/HttpTokenDataSource.d.ts +0 -0
  742. /package/lib/{cjs → types}/src/token/di/tokenModuleFactory.d.ts +0 -0
  743. /package/lib/{cjs → types}/src/token/di/tokenModuleFactory.d.ts.map +0 -0
  744. /package/lib/{cjs → types}/src/token/di/tokenTypes.d.ts +0 -0
  745. /package/lib/{cjs → types}/src/token/di/tokenTypes.d.ts.map +0 -0
  746. /package/lib/{cjs → types}/src/typed-data/data/HttpTypedDataDataSource.d.ts +0 -0
  747. /package/lib/{cjs → types}/src/typed-data/di/typedDataModuleFactory.d.ts +0 -0
  748. /package/lib/{cjs → types}/src/typed-data/di/typedDataModuleFactory.d.ts.map +0 -0
  749. /package/lib/{cjs → types}/src/typed-data/di/typedDataTypes.d.ts +0 -0
  750. /package/lib/{cjs → types}/src/typed-data/di/typedDataTypes.d.ts.map +0 -0
  751. /package/lib/{cjs → types}/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts +0 -0
  752. /package/lib/{cjs → types}/src/typed-data/domain/TypedDataContextLoader.d.ts +0 -0
  753. /package/lib/{cjs → types}/src/typed-data/domain/TypedDataContextLoader.d.ts.map +0 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/shared/utils/HexStringUtils.test.ts"],
4
+ "sourcesContent": ["import { HexStringUtils } from \"@/shared/utils/HexStringUtils\";\n\ndescribe(\"HexStringUtils\", () => {\n describe(\"appendSignatureToPayload\", () => {\n it(\"should append signature to payload\", () => {\n // GIVEN\n const payload = \"01020304\";\n const signature = \"05060708\";\n const tag = \"15\";\n // WHEN\n const result = HexStringUtils.appendSignatureToPayload(\n payload,\n signature,\n tag,\n );\n // THEN\n expect(result).toEqual(\"01020304150405060708\");\n });\n\n it(\"should append signature to payload with odd length\", () => {\n // GIVEN\n const payload = \"01020304\";\n const signature = \"5060708\";\n const tag = \"15\";\n // WHEN\n const result = HexStringUtils.appendSignatureToPayload(\n payload,\n signature,\n tag,\n );\n // THEN\n expect(result).toEqual(\"01020304150405060708\");\n });\n });\n\n describe(\"stringToHex\", () => {\n it(\"should convert string to hex\", () => {\n // GIVEN\n const str = \"test\";\n // WHEN\n const result = HexStringUtils.stringToHex(str);\n // THEN\n expect(result).toEqual(\"74657374\");\n });\n\n it(\"should convert string to hex with odd length\", () => {\n // GIVEN\n const str = \"test1\";\n // WHEN\n const result = HexStringUtils.stringToHex(str);\n // THEN\n expect(result).toEqual(\"7465737431\");\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,kBAAAA,MAAsB,gCAE/B,SAAS,iBAAkB,IAAM,CAC/B,SAAS,2BAA4B,IAAM,CACzC,GAAG,qCAAsC,IAAM,CAM7C,MAAMC,EAASD,EAAe,yBAJd,WACE,WACN,IAMZ,EAEA,OAAOC,CAAM,EAAE,QAAQ,sBAAsB,CAC/C,CAAC,EAED,GAAG,qDAAsD,IAAM,CAM7D,MAAMA,EAASD,EAAe,yBAJd,WACE,UACN,IAMZ,EAEA,OAAOC,CAAM,EAAE,QAAQ,sBAAsB,CAC/C,CAAC,CACH,CAAC,EAED,SAAS,cAAe,IAAM,CAC5B,GAAG,+BAAgC,IAAM,CAIvC,MAAMA,EAASD,EAAe,YAFlB,MAEiC,EAE7C,OAAOC,CAAM,EAAE,QAAQ,UAAU,CACnC,CAAC,EAED,GAAG,+CAAgD,IAAM,CAIvD,MAAMA,EAASD,EAAe,YAFlB,OAEiC,EAE7C,OAAOC,CAAM,EAAE,QAAQ,YAAY,CACrC,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["HexStringUtils", "result"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{KeyUsage as e}from"../../pki/model/KeyUsage";class s{static keyUsageMap=new Map([[e.GenuineCheck,1],[e.ExchangePayload,2],[e.NftMeta,3],[e.TrustedName,4],[e.BackupProvider,5],[e.ProtectOrchestrator,6],[e.PluginMeta,7],[e.CoinMeta,8],[e.SeedIdAuth,9],[e.TxSimulationSigner,10],[e.Calldata,11],[e.Network,12]]);static mapKeyUsageForFirmware(a){return this.keyUsageMap.get(a)??-1}}export{s as KeyUsageMapper};
2
+ //# sourceMappingURL=KeyUsageMapper.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/shared/utils/KeyUsageMapper.ts"],
4
+ "sourcesContent": ["import { KeyUsage } from \"@/pki/model/KeyUsage\";\n\nexport class KeyUsageMapper {\n private static keyUsageMap = new Map<KeyUsage, number>([\n [KeyUsage.GenuineCheck, 1],\n [KeyUsage.ExchangePayload, 2],\n [KeyUsage.NftMeta, 3],\n [KeyUsage.TrustedName, 4],\n [KeyUsage.BackupProvider, 5],\n [KeyUsage.ProtectOrchestrator, 6],\n [KeyUsage.PluginMeta, 7],\n [KeyUsage.CoinMeta, 8],\n [KeyUsage.SeedIdAuth, 9],\n [KeyUsage.TxSimulationSigner, 10],\n [KeyUsage.Calldata, 11],\n [KeyUsage.Network, 12],\n ]);\n\n static mapKeyUsageForFirmware(keyUsage: KeyUsage): number {\n return this.keyUsageMap.get(keyUsage as KeyUsage) ?? -1;\n }\n}\n"],
5
+ "mappings": "AAAA,OAAS,YAAAA,MAAgB,uBAElB,MAAMC,CAAe,CAC1B,OAAe,YAAc,IAAI,IAAsB,CACrD,CAACD,EAAS,aAAc,CAAC,EACzB,CAACA,EAAS,gBAAiB,CAAC,EAC5B,CAACA,EAAS,QAAS,CAAC,EACpB,CAACA,EAAS,YAAa,CAAC,EACxB,CAACA,EAAS,eAAgB,CAAC,EAC3B,CAACA,EAAS,oBAAqB,CAAC,EAChC,CAACA,EAAS,WAAY,CAAC,EACvB,CAACA,EAAS,SAAU,CAAC,EACrB,CAACA,EAAS,WAAY,CAAC,EACvB,CAACA,EAAS,mBAAoB,EAAE,EAChC,CAACA,EAAS,SAAU,EAAE,EACtB,CAACA,EAAS,QAAS,EAAE,CACvB,CAAC,EAED,OAAO,uBAAuBE,EAA4B,CACxD,OAAO,KAAK,YAAY,IAAIA,CAAoB,GAAK,EACvD,CACF",
6
+ "names": ["KeyUsage", "KeyUsageMapper", "keyUsage"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{KeyUsage as e}from"../../pki/model/KeyUsage";import{KeyUsageMapper as r}from"../../shared/utils/KeyUsageMapper";describe("KeyUsageMapper",()=>{describe("mapKeyUsageForFirmware",()=>{it.each([[e.GenuineCheck,1],[e.ExchangePayload,2],[e.NftMeta,3],[e.TrustedName,4],[e.BackupProvider,5],[e.ProtectOrchestrator,6],[e.PluginMeta,7],[e.CoinMeta,8],[e.SeedIdAuth,9],[e.TxSimulationSigner,10],[e.Calldata,11],[e.Network,12]])("should map key usage %s to %i",(a,t)=>{const o=r.mapKeyUsageForFirmware(a);expect(o).toEqual(t)}),it("should return -1 when key usage is not found",()=>{const a=r.mapKeyUsageForFirmware("unknown");expect(a).toEqual(-1)})})});
2
+ //# sourceMappingURL=KeyUsageMapper.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/shared/utils/KeyUsageMapper.test.ts"],
4
+ "sourcesContent": ["import { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { KeyUsageMapper } from \"@/shared/utils/KeyUsageMapper\";\n\ndescribe(\"KeyUsageMapper\", () => {\n describe(\"mapKeyUsageForFirmware\", () => {\n it.each([\n [KeyUsage.GenuineCheck, 1],\n [KeyUsage.ExchangePayload, 2],\n [KeyUsage.NftMeta, 3],\n [KeyUsage.TrustedName, 4],\n [KeyUsage.BackupProvider, 5],\n [KeyUsage.ProtectOrchestrator, 6],\n [KeyUsage.PluginMeta, 7],\n [KeyUsage.CoinMeta, 8],\n [KeyUsage.SeedIdAuth, 9],\n [KeyUsage.TxSimulationSigner, 10],\n [KeyUsage.Calldata, 11],\n [KeyUsage.Network, 12],\n ])(`should map key usage %s to %i`, (keyUsage, expected) => {\n // WHEN\n const result = KeyUsageMapper.mapKeyUsageForFirmware(keyUsage);\n\n // THEN\n expect(result).toEqual(expected);\n });\n\n it(\"should return -1 when key usage is not found\", () => {\n // WHEN\n const result = KeyUsageMapper.mapKeyUsageForFirmware(\n \"unknown\" as KeyUsage,\n );\n\n // THEN\n expect(result).toEqual(-1);\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,YAAAA,MAAgB,uBACzB,OAAS,kBAAAC,MAAsB,gCAE/B,SAAS,iBAAkB,IAAM,CAC/B,SAAS,yBAA0B,IAAM,CACvC,GAAG,KAAK,CACN,CAACD,EAAS,aAAc,CAAC,EACzB,CAACA,EAAS,gBAAiB,CAAC,EAC5B,CAACA,EAAS,QAAS,CAAC,EACpB,CAACA,EAAS,YAAa,CAAC,EACxB,CAACA,EAAS,eAAgB,CAAC,EAC3B,CAACA,EAAS,oBAAqB,CAAC,EAChC,CAACA,EAAS,WAAY,CAAC,EACvB,CAACA,EAAS,SAAU,CAAC,EACrB,CAACA,EAAS,WAAY,CAAC,EACvB,CAACA,EAAS,mBAAoB,EAAE,EAChC,CAACA,EAAS,SAAU,EAAE,EACtB,CAACA,EAAS,QAAS,EAAE,CACvB,CAAC,EAAE,gCAAiC,CAACE,EAAUC,IAAa,CAE1D,MAAMC,EAASH,EAAe,uBAAuBC,CAAQ,EAG7D,OAAOE,CAAM,EAAE,QAAQD,CAAQ,CACjC,CAAC,EAED,GAAG,+CAAgD,IAAM,CAEvD,MAAMC,EAASH,EAAe,uBAC5B,SACF,EAGA,OAAOG,CAAM,EAAE,QAAQ,EAAE,CAC3B,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["KeyUsage", "KeyUsageMapper", "keyUsage", "expected", "result"]
7
+ }
@@ -1,77 +1,2 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- var __param = (this && this.__param) || function (paramIndex, decorator) {
11
- return function (target, key) { decorator(target, key, paramIndex); }
12
- };
13
- import axios from "axios";
14
- import { inject, injectable } from "inversify";
15
- import { Left, Right } from "purify-ts";
16
- import { configTypes } from "../../config/di/configTypes";
17
- import { HexStringUtils } from "../../shared/utils/HexStringUtils";
18
- import PACKAGE from "../../../package.json";
19
- let HttpTokenDataSource = class HttpTokenDataSource {
20
- config;
21
- constructor(config) {
22
- this.config = config;
23
- }
24
- async getTokenInfosPayload({ chainId, address, }) {
25
- try {
26
- const response = await axios.request({
27
- method: "GET",
28
- url: `${this.config.cal.url}/tokens`,
29
- params: {
30
- contract_address: address,
31
- chain_id: chainId,
32
- output: "live_signature,ticker,decimals",
33
- },
34
- headers: {
35
- "X-Ledger-Client-Version": `context-module/${PACKAGE.version}`,
36
- },
37
- });
38
- const tokenInfos = response.data?.[0];
39
- if (!tokenInfos ||
40
- !tokenInfos.live_signature ||
41
- !tokenInfos.ticker ||
42
- !tokenInfos.decimals) {
43
- return Left(new Error(`[ContextModule] HttpTokenDataSource: no token metadata for address ${address} on chain ${chainId}`));
44
- }
45
- // 1 byte for the length of the ticker
46
- const tickerLengthBuff = tokenInfos.ticker.length
47
- .toString(16)
48
- .padStart(2, "0");
49
- // ticker ascii
50
- const tickerBuff = HexStringUtils.stringToHex(tokenInfos.ticker);
51
- // bufferized address
52
- const addressBuff = address.slice(2);
53
- // 4 bytes for the decimals
54
- const decimalsBuff = tokenInfos.decimals.toString(16).padStart(8, "0");
55
- // 4 bytes for the chainId
56
- const chainIdBuff = chainId.toString(16).padStart(8, "0");
57
- return Right([
58
- tickerLengthBuff,
59
- tickerBuff,
60
- addressBuff,
61
- decimalsBuff,
62
- chainIdBuff,
63
- tokenInfos.live_signature,
64
- ].join(""));
65
- }
66
- catch (_error) {
67
- return Left(new Error("[ContextModule] HttpTokenDataSource: Failed to fetch token informations"));
68
- }
69
- }
70
- };
71
- HttpTokenDataSource = __decorate([
72
- injectable(),
73
- __param(0, inject(configTypes.Config)),
74
- __metadata("design:paramtypes", [Object])
75
- ], HttpTokenDataSource);
76
- export { HttpTokenDataSource };
77
- //# sourceMappingURL=HttpTokenDataSource.js.map
1
+ var m=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var c=(n,t,r,e)=>{for(var o=e>1?void 0:e?p(t,r):t,i=n.length-1,a;i>=0;i--)(a=n[i])&&(o=(e?a(t,r,o):a(o))||o);return e&&o&&m(t,r,o),o},f=(n,t)=>(r,e)=>t(r,e,n);import g from"axios";import{inject as l,injectable as u}from"inversify";import{Left as d,Right as h}from"purify-ts";import{configTypes as k}from"../../config/di/configTypes";import C from"../../../package.json";let s=class{constructor(t){this.config=t}async getTokenInfosPayload({chainId:t,address:r}){try{const o=(await g.request({method:"GET",url:`${this.config.cal.url}/tokens`,params:{contract_address:r,chain_id:t,output:"descriptor,ticker",ref:`branch:${this.config.cal.branch}`},headers:{"X-Ledger-Client-Version":`context-module/${C.version}`}})).data?.[0];if(!o||!o.ticker||!o.descriptor||!o.descriptor.data||!o.descriptor.signatures||typeof o.descriptor.signatures[this.config.cal.mode]!="string")return d(new Error(`[ContextModule] HttpTokenDataSource: no token metadata for address ${r} on chain ${t}`));const i=o.ticker.length.toString(16).padStart(2,"0");return h([i,o.descriptor.data,o.descriptor.signatures[this.config.cal.mode]].join(""))}catch{return d(new Error("[ContextModule] HttpTokenDataSource: Failed to fetch token informations"))}}};s=c([u(),f(0,l(k.Config))],s);export{s as HttpTokenDataSource};
2
+ //# sourceMappingURL=HttpTokenDataSource.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"HttpTokenDataSource.js","sourceRoot":"","sources":["../../../../../src/token/data/HttpTokenDataSource.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,W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AAe;YACf,MAAM,UAAU,GAAG,cAAc,CAAC,WAAW,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YAEjE,qBAAqB;YACrB,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAErC,2BAA2B;YAC3B,MAAM,YAAY,GAAG,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;YAEvE,0BAA0B;YAC1B,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;YAE1D,OAAO,KAAK,CACV;gBACE,gBAAgB;gBAChB,UAAU;gBACV,WAAW;gBACX,YAAY;gBACZ,WAAW;gBACX,UAAU,CAAC,cAAc;aAC1B,CAAC,IAAI,CAAC,EAAE,CAAC,CACX,CAAC;QACJ,CAAC;QAAC,OAAO,MAAM,EAAE,CAAC;YAChB,OAAO,IAAI,CACT,IAAI,KAAK,CACP,yEAAyE,CAC1E,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAA;AAvEY,mBAAmB;IAD/B,UAAU,EAAE;IAGR,WAAA,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;;GAFlB,mBAAmB,CAuE/B"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/token/data/HttpTokenDataSource.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 PACKAGE from \"@root/package.json\";\n\nimport { GetTokenInfosParams, TokenDataSource } from \"./TokenDataSource\";\nimport { TokenDto } from \"./TokenDto\";\n\n@injectable()\nexport class HttpTokenDataSource implements TokenDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n public async getTokenInfosPayload({\n chainId,\n address,\n }: GetTokenInfosParams): Promise<Either<Error, string>> {\n try {\n const response = await axios.request<TokenDto[]>({\n method: \"GET\",\n url: `${this.config.cal.url}/tokens`,\n params: {\n contract_address: address,\n chain_id: chainId,\n output: \"descriptor,ticker\",\n ref: `branch:${this.config.cal.branch}`,\n },\n headers: {\n \"X-Ledger-Client-Version\": `context-module/${PACKAGE.version}`,\n },\n });\n const tokenInfos = response.data?.[0];\n\n if (\n !tokenInfos ||\n !tokenInfos.ticker ||\n !tokenInfos.descriptor ||\n !tokenInfos.descriptor.data ||\n !tokenInfos.descriptor.signatures ||\n typeof tokenInfos.descriptor.signatures[this.config.cal.mode] !==\n \"string\"\n ) {\n return Left(\n new Error(\n `[ContextModule] HttpTokenDataSource: no token metadata for address ${address} on chain ${chainId}`,\n ),\n );\n }\n\n // 1 byte for the length of the ticker\n const tickerLengthBuff = tokenInfos.ticker.length\n .toString(16)\n .padStart(2, \"0\");\n\n return Right(\n [\n tickerLengthBuff,\n tokenInfos.descriptor.data,\n tokenInfos.descriptor.signatures[this.config.cal.mode],\n ].join(\"\"),\n );\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTokenDataSource: Failed to fetch token informations\",\n ),\n );\n }\n }\n}\n"],
5
+ "mappings": "iOAAA,OAAOA,MAAW,QAClB,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAE5B,OAAOC,MAAa,qBAMb,IAAMC,EAAN,KAAqD,CAC1D,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CACH,MAAa,qBAAqB,CAChC,QAAAC,EACA,QAAAC,CACF,EAAwD,CACtD,GAAI,CAcF,MAAMC,GAbW,MAAMC,EAAM,QAAoB,CAC/C,OAAQ,MACR,IAAK,GAAG,KAAK,OAAO,IAAI,GAAG,UAC3B,OAAQ,CACN,iBAAkBF,EAClB,SAAUD,EACV,OAAQ,oBACR,IAAK,UAAU,KAAK,OAAO,IAAI,MAAM,EACvC,EACA,QAAS,CACP,0BAA2B,kBAAkBI,EAAQ,OAAO,EAC9D,CACF,CAAC,GAC2B,OAAO,CAAC,EAEpC,GACE,CAACF,GACD,CAACA,EAAW,QACZ,CAACA,EAAW,YACZ,CAACA,EAAW,WAAW,MACvB,CAACA,EAAW,WAAW,YACvB,OAAOA,EAAW,WAAW,WAAW,KAAK,OAAO,IAAI,IAAI,GAC1D,SAEF,OAAOG,EACL,IAAI,MACF,sEAAsEJ,CAAO,aAAaD,CAAO,EACnG,CACF,EAIF,MAAMM,EAAmBJ,EAAW,OAAO,OACxC,SAAS,EAAE,EACX,SAAS,EAAG,GAAG,EAElB,OAAOK,EACL,CACED,EACAJ,EAAW,WAAW,KACtBA,EAAW,WAAW,WAAW,KAAK,OAAO,IAAI,IAAI,CACvD,EAAE,KAAK,EAAE,CACX,CACF,MAAiB,CACf,OAAOG,EACL,IAAI,MACF,yEACF,CACF,CACF,CACF,CACF,EA5DaP,EAANU,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,IAFjBd",
6
+ "names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "PACKAGE", "HttpTokenDataSource", "config", "chainId", "address", "tokenInfos", "axios", "PACKAGE", "Left", "tickerLengthBuff", "Right", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import o from"axios";import{Left as n}from"purify-ts";import{HttpTokenDataSource as r}from"../../token/data/HttpTokenDataSource";import s from"../../../package.json";vi.mock("axios");describe("HttpTokenDataSource",()=>{let t;beforeAll(()=>{const e={cal:{url:"https://crypto-assets-service.api.ledger.com/v1",mode:"prod",branch:"main"}};t=new r(e),vi.clearAllMocks()}),it("should call axios with the ledger client version header",async()=>{const e=`context-module/${s.version}`,a=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(o,"request").mockImplementation(a),await t.getTokenInfosPayload({address:"0x00",chainId:1}),expect(a).toHaveBeenCalledWith(expect.objectContaining({headers:{"X-Ledger-Client-Version":e}}))}),it("should return a string when axios response is correct",async()=>{const e={ticker:"USDC",descriptor:{data:"55534443000000000800000001",signatures:{prod:"0123"}}};vi.spyOn(o,"request").mockResolvedValue({data:[e]});const a=await t.getTokenInfosPayload({address:"0x00",chainId:1});expect(a.extract()).toEqual("04555344430000000008000000010123")}),it("should return an error when data is empty",async()=>{vi.spyOn(o,"request").mockResolvedValue({data:void 0});const e=await t.getTokenInfosPayload({address:"0x00",chainId:1});expect(e).toEqual(n(new Error("[ContextModule] HttpTokenDataSource: no token metadata for address 0x00 on chain 1")))}),it("should return undefined when no signature",async()=>{vi.spyOn(o,"request").mockResolvedValue({data:[{}]});const e=await t.getTokenInfosPayload({address:"0x00",chainId:1});expect(e).toEqual(n(new Error("[ContextModule] HttpTokenDataSource: no token metadata for address 0x00 on chain 1")))}),it("should return undefined when no ticker",async()=>{const e={ticker:"USDC",descriptor:{data:"55534443000000000800000001",signatures:{test:"0123"}}};vi.spyOn(o,"request").mockResolvedValue({data:[e]});const a=await t.getTokenInfosPayload({address:"0x00",chainId:1});expect(a).toEqual(n(new Error("[ContextModule] HttpTokenDataSource: no token metadata for address 0x00 on chain 1")))}),it("should return undefined when no decimals",async()=>{vi.spyOn(o,"request").mockResolvedValue({data:[{live_signature:"0x0",ticker:"USDC"}]});const e=await t.getTokenInfosPayload({address:"0x00",chainId:1});expect(e).toEqual(n(new Error("[ContextModule] HttpTokenDataSource: no token metadata for address 0x00 on chain 1")))}),it("should return an error when axios throws an error",async()=>{vi.spyOn(o,"request").mockRejectedValue(new Error);const e=await t.getTokenInfosPayload({address:"0x00",chainId:1});expect(e).toEqual(n(new Error("[ContextModule] HttpTokenDataSource: Failed to fetch token informations")))})});
2
+ //# sourceMappingURL=HttpTokenDataSource.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/token/data/HttpTokenDataSource.test.ts"],
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { Left } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { HttpTokenDataSource } from \"@/token/data/HttpTokenDataSource\";\nimport { type TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { type TokenDto } from \"@/token/data/TokenDto\";\nimport PACKAGE from \"@root/package.json\";\n\nvi.mock(\"axios\");\n\ndescribe(\"HttpTokenDataSource\", () => {\n let datasource: TokenDataSource;\n\n beforeAll(() => {\n const config = {\n cal: {\n url: \"https://crypto-assets-service.api.ledger.com/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n } as ContextModuleConfig;\n datasource = new HttpTokenDataSource(config);\n vi.clearAllMocks();\n });\n\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(() => Promise.resolve({ data: [] }));\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getTokenInfosPayload({ address: \"0x00\", chainId: 1 });\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: { \"X-Ledger-Client-Version\": version },\n }),\n );\n });\n\n it(\"should return a string when axios response is correct\", async () => {\n // GIVEN\n const tokenDTO: TokenDto = {\n ticker: \"USDC\",\n descriptor: {\n data: \"55534443000000000800000001\",\n signatures: {\n prod: \"0123\",\n },\n },\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: [tokenDTO] });\n\n // WHEN\n const result = await datasource.getTokenInfosPayload({\n address: \"0x00\",\n chainId: 1,\n });\n\n // THEN\n expect(result.extract()).toEqual(\"04555344430000000008000000010123\");\n });\n\n it(\"should return an error when data is empty\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: undefined });\n\n // WHEN\n const result = await datasource.getTokenInfosPayload({\n address: \"0x00\",\n chainId: 1,\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTokenDataSource: no token metadata for address 0x00 on chain 1\",\n ),\n ),\n );\n });\n\n it(\"should return undefined when no signature\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: [{}] });\n\n // WHEN\n const result = await datasource.getTokenInfosPayload({\n address: \"0x00\",\n chainId: 1,\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTokenDataSource: no token metadata for address 0x00 on chain 1\",\n ),\n ),\n );\n });\n\n it(\"should return undefined when no ticker\", async () => {\n // GIVEN\n const tokenDTO: TokenDto = {\n ticker: \"USDC\",\n descriptor: {\n data: \"55534443000000000800000001\",\n signatures: {\n test: \"0123\",\n },\n },\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: [tokenDTO] });\n\n // WHEN\n const result = await datasource.getTokenInfosPayload({\n address: \"0x00\",\n chainId: 1,\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTokenDataSource: no token metadata for address 0x00 on chain 1\",\n ),\n ),\n );\n });\n\n it(\"should return undefined when no decimals\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: [{ live_signature: \"0x0\", ticker: \"USDC\" }],\n });\n\n // WHEN\n const result = await datasource.getTokenInfosPayload({\n address: \"0x00\",\n chainId: 1,\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTokenDataSource: no token metadata for address 0x00 on chain 1\",\n ),\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());\n\n // WHEN\n const result = await datasource.getTokenInfosPayload({\n address: \"0x00\",\n chainId: 1,\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTokenDataSource: Failed to fetch token informations\",\n ),\n ),\n );\n });\n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"Left", "HttpTokenDataSource", "PACKAGE", "datasource", "config", "version", "requestSpy", "tokenDTO", "result"]
7
+ }
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=TokenDataSource.js.map
1
+ //# sourceMappingURL=TokenDataSource.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"TokenDataSource.js","sourceRoot":"","sources":["../../../../../src/token/data/TokenDataSource.ts"],"names":[],"mappings":""}
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=TokenDto.js.map
1
+ //# sourceMappingURL=TokenDto.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"TokenDto.js","sourceRoot":"","sources":["../../../../../src/token/data/TokenDto.ts"],"names":[],"mappings":""}
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,9 +1,2 @@
1
- import { ContainerModule } from "inversify";
2
- import { HttpTokenDataSource } from "../../token/data/HttpTokenDataSource";
3
- import { tokenTypes } from "../../token/di/tokenTypes";
4
- import { TokenContextLoader } from "../../token/domain/TokenContextLoader";
5
- export const tokenModuleFactory = () => new ContainerModule((bind, _unbind, _isBound, _rebind) => {
6
- bind(tokenTypes.TokenDataSource).to(HttpTokenDataSource);
7
- bind(tokenTypes.TokenContextLoader).to(TokenContextLoader);
8
- });
9
- //# sourceMappingURL=tokenModuleFactory.js.map
1
+ import{ContainerModule as e}from"inversify";import{HttpTokenDataSource as r}from"../../token/data/HttpTokenDataSource";import{tokenTypes as t}from"../../token/di/tokenTypes";import{TokenContextLoader as n}from"../../token/domain/TokenContextLoader";const T=()=>new e((o,a,m,i)=>{o(t.TokenDataSource).to(r),o(t.TokenContextLoader).to(n)});export{T as tokenModuleFactory};
2
+ //# sourceMappingURL=tokenModuleFactory.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"tokenModuleFactory.js","sourceRoot":"","sources":["../../../../../src/token/di/tokenModuleFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAEvE,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE,CACrC,IAAI,eAAe,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE;IACvD,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,mBAAmB,CAAC,CAAC;IACzD,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,kBAAkB,CAAC,CAAC;AAC7D,CAAC,CAAC,CAAC"}
1
+ {
2
+ "version": 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": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,uBAAAC,MAA2B,mCACpC,OAAS,cAAAC,MAAkB,wBAC3B,OAAS,sBAAAC,MAA0B,oCAE5B,MAAMC,EAAqB,IAChC,IAAIJ,EAAgB,CAACK,EAAMC,EAASC,EAAUC,IAAY,CACxDH,EAAKH,EAAW,eAAe,EAAE,GAAGD,CAAmB,EACvDI,EAAKH,EAAW,kBAAkB,EAAE,GAAGC,CAAkB,CAC3D,CAAC",
6
+ "names": ["ContainerModule", "HttpTokenDataSource", "tokenTypes", "TokenContextLoader", "tokenModuleFactory", "bind", "_unbind", "_isBound", "_rebind"]
7
+ }
@@ -1,5 +1,2 @@
1
- export const tokenTypes = {
2
- TokenDataSource: Symbol.for("TokenDataSource"),
3
- TokenContextLoader: Symbol.for("TokenContextLoader"),
4
- };
5
- //# sourceMappingURL=tokenTypes.js.map
1
+ const o={TokenDataSource:Symbol.for("TokenDataSource"),TokenContextLoader:Symbol.for("TokenContextLoader")};export{o as tokenTypes};
2
+ //# sourceMappingURL=tokenTypes.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"tokenTypes.js","sourceRoot":"","sources":["../../../../../src/token/di/tokenTypes.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,eAAe,EAAE,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC;IAC9C,kBAAkB,EAAE,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC;CACrD,CAAC"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/token/di/tokenTypes.ts"],
4
+ "sourcesContent": ["export const tokenTypes = {\n TokenDataSource: Symbol.for(\"TokenDataSource\"),\n TokenContextLoader: Symbol.for(\"TokenContextLoader\"),\n};\n"],
5
+ "mappings": "AAAO,MAAMA,EAAa,CACxB,gBAAiB,OAAO,IAAI,iBAAiB,EAC7C,mBAAoB,OAAO,IAAI,oBAAoB,CACrD",
6
+ "names": ["tokenTypes"]
7
+ }
@@ -1,71 +1,2 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- var __param = (this && this.__param) || function (paramIndex, decorator) {
11
- return function (target, key) { decorator(target, key, paramIndex); }
12
- };
13
- import { isHexaString } from "@ledgerhq/device-management-kit";
14
- import { inject, injectable } from "inversify";
15
- import { ClearSignContextType, } from "../../shared/model/ClearSignContext";
16
- import { tokenTypes } from "../../token/di/tokenTypes";
17
- export var ERC20_SUPPORTED_SELECTORS;
18
- (function (ERC20_SUPPORTED_SELECTORS) {
19
- ERC20_SUPPORTED_SELECTORS["Approve"] = "0x095ea7b3";
20
- ERC20_SUPPORTED_SELECTORS["Transfer"] = "0xa9059cbb";
21
- })(ERC20_SUPPORTED_SELECTORS || (ERC20_SUPPORTED_SELECTORS = {}));
22
- const SUPPORTED_SELECTORS = Object.values(ERC20_SUPPORTED_SELECTORS);
23
- let TokenContextLoader = class TokenContextLoader {
24
- _dataSource;
25
- constructor(dataSource) {
26
- this._dataSource = dataSource;
27
- }
28
- async load(transaction) {
29
- if (!transaction.to || !transaction.data || transaction.data === "0x") {
30
- return [];
31
- }
32
- const selector = transaction.data.slice(0, 10);
33
- if (!isHexaString(selector)) {
34
- return [
35
- {
36
- type: ClearSignContextType.ERROR,
37
- error: new Error("Invalid selector"),
38
- },
39
- ];
40
- }
41
- if (!this.isSelectorSupported(selector)) {
42
- return [];
43
- }
44
- const payload = await this._dataSource.getTokenInfosPayload({
45
- address: transaction.to,
46
- chainId: transaction.chainId,
47
- });
48
- return [
49
- payload.caseOf({
50
- Left: (error) => ({
51
- type: ClearSignContextType.ERROR,
52
- error,
53
- }),
54
- Right: (value) => ({
55
- type: ClearSignContextType.TOKEN,
56
- payload: value,
57
- }),
58
- }),
59
- ];
60
- }
61
- isSelectorSupported(selector) {
62
- return Object.values(SUPPORTED_SELECTORS).includes(selector);
63
- }
64
- };
65
- TokenContextLoader = __decorate([
66
- injectable(),
67
- __param(0, inject(tokenTypes.TokenDataSource)),
68
- __metadata("design:paramtypes", [Object])
69
- ], TokenContextLoader);
70
- export { TokenContextLoader };
71
- //# sourceMappingURL=TokenContextLoader.js.map
1
+ var u=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var c=(n,e,t,a)=>{for(var r=a>1?void 0:a?S(e,t):e,s=n.length-1,l;s>=0;s--)(l=n[s])&&(r=(a?l(e,t,r):l(r))||r);return a&&r&&u(e,t,r),r},p=(n,e)=>(t,a)=>e(t,a,n);import{isHexaString as x}from"@ledgerhq/device-management-kit";import{inject as m,injectable as y}from"inversify";import{ClearSignContextType as o}from"../../shared/model/ClearSignContext";import{tokenTypes as f}from"../../token/di/tokenTypes";var d=(t=>(t.Approve="0x095ea7b3",t.Transfer="0xa9059cbb",t))(d||{});const g=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 x(t)?this.isSelectorSupported(t)?[(await this._dataSource.getTokenInfosPayload({address:e.to,chainId:e.chainId})).caseOf({Left:r=>({type:o.ERROR,error:r}),Right:r=>({type:o.TOKEN,payload:r})})]:[]:[{type:o.ERROR,error:new Error("Invalid selector")}]}async loadField(e){return e.type!==o.TOKEN?null:(await this._dataSource.getTokenInfosPayload({address:e.address,chainId:e.chainId})).caseOf({Left:a=>({type:o.ERROR,error:a}),Right:a=>({type:o.TOKEN,payload:a})})}isSelectorSupported(e){return Object.values(g).includes(e)}};i=c([y(),p(0,m(f.TokenDataSource))],i);export{d as ERC20_SUPPORTED_SELECTORS,i as TokenContextLoader};
2
+ //# sourceMappingURL=TokenContextLoader.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"TokenContextLoader.js","sourceRoot":"","sources":["../../../../../src/token/domain/TokenContextLoader.ts"],"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,CAAC;YAC1D,OAAO,EAAE,WAAW,CAAC,EAAE;YACvB,OAAO,EAAE,WAAW,CAAC,OAAO;SAC7B,CAAC,CAAC;QAEH,OAAO;YACL,OAAO,CAAC,MAAM,CAAC;gBACb,IAAI,EAAE,CAAC,KAAK,EAAoB,EAAE,CAAC,CAAC;oBAClC,IAAI,EAAE,oBAAoB,CAAC,KAAK;oBAChC,KAAK;iBACN,CAAC;gBACF,KAAK,EAAE,CAAC,KAAK,EAAoB,EAAE,CAAC,CAAC;oBACnC,IAAI,EAAE,oBAAoB,CAAC,KAAK;oBAChC,OAAO,EAAE,KAAK;iBACf,CAAC;aACH,CAAC;SACH,CAAC;IACJ,CAAC;IAEO,mBAAmB,CAAC,QAAoB;QAC9C,OAAO,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC/D,CAAC;CACF,CAAA;AAjDY,kBAAkB;IAD9B,UAAU,EAAE;IAIE,WAAA,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC,CAAA;;GAHpC,kBAAkB,CAiD9B"}
1
+ {
2
+ "version": 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": "iOAAA,OAAqB,gBAAAA,MAAoB,kCACzC,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YAGnC,OAEE,wBAAAC,MACK,kCAMP,OAAS,cAAAC,MAAkB,wBAEpB,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,OAAKE,EAAaD,CAAQ,EASrB,KAAK,oBAAoBA,CAAQ,EAS/B,EALS,MAAM,KAAK,YAAY,qBAAqB,CAC1D,QAASD,EAAY,GACrB,QAASA,EAAY,OACvB,CAAC,GAGS,OAAO,CACb,KAAOG,IAA6B,CAClC,KAAMC,EAAqB,MAC3B,MAAAD,CACF,GACA,MAAQE,IAA6B,CACnC,KAAMD,EAAqB,MAC3B,QAASC,CACX,EACF,CAAC,CACH,EAnBS,CAAC,EATD,CACL,CACE,KAAMD,EAAqB,MAC3B,MAAO,IAAI,MAAM,kBAAkB,CACrC,CACF,CAwBJ,CAEA,MAAM,UACJE,EACkC,CAClC,OAAIA,EAAM,OAASF,EAAqB,MAC/B,MAEO,MAAM,KAAK,YAAY,qBAAqB,CAC1D,QAASE,EAAM,QACf,QAASA,EAAM,OACjB,CAAC,GACc,OAAO,CACpB,KAAOH,IAA6B,CAClC,KAAMC,EAAqB,MAC3B,MAAAD,CACF,GACA,MAAQE,IAA6B,CACnC,KAAMD,EAAqB,MAC3B,QAASC,CACX,EACF,CAAC,CACH,CAEQ,oBAAoBJ,EAAsB,CAChD,OAAO,OAAO,OAAOJ,CAAmB,EAAE,SAASI,CAAQ,CAC7D,CACF,EAvEaH,EAANS,EAAA,CADNC,EAAW,EAIGC,EAAA,EAAAC,EAAOC,EAAW,eAAe,IAHnCb",
6
+ "names": ["isHexaString", "inject", "injectable", "ClearSignContextType", "tokenTypes", "ERC20_SUPPORTED_SELECTORS", "SUPPORTED_SELECTORS", "TokenContextLoader", "dataSource", "transaction", "selector", "isHexaString", "error", "ClearSignContextType", "value", "field", "__decorateClass", "injectable", "__decorateParam", "inject", "tokenTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{Left as r,Right as s}from"purify-ts";import{ClearSignContextType as o}from"../../shared/model/ClearSignContext";import{TokenContextLoader as c}from"../../token/domain/TokenContextLoader";describe("TokenContextLoader",()=>{const n={getTokenInfosPayload:vi.fn()},e=new c(n);beforeEach(()=>{vi.restoreAllMocks(),vi.spyOn(n,"getTokenInfosPayload").mockImplementation(({address:t})=>Promise.resolve(s(`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.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(n,"getTokenInfosPayload").mockResolvedValue(r(new Error("error")));const a=await e.load(t);expect(a).toEqual([{type:o.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.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"}])})}),describe("loadField function",()=>{it("should return an error when field type if not supported",async()=>{const t={type:o.NFT,chainId:7,address:"0x1234"},a=await e.loadField(t);expect(a).toEqual(null)}),it("should return a payload",async()=>{const t={type:o.TOKEN,chainId:7,address:"0x1234"};vi.spyOn(n,"getTokenInfosPayload").mockResolvedValue(s("payload"));const a=await e.loadField(t);expect(a).toEqual({type:o.TOKEN,payload:"payload"})}),it("should return an error when unable to fetch the datasource",async()=>{const t={type:o.TOKEN,chainId:7,address:"0x1234"};vi.spyOn(n,"getTokenInfosPayload").mockResolvedValue(r(new Error("error")));const a=await e.loadField(t);expect(a).toEqual({type:o.ERROR,error:new Error("error")})})})});
2
+ //# sourceMappingURL=TokenContextLoader.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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
+ "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAE5B,OAAS,wBAAAC,MAA4B,kCAMrC,OAAS,sBAAAC,MAA0B,oCAEnC,SAAS,qBAAsB,IAAM,CACnC,MAAMC,EAAuC,CAC3C,qBAAsB,GAAG,GAAG,CAC9B,EACMC,EAAS,IAAIF,EAAmBC,CAAmB,EAEzD,WAAW,IAAM,CACf,GAAG,gBAAgB,EACnB,GAAG,MAAMA,EAAqB,sBAAsB,EAAE,mBACpD,CAAC,CAAE,QAAAE,CAAQ,IAAM,QAAQ,QAAQL,EAAM,WAAWK,CAAO,EAAE,CAAC,CAC9D,CACF,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,GAAG,gEAAiE,SAAY,CAE9E,MAAMC,EAAc,CAAE,GAAI,OAAW,KAAM,MAAO,EAG5CC,EAAS,MAAM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AAI,6CACJ,KAAM,uBACN,QAAS,CACX,EAGMC,EAAS,MAAMH,EAAO,KAAKE,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CACrB,CACE,KAAMN,EAAqB,MAC3B,QAAS,oDACX,CACF,CAAC,CACH,CAAC,CACH,CAAC,EAED,SAAS,qBAAsB,IAAM,CACnC,GAAG,0DAA2D,SAAY,CACxE,MAAMO,EAAiC,CACrC,KAAMP,EAAqB,IAC3B,QAAS,EACT,QAAS,QACX,EAEMM,EAAS,MAAMH,EAAO,UAAUI,CAAK,EAE3C,OAAOD,CAAM,EAAE,QAAQ,IAAI,CAC7B,CAAC,EAED,GAAG,0BAA2B,SAAY,CAExC,MAAMC,EAAiC,CACrC,KAAMP,EAAqB,MAC3B,QAAS,EACT,QAAS,QACX,EAGA,GAAG,MAAME,EAAqB,sBAAsB,EAAE,kBACpDH,EAAM,SAAS,CACjB,EACA,MAAMO,EAAS,MAAMH,EAAO,UAAUI,CAAK,EAG3C,OAAOD,CAAM,EAAE,QAAQ,CACrB,KAAMN,EAAqB,MAC3B,QAAS,SACX,CAAC,CACH,CAAC,EAED,GAAG,6DAA8D,SAAY,CAE3E,MAAMO,EAAiC,CACrC,KAAMP,EAAqB,MAC3B,QAAS,EACT,QAAS,QACX,EAGA,GAAG,MAAME,EAAqB,sBAAsB,EAAE,kBACpDJ,EAAK,IAAI,MAAM,OAAO,CAAC,CACzB,EACA,MAAMQ,EAAS,MAAMH,EAAO,UAAUI,CAAK,EAG3C,OAAOD,CAAM,EAAE,QAAQ,CACrB,KAAMN,EAAqB,MAC3B,MAAO,IAAI,MAAM,OAAO,CAC1B,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["Left", "Right", "ClearSignContextType", "TokenContextLoader", "mockTokenDataSource", "loader", "address", "transaction", "result", "field"]
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=CalldataDto.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ var _=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var d=(l,e,t,r)=>{for(var o=r>1?void 0:r?S(e,t):e,n=l.length-1,i;n>=0;n--)(i=l[n])&&(o=(r?i(e,t,o):i(o))||o);return r&&o&&_(e,t,o),o},f=(l,e)=>(t,r)=>e(t,r,l);import M from"axios";import{inject as m,injectable as I}from"inversify";import{Left as c,Right as x}from"purify-ts";import{configTypes as R}from"../../config/di/configTypes";import{pkiTypes as O}from"../../pki/di/pkiTypes";import{KeyId as F}from"../../pki/model/KeyId";import{KeyUsage as U}from"../../pki/model/KeyUsage";import{ClearSignContextType as a}from"../../shared/model/ClearSignContext";import{INFO_SIGNATURE_TAG as h}from"../../shared/model/SignatureTags";import{HexStringUtils as T}from"../../shared/utils/HexStringUtils";import k from"../../../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 n;try{n=(await M.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/${k.version}`}})).data}catch(i){return c(new Error(`[ContextModule] HttpTransactionDataSource: Failed to fetch transaction informations: ${i}`))}if(!Array.isArray(n))return c(new Error("[ContextModule] HttpTransactionDataSource: Response is not an array"));if(n.length===0)return c(new Error(`[ContextModule] HttpTransactionDataSource: No data for contract ${t} and selector ${r}`));for(const i of n){t=t.toLowerCase(),r=`0x${r.slice(2).toLowerCase()}`;const s=i.descriptors_calldata?.[t]?.[r];if(!s||!this.isCalldataDescriptorV1(s,this.config.cal.mode))continue;const g=s.transaction_info.descriptor.data,E=s.transaction_info.descriptor.signatures[this.config.cal.mode],D={targetDevice:o,keyUsage:U.Calldata,keyId:F.CalCalldataKey},u=await this._certificateLoader.loadCertificate(D),V={type:a.TRANSACTION_INFO,payload:T.appendSignatureToPayload(g,E,h),certificate:u},C=[];for(const[p,b]of Object.entries(s.enums))for(const[v,{data:N,signatures:P}]of Object.entries(b))C.push({type:a.ENUM,id:Number(p),value:Number(v),payload:T.appendSignatureToPayload(N,P[this.config.cal.mode],h),certificate:u});const A=s.fields.map(p=>({type:a.TRANSACTION_FIELD_DESCRIPTION,payload:p.descriptor,reference:this.getReference(p.param)}));return x([V,...C,...A])}return c(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:a.TOKEN,valuePath:this.toGenericPath(e.token.binary_path)};if(e.type==="TOKEN_AMOUNT"&&e.token!==void 0&&e.token.type==="constant")return{type:a.TOKEN,value:e.token.value};if(e.type==="NFT"&&e.collection.type==="path")return{type:a.NFT,valuePath:this.toGenericPath(e.collection.binary_path)};if(e.type==="NFT"&&e.collection.type==="constant")return{type:a.NFT,value:e.collection.value};if(e.type==="TRUSTED_NAME"&&e.value.type==="path")return{type:a.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:a.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(([n,i])=>typeof n=="string"&&typeof i=="object"&&typeof i.data=="string"&&i.signatures!==void 0&&this.isCalldataSignatures(i.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=d([I(),f(0,m(R.Config)),f(1,m(O.PkiCertificateLoader))],y);export{y as HttpTransactionDataSource};
2
+ //# sourceMappingURL=HttpTransactionDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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": "iOAAA,OAAOA,MAAW,QAClB,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAK5B,OAAS,YAAAC,MAAgB,oBAEzB,OAAS,SAAAC,MAAa,oBACtB,OAAS,YAAAC,MAAgB,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Y,MAAM,GACzBF,EAAA,EAAAC,EAAOE,EAAS,oBAAoB,IAH5BhD",
6
+ "names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "pkiTypes", "KeyId", "KeyUsage", "ClearSignContextType", "INFO_SIGNATURE_TAG", "HexStringUtils", "PACKAGE", "HttpTransactionDataSource", "config", "_certificateLoader", "chainId", "address", "selector", "deviceModelId", "dto", "axios", "PACKAGE", "error", "Left", "calldata", "calldataDescriptor", "infoData", "infoSignature", "certificateInfos", "KeyUsage", "KeyId", "certificate", "info", "ClearSignContextType", "HexStringUtils", "INFO_SIGNATURE_TAG", "enums", "id", "values", "value", "data", "signatures", "fields", "field", "Right", "param", "path", "element", "itemSize", "rest", "leafType", "mode", "f", "obj", "e", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes", "pkiTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{DeviceModelId as c}from"@ledgerhq/device-management-kit";import o from"axios";import{Left as i}from"purify-ts";import{HttpTransactionDataSource as D}from"../../transaction/data/HttpTransactionDataSource";import h from"../../../package.json";vi.mock("axios");describe("HttpTransactionDataSource",()=>{let t,r,u,l,v,m,f,p,b,y,x;const d={loadCertificate:vi.fn()};beforeAll(()=>{vi.clearAllMocks();const e={cal:{url:"https://crypto-assets-service.api.ledger.com/v1",mode:"test",branch:"main"}};t=new D(e,d),r={descriptor:{data:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c",signatures:{test:"3045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f"}}},u={0:{1:{data:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec0401000501010606737461626c65",signatures:{test:"3045022100862e724db664f5d94484928a6a5963268a22cd8178ad36e8c4ff13769ac5c27e0220079da2b6e86810156f6b5955b8190bc016c2fe813d27fcb878a9b99658546582"}},2:{data:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04010005010206087661726961626c65",signatures:{test:"3045022100b838ee3d597d6bad2533606cef7335f6c8a45b46d5717803e646777f6c8a6897022074f04b82c3dad8445bb6230ab762010c5fc6ee06198fd3e54752287cbf95c523"}}}},f=E("FROM","UFIXED","AMOUNT","06"),p=E("TO","FIXED","DATETIME","07"),b=E("TO","BOOL","UNIT","08"),y=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"},v={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,T){return{param:{value:{type:"path",binary_path:{type:"CONTAINER",value:e},type_family:a,type_size:32},type:n},descriptor:T}}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/${h.version}`,a=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(o,"request").mockImplementation(a),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0),await t.getTransactionDescriptors({deviceModelId:c.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(o,"request").mockRejectedValue(new Error),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const e=await t.getTransactionDescriptors({deviceModelId:c.FLEX,chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e).toEqual(i(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(o,"request").mockResolvedValue(e),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const a=await t.getTransactionDescriptors({deviceModelId:c.FLEX,chainId:1,address:"0x0abc",selector:"0x01ff"});expect(a).toEqual(i(new Error("[ContextModule] HttpTransactionDataSource: Response is not an array")))}),it("should return an error when an empty array is returned",async()=>{vi.spyOn(o,"request").mockResolvedValue({data:[]}),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const e=await t.getTransactionDescriptors({deviceModelId:c.FLEX,chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e).toEqual(i(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(r,u,[l]);vi.spyOn(o,"request").mockResolvedValue({data:[e]}),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const a=await t.getTransactionDescriptors({deviceModelId:c.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x01fe"});expect(a).toEqual(i(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x01fe")))}),it("Calldata with fields references and enums",async()=>{const e=s(r,u,[l,v,m,x]);vi.spyOn(o,"request").mockResolvedValue({data:[e]}),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const a=await t.getTransactionDescriptors({deviceModelId:c.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:v.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(r,u,[l,v,m,x]),a={keyUsageNumber:11,payload:new Uint8Array([1,2,3,4,21,4,5,6,7,8])};vi.spyOn(o,"request").mockResolvedValue({data:[e]}),vi.spyOn(d,"loadCertificate").mockResolvedValueOnce(a);const n=await t.getTransactionDescriptors({deviceModelId:c.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:v.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(r,[],[f,p,b,y]);vi.spyOn(o,"request").mockResolvedValue({data:[e]}),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const a=await t.getTransactionDescriptors({deviceModelId:c.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(a.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{type:"transactionFieldDescription",payload:f.descriptor},{type:"transactionFieldDescription",payload:p.descriptor},{type:"transactionFieldDescription",payload:b.descriptor},{type:"transactionFieldDescription",payload:y.descriptor}])}),it("Calldata on third array element",async()=>{const e=s(r,[],[f,p,b,y]);vi.spyOn(o,"request").mockResolvedValue({data:[{},{},e]}),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const a=await t.getTransactionDescriptors({deviceModelId:c.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(a.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{type:"transactionFieldDescription",payload:f.descriptor},{type:"transactionFieldDescription",payload:p.descriptor},{type:"transactionFieldDescription",payload:b.descriptor},{type:"transactionFieldDescription",payload:y.descriptor}])}),it("Calldata without fields references and transaction info signature length % 2 different from 0",async()=>{const e={descriptor:{data:r.descriptor.data,signatures:{test:r.descriptor.signatures.test+"0"}}},a=s(e,[],[f,p,b,y]);vi.spyOn(o,"request").mockResolvedValue({data:[a]}),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const n=await t.getTransactionDescriptors({deviceModelId:c.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(n.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff4803045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f0",type:"transactionInfo"},{type:"transactionFieldDescription",payload:f.descriptor},{type:"transactionFieldDescription",payload:p.descriptor},{type:"transactionFieldDescription",payload:b.descriptor},{type:"transactionFieldDescription",payload:y.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(r,[],[e]);vi.spyOn(o,"request").mockResolvedValue({data:[a]}),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const n=await t.getTransactionDescriptors({deviceModelId:c.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(r,[],[e]);vi.spyOn(o,"request").mockResolvedValue({data:[a]}),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const n=await t.getTransactionDescriptors({deviceModelId:c.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:r,enums:u,fields:[l]}}}};vi.spyOn(o,"request").mockResolvedValue({data:[e]}),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const a=await t.getTransactionDescriptors({deviceModelId:c.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(a).toEqual(i(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"}}},u,[l]);vi.spyOn(o,"request").mockResolvedValue({data:[e]}),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const a=await t.getTransactionDescriptors({deviceModelId:c.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(a).toEqual(i(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(r,["badEnum"],[l]);vi.spyOn(o,"request").mockResolvedValue({data:[e]}),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const a=await t.getTransactionDescriptors({deviceModelId:c.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(a).toEqual(i(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(r,{0:{1:{data:"1234"}}},[l]);vi.spyOn(o,"request").mockResolvedValue({data:[e]}),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const a=await t.getTransactionDescriptors({deviceModelId:c.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(a).toEqual(i(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(r,{0:{1:{data:"0001010108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04010005010106067374626c65",signatures:{prod:"wrongSignature"}}}},[l]);vi.spyOn(o,"request").mockResolvedValue({data:[e]}),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const a=await t.getTransactionDescriptors({deviceModelId:c.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(a).toEqual(i(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(r,[],[{descriptor:3}]);vi.spyOn(o,"request").mockResolvedValue({data:[e]}),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const a=await t.getTransactionDescriptors({deviceModelId:c.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(a).toEqual(i(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(r,[],[{param:{value:{binary_path:"TO",type_family:"UNKNOWN",type_size:20},type:"DATETIME"},descriptor:"000100010c546f20726563697069667"}]);vi.spyOn(o,"request").mockResolvedValue({data:[a]}),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const n=await t.getTransactionDescriptors({deviceModelId:c.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(n).toEqual(i(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(r,[],[{param:{value:{binary_path:"UNKNOWN",type_family:"ADDRESS",type_size:20},type:"DATETIME"},descriptor:"000100010c546f20726563697069667"}]);vi.spyOn(o,"request").mockResolvedValue({data:[a]}),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const n=await t.getTransactionDescriptors({deviceModelId:c.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(n).toEqual(i(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(r,[],[{param:{value:{binary_path:{elements:[{type:"UNKNOWN"}]},type_family:"ADDRESS",type_size:20},type:"DATETIME"},descriptor:"000100010c546f20726563697069667"}]);vi.spyOn(o,"request").mockResolvedValue({data:[a]}),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const n=await t.getTransactionDescriptors({deviceModelId:c.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(n).toEqual(i(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(r,[],[{param:{value:{binary_path:"TO",type_family:"ADDRESS",type_size:20},type:"UNKNOWN"},descriptor:"000100010c546f20726563697069667"}]);vi.spyOn(o,"request").mockResolvedValue({data:[a]}),vi.spyOn(d,"loadCertificate").mockResolvedValue(void 0);const n=await t.getTransactionDescriptors({deviceModelId:c.FLEX,chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(n).toEqual(i(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))})});
2
+ //# sourceMappingURL=HttpTransactionDataSource.test.js.map