@ledgerhq/context-module 0.0.0-rn-hid-20250221115747 → 0.0.0-rn-hid-sync-onboarding-behavior-20250516114041

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 (270) hide show
  1. package/README.md +17 -5
  2. package/lib/cjs/package.json +12 -12
  3. package/lib/cjs/src/ContextModule.js +1 -1
  4. package/lib/cjs/src/ContextModule.js.map +1 -1
  5. package/lib/cjs/src/ContextModuleBuilder.js +1 -1
  6. package/lib/cjs/src/ContextModuleBuilder.js.map +3 -3
  7. package/lib/cjs/src/ContextModuleBuilder.test.js +1 -1
  8. package/lib/cjs/src/ContextModuleBuilder.test.js.map +3 -3
  9. package/lib/cjs/src/DefaultContextModule.js +1 -1
  10. package/lib/cjs/src/DefaultContextModule.js.map +3 -3
  11. package/lib/cjs/src/DefaultContextModule.test.js +1 -1
  12. package/lib/cjs/src/DefaultContextModule.test.js.map +3 -3
  13. package/lib/cjs/src/config/di/configModuleFactory.js +1 -1
  14. package/lib/cjs/src/config/di/configModuleFactory.js.map +3 -3
  15. package/lib/cjs/src/config/di/configTypes.js +1 -1
  16. package/lib/cjs/src/config/di/configTypes.js.map +2 -2
  17. package/lib/cjs/src/config/model/ContextModuleBuildArgs.js +2 -0
  18. package/lib/cjs/src/config/model/ContextModuleBuildArgs.js.map +7 -0
  19. package/lib/cjs/src/config/model/ContextModuleConfig.js +1 -1
  20. package/lib/cjs/src/config/model/ContextModuleConfig.js.map +1 -1
  21. package/lib/cjs/src/di.js +1 -1
  22. package/lib/cjs/src/di.js.map +3 -3
  23. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js +1 -1
  24. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js.map +3 -3
  25. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js +1 -1
  26. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +3 -3
  27. package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js +1 -1
  28. package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js.map +3 -3
  29. package/lib/cjs/src/index.js +1 -1
  30. package/lib/cjs/src/index.js.map +2 -2
  31. package/lib/cjs/src/nft/data/HttpNftDataSource.js +1 -1
  32. package/lib/cjs/src/nft/data/HttpNftDataSource.js.map +3 -3
  33. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js +1 -1
  34. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js.map +3 -3
  35. package/lib/cjs/src/nft/di/nftModuleFactory.js +1 -1
  36. package/lib/cjs/src/nft/di/nftModuleFactory.js.map +3 -3
  37. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.js +1 -1
  38. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.js.map +3 -3
  39. package/lib/cjs/src/pki/di/pkiModuleFactory.js +1 -1
  40. package/lib/cjs/src/pki/di/pkiModuleFactory.js.map +3 -3
  41. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js +1 -1
  42. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +3 -3
  43. package/lib/cjs/src/pki/model/PkiCertificateInfo.js +1 -1
  44. package/lib/cjs/src/pki/model/PkiCertificateInfo.js.map +1 -1
  45. package/lib/cjs/src/shared/constant/HttpHeaders.js +2 -0
  46. package/lib/cjs/src/shared/constant/HttpHeaders.js.map +7 -0
  47. package/lib/cjs/src/shared/model/ClearSignContext.js +1 -1
  48. package/lib/cjs/src/shared/model/ClearSignContext.js.map +2 -2
  49. package/lib/cjs/src/shared/model/TransactionSubset.js +1 -1
  50. package/lib/cjs/src/shared/model/TransactionSubset.js.map +1 -1
  51. package/lib/cjs/src/shared/model/TypedDataClearSignContext.js +1 -1
  52. package/lib/cjs/src/shared/model/TypedDataClearSignContext.js.map +2 -2
  53. package/lib/cjs/src/token/data/HttpTokenDataSource.js +1 -1
  54. package/lib/cjs/src/token/data/HttpTokenDataSource.js.map +3 -3
  55. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js +1 -1
  56. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js.map +3 -3
  57. package/lib/cjs/src/token/di/tokenModuleFactory.js +1 -1
  58. package/lib/cjs/src/token/di/tokenModuleFactory.js.map +3 -3
  59. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js +1 -1
  60. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js.map +3 -3
  61. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js +1 -1
  62. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js.map +3 -3
  63. package/lib/cjs/src/transaction/di/transactionModuleFactory.js +1 -1
  64. package/lib/cjs/src/transaction/di/transactionModuleFactory.js.map +3 -3
  65. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
  66. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js.map +3 -3
  67. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  68. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +3 -3
  69. package/lib/cjs/src/trusted-name/data/TrustedNameDataSource.js +1 -1
  70. package/lib/cjs/src/trusted-name/data/TrustedNameDataSource.js.map +1 -1
  71. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js +1 -1
  72. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js.map +3 -3
  73. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
  74. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js.map +3 -3
  75. package/lib/cjs/src/typed-data/data/FiltersDto.js +1 -1
  76. package/lib/cjs/src/typed-data/data/FiltersDto.js.map +1 -1
  77. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
  78. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js.map +3 -3
  79. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  80. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
  81. package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js +1 -1
  82. package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js.map +3 -3
  83. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js +1 -1
  84. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +3 -3
  85. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
  86. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +2 -2
  87. package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js +1 -1
  88. package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js.map +3 -3
  89. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
  90. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js.map +2 -2
  91. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.js +2 -0
  92. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.js.map +7 -0
  93. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.test.js +2 -0
  94. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.test.js.map +7 -0
  95. package/lib/cjs/src/web3-check/data/Web3CheckDataSource.js +2 -0
  96. package/lib/cjs/src/web3-check/data/Web3CheckDataSource.js.map +7 -0
  97. package/lib/cjs/src/web3-check/data/Web3CheckDto.js +2 -0
  98. package/lib/cjs/src/web3-check/data/Web3CheckDto.js.map +7 -0
  99. package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js +2 -0
  100. package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js.map +7 -0
  101. package/lib/cjs/src/web3-check/di/web3CheckTypes.js +2 -0
  102. package/lib/cjs/src/web3-check/di/web3CheckTypes.js.map +7 -0
  103. package/lib/cjs/src/web3-check/domain/DefaultWeb3CheckLoader.js +2 -0
  104. package/lib/cjs/src/web3-check/domain/DefaultWeb3CheckLoader.js.map +7 -0
  105. package/lib/cjs/src/web3-check/domain/DefaultWeb3CheckLoader.test.js +2 -0
  106. package/lib/cjs/src/web3-check/domain/DefaultWeb3CheckLoader.test.js.map +7 -0
  107. package/lib/cjs/src/web3-check/domain/Web3CheckContextLoader.js +2 -0
  108. package/lib/cjs/src/web3-check/domain/Web3CheckContextLoader.js.map +7 -0
  109. package/lib/cjs/src/web3-check/domain/web3CheckTypes.js +2 -0
  110. package/lib/cjs/src/web3-check/domain/web3CheckTypes.js.map +7 -0
  111. package/lib/esm/package.json +12 -12
  112. package/lib/esm/src/ContextModuleBuilder.js +1 -1
  113. package/lib/esm/src/ContextModuleBuilder.js.map +3 -3
  114. package/lib/esm/src/ContextModuleBuilder.test.js +1 -1
  115. package/lib/esm/src/ContextModuleBuilder.test.js.map +3 -3
  116. package/lib/esm/src/DefaultContextModule.js +1 -1
  117. package/lib/esm/src/DefaultContextModule.js.map +3 -3
  118. package/lib/esm/src/DefaultContextModule.test.js +1 -1
  119. package/lib/esm/src/DefaultContextModule.test.js.map +3 -3
  120. package/lib/esm/src/config/di/configModuleFactory.js +1 -1
  121. package/lib/esm/src/config/di/configModuleFactory.js.map +3 -3
  122. package/lib/esm/src/config/di/configTypes.js +1 -1
  123. package/lib/esm/src/config/di/configTypes.js.map +2 -2
  124. package/lib/esm/src/config/model/ContextModuleBuildArgs.js +1 -0
  125. package/lib/esm/src/config/model/ContextModuleBuildArgs.js.map +7 -0
  126. package/lib/esm/src/di.js +1 -1
  127. package/lib/esm/src/di.js.map +3 -3
  128. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js +1 -1
  129. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js.map +3 -3
  130. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js +1 -1
  131. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +3 -3
  132. package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js +1 -1
  133. package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js.map +3 -3
  134. package/lib/esm/src/index.js +1 -1
  135. package/lib/esm/src/index.js.map +2 -2
  136. package/lib/esm/src/nft/data/HttpNftDataSource.js +1 -1
  137. package/lib/esm/src/nft/data/HttpNftDataSource.js.map +3 -3
  138. package/lib/esm/src/nft/data/HttpNftDataSource.test.js +1 -1
  139. package/lib/esm/src/nft/data/HttpNftDataSource.test.js.map +3 -3
  140. package/lib/esm/src/nft/di/nftModuleFactory.js +1 -1
  141. package/lib/esm/src/nft/di/nftModuleFactory.js.map +3 -3
  142. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.js +1 -1
  143. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.js.map +3 -3
  144. package/lib/esm/src/pki/di/pkiModuleFactory.js +1 -1
  145. package/lib/esm/src/pki/di/pkiModuleFactory.js.map +3 -3
  146. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js +1 -1
  147. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +3 -3
  148. package/lib/esm/src/shared/constant/HttpHeaders.js +2 -0
  149. package/lib/esm/src/shared/constant/HttpHeaders.js.map +7 -0
  150. package/lib/esm/src/shared/model/ClearSignContext.js +1 -1
  151. package/lib/esm/src/shared/model/ClearSignContext.js.map +2 -2
  152. package/lib/esm/src/shared/model/TypedDataClearSignContext.js.map +2 -2
  153. package/lib/esm/src/token/data/HttpTokenDataSource.js +1 -1
  154. package/lib/esm/src/token/data/HttpTokenDataSource.js.map +3 -3
  155. package/lib/esm/src/token/data/HttpTokenDataSource.test.js +1 -1
  156. package/lib/esm/src/token/data/HttpTokenDataSource.test.js.map +3 -3
  157. package/lib/esm/src/token/di/tokenModuleFactory.js +1 -1
  158. package/lib/esm/src/token/di/tokenModuleFactory.js.map +3 -3
  159. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js +1 -1
  160. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js.map +3 -3
  161. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js +1 -1
  162. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js.map +3 -3
  163. package/lib/esm/src/transaction/di/transactionModuleFactory.js +1 -1
  164. package/lib/esm/src/transaction/di/transactionModuleFactory.js.map +3 -3
  165. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
  166. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js.map +3 -3
  167. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  168. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +3 -3
  169. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js +1 -1
  170. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js.map +3 -3
  171. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
  172. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js.map +3 -3
  173. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
  174. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js.map +3 -3
  175. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  176. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
  177. package/lib/esm/src/typed-data/di/typedDataModuleFactory.js +1 -1
  178. package/lib/esm/src/typed-data/di/typedDataModuleFactory.js.map +3 -3
  179. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js +1 -1
  180. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +3 -3
  181. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
  182. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +2 -2
  183. package/lib/esm/src/uniswap/di/uniswapModuleFactory.js +1 -1
  184. package/lib/esm/src/uniswap/di/uniswapModuleFactory.js.map +3 -3
  185. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
  186. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js.map +2 -2
  187. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.js +2 -0
  188. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.js.map +7 -0
  189. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.test.js +2 -0
  190. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.test.js.map +7 -0
  191. package/lib/esm/src/web3-check/data/Web3CheckDataSource.js +1 -0
  192. package/lib/esm/src/web3-check/data/Web3CheckDataSource.js.map +7 -0
  193. package/lib/esm/src/web3-check/data/Web3CheckDto.js +1 -0
  194. package/lib/esm/src/web3-check/data/Web3CheckDto.js.map +7 -0
  195. package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js +2 -0
  196. package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js.map +7 -0
  197. package/lib/esm/src/web3-check/di/web3CheckTypes.js +2 -0
  198. package/lib/esm/src/web3-check/di/web3CheckTypes.js.map +7 -0
  199. package/lib/esm/src/web3-check/domain/DefaultWeb3CheckLoader.js +2 -0
  200. package/lib/esm/src/web3-check/domain/DefaultWeb3CheckLoader.js.map +7 -0
  201. package/lib/esm/src/web3-check/domain/DefaultWeb3CheckLoader.test.js +2 -0
  202. package/lib/esm/src/web3-check/domain/DefaultWeb3CheckLoader.test.js.map +7 -0
  203. package/lib/esm/src/web3-check/domain/Web3CheckContextLoader.js +1 -0
  204. package/lib/esm/src/web3-check/domain/Web3CheckContextLoader.js.map +7 -0
  205. package/lib/esm/src/web3-check/domain/web3CheckTypes.js +1 -0
  206. package/lib/esm/src/web3-check/domain/web3CheckTypes.js.map +7 -0
  207. package/lib/types/src/ContextModule.d.ts +2 -0
  208. package/lib/types/src/ContextModule.d.ts.map +1 -1
  209. package/lib/types/src/ContextModuleBuilder.d.ts +20 -2
  210. package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -1
  211. package/lib/types/src/DefaultContextModule.d.ts +5 -1
  212. package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
  213. package/lib/types/src/config/di/configModuleFactory.d.ts.map +1 -1
  214. package/lib/types/src/config/di/configTypes.d.ts +1 -0
  215. package/lib/types/src/config/di/configTypes.d.ts.map +1 -1
  216. package/lib/types/src/config/model/ContextModuleBuildArgs.d.ts +4 -0
  217. package/lib/types/src/config/model/ContextModuleBuildArgs.d.ts.map +1 -0
  218. package/lib/types/src/config/model/ContextModuleConfig.d.ts +7 -0
  219. package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -1
  220. package/lib/types/src/di.d.ts.map +1 -1
  221. package/lib/types/src/external-plugin/data/HttpExternalPluginDataSource.d.ts.map +1 -1
  222. package/lib/types/src/index.d.ts +2 -0
  223. package/lib/types/src/index.d.ts.map +1 -1
  224. package/lib/types/src/nft/data/HttpNftDataSource.d.ts.map +1 -1
  225. package/lib/types/src/pki/data/HttpPkiCertificateDataSource.d.ts.map +1 -1
  226. package/lib/types/src/pki/model/PkiCertificateInfo.d.ts +1 -1
  227. package/lib/types/src/pki/model/PkiCertificateInfo.d.ts.map +1 -1
  228. package/lib/types/src/shared/constant/HttpHeaders.d.ts +3 -0
  229. package/lib/types/src/shared/constant/HttpHeaders.d.ts.map +1 -0
  230. package/lib/types/src/shared/model/ClearSignContext.d.ts +1 -0
  231. package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -1
  232. package/lib/types/src/shared/model/TransactionSubset.d.ts +2 -0
  233. package/lib/types/src/shared/model/TransactionSubset.d.ts.map +1 -1
  234. package/lib/types/src/shared/model/TypedDataClearSignContext.d.ts +17 -5
  235. package/lib/types/src/shared/model/TypedDataClearSignContext.d.ts.map +1 -1
  236. package/lib/types/src/token/data/HttpTokenDataSource.d.ts.map +1 -1
  237. package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts.map +1 -1
  238. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts +2 -2
  239. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts.map +1 -1
  240. package/lib/types/src/trusted-name/data/TrustedNameDataSource.d.ts +2 -0
  241. package/lib/types/src/trusted-name/data/TrustedNameDataSource.d.ts.map +1 -1
  242. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts.map +1 -1
  243. package/lib/types/src/typed-data/data/FiltersDto.d.ts +17 -1
  244. package/lib/types/src/typed-data/data/FiltersDto.d.ts.map +1 -1
  245. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts +2 -0
  246. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts.map +1 -1
  247. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts.map +1 -1
  248. package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts.map +1 -1
  249. package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.d.ts +14 -0
  250. package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.d.ts.map +1 -0
  251. package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.test.d.ts +2 -0
  252. package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.test.d.ts.map +1 -0
  253. package/lib/types/src/web3-check/data/Web3CheckDataSource.d.ts +6 -0
  254. package/lib/types/src/web3-check/data/Web3CheckDataSource.d.ts.map +1 -0
  255. package/lib/types/src/web3-check/data/Web3CheckDto.d.ts +20 -0
  256. package/lib/types/src/web3-check/data/Web3CheckDto.d.ts.map +1 -0
  257. package/lib/types/src/web3-check/di/web3CheckModuleFactory.d.ts +3 -0
  258. package/lib/types/src/web3-check/di/web3CheckModuleFactory.d.ts.map +1 -0
  259. package/lib/types/src/web3-check/di/web3CheckTypes.d.ts +5 -0
  260. package/lib/types/src/web3-check/di/web3CheckTypes.d.ts.map +1 -0
  261. package/lib/types/src/web3-check/domain/DefaultWeb3CheckLoader.d.ts +10 -0
  262. package/lib/types/src/web3-check/domain/DefaultWeb3CheckLoader.d.ts.map +1 -0
  263. package/lib/types/src/web3-check/domain/DefaultWeb3CheckLoader.test.d.ts +2 -0
  264. package/lib/types/src/web3-check/domain/DefaultWeb3CheckLoader.test.d.ts.map +1 -0
  265. package/lib/types/src/web3-check/domain/Web3CheckContextLoader.d.ts +6 -0
  266. package/lib/types/src/web3-check/domain/Web3CheckContextLoader.d.ts.map +1 -0
  267. package/lib/types/src/web3-check/domain/web3CheckTypes.d.ts +35 -0
  268. package/lib/types/src/web3-check/domain/web3CheckTypes.d.ts.map +1 -0
  269. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  270. package/package.json +13 -13
@@ -0,0 +1,2 @@
1
+ "use strict";var r=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var h=(t,e,o,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of c(e))!b.call(t,s)&&s!==o&&r(t,s,{get:()=>e[s],enumerable:!(p=a(e,s))||p.enumerable});return t};var i=t=>h(r({},"__esModule",{value:!0}),t);var k={};module.exports=i(k);
2
+ //# sourceMappingURL=Web3CheckDto.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/web3-check/data/Web3CheckDto.ts"],
4
+ "sourcesContent": ["import type { Web3CheckTypedData } from \"@/web3-check/domain/web3CheckTypes\";\n\nexport type GetWeb3ChecksTypedDataRequestDto = {\n msg: {\n from: string;\n data: Web3CheckTypedData;\n };\n};\n\nexport type GetWeb3ChecksRawTxRequestDto = {\n tx: {\n from: string;\n raw: string;\n };\n chain: number;\n};\n\nexport type GetWeb3ChecksRequestDto =\n | GetWeb3ChecksTypedDataRequestDto\n | GetWeb3ChecksRawTxRequestDto;\n\nexport type Web3CheckDto = {\n public_key_id: string;\n descriptor: string;\n};\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["Web3CheckDto_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var c=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var n=(e,o)=>{for(var r in o)c(e,r,{get:o[r],enumerable:!0})},u=(e,o,r,C)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of b(o))!f.call(e,t)&&t!==r&&c(e,t,{get:()=>o[t],enumerable:!(C=k(o,t))||C.enumerable});return e};var i=e=>u(c({},"__esModule",{value:!0}),e);var d={};n(d,{web3CheckModuleFactory:()=>W});module.exports=i(d);var m=require("inversify"),p=require("../../web3-check/data/HttpWeb3CheckDataSource"),h=require("../../web3-check/domain/DefaultWeb3CheckLoader"),a=require("./web3CheckTypes");const W=()=>new m.ContainerModule(({bind:e})=>{e(a.web3CheckTypes.Web3CheckDataSource).to(p.HttpWeb3CheckDataSource),e(a.web3CheckTypes.Web3CheckContextLoader).to(h.DefaultWeb3CheckContextLoader)});0&&(module.exports={web3CheckModuleFactory});
2
+ //# sourceMappingURL=web3CheckModuleFactory.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/web3-check/di/web3CheckModuleFactory.ts"],
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpWeb3CheckDataSource } from \"@/web3-check/data/HttpWeb3CheckDataSource\";\nimport { DefaultWeb3CheckContextLoader } from \"@/web3-check/domain/DefaultWeb3CheckLoader\";\n\nimport { web3CheckTypes } from \"./web3CheckTypes\";\n\nexport const web3CheckModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(web3CheckTypes.Web3CheckDataSource).to(HttpWeb3CheckDataSource);\n bind(web3CheckTypes.Web3CheckContextLoader).to(\n DefaultWeb3CheckContextLoader,\n );\n });\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,qBAEhCC,EAAwC,qDACxCC,EAA8C,sDAE9CC,EAA+B,4BAExB,MAAML,EAAyB,IACpC,IAAI,kBAAgB,CAAC,CAAE,KAAAM,CAAK,IAAM,CAChCA,EAAK,iBAAe,mBAAmB,EAAE,GAAG,yBAAuB,EACnEA,EAAK,iBAAe,sBAAsB,EAAE,GAC1C,+BACF,CACF,CAAC",
6
+ "names": ["web3CheckModuleFactory_exports", "__export", "web3CheckModuleFactory", "__toCommonJS", "import_inversify", "import_HttpWeb3CheckDataSource", "import_DefaultWeb3CheckLoader", "import_web3CheckTypes", "bind"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var b=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var k=(o,e)=>{for(var t in e)b(o,t,{get:e[t],enumerable:!0})},S=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of a(e))!h.call(o,c)&&c!==t&&b(o,c,{get:()=>e[c],enumerable:!(r=C(e,c))||r.enumerable});return o};var W=o=>S(b({},"__esModule",{value:!0}),o);var x={};k(x,{web3CheckTypes:()=>n});module.exports=W(x);const n={Web3CheckDataSource:Symbol.for("Web3CheckDataSource"),Web3CheckContextLoader:Symbol.for("Web3CheckContextLoader")};0&&(module.exports={web3CheckTypes});
2
+ //# sourceMappingURL=web3CheckTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/web3-check/di/web3CheckTypes.ts"],
4
+ "sourcesContent": ["export const web3CheckTypes = {\n Web3CheckDataSource: Symbol.for(\"Web3CheckDataSource\"),\n Web3CheckContextLoader: Symbol.for(\"Web3CheckContextLoader\"),\n};\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAiB,CAC5B,oBAAqB,OAAO,IAAI,qBAAqB,EACrD,uBAAwB,OAAO,IAAI,wBAAwB,CAC7D",
6
+ "names": ["web3CheckTypes_exports", "__export", "web3CheckTypes", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var i=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var n=Object.prototype.hasOwnProperty;var S=(r,e)=>{for(var o in e)i(r,o,{get:e[o],enumerable:!0})},u=(r,e,o,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of W(e))!n.call(r,t)&&t!==o&&i(r,t,{get:()=>e[t],enumerable:!(c=p(e,t))||c.enumerable});return r};var d=r=>u(i({},"__esModule",{value:!0}),r),b=(r,e,o,c)=>{for(var t=c>1?void 0:c?p(e,o):e,h=r.length-1,s;h>=0;h--)(s=r[h])&&(t=(c?s(e,o,t):s(t))||t);return c&&t&&i(e,o,t),t},C=(r,e)=>(o,c)=>e(o,c,r);var f={};S(f,{DefaultWeb3CheckContextLoader:()=>a});module.exports=d(f);var m=require("inversify"),k=require("../../web3-check/di/web3CheckTypes");let a=class{_dataSource;constructor(e){this._dataSource=e}async load(e){return await this._dataSource.getWeb3Checks(e)}};a=b([(0,m.injectable)(),C(0,(0,m.inject)(k.web3CheckTypes.Web3CheckDataSource))],a);0&&(module.exports={DefaultWeb3CheckContextLoader});
2
+ //# sourceMappingURL=DefaultWeb3CheckLoader.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/web3-check/domain/DefaultWeb3CheckLoader.ts"],
4
+ "sourcesContent": ["import { inject, injectable } from \"inversify\";\nimport { Either } from \"purify-ts\";\n\nimport { type Web3CheckDataSource } from \"@/web3-check/data/Web3CheckDataSource\";\nimport { web3CheckTypes } from \"@/web3-check/di/web3CheckTypes\";\n\nimport { Web3CheckContextLoader } from \"./Web3CheckContextLoader\";\nimport { Web3CheckContext, Web3Checks } from \"./web3CheckTypes\";\n\n@injectable()\nexport class DefaultWeb3CheckContextLoader implements Web3CheckContextLoader {\n private _dataSource: Web3CheckDataSource;\n\n constructor(\n @inject(web3CheckTypes.Web3CheckDataSource)\n dataSource: Web3CheckDataSource,\n ) {\n this._dataSource = dataSource;\n }\n\n async load(\n web3CheckContext: Web3CheckContext,\n ): Promise<Either<Error, Web3Checks>> {\n return await this._dataSource.getWeb3Checks(web3CheckContext);\n }\n}\n"],
5
+ "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAmC,qBAInCC,EAA+B,0CAMxB,IAAMC,EAAN,KAAsE,CACnE,YAER,YAEEC,EACA,CACA,KAAK,YAAcA,CACrB,CAEA,MAAM,KACJC,EACoC,CACpC,OAAO,MAAM,KAAK,YAAY,cAAcA,CAAgB,CAC9D,CACF,EAfaF,EAANG,EAAA,IADN,cAAW,EAKPC,EAAA,eAAO,iBAAe,mBAAmB,IAJjCJ",
6
+ "names": ["DefaultWeb3CheckLoader_exports", "__export", "DefaultWeb3CheckContextLoader", "__toCommonJS", "import_inversify", "import_web3CheckTypes", "DefaultWeb3CheckContextLoader", "dataSource", "web3CheckContext", "__decorateClass", "__decorateParam"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var t=require("../../web3-check/domain/DefaultWeb3CheckLoader");describe("DefaultWeb3CheckLoader",()=>{describe("load",()=>{it("should call the dataSource with the correct params",async()=>{const e={getWeb3Checks:vi.fn()},a={from:"from",rawTx:"rawTx",chainId:1};await new t.DefaultWeb3CheckContextLoader(e).load(a),expect(e.getWeb3Checks).toHaveBeenCalledWith({from:"from",rawTx:"rawTx",chainId:1})})})});
2
+ //# sourceMappingURL=DefaultWeb3CheckLoader.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/web3-check/domain/DefaultWeb3CheckLoader.test.ts"],
4
+ "sourcesContent": ["import { DefaultWeb3CheckContextLoader } from \"@/web3-check/domain/DefaultWeb3CheckLoader\";\nimport { type Web3CheckContext } from \"@/web3-check/domain/web3CheckTypes\";\n\ndescribe(\"DefaultWeb3CheckLoader\", () => {\n describe(\"load\", () => {\n it(\"should call the dataSource with the correct params\", async () => {\n // GIVEN\n const dataSource = {\n getWeb3Checks: vi.fn(),\n };\n const web3CheckContext = {\n from: \"from\",\n rawTx: \"rawTx\",\n chainId: 1,\n } as unknown as Web3CheckContext;\n\n // WHEN\n const loader = new DefaultWeb3CheckContextLoader(dataSource);\n await loader.load(web3CheckContext);\n\n // THEN\n expect(dataSource.getWeb3Checks).toHaveBeenCalledWith({\n from: \"from\",\n rawTx: \"rawTx\",\n chainId: 1,\n });\n });\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAA8C,sDAG9C,SAAS,yBAA0B,IAAM,CACvC,SAAS,OAAQ,IAAM,CACrB,GAAG,qDAAsD,SAAY,CAEnE,MAAMC,EAAa,CACjB,cAAe,GAAG,GAAG,CACvB,EACMC,EAAmB,CACvB,KAAM,OACN,MAAO,QACP,QAAS,CACX,EAIA,MADe,IAAI,gCAA8BD,CAAU,EAC9C,KAAKC,CAAgB,EAGlC,OAAOD,EAAW,aAAa,EAAE,qBAAqB,CACpD,KAAM,OACN,MAAO,QACP,QAAS,CACX,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_DefaultWeb3CheckLoader", "dataSource", "web3CheckContext"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var C=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var k=(t,e,h,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of b(e))!i.call(t,o)&&o!==h&&C(t,o,{get:()=>e[o],enumerable:!(r=c(e,o))||r.enumerable});return t};var p=t=>k(C({},"__esModule",{value:!0}),t);var m={};module.exports=p(m);
2
+ //# sourceMappingURL=Web3CheckContextLoader.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/web3-check/domain/Web3CheckContextLoader.ts"],
4
+ "sourcesContent": ["import { type Either } from \"purify-ts\";\n\nimport { type Web3CheckContext, type Web3Checks } from \"./web3CheckTypes\";\n\nexport interface Web3CheckContextLoader {\n load(web3CheckContext: Web3CheckContext): Promise<Either<Error, Web3Checks>>;\n}\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["Web3CheckContextLoader_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var n=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var p=(t,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of c(e))!d.call(t,r)&&r!==o&&n(t,r,{get:()=>e[r],enumerable:!(i=a(e,r))||i.enumerable});return t};var s=t=>p(n({},"__esModule",{value:!0}),t);var y={};module.exports=s(y);
2
+ //# sourceMappingURL=web3CheckTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/web3-check/domain/web3CheckTypes.ts"],
4
+ "sourcesContent": ["import { type DeviceModelId } from \"@ledgerhq/device-management-kit\";\n\nimport { type PkiCertificate } from \"@/pki/model/PkiCertificate\";\n\nexport type Web3CheckTypedData = {\n domain: {\n name?: string;\n version?: string;\n chainId?: number;\n verifyingContract?: string;\n salt?: string;\n };\n types: Record<string, Array<{ name: string; type: string }>>;\n primaryType: string;\n message: Record<string, unknown>;\n};\n\nexport type Web3CheckTypedDataContext = {\n from: string;\n deviceModelId: DeviceModelId;\n data: Web3CheckTypedData;\n};\n\nexport type Web3CheckRawTxContext = {\n from: string;\n deviceModelId: DeviceModelId;\n rawTx: string;\n chainId: number;\n};\n\nexport type Web3CheckContext =\n | Web3CheckTypedDataContext\n | Web3CheckRawTxContext;\n\nexport type Web3Checks = {\n publicKeyId: string;\n descriptor: string;\n certificate?: PkiCertificate;\n};\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["web3CheckTypes_exports", "__toCommonJS"]
7
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/context-module",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "private": false,
5
5
  "license": "Apache-2.0",
6
6
  "exports": {
@@ -20,9 +20,9 @@
20
20
  ],
21
21
  "scripts": {
22
22
  "prebuild": "rimraf lib",
23
- "build": "pnpm lmdk-build --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
23
+ "build": "pnpm ldmk-tool build --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
24
24
  "dev": "concurrently \"pnpm watch:builds\" \"pnpm watch:types\"",
25
- "watch:builds": "pnpm lmdk-watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
25
+ "watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
26
26
  "watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\"",
27
27
  "lint": "eslint",
28
28
  "lint:fix": "pnpm lint --fix",
@@ -36,21 +36,21 @@
36
36
  },
37
37
  "devDependencies": {
38
38
  "@ledgerhq/device-management-kit": "workspace:*",
39
- "@ledgerhq/esbuild-tools": "workspace:*",
39
+ "@ledgerhq/ldmk-tool": "workspace:*",
40
40
  "@ledgerhq/eslint-config-dsdk": "workspace:*",
41
41
  "@ledgerhq/prettier-config-dsdk": "workspace:*",
42
42
  "@ledgerhq/tsconfig-dsdk": "workspace:*",
43
43
  "@ledgerhq/vitest-config-dmk": "workspace:*",
44
- "@types/crypto-js": "^4.2.2",
45
- "ts-node": "^10.9.2"
44
+ "@types/crypto-js": "catalog:",
45
+ "ts-node": "catalog:"
46
46
  },
47
47
  "dependencies": {
48
- "axios": "^1.7.9",
49
- "crypto-js": "^4.2.0",
50
- "ethers": "6.13.4",
51
- "inversify": "^6.2.2",
52
- "purify-ts": "^2.1.0",
53
- "reflect-metadata": "^0.2.2"
48
+ "axios": "catalog:",
49
+ "crypto-js": "catalog:",
50
+ "ethers": "catalog:",
51
+ "inversify": "catalog:",
52
+ "purify-ts": "catalog:",
53
+ "reflect-metadata": "catalog:"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@ledgerhq/device-management-kit": "workspace:*"
@@ -1,2 +1,2 @@
1
- import{DefaultContextModule as e}from"./DefaultContextModule";const r="https://crypto-assets-service.api.ledger.com/v1",o={cal:{url:r,mode:"prod",branch:"main"},defaultLoaders:!0,customLoaders:[],customTypedDataLoader:void 0};class n{config=o;constructor(){}removeDefaultLoaders(){return this.config.defaultLoaders=!1,this}addLoader(t){return this.config.customLoaders.push(t),this}addTypedDataLoader(t){return this.config.customTypedDataLoader=t,this}addCalConfig(t){return this.config.cal={...o.cal,...t},this}build(){return new e(this.config)}}export{n as ContextModuleBuilder,o as DEFAULT_CONFIG};
1
+ import{DefaultContextModule as t}from"./DefaultContextModule";const r="https://crypto-assets-service.api.ledger.com/v1",n="https://web3checks-backend.api.ledger.com/v3",o={cal:{url:r,mode:"prod",branch:"main"},web3checks:{url:n},defaultLoaders:!0,customLoaders:[],customTypedDataLoader:void 0};class s{config=o;needOriginToken=!0;originToken;constructor({originToken:e}={}){this.originToken=e}removeDefaultLoaders(){return this.config.defaultLoaders=!1,this}addLoader(e){return this.config.customLoaders.push(e),this}addTypedDataLoader(e){return this.config.customTypedDataLoader=e,this}addWeb3CheckLoader(e){return this.needOriginToken=!1,this.config.customWeb3CheckLoader=e,this}addCalConfig(e){return this.config.cal={...o.cal,...e},this}addWeb3ChecksConfig(e){return this.config.web3checks={...o.web3checks,...e},this}build(){if(this.needOriginToken&&!this.originToken)throw new Error("Origin token is required");const e={...this.config,originToken:this.originToken};return new t(e)}}export{s as ContextModuleBuilder,o as DEFAULT_CONFIG};
2
2
  //# sourceMappingURL=ContextModuleBuilder.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/ContextModuleBuilder.ts"],
4
- "sourcesContent": ["import {\n type ContextModuleCalConfig,\n type ContextModuleConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport { type TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { type ContextModule } from \"./ContextModule\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst DEFAULT_CAL_URL = \"https://crypto-assets-service.api.ledger.com/v1\";\n\nexport const DEFAULT_CONFIG: ContextModuleConfig = {\n cal: {\n url: DEFAULT_CAL_URL,\n mode: \"prod\",\n branch: \"main\",\n },\n defaultLoaders: true,\n customLoaders: [],\n customTypedDataLoader: undefined,\n};\n\nexport class ContextModuleBuilder {\n private config: ContextModuleConfig = DEFAULT_CONFIG;\n\n constructor() {}\n\n /**\n * Remove default loaders from the list of loaders\n *\n * @returns this\n */\n removeDefaultLoaders() {\n this.config.defaultLoaders = false;\n return this;\n }\n\n /**\n * Add a custom loader to the list of loaders\n *\n * @param loader loader to add to the list of loaders\n * @returns this\n */\n addLoader(loader: ContextLoader) {\n this.config.customLoaders.push(loader);\n return this;\n }\n\n /**\n * Replace the default loader for typed data clear signing contexts\n *\n * @param loader loader to use for typed data clear signing contexts\n * @returns this\n */\n addTypedDataLoader(loader: TypedDataContextLoader) {\n this.config.customTypedDataLoader = loader;\n return this;\n }\n\n /**\n * Add a custom CAL configuration\n *\n * @param calConfig\n * @returns this\n */\n addCalConfig(calConfig: ContextModuleCalConfig) {\n this.config.cal = { ...DEFAULT_CONFIG.cal, ...calConfig };\n return this;\n }\n\n /**\n * Build the context module\n *\n * @returns the context module\n */\n build(): ContextModule {\n return new DefaultContextModule(this.config);\n }\n}\n"],
5
- "mappings": "AAOA,OAAS,wBAAAA,MAA4B,yBAErC,MAAMC,EAAkB,kDAEXC,EAAsC,CACjD,IAAK,CACH,IAAKD,EACL,KAAM,OACN,OAAQ,MACV,EACA,eAAgB,GAChB,cAAe,CAAC,EAChB,sBAAuB,MACzB,EAEO,MAAME,CAAqB,CACxB,OAA8BD,EAEtC,aAAc,CAAC,CAOf,sBAAuB,CACrB,YAAK,OAAO,eAAiB,GACtB,IACT,CAQA,UAAUE,EAAuB,CAC/B,YAAK,OAAO,cAAc,KAAKA,CAAM,EAC9B,IACT,CAQA,mBAAmBA,EAAgC,CACjD,YAAK,OAAO,sBAAwBA,EAC7B,IACT,CAQA,aAAaC,EAAmC,CAC9C,YAAK,OAAO,IAAM,CAAE,GAAGH,EAAe,IAAK,GAAGG,CAAU,EACjD,IACT,CAOA,OAAuB,CACrB,OAAO,IAAIL,EAAqB,KAAK,MAAM,CAC7C,CACF",
6
- "names": ["DefaultContextModule", "DEFAULT_CAL_URL", "DEFAULT_CONFIG", "ContextModuleBuilder", "loader", "calConfig"]
4
+ "sourcesContent": ["import { type ContextModuleConstructorArgs } from \"./config/model/ContextModuleBuildArgs\";\nimport {\n type ContextModuleCalConfig,\n type ContextModuleConfig,\n type ContextModuleWeb3ChecksConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport { type TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { type Web3CheckContextLoader } from \"./web3-check/domain/Web3CheckContextLoader\";\nimport { type ContextModule } from \"./ContextModule\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst DEFAULT_CAL_URL = \"https://crypto-assets-service.api.ledger.com/v1\";\nconst DEFAULT_WEB3_CHECKS_URL = \"https://web3checks-backend.api.ledger.com/v3\";\n\nexport const DEFAULT_CONFIG: ContextModuleConfig = {\n cal: {\n url: DEFAULT_CAL_URL,\n mode: \"prod\",\n branch: \"main\",\n },\n web3checks: {\n url: DEFAULT_WEB3_CHECKS_URL,\n },\n defaultLoaders: true,\n customLoaders: [],\n customTypedDataLoader: undefined,\n};\n\nexport class ContextModuleBuilder {\n private config: ContextModuleConfig = DEFAULT_CONFIG;\n private needOriginToken: boolean = true;\n private originToken?: string;\n\n constructor({ originToken }: ContextModuleConstructorArgs = {}) {\n this.originToken = originToken;\n }\n\n /**\n * Remove default loaders from the list of loaders\n *\n * @returns this\n */\n removeDefaultLoaders() {\n this.config.defaultLoaders = false;\n return this;\n }\n\n /**\n * Add a custom loader to the list of loaders\n *\n * @param loader loader to add to the list of loaders\n * @returns this\n */\n addLoader(loader: ContextLoader) {\n this.config.customLoaders.push(loader);\n return this;\n }\n\n /**\n * Replace the default loader for typed data clear signing contexts\n *\n * @param loader loader to use for typed data clear signing contexts\n * @returns this\n */\n addTypedDataLoader(loader: TypedDataContextLoader) {\n this.config.customTypedDataLoader = loader;\n return this;\n }\n\n /**\n * Replace the default loader for web3 checks\n *\n * @param loader loader to use for web3 checks\n * @returns this\n */\n addWeb3CheckLoader(loader: Web3CheckContextLoader) {\n this.needOriginToken = false;\n this.config.customWeb3CheckLoader = loader;\n return this;\n }\n\n /**\n * Add a custom CAL configuration\n *\n * @param calConfig\n * @returns this\n */\n addCalConfig(calConfig: ContextModuleCalConfig) {\n this.config.cal = { ...DEFAULT_CONFIG.cal, ...calConfig };\n return this;\n }\n\n /**\n * Add a custom web3 checks configuration\n *\n * @param web3ChecksConfig\n * @returns this\n */\n addWeb3ChecksConfig(web3ChecksConfig: ContextModuleWeb3ChecksConfig) {\n this.config.web3checks = {\n ...DEFAULT_CONFIG.web3checks,\n ...web3ChecksConfig,\n };\n return this;\n }\n\n /**\n * Build the context module\n *\n * @returns the context module\n */\n build(): ContextModule {\n if (this.needOriginToken && !this.originToken) {\n throw new Error(\"Origin token is required\");\n }\n\n const config = { ...this.config, originToken: this.originToken };\n return new DefaultContextModule(config);\n }\n}\n"],
5
+ "mappings": "AAUA,OAAS,wBAAAA,MAA4B,yBAErC,MAAMC,EAAkB,kDAClBC,EAA0B,+CAEnBC,EAAsC,CACjD,IAAK,CACH,IAAKF,EACL,KAAM,OACN,OAAQ,MACV,EACA,WAAY,CACV,IAAKC,CACP,EACA,eAAgB,GAChB,cAAe,CAAC,EAChB,sBAAuB,MACzB,EAEO,MAAME,CAAqB,CACxB,OAA8BD,EAC9B,gBAA2B,GAC3B,YAER,YAAY,CAAE,YAAAE,CAAY,EAAkC,CAAC,EAAG,CAC9D,KAAK,YAAcA,CACrB,CAOA,sBAAuB,CACrB,YAAK,OAAO,eAAiB,GACtB,IACT,CAQA,UAAUC,EAAuB,CAC/B,YAAK,OAAO,cAAc,KAAKA,CAAM,EAC9B,IACT,CAQA,mBAAmBA,EAAgC,CACjD,YAAK,OAAO,sBAAwBA,EAC7B,IACT,CAQA,mBAAmBA,EAAgC,CACjD,YAAK,gBAAkB,GACvB,KAAK,OAAO,sBAAwBA,EAC7B,IACT,CAQA,aAAaC,EAAmC,CAC9C,YAAK,OAAO,IAAM,CAAE,GAAGJ,EAAe,IAAK,GAAGI,CAAU,EACjD,IACT,CAQA,oBAAoBC,EAAiD,CACnE,YAAK,OAAO,WAAa,CACvB,GAAGL,EAAe,WAClB,GAAGK,CACL,EACO,IACT,CAOA,OAAuB,CACrB,GAAI,KAAK,iBAAmB,CAAC,KAAK,YAChC,MAAM,IAAI,MAAM,0BAA0B,EAG5C,MAAMC,EAAS,CAAE,GAAG,KAAK,OAAQ,YAAa,KAAK,WAAY,EAC/D,OAAO,IAAIT,EAAqBS,CAAM,CACxC,CACF",
6
+ "names": ["DefaultContextModule", "DEFAULT_CAL_URL", "DEFAULT_WEB3_CHECKS_URL", "DEFAULT_CONFIG", "ContextModuleBuilder", "originToken", "loader", "calConfig", "web3ChecksConfig", "config"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ContextModuleBuilder as o}from"./ContextModuleBuilder";import{DefaultContextModule as d}from"./DefaultContextModule";describe("ContextModuleBuilder",()=>{const u={url:"https://crypto-assets-service.api.ledger.com/v1",mode:"prod",branch:"main"};it("should return a default context module",()=>{const e=new o().build();expect(e).toBeInstanceOf(d)}),it("should return a custom context module",()=>{const t=new o,e={load:vi.fn()},n=t.removeDefaultLoaders().addLoader(e).build();expect(n).toBeInstanceOf(d)}),it("should return a custom context module with a custom typed data loader",()=>{const t=new o,e={load:vi.fn()},n=t.removeDefaultLoaders().addTypedDataLoader(e).build();expect(n).toBeInstanceOf(d)}),it("should return a custom context module with a custom config",()=>{const e=new o().addCalConfig(u).build();expect(e).toBeInstanceOf(d)})});
1
+ import{configTypes as i}from"./config/di/configTypes";import{ContextModuleBuilder as n}from"./ContextModuleBuilder";import{DefaultContextModule as r}from"./DefaultContextModule";describe("ContextModuleBuilder",()=>{const c={url:"https://cal/v1",mode:"prod",branch:"main"},u={url:"https://web3checks/v1"},d={originToken:"test"};it("should return a default context module",()=>{const o=new n(d).build();expect(o).toBeInstanceOf(r)}),it("should return a custom context module",()=>{const e=new n(d),o={load:vi.fn()},t=e.removeDefaultLoaders().addLoader(o).build();expect(t).toBeInstanceOf(r)}),it("should return a custom context module with a custom typed data loader",()=>{const e=new n(d),o={load:vi.fn()},t=e.removeDefaultLoaders().addTypedDataLoader(o).build();expect(t).toBeInstanceOf(r),expect(t._typedDataLoader).toBe(o)}),it("should return a custom context module with a custom config",()=>{const o=new n(d).addCalConfig(c).addWeb3ChecksConfig(u).build(),t=o._container.get(i.Config);expect(o).toBeInstanceOf(r),expect(t.cal).toEqual(c),expect(t.web3checks).toEqual(u)}),it("should return a custom context module with a custom custom web3checks loader",()=>{const e=new n,o={load:vi.fn()},t=e.removeDefaultLoaders().addWeb3CheckLoader(o).build();expect(t).toBeInstanceOf(r),expect(t._web3CheckLoader).toBe(o)}),it("should throw an error if origin token is not provided",()=>{const e=new n;expect(()=>e.build()).toThrow("Origin token is required")}),it("should not throw an error if origin token is provided",()=>{const e=new n(d);expect(()=>e.build()).not.toThrow()}),it("should not throw an error if origin token is not provided and addWeb3CheckLoader is called",()=>{const e=new n;expect(()=>e.addWeb3CheckLoader({load:vi.fn()}).build()).not.toThrow()})});
2
2
  //# sourceMappingURL=ContextModuleBuilder.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/ContextModuleBuilder.test.ts"],
4
- "sourcesContent": ["import { type ContextModuleCalConfig } from \"./config/model/ContextModuleConfig\";\nimport { ContextModuleBuilder } from \"./ContextModuleBuilder\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\ndescribe(\"ContextModuleBuilder\", () => {\n const defaultCalConfig: ContextModuleCalConfig = {\n url: \"https://crypto-assets-service.api.ledger.com/v1\",\n mode: \"prod\",\n branch: \"main\",\n };\n it(\"should return a default context module\", () => {\n const contextModuleBuilder = new ContextModuleBuilder();\n\n const res = contextModuleBuilder.build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n\n it(\"should return a custom context module\", () => {\n const contextModuleBuilder = new ContextModuleBuilder();\n const customLoader = { load: vi.fn() };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n\n it(\"should return a custom context module with a custom typed data loader\", () => {\n const contextModuleBuilder = new ContextModuleBuilder();\n const customLoader = { load: vi.fn() };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addTypedDataLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n\n it(\"should return a custom context module with a custom config\", () => {\n const contextModuleBuilder = new ContextModuleBuilder();\n\n const res = contextModuleBuilder.addCalConfig(defaultCalConfig).build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n});\n"],
5
- "mappings": "AACA,OAAS,wBAAAA,MAA4B,yBACrC,OAAS,wBAAAC,MAA4B,yBAErC,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA2C,CAC/C,IAAK,kDACL,KAAM,OACN,OAAQ,MACV,EACA,GAAG,yCAA0C,IAAM,CAGjD,MAAMC,EAFuB,IAAIH,EAAqB,EAErB,MAAM,EAEvC,OAAOG,CAAG,EAAE,eAAeF,CAAoB,CACjD,CAAC,EAED,GAAG,wCAAyC,IAAM,CAChD,MAAMG,EAAuB,IAAIJ,EAC3BK,EAAe,CAAE,KAAM,GAAG,GAAG,CAAE,EAE/BF,EAAMC,EACT,qBAAqB,EACrB,UAAUC,CAAY,EACtB,MAAM,EAET,OAAOF,CAAG,EAAE,eAAeF,CAAoB,CACjD,CAAC,EAED,GAAG,wEAAyE,IAAM,CAChF,MAAMG,EAAuB,IAAIJ,EAC3BK,EAAe,CAAE,KAAM,GAAG,GAAG,CAAE,EAE/BF,EAAMC,EACT,qBAAqB,EACrB,mBAAmBC,CAAY,EAC/B,MAAM,EAET,OAAOF,CAAG,EAAE,eAAeF,CAAoB,CACjD,CAAC,EAED,GAAG,6DAA8D,IAAM,CAGrE,MAAME,EAFuB,IAAIH,EAAqB,EAErB,aAAaE,CAAgB,EAAE,MAAM,EAEtE,OAAOC,CAAG,EAAE,eAAeF,CAAoB,CACjD,CAAC,CACH,CAAC",
6
- "names": ["ContextModuleBuilder", "DefaultContextModule", "defaultCalConfig", "res", "contextModuleBuilder", "customLoader"]
4
+ "sourcesContent": ["import { type Container } from \"inversify\";\n\nimport { configTypes } from \"./config/di/configTypes\";\nimport { type ContextModuleConstructorArgs } from \"./config/model/ContextModuleBuildArgs\";\nimport {\n type ContextModuleCalConfig,\n type ContextModuleConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { ContextModuleBuilder } from \"./ContextModuleBuilder\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\ndescribe(\"ContextModuleBuilder\", () => {\n const defaultCalConfig: ContextModuleCalConfig = {\n url: \"https://cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n };\n const defaultWeb3ChecksConfig = {\n url: \"https://web3checks/v1\",\n };\n const defaultBuilderArgs: ContextModuleConstructorArgs = {\n originToken: \"test\",\n };\n it(\"should return a default context module\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n const res = contextModuleBuilder.build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n\n it(\"should return a custom context module\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customLoader = { load: vi.fn() };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n\n it(\"should return a custom context module with a custom typed data loader\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customLoader = { load: vi.fn() };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addTypedDataLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n // @ts-expect-error _typedDataLoader is private\n expect(res[\"_typedDataLoader\"]).toBe(customLoader);\n });\n\n it(\"should return a custom context module with a custom config\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n const res = contextModuleBuilder\n .addCalConfig(defaultCalConfig)\n .addWeb3ChecksConfig(defaultWeb3ChecksConfig)\n .build();\n // @ts-expect-error _container is private\n const config = (res[\"_container\"] as Container).get<ContextModuleConfig>(\n configTypes.Config,\n );\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.cal).toEqual(defaultCalConfig);\n expect(config.web3checks).toEqual(defaultWeb3ChecksConfig);\n });\n\n it(\"should return a custom context module with a custom custom web3checks loader\", () => {\n const contextModuleBuilder = new ContextModuleBuilder();\n const customLoader = { load: vi.fn() };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addWeb3CheckLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n // @ts-expect-error _web3CheckLoader is private\n expect(res[\"_web3CheckLoader\"]).toBe(customLoader);\n });\n\n it(\"should throw an error if origin token is not provided\", () => {\n const contextModuleBuilder = new ContextModuleBuilder();\n\n expect(() => contextModuleBuilder.build()).toThrow(\n \"Origin token is required\",\n );\n });\n\n it(\"should not throw an error if origin token is provided\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n expect(() => contextModuleBuilder.build()).not.toThrow();\n });\n\n it(\"should not throw an error if origin token is not provided and addWeb3CheckLoader is called\", () => {\n const contextModuleBuilder = new ContextModuleBuilder();\n\n expect(() =>\n contextModuleBuilder.addWeb3CheckLoader({ load: vi.fn() }).build(),\n ).not.toThrow();\n });\n});\n"],
5
+ "mappings": "AAEA,OAAS,eAAAA,MAAmB,0BAM5B,OAAS,wBAAAC,MAA4B,yBACrC,OAAS,wBAAAC,MAA4B,yBAErC,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA2C,CAC/C,IAAK,iBACL,KAAM,OACN,OAAQ,MACV,EACMC,EAA0B,CAC9B,IAAK,uBACP,EACMC,EAAmD,CACvD,YAAa,MACf,EACA,GAAG,yCAA0C,IAAM,CAGjD,MAAMC,EAFuB,IAAIL,EAAqBI,CAAkB,EAEvC,MAAM,EAEvC,OAAOC,CAAG,EAAE,eAAeJ,CAAoB,CACjD,CAAC,EAED,GAAG,wCAAyC,IAAM,CAChD,MAAMK,EAAuB,IAAIN,EAAqBI,CAAkB,EAClEG,EAAe,CAAE,KAAM,GAAG,GAAG,CAAE,EAE/BF,EAAMC,EACT,qBAAqB,EACrB,UAAUC,CAAY,EACtB,MAAM,EAET,OAAOF,CAAG,EAAE,eAAeJ,CAAoB,CACjD,CAAC,EAED,GAAG,wEAAyE,IAAM,CAChF,MAAMK,EAAuB,IAAIN,EAAqBI,CAAkB,EAClEG,EAAe,CAAE,KAAM,GAAG,GAAG,CAAE,EAE/BF,EAAMC,EACT,qBAAqB,EACrB,mBAAmBC,CAAY,EAC/B,MAAM,EAET,OAAOF,CAAG,EAAE,eAAeJ,CAAoB,EAE/C,OAAOI,EAAI,gBAAmB,EAAE,KAAKE,CAAY,CACnD,CAAC,EAED,GAAG,6DAA8D,IAAM,CAGrE,MAAMF,EAFuB,IAAIL,EAAqBI,CAAkB,EAGrE,aAAaF,CAAgB,EAC7B,oBAAoBC,CAAuB,EAC3C,MAAM,EAEHK,EAAUH,EAAI,WAA4B,IAC9CN,EAAY,MACd,EAEA,OAAOM,CAAG,EAAE,eAAeJ,CAAoB,EAC/C,OAAOO,EAAO,GAAG,EAAE,QAAQN,CAAgB,EAC3C,OAAOM,EAAO,UAAU,EAAE,QAAQL,CAAuB,CAC3D,CAAC,EAED,GAAG,+EAAgF,IAAM,CACvF,MAAMG,EAAuB,IAAIN,EAC3BO,EAAe,CAAE,KAAM,GAAG,GAAG,CAAE,EAE/BF,EAAMC,EACT,qBAAqB,EACrB,mBAAmBC,CAAY,EAC/B,MAAM,EAET,OAAOF,CAAG,EAAE,eAAeJ,CAAoB,EAE/C,OAAOI,EAAI,gBAAmB,EAAE,KAAKE,CAAY,CACnD,CAAC,EAED,GAAG,wDAAyD,IAAM,CAChE,MAAMD,EAAuB,IAAIN,EAEjC,OAAO,IAAMM,EAAqB,MAAM,CAAC,EAAE,QACzC,0BACF,CACF,CAAC,EAED,GAAG,wDAAyD,IAAM,CAChE,MAAMA,EAAuB,IAAIN,EAAqBI,CAAkB,EAExE,OAAO,IAAME,EAAqB,MAAM,CAAC,EAAE,IAAI,QAAQ,CACzD,CAAC,EAED,GAAG,6FAA8F,IAAM,CACrG,MAAMA,EAAuB,IAAIN,EAEjC,OAAO,IACLM,EAAqB,mBAAmB,CAAE,KAAM,GAAG,GAAG,CAAE,CAAC,EAAE,MAAM,CACnE,EAAE,IAAI,QAAQ,CAChB,CAAC,CACH,CAAC",
6
+ "names": ["configTypes", "ContextModuleBuilder", "DefaultContextModule", "defaultCalConfig", "defaultWeb3ChecksConfig", "defaultBuilderArgs", "res", "contextModuleBuilder", "customLoader", "config"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{transactionTypes as r}from"./transaction/di/transactionTypes";import{trustedNameTypes as n}from"./trusted-name/di/trustedNameTypes";import{externalPluginTypes as i}from"./external-plugin/di/externalPluginTypes";import{nftTypes as p}from"./nft/di/nftTypes";import{ClearSignContextType as d}from"./shared/model/ClearSignContext";import{tokenTypes as s}from"./token/di/tokenTypes";import{typedDataTypes as m}from"./typed-data/di/typedDataTypes";import{uniswapTypes as C}from"./uniswap/di/uniswapTypes";import{makeContainer as l}from"./di";class h{_container;_loaders;_typedDataLoader;constructor(t){this._container=l({config:t}),this._loaders=t.defaultLoaders?this._getDefaultLoaders():[],this._loaders.push(...t.customLoaders),this._typedDataLoader=t.customTypedDataLoader??this._getDefaultTypedDataLoader()}_getDefaultLoaders(){return[this._container.get(i.ExternalPluginContextLoader),this._container.get(n.TrustedNameContextLoader),this._container.get(p.NftContextLoader),this._container.get(s.TokenContextLoader),this._container.get(r.TransactionContextLoader),this._container.get(C.UniswapContextLoader)]}_getDefaultTypedDataLoader(){return this._container.get(m.TypedDataContextLoader)}async getContexts(t){const o=this._loaders.map(e=>e.load(t));return(await Promise.all(o)).flat()}async getContext(t){const o=this._loaders.filter(e=>e.loadField).map(e=>e.loadField(t));return(await Promise.all(o)).find(e=>e!==null)||{type:d.ERROR,error:new Error(`Field type not supported: ${t.type}`)}}async getTypedDataFilters(t){return this._typedDataLoader.load(t)}}export{h as DefaultContextModule};
1
+ import{transactionTypes as n}from"./transaction/di/transactionTypes";import{trustedNameTypes as i}from"./trusted-name/di/trustedNameTypes";import{externalPluginTypes as p}from"./external-plugin/di/externalPluginTypes";import{nftTypes as d}from"./nft/di/nftTypes";import{ClearSignContextType as a}from"./shared/model/ClearSignContext";import{tokenTypes as s}from"./token/di/tokenTypes";import{typedDataTypes as C}from"./typed-data/di/typedDataTypes";import{uniswapTypes as m}from"./uniswap/di/uniswapTypes";import{web3CheckTypes as c}from"./web3-check/di/web3CheckTypes";import{makeContainer as l}from"./di";class k{_container;_loaders;_typedDataLoader;_web3CheckLoader;constructor(e){this._container=l({config:e}),this._loaders=e.defaultLoaders?this._getDefaultLoaders():[],this._loaders.push(...e.customLoaders),this._typedDataLoader=e.customTypedDataLoader??this._getDefaultTypedDataLoader(),this._web3CheckLoader=e.customWeb3CheckLoader??this._getWeb3CheckLoader()}_getDefaultLoaders(){return[this._container.get(p.ExternalPluginContextLoader),this._container.get(i.TrustedNameContextLoader),this._container.get(d.NftContextLoader),this._container.get(s.TokenContextLoader),this._container.get(n.TransactionContextLoader),this._container.get(m.UniswapContextLoader)]}_getDefaultTypedDataLoader(){return this._container.get(C.TypedDataContextLoader)}_getWeb3CheckLoader(){return this._container.get(c.Web3CheckContextLoader)}async getContexts(e){const o=this._loaders.map(t=>t.load(e));return(await Promise.all(o)).flat()}async getContext(e){const o=this._loaders.filter(t=>t.loadField).map(t=>t.loadField(e));return(await Promise.all(o)).find(t=>t!==null)||{type:a.ERROR,error:new Error(`Field type not supported: ${e.type}`)}}async getTypedDataFilters(e){return this._typedDataLoader.load(e)}async getWeb3Checks(e){return(await this._web3CheckLoader.load(e)).caseOf({Right:r=>({type:a.WEB3_CHECK,payload:r.descriptor,certificate:r.certificate}),Left:()=>null})}}export{k as DefaultContextModule};
2
2
  //# sourceMappingURL=DefaultContextModule.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/DefaultContextModule.ts"],
4
- "sourcesContent": ["import { type Container } from \"inversify\";\n\nimport type { TypedDataClearSignContext } from \"@/shared/model/TypedDataClearSignContext\";\nimport type { TypedDataContext } from \"@/shared/model/TypedDataContext\";\nimport { transactionTypes } from \"@/transaction/di/transactionTypes\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\nimport { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport { externalPluginTypes } from \"./external-plugin/di/externalPluginTypes\";\nimport { type ExternalPluginContextLoader } from \"./external-plugin/domain/ExternalPluginContextLoader\";\nimport { nftTypes } from \"./nft/di/nftTypes\";\nimport { type NftContextLoader } from \"./nft/domain/NftContextLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"./shared/model/TransactionContext\";\nimport { tokenTypes } from \"./token/di/tokenTypes\";\nimport { type TokenContextLoader } from \"./token/domain/TokenContextLoader\";\nimport { type TransactionContextLoader } from \"./transaction/domain/TransactionContextLoader\";\nimport { type TrustedNameContextLoader } from \"./trusted-name/domain/TrustedNameContextLoader\";\nimport { typedDataTypes } from \"./typed-data/di/typedDataTypes\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { uniswapTypes } from \"./uniswap/di/uniswapTypes\";\nimport { type UniswapContextLoader } from \"./uniswap/domain/UniswapContextLoader\";\nimport { type ContextModule } from \"./ContextModule\";\nimport { makeContainer } from \"./di\";\n\nexport class DefaultContextModule implements ContextModule {\n private _container: Container;\n private _loaders: ContextLoader[];\n private _typedDataLoader: TypedDataContextLoader;\n\n constructor(args: ContextModuleConfig) {\n this._container = makeContainer({ config: args });\n this._loaders = args.defaultLoaders ? this._getDefaultLoaders() : [];\n this._loaders.push(...args.customLoaders);\n this._typedDataLoader =\n args.customTypedDataLoader ?? this._getDefaultTypedDataLoader();\n }\n\n private _getDefaultLoaders(): ContextLoader[] {\n return [\n this._container.get<ExternalPluginContextLoader>(\n externalPluginTypes.ExternalPluginContextLoader,\n ),\n this._container.get<TrustedNameContextLoader>(\n trustedNameTypes.TrustedNameContextLoader,\n ),\n this._container.get<NftContextLoader>(nftTypes.NftContextLoader),\n this._container.get<TokenContextLoader>(tokenTypes.TokenContextLoader),\n this._container.get<TransactionContextLoader>(\n transactionTypes.TransactionContextLoader,\n ),\n this._container.get<UniswapContextLoader>(\n uniswapTypes.UniswapContextLoader,\n ),\n ];\n }\n\n private _getDefaultTypedDataLoader(): TypedDataContextLoader {\n return this._container.get<TypedDataContextLoader>(\n typedDataTypes.TypedDataContextLoader,\n );\n }\n\n public async getContexts(\n transaction: TransactionContext,\n ): Promise<ClearSignContext[]> {\n const promises = this._loaders.map((fetcher) => fetcher.load(transaction));\n const responses = await Promise.all(promises);\n return responses.flat();\n }\n\n public async getContext(\n field: TransactionFieldContext,\n ): Promise<ClearSignContext> {\n const promises = this._loaders\n .filter((fetcher) => fetcher.loadField)\n .map((fetcher) => fetcher.loadField!(field));\n const responses = await Promise.all(promises);\n return (\n responses.find((resp) => resp !== null) || {\n type: ClearSignContextType.ERROR,\n error: new Error(`Field type not supported: ${field.type}`),\n }\n );\n }\n\n public async getTypedDataFilters(\n typedData: TypedDataContext,\n ): Promise<TypedDataClearSignContext> {\n return this._typedDataLoader.load(typedData);\n }\n}\n"],
5
- "mappings": "AAIA,OAAS,oBAAAA,MAAwB,oCACjC,OAAS,oBAAAC,MAAwB,qCAGjC,OAAS,uBAAAC,MAA2B,2CAEpC,OAAS,YAAAC,MAAgB,oBAGzB,OAEE,wBAAAC,MACK,kCAKP,OAAS,cAAAC,MAAkB,wBAI3B,OAAS,kBAAAC,MAAsB,iCAE/B,OAAS,gBAAAC,MAAoB,4BAG7B,OAAS,iBAAAC,MAAqB,OAEvB,MAAMC,CAA8C,CACjD,WACA,SACA,iBAER,YAAYC,EAA2B,CACrC,KAAK,WAAaF,EAAc,CAAE,OAAQE,CAAK,CAAC,EAChD,KAAK,SAAWA,EAAK,eAAiB,KAAK,mBAAmB,EAAI,CAAC,EACnE,KAAK,SAAS,KAAK,GAAGA,EAAK,aAAa,EACxC,KAAK,iBACHA,EAAK,uBAAyB,KAAK,2BAA2B,CAClE,CAEQ,oBAAsC,CAC5C,MAAO,CACL,KAAK,WAAW,IACdR,EAAoB,2BACtB,EACA,KAAK,WAAW,IACdD,EAAiB,wBACnB,EACA,KAAK,WAAW,IAAsBE,EAAS,gBAAgB,EAC/D,KAAK,WAAW,IAAwBE,EAAW,kBAAkB,EACrE,KAAK,WAAW,IACdL,EAAiB,wBACnB,EACA,KAAK,WAAW,IACdO,EAAa,oBACf,CACF,CACF,CAEQ,4BAAqD,CAC3D,OAAO,KAAK,WAAW,IACrBD,EAAe,sBACjB,CACF,CAEA,MAAa,YACXK,EAC6B,CAC7B,MAAMC,EAAW,KAAK,SAAS,IAAKC,GAAYA,EAAQ,KAAKF,CAAW,CAAC,EAEzE,OADkB,MAAM,QAAQ,IAAIC,CAAQ,GAC3B,KAAK,CACxB,CAEA,MAAa,WACXE,EAC2B,CAC3B,MAAMF,EAAW,KAAK,SACnB,OAAQC,GAAYA,EAAQ,SAAS,EACrC,IAAKA,GAAYA,EAAQ,UAAWC,CAAK,CAAC,EAE7C,OADkB,MAAM,QAAQ,IAAIF,CAAQ,GAEhC,KAAMG,GAASA,IAAS,IAAI,GAAK,CACzC,KAAMX,EAAqB,MAC3B,MAAO,IAAI,MAAM,6BAA6BU,EAAM,IAAI,EAAE,CAC5D,CAEJ,CAEA,MAAa,oBACXE,EACoC,CACpC,OAAO,KAAK,iBAAiB,KAAKA,CAAS,CAC7C,CACF",
6
- "names": ["transactionTypes", "trustedNameTypes", "externalPluginTypes", "nftTypes", "ClearSignContextType", "tokenTypes", "typedDataTypes", "uniswapTypes", "makeContainer", "DefaultContextModule", "args", "transaction", "promises", "fetcher", "field", "resp", "typedData"]
4
+ "sourcesContent": ["import { type Container } from \"inversify\";\n\nimport type { TypedDataClearSignContext } from \"@/shared/model/TypedDataClearSignContext\";\nimport type { TypedDataContext } from \"@/shared/model/TypedDataContext\";\nimport { transactionTypes } from \"@/transaction/di/transactionTypes\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\nimport { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport { externalPluginTypes } from \"./external-plugin/di/externalPluginTypes\";\nimport { type ExternalPluginContextLoader } from \"./external-plugin/domain/ExternalPluginContextLoader\";\nimport { nftTypes } from \"./nft/di/nftTypes\";\nimport { type NftContextLoader } from \"./nft/domain/NftContextLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n type ClearSignContextSuccess,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"./shared/model/TransactionContext\";\nimport { tokenTypes } from \"./token/di/tokenTypes\";\nimport { type TokenContextLoader } from \"./token/domain/TokenContextLoader\";\nimport { type TransactionContextLoader } from \"./transaction/domain/TransactionContextLoader\";\nimport { type TrustedNameContextLoader } from \"./trusted-name/domain/TrustedNameContextLoader\";\nimport { typedDataTypes } from \"./typed-data/di/typedDataTypes\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { uniswapTypes } from \"./uniswap/di/uniswapTypes\";\nimport { type UniswapContextLoader } from \"./uniswap/domain/UniswapContextLoader\";\nimport { web3CheckTypes } from \"./web3-check/di/web3CheckTypes\";\nimport { type Web3CheckContextLoader } from \"./web3-check/domain/Web3CheckContextLoader\";\nimport {\n type Web3CheckContext,\n type Web3Checks,\n} from \"./web3-check/domain/web3CheckTypes\";\nimport { type ContextModule } from \"./ContextModule\";\nimport { makeContainer } from \"./di\";\n\nexport class DefaultContextModule implements ContextModule {\n private _container: Container;\n private _loaders: ContextLoader[];\n private _typedDataLoader: TypedDataContextLoader;\n private _web3CheckLoader: Web3CheckContextLoader;\n\n constructor(args: ContextModuleConfig) {\n this._container = makeContainer({ config: args });\n this._loaders = args.defaultLoaders ? this._getDefaultLoaders() : [];\n this._loaders.push(...args.customLoaders);\n this._typedDataLoader =\n args.customTypedDataLoader ?? this._getDefaultTypedDataLoader();\n this._web3CheckLoader =\n args.customWeb3CheckLoader ?? this._getWeb3CheckLoader();\n }\n\n private _getDefaultLoaders(): ContextLoader[] {\n return [\n this._container.get<ExternalPluginContextLoader>(\n externalPluginTypes.ExternalPluginContextLoader,\n ),\n this._container.get<TrustedNameContextLoader>(\n trustedNameTypes.TrustedNameContextLoader,\n ),\n this._container.get<NftContextLoader>(nftTypes.NftContextLoader),\n this._container.get<TokenContextLoader>(tokenTypes.TokenContextLoader),\n this._container.get<TransactionContextLoader>(\n transactionTypes.TransactionContextLoader,\n ),\n this._container.get<UniswapContextLoader>(\n uniswapTypes.UniswapContextLoader,\n ),\n ];\n }\n\n private _getDefaultTypedDataLoader(): TypedDataContextLoader {\n return this._container.get<TypedDataContextLoader>(\n typedDataTypes.TypedDataContextLoader,\n );\n }\n\n private _getWeb3CheckLoader(): Web3CheckContextLoader {\n return this._container.get<Web3CheckContextLoader>(\n web3CheckTypes.Web3CheckContextLoader,\n );\n }\n\n public async getContexts(\n transaction: TransactionContext,\n ): Promise<ClearSignContext[]> {\n const promises = this._loaders.map((fetcher) => fetcher.load(transaction));\n const responses = await Promise.all(promises);\n return responses.flat();\n }\n\n public async getContext(\n field: TransactionFieldContext,\n ): Promise<ClearSignContext> {\n const promises = this._loaders\n .filter((fetcher) => fetcher.loadField)\n .map((fetcher) => fetcher.loadField!(field));\n const responses = await Promise.all(promises);\n return (\n responses.find((resp) => resp !== null) || {\n type: ClearSignContextType.ERROR,\n error: new Error(`Field type not supported: ${field.type}`),\n }\n );\n }\n\n public async getTypedDataFilters(\n typedData: TypedDataContext,\n ): Promise<TypedDataClearSignContext> {\n return this._typedDataLoader.load(typedData);\n }\n\n public async getWeb3Checks(\n transactionContext: Web3CheckContext,\n ): Promise<ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null> {\n const web3Checks = await this._web3CheckLoader.load(transactionContext);\n\n return web3Checks.caseOf({\n Right: (checks: Web3Checks) => ({\n type: ClearSignContextType.WEB3_CHECK,\n payload: checks.descriptor,\n certificate: checks.certificate,\n }),\n Left: () => null,\n });\n }\n}\n"],
5
+ "mappings": "AAIA,OAAS,oBAAAA,MAAwB,oCACjC,OAAS,oBAAAC,MAAwB,qCAGjC,OAAS,uBAAAC,MAA2B,2CAEpC,OAAS,YAAAC,MAAgB,oBAGzB,OAGE,wBAAAC,MACK,kCAKP,OAAS,cAAAC,MAAkB,wBAI3B,OAAS,kBAAAC,MAAsB,iCAE/B,OAAS,gBAAAC,MAAoB,4BAE7B,OAAS,kBAAAC,MAAsB,iCAO/B,OAAS,iBAAAC,MAAqB,OAEvB,MAAMC,CAA8C,CACjD,WACA,SACA,iBACA,iBAER,YAAYC,EAA2B,CACrC,KAAK,WAAaF,EAAc,CAAE,OAAQE,CAAK,CAAC,EAChD,KAAK,SAAWA,EAAK,eAAiB,KAAK,mBAAmB,EAAI,CAAC,EACnE,KAAK,SAAS,KAAK,GAAGA,EAAK,aAAa,EACxC,KAAK,iBACHA,EAAK,uBAAyB,KAAK,2BAA2B,EAChE,KAAK,iBACHA,EAAK,uBAAyB,KAAK,oBAAoB,CAC3D,CAEQ,oBAAsC,CAC5C,MAAO,CACL,KAAK,WAAW,IACdT,EAAoB,2BACtB,EACA,KAAK,WAAW,IACdD,EAAiB,wBACnB,EACA,KAAK,WAAW,IAAsBE,EAAS,gBAAgB,EAC/D,KAAK,WAAW,IAAwBE,EAAW,kBAAkB,EACrE,KAAK,WAAW,IACdL,EAAiB,wBACnB,EACA,KAAK,WAAW,IACdO,EAAa,oBACf,CACF,CACF,CAEQ,4BAAqD,CAC3D,OAAO,KAAK,WAAW,IACrBD,EAAe,sBACjB,CACF,CAEQ,qBAA8C,CACpD,OAAO,KAAK,WAAW,IACrBE,EAAe,sBACjB,CACF,CAEA,MAAa,YACXI,EAC6B,CAC7B,MAAMC,EAAW,KAAK,SAAS,IAAKC,GAAYA,EAAQ,KAAKF,CAAW,CAAC,EAEzE,OADkB,MAAM,QAAQ,IAAIC,CAAQ,GAC3B,KAAK,CACxB,CAEA,MAAa,WACXE,EAC2B,CAC3B,MAAMF,EAAW,KAAK,SACnB,OAAQC,GAAYA,EAAQ,SAAS,EACrC,IAAKA,GAAYA,EAAQ,UAAWC,CAAK,CAAC,EAE7C,OADkB,MAAM,QAAQ,IAAIF,CAAQ,GAEhC,KAAMG,GAASA,IAAS,IAAI,GAAK,CACzC,KAAMZ,EAAqB,MAC3B,MAAO,IAAI,MAAM,6BAA6BW,EAAM,IAAI,EAAE,CAC5D,CAEJ,CAEA,MAAa,oBACXE,EACoC,CACpC,OAAO,KAAK,iBAAiB,KAAKA,CAAS,CAC7C,CAEA,MAAa,cACXC,EAC0E,CAG1E,OAFmB,MAAM,KAAK,iBAAiB,KAAKA,CAAkB,GAEpD,OAAO,CACvB,MAAQC,IAAwB,CAC9B,KAAMf,EAAqB,WAC3B,QAASe,EAAO,WAChB,YAAaA,EAAO,WACtB,GACA,KAAM,IAAM,IACd,CAAC,CACH,CACF",
6
+ "names": ["transactionTypes", "trustedNameTypes", "externalPluginTypes", "nftTypes", "ClearSignContextType", "tokenTypes", "typedDataTypes", "uniswapTypes", "web3CheckTypes", "makeContainer", "DefaultContextModule", "args", "transaction", "promises", "fetcher", "field", "resp", "typedData", "transactionContext", "checks"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{DefaultContextModule as a}from"./DefaultContextModule";const l=()=>({load:vi.fn(),loadField:vi.fn()});describe("DefaultContextModule",()=>{const d={load:vi.fn()},o={customLoaders:[],defaultLoaders:!1,customTypedDataLoader:d,cal:{url:"https://crypto-assets-service.api.ledger.com/v1",mode:"prod",branch:"main"}};beforeEach(()=>{vi.restoreAllMocks()}),it("should initialize the context module with all the default loaders",async()=>{const t=await new a(o).getContexts({});expect(t).toEqual([])}),it("should return an empty array when no loaders",async()=>{const t=await new a(o).getContexts({});expect(t).toEqual([])}),it("should call all fetch method from metadata fetcher",async()=>{const e=l();await new a({...o,customLoaders:[e,e]}).getContexts({}),expect(e.load).toHaveBeenCalledTimes(2)}),it("should return an array of context response",async()=>{const e=l(),t=[[{type:"provideERC20Info",payload:"payload1"}],[{type:"provideERC20Info",payload:"payload2"},{type:"plugin",payload:"payload3"}]];vi.spyOn(e,"load").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const n=await new a({...o,customLoaders:[e,e]}).getContexts({});expect(e.load).toHaveBeenCalledTimes(2),expect(n).toEqual(t.flat())}),it("should call the typed data loader",async()=>{await new a({...o,customTypedDataLoader:d}).getTypedDataFilters({}),expect(d.load).toHaveBeenCalledTimes(1)}),it("should return a single context",async()=>{const e=l(),t=[null,{type:"token",payload:"payload"}];vi.spyOn(e,"loadField").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const n=await new a({...o,customLoaders:[e,{load:vi.fn()},e]}).getContext({type:"token"});expect(e.loadField).toHaveBeenCalledTimes(2),expect(n).toEqual({type:"token",payload:"payload"})}),it("context field not supported",async()=>{const e=l(),t=[null,null];vi.spyOn(e,"loadField").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const n=await new a({...o,customLoaders:[e,{load:vi.fn()},e]}).getContext({type:"token"});expect(e.loadField).toHaveBeenCalledTimes(2),expect(n).toEqual({type:"error",error:new Error("Field type not supported: token")})}),it("getField not implemented",async()=>{const t=await new a({...o,customLoaders:[{load:vi.fn()}]}).getContext({type:"token"});expect(t).toEqual({type:"error",error:new Error("Field type not supported: token")})})});
1
+ import{DeviceModelId as c}from"@ledgerhq/device-management-kit";import{Left as r,Right as i}from"purify-ts";import{DefaultContextModule as a}from"./DefaultContextModule";const d=()=>({load:vi.fn(),loadField:vi.fn()});describe("DefaultContextModule",()=>{const s={load:vi.fn()},o={customLoaders:[],defaultLoaders:!1,customTypedDataLoader:s,cal:{url:"https://cal/v1",mode:"prod",branch:"main"},web3checks:{url:"https://web3checks/v3"},originToken:"originToken"};beforeEach(()=>{vi.restoreAllMocks()}),it("should initialize the context module with all the default loaders",async()=>{const t=await new a(o).getContexts({});expect(t).toEqual([])}),it("should return an empty array when no loaders",async()=>{const t=await new a(o).getContexts({});expect(t).toEqual([])}),it("should call all fetch method from metadata fetcher",async()=>{const e=d();await new a({...o,customLoaders:[e,e]}).getContexts({}),expect(e.load).toHaveBeenCalledTimes(2)}),it("should return an array of context response",async()=>{const e=d(),t=[[{type:"provideERC20Info",payload:"payload1"}],[{type:"provideERC20Info",payload:"payload2"},{type:"plugin",payload:"payload3"}]];vi.spyOn(e,"load").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const l=await new a({...o,customLoaders:[e,e]}).getContexts({});expect(e.load).toHaveBeenCalledTimes(2),expect(l).toEqual(t.flat())}),it("should call the typed data loader",async()=>{await new a({...o,customTypedDataLoader:s}).getTypedDataFilters({}),expect(s.load).toHaveBeenCalledTimes(1)}),it("should return a single context",async()=>{const e=d(),t=[null,{type:"token",payload:"payload"}];vi.spyOn(e,"loadField").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const l=await new a({...o,customLoaders:[e,{load:vi.fn()},e]}).getContext({type:"token"});expect(e.loadField).toHaveBeenCalledTimes(2),expect(l).toEqual({type:"token",payload:"payload"})}),it("should return a web3 check context",async()=>{const e=d();vi.spyOn(e,"load").mockResolvedValueOnce(i({descriptor:"payload"}));const n=await new a({...o,customLoaders:[],customWeb3CheckLoader:e}).getWeb3Checks({deviceModelId:c.FLEX,from:"from",rawTx:"rawTx",chainId:1});expect(e.load).toHaveBeenCalledTimes(1),expect(n).toEqual({type:"web3Check",payload:"payload"})}),it("should return null if no web3 check context",async()=>{const e=d();vi.spyOn(e,"load").mockResolvedValue(r(new Error("error")));const n=await new a({...o,customLoaders:[],customWeb3CheckLoader:e}).getWeb3Checks({deviceModelId:c.FLEX,from:"from",rawTx:"rawTx",chainId:1});expect(e.load).toHaveBeenCalledTimes(1),expect(n).toBeNull()}),it("context field not supported",async()=>{const e=d(),t=[null,null];vi.spyOn(e,"loadField").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const l=await new a({...o,customLoaders:[e,{load:vi.fn()},e]}).getContext({type:"token"});expect(e.loadField).toHaveBeenCalledTimes(2),expect(l).toEqual({type:"error",error:new Error("Field type not supported: token")})}),it("getField not implemented",async()=>{const t=await new a({...o,customLoaders:[{load:vi.fn()}]}).getContext({type:"token"});expect(t).toEqual({type:"error",error:new Error("Field type not supported: token")})}),it("should throw an error if origin token is not provided",()=>{expect(()=>new a({...o,originToken:void 0})).toThrow("Origin token is required")})});
2
2
  //# sourceMappingURL=DefaultContextModule.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/DefaultContextModule.test.ts"],
4
- "sourcesContent": ["import { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"./shared/model/TransactionContext\";\nimport { type TypedDataContext } from \"./shared/model/TypedDataContext\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst contextLoaderStubBuilder = () => {\n return { load: vi.fn(), loadField: vi.fn() };\n};\n\ndescribe(\"DefaultContextModule\", () => {\n const typedDataLoader: TypedDataContextLoader = { load: vi.fn() };\n const defaultContextModuleConfig: ContextModuleConfig = {\n customLoaders: [],\n defaultLoaders: false,\n customTypedDataLoader: typedDataLoader,\n cal: {\n url: \"https://crypto-assets-service.api.ledger.com/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n };\n\n beforeEach(() => {\n vi.restoreAllMocks();\n });\n\n it(\"should initialize the context module with all the default loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({} as TransactionContext);\n\n expect(res).toEqual([]);\n });\n\n it(\"should return an empty array when no loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({} as TransactionContext);\n\n expect(res).toEqual([]);\n });\n\n it(\"should call all fetch method from metadata fetcher\", async () => {\n const loader = contextLoaderStubBuilder();\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n await contextModule.getContexts({} as TransactionContext);\n\n expect(loader.load).toHaveBeenCalledTimes(2);\n });\n\n it(\"should return an array of context response\", async () => {\n const loader = contextLoaderStubBuilder();\n const responses = [\n [{ type: \"provideERC20Info\", payload: \"payload1\" }],\n [\n { type: \"provideERC20Info\", payload: \"payload2\" },\n { type: \"plugin\", payload: \"payload3\" },\n ],\n ];\n vi.spyOn(loader, \"load\")\n .mockResolvedValueOnce(responses[0])\n .mockResolvedValueOnce(responses[1]);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n const res = await contextModule.getContexts({} as TransactionContext);\n\n expect(loader.load).toHaveBeenCalledTimes(2);\n expect(res).toEqual(responses.flat());\n });\n\n it(\"should call the typed data loader\", async () => {\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customTypedDataLoader: typedDataLoader,\n });\n\n await contextModule.getTypedDataFilters({} as TypedDataContext);\n\n expect(typedDataLoader.load).toHaveBeenCalledTimes(1);\n });\n\n it(\"should return a single context\", async () => {\n const loader = contextLoaderStubBuilder();\n const responses = [null, { type: \"token\", payload: \"payload\" }];\n vi.spyOn(loader, \"loadField\")\n .mockResolvedValueOnce(responses[0])\n .mockResolvedValueOnce(responses[1]);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, { load: vi.fn() }, loader],\n });\n\n const res = await contextModule.getContext({\n type: \"token\",\n } as TransactionFieldContext);\n\n expect(loader.loadField).toHaveBeenCalledTimes(2);\n expect(res).toEqual({ type: \"token\", payload: \"payload\" });\n });\n\n it(\"context field not supported\", async () => {\n const loader = contextLoaderStubBuilder();\n const responses = [null, null];\n vi.spyOn(loader, \"loadField\")\n .mockResolvedValueOnce(responses[0])\n .mockResolvedValueOnce(responses[1]);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, { load: vi.fn() }, loader],\n });\n\n const res = await contextModule.getContext({\n type: \"token\",\n } as TransactionFieldContext);\n\n expect(loader.loadField).toHaveBeenCalledTimes(2);\n expect(res).toEqual({\n type: \"error\",\n error: new Error(\"Field type not supported: token\"),\n });\n });\n\n it(\"getField not implemented\", async () => {\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [{ load: vi.fn() }],\n });\n\n const res = await contextModule.getContext({\n type: \"token\",\n } as TransactionFieldContext);\n\n expect(res).toEqual({\n type: \"error\",\n error: new Error(\"Field type not supported: token\"),\n });\n });\n});\n"],
5
- "mappings": "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",
6
- "names": ["DefaultContextModule", "contextLoaderStubBuilder", "typedDataLoader", "defaultContextModuleConfig", "res", "loader", "responses"]
4
+ "sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"./shared/model/TransactionContext\";\nimport { type TypedDataContext } from \"./shared/model/TypedDataContext\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst contextLoaderStubBuilder = () => {\n return { load: vi.fn(), loadField: vi.fn() };\n};\n\ndescribe(\"DefaultContextModule\", () => {\n const typedDataLoader: TypedDataContextLoader = { load: vi.fn() };\n const defaultContextModuleConfig: ContextModuleConfig = {\n customLoaders: [],\n defaultLoaders: false,\n customTypedDataLoader: typedDataLoader,\n cal: {\n url: \"https://cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n web3checks: {\n url: \"https://web3checks/v3\",\n },\n originToken: \"originToken\",\n };\n\n beforeEach(() => {\n vi.restoreAllMocks();\n });\n\n it(\"should initialize the context module with all the default loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({} as TransactionContext);\n\n expect(res).toEqual([]);\n });\n\n it(\"should return an empty array when no loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({} as TransactionContext);\n\n expect(res).toEqual([]);\n });\n\n it(\"should call all fetch method from metadata fetcher\", async () => {\n const loader = contextLoaderStubBuilder();\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n await contextModule.getContexts({} as TransactionContext);\n\n expect(loader.load).toHaveBeenCalledTimes(2);\n });\n\n it(\"should return an array of context response\", async () => {\n const loader = contextLoaderStubBuilder();\n const responses = [\n [{ type: \"provideERC20Info\", payload: \"payload1\" }],\n [\n { type: \"provideERC20Info\", payload: \"payload2\" },\n { type: \"plugin\", payload: \"payload3\" },\n ],\n ];\n vi.spyOn(loader, \"load\")\n .mockResolvedValueOnce(responses[0])\n .mockResolvedValueOnce(responses[1]);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n const res = await contextModule.getContexts({} as TransactionContext);\n\n expect(loader.load).toHaveBeenCalledTimes(2);\n expect(res).toEqual(responses.flat());\n });\n\n it(\"should call the typed data loader\", async () => {\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customTypedDataLoader: typedDataLoader,\n });\n\n await contextModule.getTypedDataFilters({} as TypedDataContext);\n\n expect(typedDataLoader.load).toHaveBeenCalledTimes(1);\n });\n\n it(\"should return a single context\", async () => {\n const loader = contextLoaderStubBuilder();\n const responses = [null, { type: \"token\", payload: \"payload\" }];\n vi.spyOn(loader, \"loadField\")\n .mockResolvedValueOnce(responses[0])\n .mockResolvedValueOnce(responses[1]);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, { load: vi.fn() }, loader],\n });\n\n const res = await contextModule.getContext({\n type: \"token\",\n } as TransactionFieldContext);\n\n expect(loader.loadField).toHaveBeenCalledTimes(2);\n expect(res).toEqual({ type: \"token\", payload: \"payload\" });\n });\n\n it(\"should return a web3 check context\", async () => {\n const loader = contextLoaderStubBuilder();\n vi.spyOn(loader, \"load\").mockResolvedValueOnce(\n Right({ descriptor: \"payload\" }),\n );\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [],\n customWeb3CheckLoader: loader,\n });\n\n const res = await contextModule.getWeb3Checks({\n deviceModelId: DeviceModelId.FLEX,\n from: \"from\",\n rawTx: \"rawTx\",\n chainId: 1,\n });\n\n expect(loader.load).toHaveBeenCalledTimes(1);\n expect(res).toEqual({ type: \"web3Check\", payload: \"payload\" });\n });\n\n it(\"should return null if no web3 check context\", async () => {\n const loader = contextLoaderStubBuilder();\n vi.spyOn(loader, \"load\").mockResolvedValue(Left(new Error(\"error\")));\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [],\n customWeb3CheckLoader: loader,\n });\n\n const res = await contextModule.getWeb3Checks({\n deviceModelId: DeviceModelId.FLEX,\n from: \"from\",\n rawTx: \"rawTx\",\n chainId: 1,\n });\n\n expect(loader.load).toHaveBeenCalledTimes(1);\n expect(res).toBeNull();\n });\n\n it(\"context field not supported\", async () => {\n const loader = contextLoaderStubBuilder();\n const responses = [null, null];\n vi.spyOn(loader, \"loadField\")\n .mockResolvedValueOnce(responses[0])\n .mockResolvedValueOnce(responses[1]);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, { load: vi.fn() }, loader],\n });\n\n const res = await contextModule.getContext({\n type: \"token\",\n } as TransactionFieldContext);\n\n expect(loader.loadField).toHaveBeenCalledTimes(2);\n expect(res).toEqual({\n type: \"error\",\n error: new Error(\"Field type not supported: token\"),\n });\n });\n\n it(\"getField not implemented\", async () => {\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [{ load: vi.fn() }],\n });\n\n const res = await contextModule.getContext({\n type: \"token\",\n } as TransactionFieldContext);\n\n expect(res).toEqual({\n type: \"error\",\n error: new Error(\"Field type not supported: token\"),\n });\n });\n\n it(\"should throw an error if origin token is not provided\", () => {\n expect(\n () =>\n new DefaultContextModule({\n ...defaultContextModuleConfig,\n originToken: undefined,\n }),\n ).toThrow(\"Origin token is required\");\n });\n});\n"],
5
+ "mappings": "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",
6
+ "names": ["DeviceModelId", "Left", "Right", "DefaultContextModule", "contextLoaderStubBuilder", "typedDataLoader", "defaultContextModuleConfig", "res", "loader", "responses"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ContainerModule as t}from"inversify";import{configTypes as e}from"./configTypes";const u=o=>new t((n,i,r,f)=>{n(e.Config).toConstantValue(o)});export{u as configModuleFactory};
1
+ import{ContainerModule as n}from"inversify";import{configTypes as e}from"./configTypes";const r=o=>new n(({bind:t})=>{t(e.Config).toConstantValue(o)});export{r as configModuleFactory};
2
2
  //# sourceMappingURL=configModuleFactory.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/config/di/configModuleFactory.ts"],
4
- "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\n\nimport { configTypes } from \"./configTypes\";\n\nexport const configModuleFactory = (config: ContextModuleConfig) =>\n new ContainerModule((bind, _unbind, _isBound, _rebind) => {\n bind<ContextModuleConfig>(configTypes.Config).toConstantValue(config);\n });\n"],
5
- "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAIhC,OAAS,eAAAC,MAAmB,gBAErB,MAAMC,EAAuBC,GAClC,IAAIH,EAAgB,CAACI,EAAMC,EAASC,EAAUC,IAAY,CACxDH,EAA0BH,EAAY,MAAM,EAAE,gBAAgBE,CAAM,CACtE,CAAC",
6
- "names": ["ContainerModule", "configTypes", "configModuleFactory", "config", "bind", "_unbind", "_isBound", "_rebind"]
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\n\nimport { configTypes } from \"./configTypes\";\n\nexport const configModuleFactory = (config: ContextModuleConfig) =>\n new ContainerModule(({ bind }) => {\n bind<ContextModuleConfig>(configTypes.Config).toConstantValue(config);\n });\n"],
5
+ "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAIhC,OAAS,eAAAC,MAAmB,gBAErB,MAAMC,EAAuBC,GAClC,IAAIH,EAAgB,CAAC,CAAE,KAAAI,CAAK,IAAM,CAChCA,EAA0BH,EAAY,MAAM,EAAE,gBAAgBE,CAAM,CACtE,CAAC",
6
+ "names": ["ContainerModule", "configTypes", "configModuleFactory", "config", "bind"]
7
7
  }
@@ -1,2 +1,2 @@
1
- const o={Config:Symbol.for("config")};export{o as configTypes};
1
+ const o={Config:Symbol.for("config"),OriginToken:Symbol.for("originToken")};export{o as configTypes};
2
2
  //# sourceMappingURL=configTypes.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/config/di/configTypes.ts"],
4
- "sourcesContent": ["export const configTypes = {\n Config: Symbol.for(\"config\"),\n};\n"],
5
- "mappings": "AAAO,MAAMA,EAAc,CACzB,OAAQ,OAAO,IAAI,QAAQ,CAC7B",
4
+ "sourcesContent": ["export const configTypes = {\n Config: Symbol.for(\"config\"),\n OriginToken: Symbol.for(\"originToken\"),\n};\n"],
5
+ "mappings": "AAAO,MAAMA,EAAc,CACzB,OAAQ,OAAO,IAAI,QAAQ,EAC3B,YAAa,OAAO,IAAI,aAAa,CACvC",
6
6
  "names": ["configTypes"]
7
7
  }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=ContextModuleBuildArgs.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
package/lib/esm/src/di.js CHANGED
@@ -1,2 +1,2 @@
1
- import{Container as t}from"inversify";import{configModuleFactory as e}from"./config/di/configModuleFactory";import{externalPluginModuleFactory as n}from"./external-plugin/di/externalPluginModuleFactory";import{nftModuleFactory as a}from"./nft/di/nftModuleFactory";import{nanoPkiModuleFactory as i}from"./pki/di/pkiModuleFactory";import{tokenModuleFactory as m}from"./token/di/tokenModuleFactory";import{transactionModuleFactory as f}from"./transaction/di/transactionModuleFactory";import{trustedNameModuleFactory as p}from"./trusted-name/di/trustedNameModuleFactory";import{typedDataModuleFactory as c}from"./typed-data/di/typedDataModuleFactory";import{uniswapModuleFactory as u}from"./uniswap/di/uniswapModuleFactory";const w=({config:r})=>{const o=new t;return o.load(e(r),n(),a(),m(),f(),p(),c(),i(),u()),o};export{w as makeContainer};
1
+ import{Container as t}from"inversify";import{configModuleFactory as e}from"./config/di/configModuleFactory";import{externalPluginModuleFactory as n}from"./external-plugin/di/externalPluginModuleFactory";import{nftModuleFactory as a}from"./nft/di/nftModuleFactory";import{nanoPkiModuleFactory as m}from"./pki/di/pkiModuleFactory";import{tokenModuleFactory as i}from"./token/di/tokenModuleFactory";import{transactionModuleFactory as c}from"./transaction/di/transactionModuleFactory";import{trustedNameModuleFactory as f}from"./trusted-name/di/trustedNameModuleFactory";import{typedDataModuleFactory as p}from"./typed-data/di/typedDataModuleFactory";import{uniswapModuleFactory as u}from"./uniswap/di/uniswapModuleFactory";import{web3CheckModuleFactory as d}from"./web3-check/di/web3CheckModuleFactory";const P=({config:r})=>{const o=new t;return o.loadSync(e(r),n(),a(),i(),c(),f(),p(),m(),u(),d()),o};export{P as makeContainer};
2
2
  //# sourceMappingURL=di.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/di.ts"],
4
- "sourcesContent": ["import { Container } from \"inversify\";\n\nimport { configModuleFactory } from \"@/config/di/configModuleFactory\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { externalPluginModuleFactory } from \"@/external-plugin/di/externalPluginModuleFactory\";\nimport { nftModuleFactory } from \"@/nft/di/nftModuleFactory\";\nimport { nanoPkiModuleFactory } from \"@/pki/di/pkiModuleFactory\";\nimport { tokenModuleFactory } from \"@/token/di/tokenModuleFactory\";\nimport { transactionModuleFactory } from \"@/transaction/di/transactionModuleFactory\";\nimport { trustedNameModuleFactory } from \"@/trusted-name/di/trustedNameModuleFactory\";\nimport { typedDataModuleFactory } from \"@/typed-data/di/typedDataModuleFactory\";\nimport { uniswapModuleFactory } from \"@/uniswap/di/uniswapModuleFactory\";\n\ntype MakeContainerArgs = {\n config: ContextModuleConfig;\n};\n\nexport const makeContainer = ({ config }: MakeContainerArgs) => {\n const container = new Container();\n\n container.load(\n configModuleFactory(config),\n externalPluginModuleFactory(),\n nftModuleFactory(),\n tokenModuleFactory(),\n transactionModuleFactory(),\n trustedNameModuleFactory(),\n typedDataModuleFactory(),\n nanoPkiModuleFactory(),\n uniswapModuleFactory(),\n );\n\n return container;\n};\n"],
5
- "mappings": "AAAA,OAAS,aAAAA,MAAiB,YAE1B,OAAS,uBAAAC,MAA2B,kCAEpC,OAAS,+BAAAC,MAAmC,mDAC5C,OAAS,oBAAAC,MAAwB,4BACjC,OAAS,wBAAAC,MAA4B,4BACrC,OAAS,sBAAAC,MAA0B,gCACnC,OAAS,4BAAAC,MAAgC,4CACzC,OAAS,4BAAAC,MAAgC,6CACzC,OAAS,0BAAAC,MAA8B,yCACvC,OAAS,wBAAAC,MAA4B,oCAM9B,MAAMC,EAAgB,CAAC,CAAE,OAAAC,CAAO,IAAyB,CAC9D,MAAMC,EAAY,IAAIZ,EAEtB,OAAAY,EAAU,KACRX,EAAoBU,CAAM,EAC1BT,EAA4B,EAC5BC,EAAiB,EACjBE,EAAmB,EACnBC,EAAyB,EACzBC,EAAyB,EACzBC,EAAuB,EACvBJ,EAAqB,EACrBK,EAAqB,CACvB,EAEOG,CACT",
6
- "names": ["Container", "configModuleFactory", "externalPluginModuleFactory", "nftModuleFactory", "nanoPkiModuleFactory", "tokenModuleFactory", "transactionModuleFactory", "trustedNameModuleFactory", "typedDataModuleFactory", "uniswapModuleFactory", "makeContainer", "config", "container"]
4
+ "sourcesContent": ["import { Container } from \"inversify\";\n\nimport { configModuleFactory } from \"@/config/di/configModuleFactory\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { externalPluginModuleFactory } from \"@/external-plugin/di/externalPluginModuleFactory\";\nimport { nftModuleFactory } from \"@/nft/di/nftModuleFactory\";\nimport { nanoPkiModuleFactory } from \"@/pki/di/pkiModuleFactory\";\nimport { tokenModuleFactory } from \"@/token/di/tokenModuleFactory\";\nimport { transactionModuleFactory } from \"@/transaction/di/transactionModuleFactory\";\nimport { trustedNameModuleFactory } from \"@/trusted-name/di/trustedNameModuleFactory\";\nimport { typedDataModuleFactory } from \"@/typed-data/di/typedDataModuleFactory\";\nimport { uniswapModuleFactory } from \"@/uniswap/di/uniswapModuleFactory\";\nimport { web3CheckModuleFactory } from \"@/web3-check/di/web3CheckModuleFactory\";\n\ntype MakeContainerArgs = {\n config: ContextModuleConfig;\n};\n\nexport const makeContainer = ({ config }: MakeContainerArgs) => {\n const container = new Container();\n\n container.loadSync(\n configModuleFactory(config),\n externalPluginModuleFactory(),\n nftModuleFactory(),\n tokenModuleFactory(),\n transactionModuleFactory(),\n trustedNameModuleFactory(),\n typedDataModuleFactory(),\n nanoPkiModuleFactory(),\n uniswapModuleFactory(),\n web3CheckModuleFactory(),\n );\n\n return container;\n};\n"],
5
+ "mappings": "AAAA,OAAS,aAAAA,MAAiB,YAE1B,OAAS,uBAAAC,MAA2B,kCAEpC,OAAS,+BAAAC,MAAmC,mDAC5C,OAAS,oBAAAC,MAAwB,4BACjC,OAAS,wBAAAC,MAA4B,4BACrC,OAAS,sBAAAC,MAA0B,gCACnC,OAAS,4BAAAC,MAAgC,4CACzC,OAAS,4BAAAC,MAAgC,6CACzC,OAAS,0BAAAC,MAA8B,yCACvC,OAAS,wBAAAC,MAA4B,oCACrC,OAAS,0BAAAC,MAA8B,yCAMhC,MAAMC,EAAgB,CAAC,CAAE,OAAAC,CAAO,IAAyB,CAC9D,MAAMC,EAAY,IAAIb,EAEtB,OAAAa,EAAU,SACRZ,EAAoBW,CAAM,EAC1BV,EAA4B,EAC5BC,EAAiB,EACjBE,EAAmB,EACnBC,EAAyB,EACzBC,EAAyB,EACzBC,EAAuB,EACvBJ,EAAqB,EACrBK,EAAqB,EACrBC,EAAuB,CACzB,EAEOG,CACT",
6
+ "names": ["Container", "configModuleFactory", "externalPluginModuleFactory", "nftModuleFactory", "nanoPkiModuleFactory", "tokenModuleFactory", "transactionModuleFactory", "trustedNameModuleFactory", "typedDataModuleFactory", "uniswapModuleFactory", "web3CheckModuleFactory", "makeContainer", "config", "container"]
7
7
  }
@@ -1,2 +1,2 @@
1
- var D=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var u=(a,r,o,e)=>{for(var t=e>1?void 0:e?C(r,o):r,i=a.length-1,n;i>=0;i--)(n=a[i])&&(t=(e?n(r,o,t):n(t))||t);return e&&t&&D(r,o,t),t},d=(a,r)=>(o,e)=>r(o,e,a);import h from"axios";import{inject as b,injectable as x}from"inversify";import{Left as E,Right as s}from"purify-ts";import{configTypes as I}from"../../config/di/configTypes";import y from"../../../package.json";let f=class{constructor(r){this.config=r}async getDappInfos({chainId:r,address:o,selector:e}){try{const t=await h.request({method:"GET",url:`${this.config.cal.url}/dapps`,params:{output:"b2c,b2c_signatures,abis",chain_id:r,contracts:o},headers:{"X-Ledger-Client-Version":`context-module/${y.version}`}});if(!t.data[0])return s(void 0);o=o.toLowerCase(),e=`0x${e.slice(2).toLowerCase()}`;const{erc20OfInterest:i,method:n,plugin:p}=t.data[0].b2c?.contracts?.find(g=>g.address===o)?.selectors?.[e]||{},{signature:c,serialized_data:m}=t.data[0].b2c_signatures?.[o]?.[e]||{};if(!i||!n||!p||!c||!m)return s(void 0);const l=t.data[0].abis?.[o];return l?s({selectorDetails:{method:n,plugin:p,erc20OfInterest:i,signature:c,serializedData:m},abi:l}):s(void 0)}catch{return E(new Error("[ContextModule] HttpExternalPluginDataSource: Error fetching dapp infos"))}}};f=u([x(),d(0,b(I.Config))],f);export{f as HttpExternalPluginDataSource};
1
+ var g=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var l=(a,r,t,e)=>{for(var o=e>1?void 0:e?E(r,t):r,i=a.length-1,n;i>=0;i--)(n=a[i])&&(o=(e?n(r,t,o):n(o))||o);return e&&o&&g(r,t,o),o},d=(a,r)=>(t,e)=>r(t,e,a);import C from"axios";import{inject as h,injectable as I}from"inversify";import{Left as b,Right as s}from"purify-ts";import{configTypes as x}from"../../config/di/configTypes";import{LEDGER_CLIENT_VERSION_HEADER as _}from"../../shared/constant/HttpHeaders";import y from"../../../package.json";let f=class{constructor(r){this.config=r}async getDappInfos({chainId:r,address:t,selector:e}){try{const o=await C.request({method:"GET",url:`${this.config.cal.url}/dapps`,params:{output:"b2c,b2c_signatures,abis",chain_id:r,contracts:t},headers:{[_]:`context-module/${y.version}`}});if(!o.data[0])return s(void 0);t=t.toLowerCase(),e=`0x${e.slice(2).toLowerCase()}`;const{erc20OfInterest:i,method:n,plugin:p}=o.data[0].b2c?.contracts?.find(D=>D.address===t)?.selectors?.[e]||{},{signature:c,serialized_data:m}=o.data[0].b2c_signatures?.[t]?.[e]||{};if(!i||!n||!p||!c||!m)return s(void 0);const u=o.data[0].abis?.[t];return u?s({selectorDetails:{method:n,plugin:p,erc20OfInterest:i,signature:c,serializedData:m},abi:u}):s(void 0)}catch{return b(new Error("[ContextModule] HttpExternalPluginDataSource: Error fetching dapp infos"))}}};f=l([I(),d(0,h(x.Config))],f);export{f as HttpExternalPluginDataSource};
2
2
  //# sourceMappingURL=HttpExternalPluginDataSource.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/external-plugin/data/HttpExternalPluginDataSource.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 { DAppDto } from \"@/external-plugin/data/DAppDto\";\nimport {\n ExternalPluginDataSource,\n GetDappInfos,\n} from \"@/external-plugin/data/ExternalPluginDataSource\";\nimport { DappInfos } from \"@/external-plugin/model/DappInfos\";\nimport { SelectorDetails } from \"@/external-plugin/model/SelectorDetails\";\nimport PACKAGE from \"@root/package.json\";\n\n@injectable()\nexport class HttpExternalPluginDataSource implements ExternalPluginDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n async getDappInfos({\n chainId,\n address,\n selector,\n }: GetDappInfos): Promise<Either<Error, DappInfos | undefined>> {\n try {\n const dappInfos = await axios.request<DAppDto[]>({\n method: \"GET\",\n url: `${this.config.cal.url}/dapps`,\n params: {\n output: \"b2c,b2c_signatures,abis\",\n chain_id: chainId,\n contracts: address,\n },\n headers: {\n \"X-Ledger-Client-Version\": `context-module/${PACKAGE.version}`,\n },\n });\n\n if (!dappInfos.data[0]) {\n return Right(undefined);\n }\n\n // Normalize the address and selector\n address = address.toLowerCase();\n selector = `0x${selector.slice(2).toLowerCase()}`;\n\n const { erc20OfInterest, method, plugin } =\n dappInfos.data[0].b2c?.contracts?.find((c) => c.address === address)\n ?.selectors?.[selector] || {};\n const { signature, serialized_data: serializedData } =\n dappInfos.data[0].b2c_signatures?.[address]?.[selector] || {};\n\n if (\n !erc20OfInterest ||\n !method ||\n !plugin ||\n !signature ||\n !serializedData\n ) {\n return Right(undefined);\n }\n\n const abi = dappInfos.data[0].abis?.[address];\n\n if (!abi) {\n return Right(undefined);\n }\n\n const selectorDetails: SelectorDetails = {\n method,\n plugin,\n erc20OfInterest,\n signature,\n serializedData,\n };\n\n return Right({ selectorDetails, abi });\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpExternalPluginDataSource: Error fetching dapp infos\",\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,0BAS5B,OAAOC,MAAa,qBAGb,IAAMC,EAAN,KAAuE,CAC5E,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CAEH,MAAM,aAAa,CACjB,QAAAC,EACA,QAAAC,EACA,SAAAC,CACF,EAAgE,CAC9D,GAAI,CACF,MAAMC,EAAY,MAAMC,EAAM,QAAmB,CAC/C,OAAQ,MACR,IAAK,GAAG,KAAK,OAAO,IAAI,GAAG,SAC3B,OAAQ,CACN,OAAQ,0BACR,SAAUJ,EACV,UAAWC,CACb,EACA,QAAS,CACP,0BAA2B,kBAAkBI,EAAQ,OAAO,EAC9D,CACF,CAAC,EAED,GAAI,CAACF,EAAU,KAAK,CAAC,EACnB,OAAOG,EAAM,MAAS,EAIxBL,EAAUA,EAAQ,YAAY,EAC9BC,EAAW,KAAKA,EAAS,MAAM,CAAC,EAAE,YAAY,CAAC,GAE/C,KAAM,CAAE,gBAAAK,EAAiB,OAAAC,EAAQ,OAAAC,CAAO,EACtCN,EAAU,KAAK,CAAC,EAAE,KAAK,WAAW,KAAMO,GAAMA,EAAE,UAAYT,CAAO,GAC/D,YAAYC,CAAQ,GAAK,CAAC,EAC1B,CAAE,UAAAS,EAAW,gBAAiBC,CAAe,EACjDT,EAAU,KAAK,CAAC,EAAE,iBAAiBF,CAAO,IAAIC,CAAQ,GAAK,CAAC,EAE9D,GACE,CAACK,GACD,CAACC,GACD,CAACC,GACD,CAACE,GACD,CAACC,EAED,OAAON,EAAM,MAAS,EAGxB,MAAMO,EAAMV,EAAU,KAAK,CAAC,EAAE,OAAOF,CAAO,EAE5C,OAAKY,EAYEP,EAAM,CAAE,gBAR0B,CACvC,OAAAE,EACA,OAAAC,EACA,gBAAAF,EACA,UAAAI,EACA,eAAAC,CACF,EAEgC,IAAAC,CAAI,CAAC,EAX5BP,EAAM,MAAS,CAY1B,MAAiB,CACf,OAAOQ,EACL,IAAI,MACF,yEACF,CACF,CACF,CACF,CACF,EAvEahB,EAANiB,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,IAFjBrB",
6
- "names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "PACKAGE", "HttpExternalPluginDataSource", "config", "chainId", "address", "selector", "dappInfos", "axios", "PACKAGE", "Right", "erc20OfInterest", "method", "plugin", "c", "signature", "serializedData", "abi", "Left", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes"]
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 { DAppDto } from \"@/external-plugin/data/DAppDto\";\nimport {\n ExternalPluginDataSource,\n GetDappInfos,\n} from \"@/external-plugin/data/ExternalPluginDataSource\";\nimport { DappInfos } from \"@/external-plugin/model/DappInfos\";\nimport { SelectorDetails } from \"@/external-plugin/model/SelectorDetails\";\nimport { LEDGER_CLIENT_VERSION_HEADER } from \"@/shared/constant/HttpHeaders\";\nimport PACKAGE from \"@root/package.json\";\n\n@injectable()\nexport class HttpExternalPluginDataSource implements ExternalPluginDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n async getDappInfos({\n chainId,\n address,\n selector,\n }: GetDappInfos): Promise<Either<Error, DappInfos | undefined>> {\n try {\n const dappInfos = await axios.request<DAppDto[]>({\n method: \"GET\",\n url: `${this.config.cal.url}/dapps`,\n params: {\n output: \"b2c,b2c_signatures,abis\",\n chain_id: chainId,\n contracts: address,\n },\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n },\n });\n\n if (!dappInfos.data[0]) {\n return Right(undefined);\n }\n\n // Normalize the address and selector\n address = address.toLowerCase();\n selector = `0x${selector.slice(2).toLowerCase()}`;\n\n const { erc20OfInterest, method, plugin } =\n dappInfos.data[0].b2c?.contracts?.find((c) => c.address === address)\n ?.selectors?.[selector] || {};\n const { signature, serialized_data: serializedData } =\n dappInfos.data[0].b2c_signatures?.[address]?.[selector] || {};\n\n if (\n !erc20OfInterest ||\n !method ||\n !plugin ||\n !signature ||\n !serializedData\n ) {\n return Right(undefined);\n }\n\n const abi = dappInfos.data[0].abis?.[address];\n\n if (!abi) {\n return Right(undefined);\n }\n\n const selectorDetails: SelectorDetails = {\n method,\n plugin,\n erc20OfInterest,\n signature,\n serializedData,\n };\n\n return Right({ selectorDetails, abi });\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpExternalPluginDataSource: Error fetching dapp infos\",\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,0BAS5B,OAAS,gCAAAC,MAAoC,gCAC7C,OAAOC,MAAa,qBAGb,IAAMC,EAAN,KAAuE,CAC5E,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CAEH,MAAM,aAAa,CACjB,QAAAC,EACA,QAAAC,EACA,SAAAC,CACF,EAAgE,CAC9D,GAAI,CACF,MAAMC,EAAY,MAAMC,EAAM,QAAmB,CAC/C,OAAQ,MACR,IAAK,GAAG,KAAK,OAAO,IAAI,GAAG,SAC3B,OAAQ,CACN,OAAQ,0BACR,SAAUJ,EACV,UAAWC,CACb,EACA,QAAS,CACP,CAACI,CAA4B,EAAG,kBAAkBC,EAAQ,OAAO,EACnE,CACF,CAAC,EAED,GAAI,CAACH,EAAU,KAAK,CAAC,EACnB,OAAOI,EAAM,MAAS,EAIxBN,EAAUA,EAAQ,YAAY,EAC9BC,EAAW,KAAKA,EAAS,MAAM,CAAC,EAAE,YAAY,CAAC,GAE/C,KAAM,CAAE,gBAAAM,EAAiB,OAAAC,EAAQ,OAAAC,CAAO,EACtCP,EAAU,KAAK,CAAC,EAAE,KAAK,WAAW,KAAMQ,GAAMA,EAAE,UAAYV,CAAO,GAC/D,YAAYC,CAAQ,GAAK,CAAC,EAC1B,CAAE,UAAAU,EAAW,gBAAiBC,CAAe,EACjDV,EAAU,KAAK,CAAC,EAAE,iBAAiBF,CAAO,IAAIC,CAAQ,GAAK,CAAC,EAE9D,GACE,CAACM,GACD,CAACC,GACD,CAACC,GACD,CAACE,GACD,CAACC,EAED,OAAON,EAAM,MAAS,EAGxB,MAAMO,EAAMX,EAAU,KAAK,CAAC,EAAE,OAAOF,CAAO,EAE5C,OAAKa,EAYEP,EAAM,CAAE,gBAR0B,CACvC,OAAAE,EACA,OAAAC,EACA,gBAAAF,EACA,UAAAI,EACA,eAAAC,CACF,EAEgC,IAAAC,CAAI,CAAC,EAX5BP,EAAM,MAAS,CAY1B,MAAiB,CACf,OAAOQ,EACL,IAAI,MACF,yEACF,CACF,CACF,CACF,CACF,EAvEajB,EAANkB,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,IAFjBtB",
6
+ "names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "HttpExternalPluginDataSource", "config", "chainId", "address", "selector", "dappInfos", "axios", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "Right", "erc20OfInterest", "method", "plugin", "c", "signature", "serializedData", "abi", "Left", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import n from"axios";import u from"@/external-plugin/__tests__/abi.json";import{HttpExternalPluginDataSource as d}from"../../external-plugin/data/HttpExternalPluginDataSource";import l from"../../../package.json";vi.mock("axios");const a=t=>({data:t});describe("HttpExternalPuginDataSource",()=>{let t;const i={blockchainName:"ethereum",chainId:1,contracts:[{address:"0x1ef",contractName:"otherName",selectors:{"0x01ee":{erc20OfInterest:["fromToken"],method:"swap",plugin:"plugin"}}},{address:"0x0abc",contractName:"name",selectors:{"0x01ff":{erc20OfInterest:["fromToken"],method:"swap",plugin:"plugin"}}}],name:"test"},r={"0x1ef":u,"0x0abc":u},o={"0x1ef":{"0x01ee":{plugin:"plugin",serialized_data:"0x001",signature:"0x002"}},"0x0abc":{"0x01ff":{plugin:"plugin",serialized_data:"0x001",signature:"0x002"}}};beforeAll(()=>{const s={cal:{url:"https://crypto-assets-service.api.ledger.com/v1"}};t=new d(s),vi.clearAllMocks()}),it("should call axios with the ledger client version header",async()=>{const s=`context-module/${l.version}`,e=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(n,"request").mockImplementation(e),await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"}),expect(e).toHaveBeenCalledWith(expect.objectContaining({headers:{"X-Ledger-Client-Version":s}}))}),it("should return undefined when no abis is undefined",async()=>{const s=a([{b2c:i,b2c_signatures:o}]);vi.spyOn(n,"request").mockResolvedValue(s);const e=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e.extract()).toEqual(void 0)}),it("should return undefined when no selectors",async()=>{const s=a([{abis:r,b2c_signatures:o}]);vi.spyOn(n,"request").mockResolvedValue(s);const e=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e.extract()).toEqual(void 0)}),it("should return undefined when no abis data",async()=>{const s=a([{abis:{},b2c:i,b2c_signatures:o}]);vi.spyOn(n,"request").mockResolvedValue(s);const e=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e.extract()).toEqual(void 0)}),it("should return undefined when no abis data",async()=>{const s=a([{abis:{},b2c:i,b2c_signatures:o}]);vi.spyOn(n,"request").mockResolvedValue(s);const e=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e.extract()).toEqual(void 0)}),it("should return undefined when no abis data for the contract address",async()=>{const e=a([{abis:{"0x1":u},b2c:i,b2c_signatures:o}]);vi.spyOn(n,"request").mockResolvedValue(e);const c=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(c.extract()).toEqual(void 0)}),it("should return undefined when no b2c signature",async()=>{const s=a([{b2c:i,abis:r}]);vi.spyOn(n,"request").mockResolvedValue(s);const e=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e.extract()).toEqual(void 0)}),it("should return undefined when no ecc20OfInterest",async()=>{const e=a([{b2c:{blockchainName:"ethereum",chainId:1,contracts:[{address:"0x0abc",contractName:"name",selectors:{"0x01ff":{method:"swap",plugin:"plugin"}}}],name:"test"},abis:r,b2c_signatures:o}]);vi.spyOn(n,"request").mockResolvedValue(e);const c=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(c.extract()).toEqual(void 0)}),it("should return undefined when no method",async()=>{const e=a([{b2c:{blockchainName:"ethereum",chainId:1,contracts:[{address:"0x0abc",contractName:"name",selectors:{"0x01ff":{erc20OfInterest:["fromToken"],plugin:"plugin"}}}],name:"test"},abis:r,b2c_signatures:o}]);vi.spyOn(n,"request").mockResolvedValue(e);const c=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(c.extract()).toEqual(void 0)}),it("should return undefined when no plugin",async()=>{const e=a([{b2c:{blockchainName:"ethereum",chainId:1,contracts:[{address:"0x0abc",contractName:"name",selectors:{"0x01ff":{erc20OfInterest:["fromToken"],method:"swap"}}}],name:"test"},abis:r,b2c_signatures:o}]);vi.spyOn(n,"request").mockResolvedValue(e);const c=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(c.extract()).toEqual(void 0)}),it("should return undefined when no method",async()=>{const e=a([{b2c:{blockchainName:"ethereum",chainId:1,contracts:[{address:"0x0abc",contractName:"name",selectors:{"0x01ff":{erc20OfInterest:["fromToken"],plugin:"plugin"}}}],name:"test"},abis:r,b2c_signatures:o}]);vi.spyOn(n,"request").mockResolvedValue(e);const c=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(c.extract()).toEqual(void 0)}),it("should return undefined when no signature",async()=>{const e=a([{b2c:i,abis:r,b2c_signatures:{"0x0abc":{"0x01ff":{plugin:"plugin",serialized_data:"0x001"}}}}]);vi.spyOn(n,"request").mockResolvedValue(e);const c=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(c.extract()).toEqual(void 0)}),it("should return undefined when no serialized data",async()=>{const e=a([{b2c:i,abis:r,b2c_signatures:{"0x0abc":{"0x01ff":{plugin:"plugin",signature:"0x002"}}}}]);vi.spyOn(n,"request").mockResolvedValue(e);const c=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(c.extract()).toEqual(void 0)}),it("should return a correct response",async()=>{const s=a([{b2c:i,abis:r,b2c_signatures:o}]);vi.spyOn(n,"request").mockResolvedValue(s);const e=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e.extract()).toEqual({abi:u,selectorDetails:{erc20OfInterest:["fromToken"],method:"swap",plugin:"plugin",serializedData:"0x001",signature:"0x002"}})}),it("should normalize the address and selector",async()=>{const s=a([{b2c:i,abis:r,b2c_signatures:o}]);vi.spyOn(n,"request").mockResolvedValue(s);const e=await t.getDappInfos({chainId:1,address:"0x0AbC",selector:"0x01Ff"});expect(e.extract()).toEqual({abi:u,selectorDetails:{erc20OfInterest:["fromToken"],method:"swap",plugin:"plugin",serializedData:"0x001",signature:"0x002"}})}),it("should return an error when axios throws an error",async()=>{vi.spyOn(n,"request").mockRejectedValue(new Error("error"));const s=await t.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(s.extract()).toEqual(new Error("[ContextModule] HttpExternalPluginDataSource: Error fetching dapp infos"))})});
1
+ import n from"axios";import u from"@/external-plugin/__tests__/abi.json";import{HttpExternalPluginDataSource as d}from"../../external-plugin/data/HttpExternalPluginDataSource";import{LEDGER_CLIENT_VERSION_HEADER as l}from"../../shared/constant/HttpHeaders";import p from"../../../package.json";vi.mock("axios");const a=s=>({data:s});describe("HttpExternalPuginDataSource",()=>{let s;const i={blockchainName:"ethereum",chainId:1,contracts:[{address:"0x1ef",contractName:"otherName",selectors:{"0x01ee":{erc20OfInterest:["fromToken"],method:"swap",plugin:"plugin"}}},{address:"0x0abc",contractName:"name",selectors:{"0x01ff":{erc20OfInterest:["fromToken"],method:"swap",plugin:"plugin"}}}],name:"test"},r={"0x1ef":u,"0x0abc":u},o={"0x1ef":{"0x01ee":{plugin:"plugin",serialized_data:"0x001",signature:"0x002"}},"0x0abc":{"0x01ff":{plugin:"plugin",serialized_data:"0x001",signature:"0x002"}}};beforeAll(()=>{const t={cal:{url:"https://crypto-assets-service.api.ledger.com/v1"}};s=new d(t),vi.clearAllMocks()}),it("should call axios with the ledger client version header",async()=>{const t=`context-module/${p.version}`,e=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(n,"request").mockImplementation(e),await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"}),expect(e).toHaveBeenCalledWith(expect.objectContaining({headers:{[l]:t}}))}),it("should return undefined when no abis is undefined",async()=>{const t=a([{b2c:i,b2c_signatures:o}]);vi.spyOn(n,"request").mockResolvedValue(t);const e=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e.extract()).toEqual(void 0)}),it("should return undefined when no selectors",async()=>{const t=a([{abis:r,b2c_signatures:o}]);vi.spyOn(n,"request").mockResolvedValue(t);const e=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e.extract()).toEqual(void 0)}),it("should return undefined when no abis data",async()=>{const t=a([{abis:{},b2c:i,b2c_signatures:o}]);vi.spyOn(n,"request").mockResolvedValue(t);const e=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e.extract()).toEqual(void 0)}),it("should return undefined when no abis data",async()=>{const t=a([{abis:{},b2c:i,b2c_signatures:o}]);vi.spyOn(n,"request").mockResolvedValue(t);const e=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e.extract()).toEqual(void 0)}),it("should return undefined when no abis data for the contract address",async()=>{const e=a([{abis:{"0x1":u},b2c:i,b2c_signatures:o}]);vi.spyOn(n,"request").mockResolvedValue(e);const c=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(c.extract()).toEqual(void 0)}),it("should return undefined when no b2c signature",async()=>{const t=a([{b2c:i,abis:r}]);vi.spyOn(n,"request").mockResolvedValue(t);const e=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e.extract()).toEqual(void 0)}),it("should return undefined when no ecc20OfInterest",async()=>{const e=a([{b2c:{blockchainName:"ethereum",chainId:1,contracts:[{address:"0x0abc",contractName:"name",selectors:{"0x01ff":{method:"swap",plugin:"plugin"}}}],name:"test"},abis:r,b2c_signatures:o}]);vi.spyOn(n,"request").mockResolvedValue(e);const c=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(c.extract()).toEqual(void 0)}),it("should return undefined when no method",async()=>{const e=a([{b2c:{blockchainName:"ethereum",chainId:1,contracts:[{address:"0x0abc",contractName:"name",selectors:{"0x01ff":{erc20OfInterest:["fromToken"],plugin:"plugin"}}}],name:"test"},abis:r,b2c_signatures:o}]);vi.spyOn(n,"request").mockResolvedValue(e);const c=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(c.extract()).toEqual(void 0)}),it("should return undefined when no plugin",async()=>{const e=a([{b2c:{blockchainName:"ethereum",chainId:1,contracts:[{address:"0x0abc",contractName:"name",selectors:{"0x01ff":{erc20OfInterest:["fromToken"],method:"swap"}}}],name:"test"},abis:r,b2c_signatures:o}]);vi.spyOn(n,"request").mockResolvedValue(e);const c=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(c.extract()).toEqual(void 0)}),it("should return undefined when no method",async()=>{const e=a([{b2c:{blockchainName:"ethereum",chainId:1,contracts:[{address:"0x0abc",contractName:"name",selectors:{"0x01ff":{erc20OfInterest:["fromToken"],plugin:"plugin"}}}],name:"test"},abis:r,b2c_signatures:o}]);vi.spyOn(n,"request").mockResolvedValue(e);const c=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(c.extract()).toEqual(void 0)}),it("should return undefined when no signature",async()=>{const e=a([{b2c:i,abis:r,b2c_signatures:{"0x0abc":{"0x01ff":{plugin:"plugin",serialized_data:"0x001"}}}}]);vi.spyOn(n,"request").mockResolvedValue(e);const c=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(c.extract()).toEqual(void 0)}),it("should return undefined when no serialized data",async()=>{const e=a([{b2c:i,abis:r,b2c_signatures:{"0x0abc":{"0x01ff":{plugin:"plugin",signature:"0x002"}}}}]);vi.spyOn(n,"request").mockResolvedValue(e);const c=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(c.extract()).toEqual(void 0)}),it("should return a correct response",async()=>{const t=a([{b2c:i,abis:r,b2c_signatures:o}]);vi.spyOn(n,"request").mockResolvedValue(t);const e=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e.extract()).toEqual({abi:u,selectorDetails:{erc20OfInterest:["fromToken"],method:"swap",plugin:"plugin",serializedData:"0x001",signature:"0x002"}})}),it("should normalize the address and selector",async()=>{const t=a([{b2c:i,abis:r,b2c_signatures:o}]);vi.spyOn(n,"request").mockResolvedValue(t);const e=await s.getDappInfos({chainId:1,address:"0x0AbC",selector:"0x01Ff"});expect(e.extract()).toEqual({abi:u,selectorDetails:{erc20OfInterest:["fromToken"],method:"swap",plugin:"plugin",serializedData:"0x001",signature:"0x002"}})}),it("should return an error when axios throws an error",async()=>{vi.spyOn(n,"request").mockRejectedValue(new Error("error"));const t=await s.getDappInfos({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(t.extract()).toEqual(new Error("[ContextModule] HttpExternalPluginDataSource: Error fetching dapp infos"))})});
2
2
  //# sourceMappingURL=HttpExternalPluginDataSource.test.js.map