@ledgerhq/context-module 0.1.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (542) hide show
  1. package/LICENSE.MD +202 -0
  2. package/README.md +125 -0
  3. package/lib/cjs/index.js +2 -0
  4. package/lib/cjs/index.js.map +7 -0
  5. package/lib/cjs/package.json +57 -0
  6. package/lib/cjs/src/ContextModule.js +2 -0
  7. package/lib/cjs/src/ContextModule.js.map +7 -0
  8. package/lib/cjs/src/ContextModuleBuilder.js +2 -0
  9. package/lib/cjs/src/ContextModuleBuilder.js.map +7 -0
  10. package/lib/cjs/src/ContextModuleBuilder.test.js +2 -0
  11. package/lib/cjs/src/ContextModuleBuilder.test.js.map +7 -0
  12. package/lib/cjs/src/DefaultContextModule.js +2 -0
  13. package/lib/cjs/src/DefaultContextModule.js.map +7 -0
  14. package/lib/cjs/src/DefaultContextModule.test.js +2 -0
  15. package/lib/cjs/src/DefaultContextModule.test.js.map +7 -0
  16. package/lib/cjs/src/config/di/configModuleFactory.js +2 -0
  17. package/lib/cjs/src/config/di/configModuleFactory.js.map +7 -0
  18. package/lib/cjs/src/config/di/configTypes.js +2 -0
  19. package/lib/cjs/src/config/di/configTypes.js.map +7 -0
  20. package/lib/cjs/src/config/model/ContextModuleConfig.js +2 -0
  21. package/lib/cjs/src/config/model/ContextModuleConfig.js.map +7 -0
  22. package/lib/cjs/src/di.js +2 -0
  23. package/lib/cjs/src/di.js.map +7 -0
  24. package/lib/cjs/src/external-plugin/data/DAppDto.js +2 -0
  25. package/lib/cjs/src/external-plugin/data/DAppDto.js.map +7 -0
  26. package/lib/cjs/src/external-plugin/data/ExternalPluginDataSource.js +2 -0
  27. package/lib/cjs/src/external-plugin/data/ExternalPluginDataSource.js.map +7 -0
  28. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js +2 -0
  29. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js.map +7 -0
  30. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js +2 -0
  31. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +7 -0
  32. package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js +2 -0
  33. package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js.map +7 -0
  34. package/lib/cjs/src/external-plugin/di/externalPluginTypes.js +2 -0
  35. package/lib/cjs/src/external-plugin/di/externalPluginTypes.js.map +7 -0
  36. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js +2 -0
  37. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js.map +7 -0
  38. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js +2 -0
  39. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +7 -0
  40. package/lib/cjs/src/external-plugin/model/DappInfos.js +2 -0
  41. package/lib/cjs/src/external-plugin/model/DappInfos.js.map +7 -0
  42. package/lib/cjs/src/external-plugin/model/SelectorDetails.js +2 -0
  43. package/lib/cjs/src/external-plugin/model/SelectorDetails.js.map +7 -0
  44. package/lib/cjs/src/index.js +2 -0
  45. package/lib/cjs/src/index.js.map +7 -0
  46. package/lib/cjs/src/nft/data/HttpNftDataSource.js +2 -0
  47. package/lib/cjs/src/nft/data/HttpNftDataSource.js.map +7 -0
  48. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js +2 -0
  49. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js.map +7 -0
  50. package/lib/cjs/src/nft/data/NftDataSource.js +2 -0
  51. package/lib/cjs/src/nft/data/NftDataSource.js.map +7 -0
  52. package/lib/cjs/src/nft/di/nftModuleFactory.js +2 -0
  53. package/lib/cjs/src/nft/di/nftModuleFactory.js.map +7 -0
  54. package/lib/cjs/src/nft/di/nftTypes.js +2 -0
  55. package/lib/cjs/src/nft/di/nftTypes.js.map +7 -0
  56. package/lib/cjs/src/nft/domain/NftContextLoader.js +2 -0
  57. package/lib/cjs/src/nft/domain/NftContextLoader.js.map +7 -0
  58. package/lib/cjs/src/nft/domain/NftContextLoader.test.js +2 -0
  59. package/lib/cjs/src/nft/domain/NftContextLoader.test.js.map +7 -0
  60. package/lib/cjs/src/shared/domain/ContextLoader.js +2 -0
  61. package/lib/cjs/src/shared/domain/ContextLoader.js.map +7 -0
  62. package/lib/cjs/src/shared/model/ClearSignContext.js +2 -0
  63. package/lib/cjs/src/shared/model/ClearSignContext.js.map +7 -0
  64. package/lib/cjs/src/shared/model/GenericPath.js +2 -0
  65. package/lib/cjs/src/shared/model/GenericPath.js.map +7 -0
  66. package/lib/cjs/src/shared/model/TransactionContext.js +2 -0
  67. package/lib/cjs/src/shared/model/TransactionContext.js.map +7 -0
  68. package/lib/cjs/src/shared/model/TransactionSubset.js +2 -0
  69. package/lib/cjs/src/shared/model/TransactionSubset.js.map +7 -0
  70. package/lib/cjs/src/shared/model/TypedDataClearSignContext.js +2 -0
  71. package/lib/cjs/src/shared/model/TypedDataClearSignContext.js.map +7 -0
  72. package/lib/cjs/src/shared/model/TypedDataContext.js +2 -0
  73. package/lib/cjs/src/shared/model/TypedDataContext.js.map +7 -0
  74. package/lib/cjs/src/shared/utils/HexStringUtils.js +2 -0
  75. package/lib/cjs/src/shared/utils/HexStringUtils.js.map +7 -0
  76. package/lib/cjs/src/token/data/HttpTokenDataSource.js +2 -0
  77. package/lib/cjs/src/token/data/HttpTokenDataSource.js.map +7 -0
  78. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js +2 -0
  79. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js.map +7 -0
  80. package/lib/cjs/src/token/data/TokenDataSource.js +2 -0
  81. package/lib/cjs/src/token/data/TokenDataSource.js.map +7 -0
  82. package/lib/cjs/src/token/data/TokenDto.js +2 -0
  83. package/lib/cjs/src/token/data/TokenDto.js.map +7 -0
  84. package/lib/cjs/src/token/di/tokenModuleFactory.js +2 -0
  85. package/lib/cjs/src/token/di/tokenModuleFactory.js.map +7 -0
  86. package/lib/cjs/src/token/di/tokenTypes.js +2 -0
  87. package/lib/cjs/src/token/di/tokenTypes.js.map +7 -0
  88. package/lib/cjs/src/token/domain/TokenContextLoader.js +2 -0
  89. package/lib/cjs/src/token/domain/TokenContextLoader.js.map +7 -0
  90. package/lib/cjs/src/token/domain/TokenContextLoader.test.js +2 -0
  91. package/lib/cjs/src/token/domain/TokenContextLoader.test.js.map +7 -0
  92. package/lib/cjs/src/transaction/data/CalldataDto.js +2 -0
  93. package/lib/cjs/src/transaction/data/CalldataDto.js.map +7 -0
  94. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js +2 -0
  95. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js.map +7 -0
  96. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js +2 -0
  97. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js.map +7 -0
  98. package/lib/cjs/src/transaction/data/TransactionDataSource.js +2 -0
  99. package/lib/cjs/src/transaction/data/TransactionDataSource.js.map +7 -0
  100. package/lib/cjs/src/transaction/di/transactionModuleFactory.js +2 -0
  101. package/lib/cjs/src/transaction/di/transactionModuleFactory.js.map +7 -0
  102. package/lib/cjs/src/transaction/di/transactionTypes.js +2 -0
  103. package/lib/cjs/src/transaction/di/transactionTypes.js.map +7 -0
  104. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js +2 -0
  105. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js.map +7 -0
  106. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js +2 -0
  107. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js.map +7 -0
  108. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js +2 -0
  109. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js.map +7 -0
  110. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js +2 -0
  111. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +7 -0
  112. package/lib/cjs/src/trusted-name/data/TrustedNameDataSource.js +2 -0
  113. package/lib/cjs/src/trusted-name/data/TrustedNameDataSource.js.map +7 -0
  114. package/lib/cjs/src/trusted-name/data/TrustedNameDto.js +2 -0
  115. package/lib/cjs/src/trusted-name/data/TrustedNameDto.js.map +7 -0
  116. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js +2 -0
  117. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js.map +7 -0
  118. package/lib/cjs/src/trusted-name/di/trustedNameTypes.js +2 -0
  119. package/lib/cjs/src/trusted-name/di/trustedNameTypes.js.map +7 -0
  120. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js +2 -0
  121. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js.map +7 -0
  122. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js +2 -0
  123. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +7 -0
  124. package/lib/cjs/src/typed-data/data/FiltersDto.js +2 -0
  125. package/lib/cjs/src/typed-data/data/FiltersDto.js.map +7 -0
  126. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js +2 -0
  127. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js.map +7 -0
  128. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js +2 -0
  129. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js.map +7 -0
  130. package/lib/cjs/src/typed-data/data/TypedDataDataSource.js +2 -0
  131. package/lib/cjs/src/typed-data/data/TypedDataDataSource.js.map +7 -0
  132. package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js +2 -0
  133. package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js.map +7 -0
  134. package/lib/cjs/src/typed-data/di/typedDataTypes.js +2 -0
  135. package/lib/cjs/src/typed-data/di/typedDataTypes.js.map +7 -0
  136. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js +2 -0
  137. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +7 -0
  138. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +2 -0
  139. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +7 -0
  140. package/lib/cjs/src/typed-data/domain/TypedDataContextLoader.js +2 -0
  141. package/lib/cjs/src/typed-data/domain/TypedDataContextLoader.js.map +7 -0
  142. package/lib/esm/index.js +2 -0
  143. package/lib/esm/index.js.map +7 -0
  144. package/lib/esm/package.json +57 -0
  145. package/lib/esm/src/ContextModule.js +1 -0
  146. package/lib/esm/src/ContextModule.js.map +7 -0
  147. package/lib/esm/src/ContextModuleBuilder.js +2 -0
  148. package/lib/esm/src/ContextModuleBuilder.js.map +7 -0
  149. package/lib/esm/src/ContextModuleBuilder.test.js +2 -0
  150. package/lib/esm/src/ContextModuleBuilder.test.js.map +7 -0
  151. package/lib/esm/src/DefaultContextModule.js +2 -0
  152. package/lib/esm/src/DefaultContextModule.js.map +7 -0
  153. package/lib/esm/src/DefaultContextModule.test.js +2 -0
  154. package/lib/esm/src/DefaultContextModule.test.js.map +7 -0
  155. package/lib/esm/src/config/di/configModuleFactory.js +2 -0
  156. package/lib/esm/src/config/di/configModuleFactory.js.map +7 -0
  157. package/lib/esm/src/config/di/configTypes.js +2 -0
  158. package/lib/esm/src/config/di/configTypes.js.map +7 -0
  159. package/lib/esm/src/config/model/ContextModuleConfig.js +1 -0
  160. package/lib/esm/src/config/model/ContextModuleConfig.js.map +7 -0
  161. package/lib/esm/src/di.js +2 -0
  162. package/lib/esm/src/di.js.map +7 -0
  163. package/lib/esm/src/external-plugin/data/DAppDto.js +1 -0
  164. package/lib/esm/src/external-plugin/data/DAppDto.js.map +7 -0
  165. package/lib/esm/src/external-plugin/data/ExternalPluginDataSource.js +1 -0
  166. package/lib/esm/src/external-plugin/data/ExternalPluginDataSource.js.map +7 -0
  167. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js +2 -0
  168. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js.map +7 -0
  169. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js +2 -0
  170. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +7 -0
  171. package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js +2 -0
  172. package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js.map +7 -0
  173. package/lib/esm/src/external-plugin/di/externalPluginTypes.js +2 -0
  174. package/lib/esm/src/external-plugin/di/externalPluginTypes.js.map +7 -0
  175. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js +2 -0
  176. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js.map +7 -0
  177. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js +2 -0
  178. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +7 -0
  179. package/lib/esm/src/external-plugin/model/DappInfos.js +1 -0
  180. package/lib/esm/src/external-plugin/model/DappInfos.js.map +7 -0
  181. package/lib/esm/src/external-plugin/model/SelectorDetails.js +1 -0
  182. package/lib/esm/src/external-plugin/model/SelectorDetails.js.map +7 -0
  183. package/lib/esm/src/index.js +2 -0
  184. package/lib/esm/src/index.js.map +7 -0
  185. package/lib/esm/src/nft/data/HttpNftDataSource.js +2 -0
  186. package/lib/esm/src/nft/data/HttpNftDataSource.js.map +7 -0
  187. package/lib/esm/src/nft/data/HttpNftDataSource.test.js +2 -0
  188. package/lib/esm/src/nft/data/HttpNftDataSource.test.js.map +7 -0
  189. package/lib/esm/src/nft/data/NftDataSource.js +1 -0
  190. package/lib/esm/src/nft/data/NftDataSource.js.map +7 -0
  191. package/lib/esm/src/nft/di/nftModuleFactory.js +2 -0
  192. package/lib/esm/src/nft/di/nftModuleFactory.js.map +7 -0
  193. package/lib/esm/src/nft/di/nftTypes.js +2 -0
  194. package/lib/esm/src/nft/di/nftTypes.js.map +7 -0
  195. package/lib/esm/src/nft/domain/NftContextLoader.js +2 -0
  196. package/lib/esm/src/nft/domain/NftContextLoader.js.map +7 -0
  197. package/lib/esm/src/nft/domain/NftContextLoader.test.js +2 -0
  198. package/lib/esm/src/nft/domain/NftContextLoader.test.js.map +7 -0
  199. package/lib/esm/src/shared/domain/ContextLoader.js +1 -0
  200. package/lib/esm/src/shared/domain/ContextLoader.js.map +7 -0
  201. package/lib/esm/src/shared/model/ClearSignContext.js +2 -0
  202. package/lib/esm/src/shared/model/ClearSignContext.js.map +7 -0
  203. package/lib/esm/src/shared/model/GenericPath.js +2 -0
  204. package/lib/esm/src/shared/model/GenericPath.js.map +7 -0
  205. package/lib/esm/src/shared/model/TransactionContext.js +1 -0
  206. package/lib/esm/src/shared/model/TransactionContext.js.map +7 -0
  207. package/lib/esm/src/shared/model/TransactionSubset.js +1 -0
  208. package/lib/esm/src/shared/model/TransactionSubset.js.map +7 -0
  209. package/lib/esm/src/shared/model/TypedDataClearSignContext.js +2 -0
  210. package/lib/esm/src/shared/model/TypedDataClearSignContext.js.map +7 -0
  211. package/lib/esm/src/shared/model/TypedDataContext.js +1 -0
  212. package/lib/esm/src/shared/model/TypedDataContext.js.map +7 -0
  213. package/lib/esm/src/shared/utils/HexStringUtils.js +2 -0
  214. package/lib/esm/src/shared/utils/HexStringUtils.js.map +7 -0
  215. package/lib/esm/src/token/data/HttpTokenDataSource.js +2 -0
  216. package/lib/esm/src/token/data/HttpTokenDataSource.js.map +7 -0
  217. package/lib/esm/src/token/data/HttpTokenDataSource.test.js +2 -0
  218. package/lib/esm/src/token/data/HttpTokenDataSource.test.js.map +7 -0
  219. package/lib/esm/src/token/data/TokenDataSource.js +1 -0
  220. package/lib/esm/src/token/data/TokenDataSource.js.map +7 -0
  221. package/lib/esm/src/token/data/TokenDto.js +1 -0
  222. package/lib/esm/src/token/data/TokenDto.js.map +7 -0
  223. package/lib/esm/src/token/di/tokenModuleFactory.js +2 -0
  224. package/lib/esm/src/token/di/tokenModuleFactory.js.map +7 -0
  225. package/lib/esm/src/token/di/tokenTypes.js +2 -0
  226. package/lib/esm/src/token/di/tokenTypes.js.map +7 -0
  227. package/lib/esm/src/token/domain/TokenContextLoader.js +2 -0
  228. package/lib/esm/src/token/domain/TokenContextLoader.js.map +7 -0
  229. package/lib/esm/src/token/domain/TokenContextLoader.test.js +2 -0
  230. package/lib/esm/src/token/domain/TokenContextLoader.test.js.map +7 -0
  231. package/lib/esm/src/transaction/data/CalldataDto.js +1 -0
  232. package/lib/esm/src/transaction/data/CalldataDto.js.map +7 -0
  233. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js +2 -0
  234. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js.map +7 -0
  235. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js +2 -0
  236. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js.map +7 -0
  237. package/lib/esm/src/transaction/data/TransactionDataSource.js +1 -0
  238. package/lib/esm/src/transaction/data/TransactionDataSource.js.map +7 -0
  239. package/lib/esm/src/transaction/di/transactionModuleFactory.js +2 -0
  240. package/lib/esm/src/transaction/di/transactionModuleFactory.js.map +7 -0
  241. package/lib/esm/src/transaction/di/transactionTypes.js +2 -0
  242. package/lib/esm/src/transaction/di/transactionTypes.js.map +7 -0
  243. package/lib/esm/src/transaction/domain/TransactionContextLoader.js +2 -0
  244. package/lib/esm/src/transaction/domain/TransactionContextLoader.js.map +7 -0
  245. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js +2 -0
  246. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js.map +7 -0
  247. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js +2 -0
  248. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js.map +7 -0
  249. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js +2 -0
  250. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +7 -0
  251. package/lib/esm/src/trusted-name/data/TrustedNameDataSource.js +1 -0
  252. package/lib/esm/src/trusted-name/data/TrustedNameDataSource.js.map +7 -0
  253. package/lib/esm/src/trusted-name/data/TrustedNameDto.js +1 -0
  254. package/lib/esm/src/trusted-name/data/TrustedNameDto.js.map +7 -0
  255. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js +2 -0
  256. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js.map +7 -0
  257. package/lib/esm/src/trusted-name/di/trustedNameTypes.js +2 -0
  258. package/lib/esm/src/trusted-name/di/trustedNameTypes.js.map +7 -0
  259. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js +2 -0
  260. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js.map +7 -0
  261. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js +2 -0
  262. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +7 -0
  263. package/lib/esm/src/typed-data/data/FiltersDto.js +1 -0
  264. package/lib/esm/src/typed-data/data/FiltersDto.js.map +7 -0
  265. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js +2 -0
  266. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js.map +7 -0
  267. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js +2 -0
  268. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js.map +7 -0
  269. package/lib/esm/src/typed-data/data/TypedDataDataSource.js +1 -0
  270. package/lib/esm/src/typed-data/data/TypedDataDataSource.js.map +7 -0
  271. package/lib/esm/src/typed-data/di/typedDataModuleFactory.js +2 -0
  272. package/lib/esm/src/typed-data/di/typedDataModuleFactory.js.map +7 -0
  273. package/lib/esm/src/typed-data/di/typedDataTypes.js +2 -0
  274. package/lib/esm/src/typed-data/di/typedDataTypes.js.map +7 -0
  275. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js +2 -0
  276. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +7 -0
  277. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +2 -0
  278. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +7 -0
  279. package/lib/esm/src/typed-data/domain/TypedDataContextLoader.js +1 -0
  280. package/lib/esm/src/typed-data/domain/TypedDataContextLoader.js.map +7 -0
  281. package/lib/types/index.d.ts +3 -0
  282. package/lib/types/index.d.ts.map +1 -0
  283. package/lib/types/src/ContextModule.d.ts +10 -0
  284. package/lib/types/src/ContextModule.d.ts.map +1 -0
  285. package/lib/types/src/ContextModuleBuilder.d.ts +43 -0
  286. package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -0
  287. package/lib/types/src/ContextModuleBuilder.test.d.ts.map +1 -0
  288. package/lib/types/src/DefaultContextModule.d.ts +18 -0
  289. package/lib/types/src/DefaultContextModule.d.ts.map +1 -0
  290. package/lib/types/src/DefaultContextModule.test.d.ts.map +1 -0
  291. package/lib/types/src/config/di/configModuleFactory.d.ts +4 -0
  292. package/lib/types/src/config/di/configModuleFactory.d.ts.map +1 -0
  293. package/lib/types/src/config/di/configTypes.d.ts +4 -0
  294. package/lib/types/src/config/di/configTypes.d.ts.map +1 -0
  295. package/lib/types/src/config/model/ContextModuleConfig.d.ts +16 -0
  296. package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -0
  297. package/lib/types/src/di.d.ts +8 -0
  298. package/lib/types/src/di.d.ts.map +1 -0
  299. package/lib/types/src/external-plugin/data/DAppDto.d.ts.map +1 -0
  300. package/lib/types/src/external-plugin/data/ExternalPluginDataSource.d.ts +12 -0
  301. package/lib/types/src/external-plugin/data/ExternalPluginDataSource.d.ts.map +1 -0
  302. package/lib/types/src/external-plugin/data/HttpExternalPluginDataSource.d.ts +10 -0
  303. package/lib/types/src/external-plugin/data/HttpExternalPluginDataSource.d.ts.map +1 -0
  304. package/lib/types/src/external-plugin/data/HttpExternalPluginDataSource.test.d.ts.map +1 -0
  305. package/lib/types/src/external-plugin/di/externalPluginModuleFactory.d.ts +3 -0
  306. package/lib/types/src/external-plugin/di/externalPluginModuleFactory.d.ts.map +1 -0
  307. package/lib/types/src/external-plugin/di/externalPluginTypes.d.ts +5 -0
  308. package/lib/types/src/external-plugin/di/externalPluginTypes.d.ts.map +1 -0
  309. package/lib/{external-plugin → types/src/external-plugin}/domain/ExternalPluginContextLoader.d.ts +4 -3
  310. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.d.ts.map +1 -0
  311. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.test.d.ts.map +1 -0
  312. package/lib/types/src/external-plugin/model/DappInfos.d.ts +6 -0
  313. package/lib/types/src/external-plugin/model/DappInfos.d.ts.map +1 -0
  314. package/lib/types/src/external-plugin/model/SelectorDetails.d.ts.map +1 -0
  315. package/lib/{index.d.ts → types/src/index.d.ts} +8 -3
  316. package/lib/types/src/index.d.ts.map +1 -0
  317. package/lib/types/src/nft/data/HttpNftDataSource.d.ts +7 -0
  318. package/lib/types/src/nft/data/HttpNftDataSource.d.ts.map +1 -0
  319. package/lib/types/src/nft/data/HttpNftDataSource.test.d.ts.map +1 -0
  320. package/lib/{nft → types/src/nft}/data/NftDataSource.d.ts +3 -2
  321. package/lib/types/src/nft/data/NftDataSource.d.ts.map +1 -0
  322. package/lib/types/src/nft/di/nftModuleFactory.d.ts +3 -0
  323. package/lib/types/src/nft/di/nftModuleFactory.d.ts.map +1 -0
  324. package/lib/types/src/nft/di/nftTypes.d.ts +5 -0
  325. package/lib/types/src/nft/di/nftTypes.d.ts.map +1 -0
  326. package/lib/{nft → types/src/nft}/domain/NftContextLoader.d.ts +3 -2
  327. package/lib/types/src/nft/domain/NftContextLoader.d.ts.map +1 -0
  328. package/lib/types/src/nft/domain/NftContextLoader.test.d.ts.map +1 -0
  329. package/lib/types/src/shared/domain/ContextLoader.d.ts +7 -0
  330. package/lib/types/src/shared/domain/ContextLoader.d.ts.map +1 -0
  331. package/lib/types/src/shared/model/ClearSignContext.d.ts +40 -0
  332. package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -0
  333. package/lib/types/src/shared/model/GenericPath.d.ts +105 -0
  334. package/lib/types/src/shared/model/GenericPath.d.ts.map +1 -0
  335. package/lib/types/src/shared/model/TransactionContext.d.ts +19 -0
  336. package/lib/types/src/shared/model/TransactionContext.d.ts.map +1 -0
  337. package/lib/types/src/shared/model/TransactionSubset.d.ts.map +1 -0
  338. package/lib/types/src/shared/model/TypedDataClearSignContext.d.ts +33 -0
  339. package/lib/types/src/shared/model/TypedDataClearSignContext.d.ts.map +1 -0
  340. package/lib/types/src/shared/model/TypedDataContext.d.ts +16 -0
  341. package/lib/types/src/shared/model/TypedDataContext.d.ts.map +1 -0
  342. package/lib/types/src/shared/utils/HexStringUtils.d.ts +4 -0
  343. package/lib/types/src/shared/utils/HexStringUtils.d.ts.map +1 -0
  344. package/lib/types/src/token/data/HttpTokenDataSource.d.ts +9 -0
  345. package/lib/types/src/token/data/HttpTokenDataSource.d.ts.map +1 -0
  346. package/lib/types/src/token/data/HttpTokenDataSource.test.d.ts.map +1 -0
  347. package/lib/types/src/token/data/TokenDataSource.d.ts +9 -0
  348. package/lib/types/src/token/data/TokenDataSource.d.ts.map +1 -0
  349. package/lib/types/src/token/data/TokenDto.d.ts +16 -0
  350. package/lib/types/src/token/data/TokenDto.d.ts.map +1 -0
  351. package/lib/types/src/token/di/tokenModuleFactory.d.ts +3 -0
  352. package/lib/types/src/token/di/tokenModuleFactory.d.ts.map +1 -0
  353. package/lib/types/src/token/di/tokenTypes.d.ts +5 -0
  354. package/lib/types/src/token/di/tokenTypes.d.ts.map +1 -0
  355. package/lib/{token → types/src/token}/domain/TokenContextLoader.d.ts +3 -2
  356. package/lib/types/src/token/domain/TokenContextLoader.d.ts.map +1 -0
  357. package/lib/types/src/token/domain/TokenContextLoader.test.d.ts.map +1 -0
  358. package/lib/types/src/transaction/data/CalldataDto.d.ts +117 -0
  359. package/lib/types/src/transaction/data/CalldataDto.d.ts.map +1 -0
  360. package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts +19 -0
  361. package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts.map +1 -0
  362. package/lib/types/src/transaction/data/HttpTransactionDataSource.test.d.ts +2 -0
  363. package/lib/types/src/transaction/data/HttpTransactionDataSource.test.d.ts.map +1 -0
  364. package/lib/types/src/transaction/data/TransactionDataSource.d.ts +12 -0
  365. package/lib/types/src/transaction/data/TransactionDataSource.d.ts.map +1 -0
  366. package/lib/types/src/transaction/di/transactionModuleFactory.d.ts +3 -0
  367. package/lib/types/src/transaction/di/transactionModuleFactory.d.ts.map +1 -0
  368. package/lib/types/src/transaction/di/transactionTypes.d.ts +5 -0
  369. package/lib/types/src/transaction/di/transactionTypes.d.ts.map +1 -0
  370. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts +10 -0
  371. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts.map +1 -0
  372. package/lib/types/src/transaction/domain/TransactionContextLoader.test.d.ts +2 -0
  373. package/lib/types/src/transaction/domain/TransactionContextLoader.test.d.ts.map +1 -0
  374. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts +11 -0
  375. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts.map +1 -0
  376. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.test.d.ts +2 -0
  377. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.test.d.ts.map +1 -0
  378. package/lib/types/src/trusted-name/data/TrustedNameDataSource.d.ts +16 -0
  379. package/lib/types/src/trusted-name/data/TrustedNameDataSource.d.ts.map +1 -0
  380. package/lib/types/src/trusted-name/data/TrustedNameDto.d.ts +15 -0
  381. package/lib/types/src/trusted-name/data/TrustedNameDto.d.ts.map +1 -0
  382. package/lib/types/src/trusted-name/di/trustedNameModuleFactory.d.ts +3 -0
  383. package/lib/types/src/trusted-name/di/trustedNameModuleFactory.d.ts.map +1 -0
  384. package/lib/types/src/trusted-name/di/trustedNameTypes.d.ts +5 -0
  385. package/lib/types/src/trusted-name/di/trustedNameTypes.d.ts.map +1 -0
  386. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts +12 -0
  387. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts.map +1 -0
  388. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.test.d.ts +2 -0
  389. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.test.d.ts.map +1 -0
  390. package/lib/types/src/typed-data/data/FiltersDto.d.ts +58 -0
  391. package/lib/types/src/typed-data/data/FiltersDto.d.ts.map +1 -0
  392. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts +14 -0
  393. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts.map +1 -0
  394. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts +3 -0
  395. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts.map +1 -0
  396. package/lib/types/src/typed-data/data/TypedDataDataSource.d.ts +17 -0
  397. package/lib/types/src/typed-data/data/TypedDataDataSource.d.ts.map +1 -0
  398. package/lib/types/src/typed-data/di/typedDataModuleFactory.d.ts +3 -0
  399. package/lib/types/src/typed-data/di/typedDataModuleFactory.d.ts.map +1 -0
  400. package/lib/types/src/typed-data/di/typedDataTypes.d.ts +5 -0
  401. package/lib/types/src/typed-data/di/typedDataTypes.d.ts.map +1 -0
  402. package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts +13 -0
  403. package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts.map +1 -0
  404. package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.test.d.ts +2 -0
  405. package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.test.d.ts.map +1 -0
  406. package/lib/types/src/typed-data/domain/TypedDataContextLoader.d.ts +6 -0
  407. package/lib/types/src/typed-data/domain/TypedDataContextLoader.d.ts.map +1 -0
  408. package/lib/types/tsconfig.prod.tsbuildinfo +1 -0
  409. package/package.json +44 -20
  410. package/LICENSE.txt +0 -21
  411. package/lib/ContextModule.d.ts +0 -6
  412. package/lib/ContextModule.d.ts.map +0 -1
  413. package/lib/ContextModule.js +0 -3
  414. package/lib/ContextModule.js.map +0 -1
  415. package/lib/ContextModuleBuilder.d.ts +0 -27
  416. package/lib/ContextModuleBuilder.d.ts.map +0 -1
  417. package/lib/ContextModuleBuilder.js +0 -54
  418. package/lib/ContextModuleBuilder.js.map +0 -1
  419. package/lib/ContextModuleBuilder.test.d.ts.map +0 -1
  420. package/lib/ContextModuleBuilder.test.js +0 -18
  421. package/lib/ContextModuleBuilder.test.js.map +0 -1
  422. package/lib/DefaultContextModule.d.ts +0 -14
  423. package/lib/DefaultContextModule.d.ts.map +0 -1
  424. package/lib/DefaultContextModule.js +0 -26
  425. package/lib/DefaultContextModule.js.map +0 -1
  426. package/lib/DefaultContextModule.test.d.ts.map +0 -1
  427. package/lib/DefaultContextModule.test.js +0 -55
  428. package/lib/DefaultContextModule.test.js.map +0 -1
  429. package/lib/external-plugin/__tests__/abi.json +0 -92
  430. package/lib/external-plugin/data/DAppDto.d.ts.map +0 -1
  431. package/lib/external-plugin/data/DAppDto.js +0 -3
  432. package/lib/external-plugin/data/DAppDto.js.map +0 -1
  433. package/lib/external-plugin/data/ExternalPluginDataSource.d.ts +0 -10
  434. package/lib/external-plugin/data/ExternalPluginDataSource.d.ts.map +0 -1
  435. package/lib/external-plugin/data/ExternalPluginDataSource.js +0 -3
  436. package/lib/external-plugin/data/ExternalPluginDataSource.js.map +0 -1
  437. package/lib/external-plugin/data/HttpExternalPluginDataSource.d.ts +0 -7
  438. package/lib/external-plugin/data/HttpExternalPluginDataSource.d.ts.map +0 -1
  439. package/lib/external-plugin/data/HttpExternalPluginDataSource.js +0 -55
  440. package/lib/external-plugin/data/HttpExternalPluginDataSource.js.map +0 -1
  441. package/lib/external-plugin/data/HttpExternalPluginDataSource.test.d.ts.map +0 -1
  442. package/lib/external-plugin/data/HttpExternalPluginDataSource.test.js +0 -268
  443. package/lib/external-plugin/data/HttpExternalPluginDataSource.test.js.map +0 -1
  444. package/lib/external-plugin/domain/ExternalPluginContextLoader.d.ts.map +0 -1
  445. package/lib/external-plugin/domain/ExternalPluginContextLoader.js +0 -96
  446. package/lib/external-plugin/domain/ExternalPluginContextLoader.js.map +0 -1
  447. package/lib/external-plugin/domain/ExternalPluginContextLoader.test.d.ts.map +0 -1
  448. package/lib/external-plugin/domain/ExternalPluginContextLoader.test.js +0 -344
  449. package/lib/external-plugin/domain/ExternalPluginContextLoader.test.js.map +0 -1
  450. package/lib/external-plugin/model/DappInfos.d.ts +0 -6
  451. package/lib/external-plugin/model/DappInfos.d.ts.map +0 -1
  452. package/lib/external-plugin/model/DappInfos.js +0 -3
  453. package/lib/external-plugin/model/DappInfos.js.map +0 -1
  454. package/lib/external-plugin/model/SelectorDetails.d.ts.map +0 -1
  455. package/lib/external-plugin/model/SelectorDetails.js +0 -3
  456. package/lib/external-plugin/model/SelectorDetails.js.map +0 -1
  457. package/lib/forward-domain/data/ForwardDomainDataSource.d.ts +0 -8
  458. package/lib/forward-domain/data/ForwardDomainDataSource.d.ts.map +0 -1
  459. package/lib/forward-domain/data/ForwardDomainDataSource.js +0 -3
  460. package/lib/forward-domain/data/ForwardDomainDataSource.js.map +0 -1
  461. package/lib/forward-domain/data/HttpForwardDomainDataSource.d.ts +0 -5
  462. package/lib/forward-domain/data/HttpForwardDomainDataSource.d.ts.map +0 -1
  463. package/lib/forward-domain/data/HttpForwardDomainDataSource.js +0 -36
  464. package/lib/forward-domain/data/HttpForwardDomainDataSource.js.map +0 -1
  465. package/lib/forward-domain/data/HttpForwardDomainDataSource.test.d.ts +0 -2
  466. package/lib/forward-domain/data/HttpForwardDomainDataSource.test.d.ts.map +0 -1
  467. package/lib/forward-domain/data/HttpForwardDomainDataSource.test.js +0 -53
  468. package/lib/forward-domain/data/HttpForwardDomainDataSource.test.js.map +0 -1
  469. package/lib/forward-domain/domain/ForwardDomainContextLoader.d.ts +0 -11
  470. package/lib/forward-domain/domain/ForwardDomainContextLoader.d.ts.map +0 -1
  471. package/lib/forward-domain/domain/ForwardDomainContextLoader.js +0 -54
  472. package/lib/forward-domain/domain/ForwardDomainContextLoader.js.map +0 -1
  473. package/lib/forward-domain/domain/ForwardDomainContextLoader.test.d.ts +0 -2
  474. package/lib/forward-domain/domain/ForwardDomainContextLoader.test.d.ts.map +0 -1
  475. package/lib/forward-domain/domain/ForwardDomainContextLoader.test.js +0 -83
  476. package/lib/forward-domain/domain/ForwardDomainContextLoader.test.js.map +0 -1
  477. package/lib/index.d.ts.map +0 -1
  478. package/lib/index.js +0 -27
  479. package/lib/index.js.map +0 -1
  480. package/lib/nft/data/HttpNftDataSource.d.ts +0 -6
  481. package/lib/nft/data/HttpNftDataSource.d.ts.map +0 -1
  482. package/lib/nft/data/HttpNftDataSource.js +0 -51
  483. package/lib/nft/data/HttpNftDataSource.js.map +0 -1
  484. package/lib/nft/data/HttpNftDataSource.test.d.ts.map +0 -1
  485. package/lib/nft/data/HttpNftDataSource.test.js +0 -62
  486. package/lib/nft/data/HttpNftDataSource.test.js.map +0 -1
  487. package/lib/nft/data/NftDataSource.d.ts.map +0 -1
  488. package/lib/nft/data/NftDataSource.js +0 -3
  489. package/lib/nft/data/NftDataSource.js.map +0 -1
  490. package/lib/nft/domain/NftContextLoader.d.ts.map +0 -1
  491. package/lib/nft/domain/NftContextLoader.js +0 -79
  492. package/lib/nft/domain/NftContextLoader.js.map +0 -1
  493. package/lib/nft/domain/NftContextLoader.test.d.ts.map +0 -1
  494. package/lib/nft/domain/NftContextLoader.test.js +0 -106
  495. package/lib/nft/domain/NftContextLoader.test.js.map +0 -1
  496. package/lib/shared/domain/ContextLoader.d.ts +0 -6
  497. package/lib/shared/domain/ContextLoader.d.ts.map +0 -1
  498. package/lib/shared/domain/ContextLoader.js +0 -3
  499. package/lib/shared/domain/ContextLoader.js.map +0 -1
  500. package/lib/shared/model/ClearSignContext.d.ts +0 -11
  501. package/lib/shared/model/ClearSignContext.d.ts.map +0 -1
  502. package/lib/shared/model/ClearSignContext.js +0 -3
  503. package/lib/shared/model/ClearSignContext.js.map +0 -1
  504. package/lib/shared/model/TransactionContext.d.ts +0 -6
  505. package/lib/shared/model/TransactionContext.d.ts.map +0 -1
  506. package/lib/shared/model/TransactionContext.js +0 -3
  507. package/lib/shared/model/TransactionContext.js.map +0 -1
  508. package/lib/shared/model/TransactionSubset.d.ts.map +0 -1
  509. package/lib/shared/model/TransactionSubset.js +0 -3
  510. package/lib/shared/model/TransactionSubset.js.map +0 -1
  511. package/lib/token/data/HttpTokenDataSource.d.ts +0 -5
  512. package/lib/token/data/HttpTokenDataSource.d.ts.map +0 -1
  513. package/lib/token/data/HttpTokenDataSource.js +0 -68
  514. package/lib/token/data/HttpTokenDataSource.js.map +0 -1
  515. package/lib/token/data/HttpTokenDataSource.test.d.ts.map +0 -1
  516. package/lib/token/data/HttpTokenDataSource.test.js +0 -87
  517. package/lib/token/data/HttpTokenDataSource.test.js.map +0 -1
  518. package/lib/token/data/TokenDataSource.d.ts +0 -8
  519. package/lib/token/data/TokenDataSource.d.ts.map +0 -1
  520. package/lib/token/data/TokenDataSource.js +0 -3
  521. package/lib/token/data/TokenDataSource.js.map +0 -1
  522. package/lib/token/data/TokenDto.d.ts +0 -6
  523. package/lib/token/data/TokenDto.d.ts.map +0 -1
  524. package/lib/token/data/TokenDto.js +0 -3
  525. package/lib/token/data/TokenDto.js.map +0 -1
  526. package/lib/token/domain/TokenContextLoader.d.ts.map +0 -1
  527. package/lib/token/domain/TokenContextLoader.js +0 -52
  528. package/lib/token/domain/TokenContextLoader.js.map +0 -1
  529. package/lib/token/domain/TokenContextLoader.test.d.ts.map +0 -1
  530. package/lib/token/domain/TokenContextLoader.test.js +0 -96
  531. package/lib/token/domain/TokenContextLoader.test.js.map +0 -1
  532. /package/lib/{ContextModuleBuilder.test.d.ts → types/src/ContextModuleBuilder.test.d.ts} +0 -0
  533. /package/lib/{DefaultContextModule.test.d.ts → types/src/DefaultContextModule.test.d.ts} +0 -0
  534. /package/lib/{external-plugin → types/src/external-plugin}/data/DAppDto.d.ts +0 -0
  535. /package/lib/{external-plugin → types/src/external-plugin}/data/HttpExternalPluginDataSource.test.d.ts +0 -0
  536. /package/lib/{external-plugin → types/src/external-plugin}/domain/ExternalPluginContextLoader.test.d.ts +0 -0
  537. /package/lib/{external-plugin → types/src/external-plugin}/model/SelectorDetails.d.ts +0 -0
  538. /package/lib/{nft → types/src/nft}/data/HttpNftDataSource.test.d.ts +0 -0
  539. /package/lib/{nft → types/src/nft}/domain/NftContextLoader.test.d.ts +0 -0
  540. /package/lib/{shared → types/src/shared}/model/TransactionSubset.d.ts +0 -0
  541. /package/lib/{token → types/src/token}/data/HttpTokenDataSource.test.d.ts +0 -0
  542. /package/lib/{token → types/src/token}/domain/TokenContextLoader.test.d.ts +0 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ var T=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var f=(s,e,t,r)=>{for(var o=r>1?void 0:r?g(e,t):e,n=s.length-1,p;n>=0;n--)(p=s[n])&&(o=(r?p(e,t,o):p(o))||o);return r&&o&&T(e,t,o),o},y=(s,e)=>(t,r)=>e(t,r,s);import E from"axios";import{inject as d,injectable as A}from"inversify";import{Left as l,Right as D}from"purify-ts";import{configTypes as V}from"../../config/di/configTypes";import{ClearSignContextType as a}from"../../shared/model/ClearSignContext";import b from"../../../package.json";let c=class{constructor(e){this.config=e}async getTransactionDescriptors({chainId:e,address:t,selector:r}){let o;try{o=(await E.request({method:"GET",url:`${this.config.cal.url}/dapps`,params:{output:"descriptors_calldata",chain_id:e,contracts:t,ref:`branch:${this.config.cal.branch}`},headers:{"X-Ledger-Client-Version":`context-module/${b.version}`}})).data?.[0]}catch(i){return l(new Error(`[ContextModule] HttpTransactionDataSource: Failed to fetch transaction informations: ${i}`))}if(!o)return l(new Error(`[ContextModule] HttpTransactionDataSource: No generic descriptor for contract ${t}`));t=t.toLowerCase(),r=`0x${r.slice(2).toLowerCase()}`;const n=o.descriptors_calldata?.[t]?.[r];if(!n)return l(new Error(`[ContextModule] HttpTransactionDataSource: Invalid response for contract ${t} and selector ${r}`));if(!this.isCalldataDescriptorV1(n,this.config.cal.mode))return l(new Error(`[ContextModule] HttpTransactionDataSource: Failed to decode transaction descriptor for contract ${t} and selector ${r}`));const p=n.transaction_info.descriptor.data,u=n.transaction_info.descriptor.signatures[this.config.cal.mode],C={type:a.TRANSACTION_INFO,payload:this.formatTransactionInfo(p,u)},m=n.enums.map(i=>({type:a.ENUM,payload:i.descriptor})),h=n.fields.map(i=>({type:a.TRANSACTION_FIELD_DESCRIPTION,payload:i.descriptor,reference:this.getReference(i.param)}));return D([C,...m,...h])}formatTransactionInfo(e,t){t.length%2!==0&&(t="0"+t);const r="81ff",o=(t.length/2).toString(16);return`${e}${r}${o}${t}`}getReference(e){if(e.type==="TOKEN_AMOUNT"&&e.token!==void 0)return{type:a.TOKEN,valuePath:this.toGenericPath(e.token.binary_path)};if(e.type==="NFT")return{type:a.NFT,valuePath:this.toGenericPath(e.collection.binary_path)};if(e.type==="TRUSTED_NAME")return{type:a.TRUSTED_NAME,valuePath:this.toGenericPath(e.value.binary_path),types:e.types,sources:e.sources}}toGenericPath(e){return e.type==="CONTAINER"?e.value:e.elements.map(t=>{if(t.type==="ARRAY"){const{weight:r,...o}=t;return{itemSize:r,...o}}else if(t.type==="LEAF"){const{leaf_type:r,...o}=t;return{leafType:r,...o}}return t})}isCalldataDescriptorV1(e,t){return typeof e=="object"&&e.type==="calldata"&&e.version==="v1"&&this.isTransactionInfoV1(e.transaction_info,t)&&Array.isArray(e.enums)&&Array.isArray(e.fields)&&e.enums.every(r=>this.isEnumV1(r))&&e.fields.every(r=>this.isFieldV1(r))}isTransactionInfoV1(e,t){return typeof e=="object"&&typeof e.descriptor=="object"&&typeof e.descriptor.data=="string"&&typeof e.descriptor.signatures=="object"&&typeof e.descriptor.signatures[t]=="string"}isEnumV1(e){return typeof e=="object"&&typeof e.descriptor=="string"}isFieldV1(e){return typeof e=="object"&&typeof e.descriptor=="string"&&typeof e.param=="object"&&typeof e.param.value=="object"&&this.isDescriptorValueV1(e.param.value)&&(e.param.type==="RAW"||e.param.type==="AMOUNT"||e.param.type==="DATETIME"||e.param.type==="DURATION"||e.param.type==="UNIT"||e.param.type==="ENUM"||e.param.type==="NFT"&&this.isDescriptorValueV1(e.param.collection)||e.param.type==="TOKEN_AMOUNT"&&(e.param.token===void 0||this.isDescriptorValueV1(e.param.token))||e.param.type==="TRUSTED_NAME"&&Array.isArray(e.param.types)&&Array.isArray(e.param.sources)&&e.param.types.every(t=>typeof t=="string")&&e.param.sources.every(t=>typeof t=="string"))}isDescriptorValueV1(e){return typeof e=="object"&&typeof e.type_family=="string"&&["UINT","INT","UFIXED","FIXED","ADDRESS","BOOL","BYTES","STRING"].includes(e.type_family)&&(typeof e.type_size>"u"||typeof e.type_size=="number")&&(typeof e.binary_path=="object"&&e.binary_path.type==="CONTAINER"&&["FROM","TO","VALUE"].includes(e.binary_path.value)||e.binary_path.type==="DATA"&&Array.isArray(e.binary_path.elements)&&e.binary_path.elements.every(t=>this.isPathElementV1(t)))}isPathElementV1(e){return typeof e=="object"&&(e.type==="REF"||e.type==="TUPLE"&&typeof e.offset=="number"||e.type==="ARRAY"&&typeof e.weight=="number"&&(typeof e.start>"u"||typeof e.start=="number")&&(typeof e.length>"u"||typeof e.length=="number")||e.type==="LEAF"&&typeof e.leaf_type=="string"&&["ARRAY_LEAF","TUPLE_LEAF","STATIC_LEAF","DYNAMIC_LEAF"].includes(e.leaf_type)||e.type==="SLICE"&&(typeof e.start>"u"||typeof e.start=="number")&&(typeof e.end>"u"||typeof e.end=="number"))}};c=f([A(),y(0,d(V.Config))],c);export{c as HttpTransactionDataSource};
2
+ //# sourceMappingURL=HttpTransactionDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/transaction/data/HttpTransactionDataSource.ts"],
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport type {\n ContextModuleCalMode,\n ContextModuleConfig,\n} from \"@/config/model/ContextModuleConfig\";\nimport {\n ClearSignContextReference,\n ClearSignContextSuccess,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { GenericPath } from \"@/shared/model/GenericPath\";\nimport PACKAGE from \"@root/package.json\";\n\nimport {\n CalldataDescriptor,\n CalldataDescriptorContainerPathV1,\n CalldataDescriptorParam,\n CalldataDescriptorPathElementsV1,\n CalldataDescriptorPathElementV1,\n CalldataDescriptorV1,\n CalldataDescriptorValueV1,\n CalldataDto,\n CalldataEnumV1,\n CalldataFieldV1,\n CalldataTransactionInfoV1,\n} from \"./CalldataDto\";\nimport {\n GetTransactionDescriptorsParams,\n TransactionDataSource,\n} from \"./TransactionDataSource\";\n\n@injectable()\nexport class HttpTransactionDataSource implements TransactionDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n public async getTransactionDescriptors({\n chainId,\n address,\n selector,\n }: GetTransactionDescriptorsParams): Promise<\n Either<Error, ClearSignContextSuccess[]>\n > {\n let calldata: CalldataDto | undefined;\n try {\n const response = await axios.request<CalldataDto[]>({\n method: \"GET\",\n url: `${this.config.cal.url}/dapps`,\n params: {\n output: \"descriptors_calldata\",\n chain_id: chainId,\n contracts: address,\n ref: `branch:${this.config.cal.branch}`,\n },\n headers: {\n \"X-Ledger-Client-Version\": `context-module/${PACKAGE.version}`,\n },\n });\n calldata = response.data?.[0];\n } catch (error) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Failed to fetch transaction informations: ${error}`,\n ),\n );\n }\n\n if (!calldata) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: No generic descriptor for contract ${address}`,\n ),\n );\n }\n\n // Normalize the address and selector\n address = address.toLowerCase();\n selector = `0x${selector.slice(2).toLowerCase()}`;\n\n const calldataDescriptor =\n calldata.descriptors_calldata?.[address]?.[selector];\n if (!calldataDescriptor) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Invalid response for contract ${address} and selector ${selector}`,\n ),\n );\n }\n\n if (\n !this.isCalldataDescriptorV1(calldataDescriptor, this.config.cal.mode)\n ) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Failed to decode transaction descriptor for contract ${address} and selector ${selector}`,\n ),\n );\n }\n\n const infoData = calldataDescriptor.transaction_info.descriptor.data;\n const infoSignature =\n calldataDescriptor.transaction_info.descriptor.signatures[\n this.config.cal.mode\n ];\n const info: ClearSignContextSuccess = {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: this.formatTransactionInfo(infoData, infoSignature),\n };\n const enums: ClearSignContextSuccess[] = calldataDescriptor.enums.map(\n (e) => ({\n type: ClearSignContextType.ENUM,\n payload: e.descriptor,\n }),\n );\n const fields: ClearSignContextSuccess[] = calldataDescriptor.fields.map(\n (field) => ({\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: field.descriptor,\n reference: this.getReference(field.param),\n }),\n );\n return Right([info, ...enums, ...fields]);\n }\n\n private formatTransactionInfo(\n infoData: string,\n infoSignature: string,\n ): string {\n // Ensure correct padding\n if (infoSignature.length % 2 !== 0) {\n infoSignature = \"0\" + infoSignature;\n }\n // TLV encoding as according to generic parser documentation\n const infoSignatureTag = \"81ff\";\n const infoSignatureLength = (infoSignature.length / 2).toString(16);\n return `${infoData}${infoSignatureTag}${infoSignatureLength}${infoSignature}`;\n }\n\n private getReference(\n param: CalldataDescriptorParam,\n ): ClearSignContextReference | undefined {\n if (param.type === \"TOKEN_AMOUNT\" && param.token !== undefined) {\n return {\n type: ClearSignContextType.TOKEN,\n valuePath: this.toGenericPath(param.token.binary_path),\n };\n } else if (param.type === \"NFT\") {\n return {\n type: ClearSignContextType.NFT,\n valuePath: this.toGenericPath(param.collection.binary_path),\n };\n } else if (param.type === \"TRUSTED_NAME\") {\n return {\n type: ClearSignContextType.TRUSTED_NAME,\n valuePath: this.toGenericPath(param.value.binary_path),\n types: param.types,\n sources: param.sources,\n };\n }\n return undefined;\n }\n\n private toGenericPath(\n path: CalldataDescriptorContainerPathV1 | CalldataDescriptorPathElementsV1,\n ): GenericPath {\n if (path.type === \"CONTAINER\") {\n return path.value;\n }\n return path.elements.map((element) => {\n if (element.type === \"ARRAY\") {\n const { weight: itemSize, ...rest } = element;\n return {\n itemSize,\n ...rest,\n };\n } else if (element.type === \"LEAF\") {\n const { leaf_type: leafType, ...rest } = element;\n return {\n leafType,\n ...rest,\n };\n }\n return element;\n });\n }\n\n private isCalldataDescriptorV1(\n data: CalldataDescriptor,\n mode: ContextModuleCalMode,\n ): data is CalldataDescriptorV1 & {\n transaction_info: {\n descriptor: {\n signatures: { [key in ContextModuleCalMode]: string };\n };\n };\n } {\n return (\n typeof data === \"object\" &&\n data.type === \"calldata\" &&\n data.version === \"v1\" &&\n this.isTransactionInfoV1(data.transaction_info, mode) &&\n Array.isArray(data.enums) &&\n Array.isArray(data.fields) &&\n data.enums.every((e) => this.isEnumV1(e)) &&\n data.fields.every((f) => this.isFieldV1(f))\n );\n }\n\n private isTransactionInfoV1(\n data: CalldataTransactionInfoV1,\n mode: ContextModuleCalMode,\n ): data is CalldataTransactionInfoV1 & {\n descriptor: {\n signatures: { [key in ContextModuleCalMode]: string };\n };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.descriptor === \"object\" &&\n typeof data.descriptor.data === \"string\" &&\n typeof data.descriptor.signatures === \"object\" &&\n typeof data.descriptor.signatures[mode] === \"string\"\n );\n }\n\n private isEnumV1(data: CalldataEnumV1): boolean {\n return typeof data === \"object\" && typeof data.descriptor === \"string\";\n }\n\n private isFieldV1(data: CalldataFieldV1): boolean {\n return (\n typeof data === \"object\" &&\n typeof data.descriptor === \"string\" &&\n typeof data.param === \"object\" &&\n typeof data.param.value === \"object\" &&\n this.isDescriptorValueV1(data.param.value) &&\n (data.param.type === \"RAW\" ||\n data.param.type === \"AMOUNT\" ||\n data.param.type === \"DATETIME\" ||\n data.param.type === \"DURATION\" ||\n data.param.type === \"UNIT\" ||\n data.param.type === \"ENUM\" ||\n (data.param.type === \"NFT\" &&\n this.isDescriptorValueV1(data.param.collection)) ||\n (data.param.type === \"TOKEN_AMOUNT\" &&\n (data.param.token === undefined ||\n this.isDescriptorValueV1(data.param.token))) ||\n (data.param.type === \"TRUSTED_NAME\" &&\n Array.isArray(data.param.types) &&\n Array.isArray(data.param.sources) &&\n data.param.types.every((t) => typeof t === \"string\") &&\n data.param.sources.every((t) => typeof t === \"string\")))\n );\n }\n\n private isDescriptorValueV1(data: CalldataDescriptorValueV1): boolean {\n return (\n typeof data === \"object\" &&\n typeof data.type_family === \"string\" &&\n [\n \"UINT\",\n \"INT\",\n \"UFIXED\",\n \"FIXED\",\n \"ADDRESS\",\n \"BOOL\",\n \"BYTES\",\n \"STRING\",\n ].includes(data.type_family) &&\n (typeof data.type_size === \"undefined\" ||\n typeof data.type_size === \"number\") &&\n ((typeof data.binary_path === \"object\" &&\n data.binary_path.type === \"CONTAINER\" &&\n [\"FROM\", \"TO\", \"VALUE\"].includes(data.binary_path.value)) ||\n (data.binary_path.type === \"DATA\" &&\n Array.isArray(data.binary_path.elements) &&\n data.binary_path.elements.every((e) => this.isPathElementV1(e))))\n );\n }\n\n private isPathElementV1(data: CalldataDescriptorPathElementV1): boolean {\n return (\n typeof data === \"object\" &&\n (data.type === \"REF\" ||\n (data.type === \"TUPLE\" && typeof data.offset === \"number\") ||\n (data.type === \"ARRAY\" &&\n typeof data.weight === \"number\" &&\n (typeof data.start === \"undefined\" ||\n typeof data.start === \"number\") &&\n (typeof data.length === \"undefined\" ||\n typeof data.length === \"number\")) ||\n (data.type === \"LEAF\" &&\n typeof data.leaf_type === \"string\" &&\n [\"ARRAY_LEAF\", \"TUPLE_LEAF\", \"STATIC_LEAF\", \"DYNAMIC_LEAF\"].includes(\n data.leaf_type,\n )) ||\n (data.type === \"SLICE\" &&\n (typeof data.start === \"undefined\" ||\n typeof data.start === \"number\") &&\n (typeof data.end === \"undefined\" || typeof data.end === \"number\")))\n );\n }\n}\n"],
5
+ "mappings": "iOAAA,OAAOA,MAAW,QAClB,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAK5B,OAGE,wBAAAC,MACK,kCAEP,OAAOC,MAAa,qBAqBb,IAAMC,EAAN,KAAiE,CACtE,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CACH,MAAa,0BAA0B,CACrC,QAAAC,EACA,QAAAC,EACA,SAAAC,CACF,EAEE,CACA,IAAIC,EACJ,GAAI,CAcFA,GAbiB,MAAMC,EAAM,QAAuB,CAClD,OAAQ,MACR,IAAK,GAAG,KAAK,OAAO,IAAI,GAAG,SAC3B,OAAQ,CACN,OAAQ,uBACR,SAAUJ,EACV,UAAWC,EACX,IAAK,UAAU,KAAK,OAAO,IAAI,MAAM,EACvC,EACA,QAAS,CACP,0BAA2B,kBAAkBI,EAAQ,OAAO,EAC9D,CACF,CAAC,GACmB,OAAO,CAAC,CAC9B,OAASC,EAAO,CACd,OAAOC,EACL,IAAI,MACF,wFAAwFD,CAAK,EAC/F,CACF,CACF,CAEA,GAAI,CAACH,EACH,OAAOI,EACL,IAAI,MACF,iFAAiFN,CAAO,EAC1F,CACF,EAIFA,EAAUA,EAAQ,YAAY,EAC9BC,EAAW,KAAKA,EAAS,MAAM,CAAC,EAAE,YAAY,CAAC,GAE/C,MAAMM,EACJL,EAAS,uBAAuBF,CAAO,IAAIC,CAAQ,EACrD,GAAI,CAACM,EACH,OAAOD,EACL,IAAI,MACF,4EAA4EN,CAAO,iBAAiBC,CAAQ,EAC9G,CACF,EAGF,GACE,CAAC,KAAK,uBAAuBM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,EAAK,OAAS,UACZ,OAAOA,EAAK,MAAU,KACrB,OAAOA,EAAK,OAAU,YACvB,OAAOA,EAAK,IAAQ,KAAe,OAAOA,EAAK,KAAQ,UAEhE,CACF,EA9Qa5B,EAAN+B,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,IAFjBnC",
6
+ "names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "ClearSignContextType", "PACKAGE", "HttpTransactionDataSource", "config", "chainId", "address", "selector", "calldata", "axios", "PACKAGE", "error", "Left", "calldataDescriptor", "infoData", "infoSignature", "info", "ClearSignContextType", "enums", "e", "fields", "field", "Right", "infoSignatureTag", "infoSignatureLength", "param", "path", "element", "itemSize", "rest", "leafType", "data", "mode", "f", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import d from"axios";import{Left as o}from"purify-ts";import{HttpTransactionDataSource as T}from"../../transaction/data/HttpTransactionDataSource";import D from"../../../package.json";jest.mock("axios");describe("HttpTransactionDataSource",()=>{let t,c,l,s,f,p,b,u,y,x;beforeAll(()=>{jest.clearAllMocks();const a={cal:{url:"https://crypto-assets-service.api.ledger.com/v1",mode:"test",branch:"main"}};t=new T(a),c={descriptor:{data:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c",signatures:{test:"3045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f"}}},l=[{descriptor:"0001000401000501010606737461626c65"},{descriptor:"00010004010005010206087661726961626c65"}],b=i("FROM","UFIXED","AMOUNT","06"),u=i("TO","FIXED","DATETIME","07"),y=i("TO","BOOL","UNIT","08"),x=i("VALUE","INT","DURATION","09"),s={param:{value:{binary_path:{type:"DATA",elements:[{type:"TUPLE",offset:0},{type:"LEAF",leaf_type:"STATIC_LEAF"}]},type_family:"UINT",type_size:32},type:"TOKEN_AMOUNT",token:{binary_path:{type:"DATA",elements:[{type:"ARRAY",start:0,length:5,weight:1},{type:"LEAF",leaf_type:"DYNAMIC_LEAF"}]},type_family:"ADDRESS",type_size:20}},descriptor:"0001000112416d6f756e7420746f20776974686472617702010203580001000115000100010101020120030a000100010200010401030215000100010105020114030a000100010200000401030420ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff05034d6178"},f={param:{value:{binary_path:{type:"CONTAINER",value:"TO"},type_family:"STRING",type_size:20},type:"TRUSTED_NAME",types:["eoa"],sources:["ens","unstoppable_domain"]},descriptor:"000100010c546f20726563697069656e7402010803230001000115000100010105020114030a00010001020002040103020101030402030402"},p={param:{value:{binary_path:{type:"DATA",elements:[{type:"ARRAY",weight:2},{type:"LEAF",leaf_type:"TUPLE_LEAF"},{type:"SLICE",end:2}]},type_family:"BYTES",type_size:20},collection:{binary_path:{type:"DATA",elements:[{type:"REF"},{type:"LEAF",leaf_type:"ARRAY_LEAF"},{type:"SLICE",start:1}]},type_family:"INT",type_size:20},type:"NFT"},descriptor:"000100010c546f20726563697069656e7402010803230001000115000100010105020114"}});function i(a,e,r,m){return{param:{value:{binary_path:{type:"CONTAINER",value:a},type_family:e,type_size:32},type:r},descriptor:m}}function n(a,e,r){return{descriptors_calldata:{"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9":{"0x69328dec":{type:"calldata",version:"v1",transaction_info:a,enums:e,fields:r}}}}}it("should call axios with the ledger client version header",async()=>{const a=`context-module/${D.version}`,e=jest.fn(()=>Promise.resolve({data:[]}));jest.spyOn(d,"request").mockImplementation(e),await t.getTransactionDescriptors({chainId:1,address:"0x0abc",selector:"0x01ff"}),expect(e).toHaveBeenCalledWith(expect.objectContaining({headers:{"X-Ledger-Client-Version":a}}))}),it("should return an error when axios throws an error",async()=>{jest.spyOn(d,"request").mockRejectedValue(new Error);const a=await t.getTransactionDescriptors({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(a).toEqual(o(new Error("[ContextModule] HttpTransactionDataSource: Failed to fetch transaction informations: Error")))}),it("should return an error when no payload is returned",async()=>{const a={data:{test:""}};jest.spyOn(d,"request").mockResolvedValue(a);const e=await t.getTransactionDescriptors({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e).toEqual(o(new Error("[ContextModule] HttpTransactionDataSource: No generic descriptor for contract 0x0abc")))}),it("should return an error when selector is not found",async()=>{const a=n(c,l,[s]);jest.spyOn(d,"request").mockResolvedValue({data:[a]});const e=await t.getTransactionDescriptors({chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x01fe"});expect(e).toEqual(o(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x01fe")))}),it("Calldata with fields references and enums",async()=>{const a=n(c,l,[s,f,p]);jest.spyOn(d,"request").mockResolvedValue({data:[a]});const e=await t.getTransactionDescriptors({chainId:1,address:"0x7d2768de32b0b80B7a3454c06bdac94a69ddc7a9",selector:"0x69328dEc"});expect(e.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{payload:"0001000401000501010606737461626c65",type:"enum"},{payload:"00010004010005010206087661726961626c65",type:"enum"},{payload:s.descriptor,type:"transactionFieldDescription",reference:{type:"token",valuePath:[{type:"ARRAY",start:0,length:5,itemSize:1},{type:"LEAF",leafType:"DYNAMIC_LEAF"}]}},{payload:f.descriptor,type:"transactionFieldDescription",reference:{type:"trustedName",valuePath:"TO",types:["eoa"],sources:["ens","unstoppable_domain"]}},{payload:p.descriptor,type:"transactionFieldDescription",reference:{type:"nft",valuePath:[{type:"REF"},{type:"LEAF",leafType:"ARRAY_LEAF"},{type:"SLICE",start:1}]}}])}),it("Calldata without fields references",async()=>{const a=n(c,[],[b,u,y,x]);jest.spyOn(d,"request").mockResolvedValue({data:[a]});const e=await t.getTransactionDescriptors({chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e.extract()).toEqual([{payload:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f",type:"transactionInfo"},{type:"transactionFieldDescription",payload:b.descriptor},{type:"transactionFieldDescription",payload:u.descriptor},{type:"transactionFieldDescription",payload:y.descriptor},{type:"transactionFieldDescription",payload:x.descriptor}])}),it("should return an error when calldata is not correctly formatted",async()=>{const a={descriptors_calldata:{"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9":{"0x69328dec":{type:"calldat",version:"v1",transaction_info:c,enums:l,fields:[s]}}}};jest.spyOn(d,"request").mockResolvedValue({data:[a]});const e=await t.getTransactionDescriptors({chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e).toEqual(o(new Error("[ContextModule] HttpTransactionDataSource: Failed to decode transaction descriptor for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when transactionInfo is not correctly formatted",async()=>{const a=n({descriptor:{data:"1234",signatures:{prod:"1234"}}},l,[s]);jest.spyOn(d,"request").mockResolvedValue({data:[a]});const e=await t.getTransactionDescriptors({chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e).toEqual(o(new Error("[ContextModule] HttpTransactionDataSource: Failed to decode transaction descriptor for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when enum is not correctly formatted",async()=>{const a=n(c,["badEnum"],[s]);jest.spyOn(d,"request").mockResolvedValue({data:[a]});const e=await t.getTransactionDescriptors({chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e).toEqual(o(new Error("[ContextModule] HttpTransactionDataSource: Failed to decode transaction descriptor for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when field is not correctly formatted",async()=>{const a=n(c,[],[{descriptor:3}]);jest.spyOn(d,"request").mockResolvedValue({data:[a]});const e=await t.getTransactionDescriptors({chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e).toEqual(o(new Error("[ContextModule] HttpTransactionDataSource: Failed to decode transaction descriptor for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when field value is not correctly formatted",async()=>{const e=n(c,[],[{param:{value:{binary_path:"TO",type_family:"UNKNOWN",type_size:20},type:"DATETIME"},descriptor:"000100010c546f20726563697069667"}]);jest.spyOn(d,"request").mockResolvedValue({data:[e]});const r=await t.getTransactionDescriptors({chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(r).toEqual(o(new Error("[ContextModule] HttpTransactionDataSource: Failed to decode transaction descriptor for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when field container path is not correctly formatted",async()=>{const e=n(c,[],[{param:{value:{binary_path:"UNKNOWN",type_family:"ADDRESS",type_size:20},type:"DATETIME"},descriptor:"000100010c546f20726563697069667"}]);jest.spyOn(d,"request").mockResolvedValue({data:[e]});const r=await t.getTransactionDescriptors({chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(r).toEqual(o(new Error("[ContextModule] HttpTransactionDataSource: Failed to decode transaction descriptor for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when field calldata path is not correctly formatted",async()=>{const e=n(c,[],[{param:{value:{binary_path:{elements:[{type:"UNKNOWN"}]},type_family:"ADDRESS",type_size:20},type:"DATETIME"},descriptor:"000100010c546f20726563697069667"}]);jest.spyOn(d,"request").mockResolvedValue({data:[e]});const r=await t.getTransactionDescriptors({chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(r).toEqual(o(new Error("[ContextModule] HttpTransactionDataSource: Failed to decode transaction descriptor for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))}),it("should return an error when field type is not correctly formatted",async()=>{const e=n(c,[],[{param:{value:{binary_path:"TO",type_family:"ADDRESS",type_size:20},type:"UNKNOWN"},descriptor:"000100010c546f20726563697069667"}]);jest.spyOn(d,"request").mockResolvedValue({data:[e]});const r=await t.getTransactionDescriptors({chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(r).toEqual(o(new Error("[ContextModule] HttpTransactionDataSource: Failed to decode transaction descriptor for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec")))})});
2
+ //# sourceMappingURL=HttpTransactionDataSource.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/transaction/data/HttpTransactionDataSource.test.ts"],
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { Left } from \"purify-ts\";\n\nimport type { ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport type {\n CalldataEnumV1,\n CalldataFieldV1,\n CalldataTransactionInfoV1,\n} from \"@/transaction/data/CalldataDto\";\nimport { HttpTransactionDataSource } from \"@/transaction/data/HttpTransactionDataSource\";\nimport type { TransactionDataSource } from \"@/transaction/data/TransactionDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\njest.mock(\"axios\");\n\ndescribe(\"HttpTransactionDataSource\", () => {\n let datasource: TransactionDataSource;\n let transactionInfo: CalldataTransactionInfoV1;\n let enums: CalldataEnumV1[];\n let fieldToken: CalldataFieldV1;\n let fieldTrustedName: CalldataFieldV1;\n let fieldNft: CalldataFieldV1;\n let fieldAmount: CalldataFieldV1;\n let fieldDatetime: CalldataFieldV1;\n let fieldUnit: CalldataFieldV1;\n let fieldDuration: CalldataFieldV1;\n\n beforeAll(() => {\n jest.clearAllMocks();\n const config = {\n cal: {\n url: \"https://crypto-assets-service.api.ledger.com/v1\",\n mode: \"test\",\n branch: \"main\",\n },\n } as ContextModuleConfig;\n datasource = new HttpTransactionDataSource(config);\n\n transactionInfo = {\n descriptor: {\n data: \"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c\",\n signatures: {\n test: \"3045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f\",\n },\n },\n };\n enums = [\n { descriptor: \"0001000401000501010606737461626c65\" },\n { descriptor: \"00010004010005010206087661726961626c65\" },\n ];\n fieldAmount = createFieldWithoutReference(\"FROM\", \"UFIXED\", \"AMOUNT\", \"06\");\n fieldDatetime = createFieldWithoutReference(\n \"TO\",\n \"FIXED\",\n \"DATETIME\",\n \"07\",\n );\n fieldUnit = createFieldWithoutReference(\"TO\", \"BOOL\", \"UNIT\", \"08\");\n fieldDuration = createFieldWithoutReference(\n \"VALUE\",\n \"INT\",\n \"DURATION\",\n \"09\",\n );\n fieldToken = {\n param: {\n value: {\n binary_path: {\n type: \"DATA\",\n elements: [\n {\n type: \"TUPLE\",\n offset: 0,\n },\n {\n type: \"LEAF\",\n leaf_type: \"STATIC_LEAF\",\n },\n ],\n },\n type_family: \"UINT\",\n type_size: 32,\n },\n type: \"TOKEN_AMOUNT\",\n token: {\n binary_path: {\n type: \"DATA\",\n elements: [\n {\n type: \"ARRAY\",\n start: 0,\n length: 5,\n weight: 1,\n },\n {\n type: \"LEAF\",\n leaf_type: \"DYNAMIC_LEAF\",\n },\n ],\n },\n type_family: \"ADDRESS\",\n type_size: 20,\n },\n },\n descriptor:\n \"0001000112416d6f756e7420746f20776974686472617702010203580001000115000100010101020120030a000100010200010401030215000100010105020114030a000100010200000401030420ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff05034d6178\",\n };\n fieldTrustedName = {\n param: {\n value: {\n binary_path: {\n type: \"CONTAINER\",\n value: \"TO\",\n },\n type_family: \"STRING\",\n type_size: 20,\n },\n type: \"TRUSTED_NAME\",\n types: [\"eoa\"],\n sources: [\"ens\", \"unstoppable_domain\"],\n },\n descriptor:\n \"000100010c546f20726563697069656e7402010803230001000115000100010105020114030a00010001020002040103020101030402030402\",\n };\n fieldNft = {\n param: {\n value: {\n binary_path: {\n type: \"DATA\",\n elements: [\n {\n type: \"ARRAY\",\n weight: 2,\n },\n {\n type: \"LEAF\",\n leaf_type: \"TUPLE_LEAF\",\n },\n {\n type: \"SLICE\",\n end: 2,\n },\n ],\n },\n type_family: \"BYTES\",\n type_size: 20,\n },\n collection: {\n binary_path: {\n type: \"DATA\",\n elements: [\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leaf_type: \"ARRAY_LEAF\",\n },\n {\n type: \"SLICE\",\n start: 1,\n },\n ],\n },\n type_family: \"INT\",\n type_size: 20,\n },\n type: \"NFT\",\n },\n descriptor:\n \"000100010c546f20726563697069656e7402010803230001000115000100010105020114\",\n };\n });\n\n function createFieldWithoutReference(\n binary_path: string,\n type_family: string,\n type: string,\n descriptor: string,\n ): CalldataFieldV1 {\n return {\n param: {\n value: {\n binary_path: {\n type: \"CONTAINER\",\n value: binary_path,\n },\n type_family,\n type_size: 32,\n },\n type,\n },\n descriptor,\n } as CalldataFieldV1;\n }\n\n function createCalldata(\n transactionInfo: unknown,\n enums: unknown[],\n fields: unknown[],\n ): unknown {\n return {\n descriptors_calldata: {\n \"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9\": {\n \"0x69328dec\": {\n type: \"calldata\",\n version: \"v1\",\n transaction_info: transactionInfo,\n enums: enums,\n fields: fields,\n },\n },\n },\n };\n }\n\n it(\"should call axios with the ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = jest.fn(() => Promise.resolve({ data: [] }));\n jest.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getTransactionDescriptors({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: { \"X-Ledger-Client-Version\": version },\n }),\n );\n });\n\n it(\"should return an error when axios throws an error\", async () => {\n // GIVEN\n jest.spyOn(axios, \"request\").mockRejectedValue(new Error());\n\n // WHEN\n const result = await datasource.getTransactionDescriptors({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTransactionDataSource: Failed to fetch transaction informations: Error\",\n ),\n ),\n );\n });\n\n it(\"should return an error when no payload is returned\", async () => {\n // GIVEN\n const response = { data: { test: \"\" } };\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTransactionDescriptors({\n chainId: 1,\n address: \"0x0abc\",\n selector: \"0x01ff\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTransactionDataSource: No generic descriptor for contract 0x0abc\",\n ),\n ),\n );\n });\n\n it(\"should return an error when selector is not found\", async () => {\n // GIVEN\n const calldataDTO = createCalldata(transactionInfo, enums, [fieldToken]);\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: [calldataDTO] });\n\n // WHEN\n const result = await datasource.getTransactionDescriptors({\n chainId: 1,\n address: \"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9\",\n selector: \"0x01fe\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x01fe\",\n ),\n ),\n );\n });\n\n it(\"Calldata with fields references and enums\", async () => {\n // GIVEN\n const calldataDTO = createCalldata(transactionInfo, enums, [\n fieldToken,\n fieldTrustedName,\n fieldNft,\n ]);\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: [calldataDTO] });\n\n // WHEN\n const result = await datasource.getTransactionDescriptors({\n chainId: 1,\n address: \"0x7d2768de32b0b80B7a3454c06bdac94a69ddc7a9\",\n selector: \"0x69328dEc\",\n });\n\n // THEN\n expect(result.extract()).toEqual([\n {\n payload:\n \"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f\",\n type: \"transactionInfo\",\n },\n {\n payload: \"0001000401000501010606737461626c65\",\n type: \"enum\",\n },\n {\n payload: \"00010004010005010206087661726961626c65\",\n type: \"enum\",\n },\n {\n payload: fieldToken.descriptor,\n type: \"transactionFieldDescription\",\n reference: {\n type: \"token\",\n valuePath: [\n {\n type: \"ARRAY\",\n start: 0,\n length: 5,\n itemSize: 1,\n },\n {\n type: \"LEAF\",\n leafType: \"DYNAMIC_LEAF\",\n },\n ],\n },\n },\n {\n payload: fieldTrustedName.descriptor,\n type: \"transactionFieldDescription\",\n reference: {\n type: \"trustedName\",\n valuePath: \"TO\",\n types: [\"eoa\"],\n sources: [\"ens\", \"unstoppable_domain\"],\n },\n },\n {\n payload: fieldNft.descriptor,\n type: \"transactionFieldDescription\",\n reference: {\n type: \"nft\",\n valuePath: [\n {\n type: \"REF\",\n },\n {\n type: \"LEAF\",\n leafType: \"ARRAY_LEAF\",\n },\n {\n type: \"SLICE\",\n start: 1,\n },\n ],\n },\n },\n ]);\n });\n\n it(\"Calldata without fields references\", async () => {\n // GIVEN\n const calldataDTO = createCalldata(\n transactionInfo,\n [],\n [fieldAmount, fieldDatetime, fieldUnit, fieldDuration],\n );\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: [calldataDTO] });\n\n // WHEN\n const result = await datasource.getTransactionDescriptors({\n chainId: 1,\n address: \"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9\",\n selector: \"0x69328dec\",\n });\n\n // THEN\n expect(result.extract()).toEqual([\n {\n payload:\n \"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c81ff473045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f\",\n type: \"transactionInfo\",\n },\n {\n type: \"transactionFieldDescription\",\n payload: fieldAmount.descriptor,\n },\n {\n type: \"transactionFieldDescription\",\n payload: fieldDatetime.descriptor,\n },\n {\n type: \"transactionFieldDescription\",\n payload: fieldUnit.descriptor,\n },\n {\n type: \"transactionFieldDescription\",\n payload: fieldDuration.descriptor,\n },\n ]);\n });\n\n it(\"should return an error when calldata is not correctly formatted\", async () => {\n // GIVEN\n const calldataDTO = {\n descriptors_calldata: {\n \"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9\": {\n \"0x69328dec\": {\n type: \"calldat\",\n version: \"v1\",\n transaction_info: transactionInfo,\n enums: enums,\n fields: [fieldToken],\n },\n },\n },\n };\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: [calldataDTO] });\n\n // WHEN\n const result = await datasource.getTransactionDescriptors({\n chainId: 1,\n address: \"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9\",\n selector: \"0x69328dec\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTransactionDataSource: Failed to decode transaction descriptor for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec\",\n ),\n ),\n );\n });\n\n it(\"should return an error when transactionInfo is not correctly formatted\", async () => {\n // GIVEN\n const calldataDTO = createCalldata(\n {\n descriptor: {\n data: \"1234\",\n signatures: {\n prod: \"1234\",\n },\n },\n },\n enums,\n [fieldToken],\n );\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: [calldataDTO] });\n\n // WHEN\n const result = await datasource.getTransactionDescriptors({\n chainId: 1,\n address: \"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9\",\n selector: \"0x69328dec\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTransactionDataSource: Failed to decode transaction descriptor for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec\",\n ),\n ),\n );\n });\n\n it(\"should return an error when enum is not correctly formatted\", async () => {\n // GIVEN\n const calldataDTO = createCalldata(\n transactionInfo,\n [\"badEnum\"],\n [fieldToken],\n );\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: [calldataDTO] });\n\n // WHEN\n const result = await datasource.getTransactionDescriptors({\n chainId: 1,\n address: \"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9\",\n selector: \"0x69328dec\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTransactionDataSource: Failed to decode transaction descriptor for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec\",\n ),\n ),\n );\n });\n\n it(\"should return an error when field is not correctly formatted\", async () => {\n // GIVEN\n const calldataDTO = createCalldata(\n transactionInfo,\n [],\n [{ descriptor: 3 }],\n );\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: [calldataDTO] });\n\n // WHEN\n const result = await datasource.getTransactionDescriptors({\n chainId: 1,\n address: \"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9\",\n selector: \"0x69328dec\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTransactionDataSource: Failed to decode transaction descriptor for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec\",\n ),\n ),\n );\n });\n\n it(\"should return an error when field value is not correctly formatted\", async () => {\n // GIVEN\n const field = {\n param: {\n value: {\n binary_path: \"TO\",\n type_family: \"UNKNOWN\",\n type_size: 20,\n },\n type: \"DATETIME\",\n },\n descriptor: \"000100010c546f20726563697069667\",\n };\n const calldataDTO = createCalldata(transactionInfo, [], [field]);\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: [calldataDTO] });\n\n // WHEN\n const result = await datasource.getTransactionDescriptors({\n chainId: 1,\n address: \"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9\",\n selector: \"0x69328dec\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTransactionDataSource: Failed to decode transaction descriptor for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec\",\n ),\n ),\n );\n });\n\n it(\"should return an error when field container path is not correctly formatted\", async () => {\n // GIVEN\n const field = {\n param: {\n value: {\n binary_path: \"UNKNOWN\",\n type_family: \"ADDRESS\",\n type_size: 20,\n },\n type: \"DATETIME\",\n },\n descriptor: \"000100010c546f20726563697069667\",\n };\n const calldataDTO = createCalldata(transactionInfo, [], [field]);\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: [calldataDTO] });\n\n // WHEN\n const result = await datasource.getTransactionDescriptors({\n chainId: 1,\n address: \"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9\",\n selector: \"0x69328dec\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTransactionDataSource: Failed to decode transaction descriptor for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec\",\n ),\n ),\n );\n });\n\n it(\"should return an error when field calldata path is not correctly formatted\", async () => {\n // GIVEN\n const field = {\n param: {\n value: {\n binary_path: {\n elements: [\n {\n type: \"UNKNOWN\",\n },\n ],\n },\n type_family: \"ADDRESS\",\n type_size: 20,\n },\n type: \"DATETIME\",\n },\n descriptor: \"000100010c546f20726563697069667\",\n };\n const calldataDTO = createCalldata(transactionInfo, [], [field]);\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: [calldataDTO] });\n\n // WHEN\n const result = await datasource.getTransactionDescriptors({\n chainId: 1,\n address: \"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9\",\n selector: \"0x69328dec\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTransactionDataSource: Failed to decode transaction descriptor for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec\",\n ),\n ),\n );\n });\n\n it(\"should return an error when field type is not correctly formatted\", async () => {\n // GIVEN\n const field = {\n param: {\n value: {\n binary_path: \"TO\",\n type_family: \"ADDRESS\",\n type_size: 20,\n },\n type: \"UNKNOWN\",\n },\n descriptor: \"000100010c546f20726563697069667\",\n };\n const calldataDTO = createCalldata(transactionInfo, [], [field]);\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: [calldataDTO] });\n\n // WHEN\n const result = await datasource.getTransactionDescriptors({\n chainId: 1,\n address: \"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9\",\n selector: \"0x69328dec\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTransactionDataSource: Failed to decode transaction descriptor for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x69328dec\",\n ),\n ),\n );\n });\n});\n"],
5
+ "mappings": "AAAA,OAAOA,MAAW,QAClB,OAAS,QAAAC,MAAY,YAQrB,OAAS,6BAAAC,MAAiC,+CAE1C,OAAOC,MAAa,qBAEpB,KAAK,KAAK,OAAO,EAEjB,SAAS,4BAA6B,IAAM,CAC1C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,UAAU,IAAM,CACd,KAAK,cAAc,EACnB,MAAMC,EAAS,CACb,IAAK,CACH,IAAK,kDACL,KAAM,OACN,OAAQ,MACV,CACF,EACAV,EAAa,IAAIF,EAA0BY,CAAM,EAEjDT,EAAkB,CAChB,WAAY,CACV,KAAM,6PACN,WAAY,CACV,KAAM,gJACR,CACF,CACF,EACAC,EAAQ,CACN,CAAE,WAAY,oCAAqC,EACnD,CAAE,WAAY,wCAAyC,CACzD,EACAI,EAAcK,EAA4B,OAAQ,SAAU,SAAU,IAAI,EAC1EJ,EAAgBI,EACd,KACA,QACA,WACA,IACF,EACAH,EAAYG,EAA4B,KAAM,OAAQ,OAAQ,IAAI,EAClEF,EAAgBE,EACd,QACA,MACA,WACA,IACF,EACAR,EAAa,CACX,MAAO,CACL,MAAO,CACL,YAAa,CACX,KAAM,OACN,SAAU,CACR,CACE,KAAM,QACN,OAAQ,CACV,EACA,CACE,KAAM,OACN,UAAW,aACb,CACF,CACF,EACA,YAAa,OACb,UAAW,EACb,EACA,KAAM,eACN,MAAO,CACL,YAAa,CACX,KAAM,OACN,SAAU,CACR,CACE,KAAM,QACN,MAAO,EACP,OAAQ,EACR,OAAQ,CACV,EACA,CACE,KAAM,OACN,UAAW,cACb,CACF,CACF,EACA,YAAa,UACb,UAAW,EACb,CACF,EACA,WACE,0OACJ,EACAC,EAAmB,CACjB,MAAO,CACL,MAAO,CACL,YAAa,CACX,KAAM,YACN,MAAO,IACT,EACA,YAAa,SACb,UAAW,EACb,EACA,KAAM,eACN,MAAO,CAAC,KAAK,EACb,QAAS,CAAC,MAAO,oBAAoB,CACvC,EACA,WACE,oHACJ,EACAC,EAAW,CACT,MAAO,CACL,MAAO,CACL,YAAa,CACX,KAAM,OACN,SAAU,CACR,CACE,KAAM,QACN,OAAQ,CACV,EACA,CACE,KAAM,OACN,UAAW,YACb,EACA,CACE,KAAM,QACN,IAAK,CACP,CACF,CACF,EACA,YAAa,QACb,UAAW,EACb,EACA,WAAY,CACV,YAAa,CACX,KAAM,OACN,SAAU,CACR,CACE,KAAM,KACR,EACA,CACE,KAAM,OACN,UAAW,YACb,EACA,CACE,KAAM,QACN,MAAO,CACT,CACF,CACF,EACA,YAAa,MACb,UAAW,EACb,EACA,KAAM,KACR,EACA,WACE,0EACJ,CACF,CAAC,EAED,SAASM,EACPC,EACAC,EACAC,EACAC,EACiB,CACjB,MAAO,CACL,MAAO,CACL,MAAO,CACL,YAAa,CACX,KAAM,YACN,MAAOH,CACT,EACA,YAAAC,EACA,UAAW,EACb,EACA,KAAAC,CACF,EACA,WAAAC,CACF,CACF,CAEA,SAASC,EACPf,EACAC,EACAe,EACS,CACT,MAAO,CACL,qBAAsB,CACpB,6CAA8C,CAC5C,aAAc,CACZ,KAAM,WACN,QAAS,KACT,iBAAkBhB,EAClB,MAAOC,EACP,OAAQe,CACV,CACF,CACF,CACF,CACF,CAEA,GAAG,0DAA2D,SAAY,CAExE,MAAMC,EAAU,kBAAkBnB,EAAQ,OAAO,GAC3CoB,EAAa,KAAK,GAAG,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EACT,QAAS,6CACT,SAAU,YACZ,CAAC,EAGD,OAAOoB,CAAM,EAAE,QACbvB,EACE,IAAI,MACF,oKACF,CACF,CACF,CACF,CAAC,EAED,GAAG,6EAA8E,SAAY,CAmB3F,MAAMyB,EAAcN,EAAef,EAAiB,CAAC,EAAG,CAjB1C,CACZ,MAAO,CACL,MAAO,CACL,YAAa,CACX,SAAU,CACR,CACE,KAAM,SACR,CACF,CACF,EACA,YAAa,UACb,UAAW,EACb,EACA,KAAM,UACR,EACA,WAAY,iCACd,CAC8D,CAAC,EAC/D,KAAK,MAAML,EAAO,SAAS,EAAE,kBAAkB,CAAE,KAAM,CAAC0B,CAAW,CAAE,CAAC,EAGtE,MAAMF,EAAS,MAAMpB,EAAW,0BAA0B,CACxD,QAAS,EACT,QAAS,6CACT,SAAU,YACZ,CAAC,EAGD,OAAOoB,CAAM,EAAE,QACbvB,EACE,IAAI,MACF,oKACF,CACF,CACF,CACF,CAAC,EAED,GAAG,oEAAqE,SAAY,CAalF,MAAMyB,EAAcN,EAAef,EAAiB,CAAC,EAAG,CAX1C,CACZ,MAAO,CACL,MAAO,CACL,YAAa,KACb,YAAa,UACb,UAAW,EACb,EACA,KAAM,SACR,EACA,WAAY,iCACd,CAC8D,CAAC,EAC/D,KAAK,MAAML,EAAO,SAAS,EAAE,kBAAkB,CAAE,KAAM,CAAC0B,CAAW,CAAE,CAAC,EAGtE,MAAMF,EAAS,MAAMpB,EAAW,0BAA0B,CACxD,QAAS,EACT,QAAS,6CACT,SAAU,YACZ,CAAC,EAGD,OAAOoB,CAAM,EAAE,QACbvB,EACE,IAAI,MACF,oKACF,CACF,CACF,CACF,CAAC,CACH,CAAC",
6
+ "names": ["axios", "Left", "HttpTransactionDataSource", "PACKAGE", "datasource", "transactionInfo", "enums", "fieldToken", "fieldTrustedName", "fieldNft", "fieldAmount", "fieldDatetime", "fieldUnit", "fieldDuration", "config", "createFieldWithoutReference", "binary_path", "type_family", "type", "descriptor", "createCalldata", "fields", "version", "requestSpy", "result", "response", "calldataDTO"]
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=TransactionDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ import{ContainerModule as r}from"inversify";import{HttpTransactionDataSource as n}from"../../transaction/data/HttpTransactionDataSource";import{transactionTypes as t}from"../../transaction/di/transactionTypes";import{TransactionContextLoader as a}from"../../transaction/domain/TransactionContextLoader";const u=()=>new r((o,e,i,c)=>{o(t.TransactionDataSource).to(n),o(t.TransactionContextLoader).to(a)});export{u as transactionModuleFactory};
2
+ //# sourceMappingURL=transactionModuleFactory.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/transaction/di/transactionModuleFactory.ts"],
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpTransactionDataSource } from \"@/transaction/data/HttpTransactionDataSource\";\nimport { transactionTypes } from \"@/transaction/di/transactionTypes\";\nimport { TransactionContextLoader } from \"@/transaction/domain/TransactionContextLoader\";\n\nexport const transactionModuleFactory = () =>\n new ContainerModule((bind, _unbind, _isBound, _rebind) => {\n bind(transactionTypes.TransactionDataSource).to(HttpTransactionDataSource);\n bind(transactionTypes.TransactionContextLoader).to(\n TransactionContextLoader,\n );\n });\n"],
5
+ "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,6BAAAC,MAAiC,+CAC1C,OAAS,oBAAAC,MAAwB,oCACjC,OAAS,4BAAAC,MAAgC,gDAElC,MAAMC,EAA2B,IACtC,IAAIJ,EAAgB,CAACK,EAAMC,EAASC,EAAUC,IAAY,CACxDH,EAAKH,EAAiB,qBAAqB,EAAE,GAAGD,CAAyB,EACzEI,EAAKH,EAAiB,wBAAwB,EAAE,GAC9CC,CACF,CACF,CAAC",
6
+ "names": ["ContainerModule", "HttpTransactionDataSource", "transactionTypes", "TransactionContextLoader", "transactionModuleFactory", "bind", "_unbind", "_isBound", "_rebind"]
7
+ }
@@ -0,0 +1,2 @@
1
+ const o={TransactionDataSource:Symbol.for("TransactionDataSource"),TransactionContextLoader:Symbol.for("TransactionContextLoader")};export{o as transactionTypes};
2
+ //# sourceMappingURL=transactionTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/transaction/di/transactionTypes.ts"],
4
+ "sourcesContent": ["export const transactionTypes = {\n TransactionDataSource: Symbol.for(\"TransactionDataSource\"),\n TransactionContextLoader: Symbol.for(\"TransactionContextLoader\"),\n};\n"],
5
+ "mappings": "AAAO,MAAMA,EAAmB,CAC9B,sBAAuB,OAAO,IAAI,uBAAuB,EACzD,yBAA0B,OAAO,IAAI,0BAA0B,CACjE",
6
+ "names": ["transactionTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ var l=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var s=(o,t,e,a)=>{for(var r=a>1?void 0:a?u(t,e):t,n=o.length-1,c;n>=0;n--)(c=o[n])&&(r=(a?c(t,e,r):c(r))||r);return a&&r&&l(t,e,r),r},m=(o,t)=>(e,a)=>t(e,a,o);import{isHexaString as S}from"@ledgerhq/device-management-kit";import{inject as f,injectable as C}from"inversify";import{ClearSignContextType as p}from"../../shared/model/ClearSignContext";import{transactionTypes as d}from"../../transaction/di/transactionTypes";let i=class{constructor(t){this.transactionDataSource=t}async load(t){if(!t.to||!t.data||t.data==="0x")return[];const e=t.data.slice(0,10);return S(e)?(await this.transactionDataSource.getTransactionDescriptors({address:t.to,chainId:t.chainId,selector:e})).caseOf({Left:r=>[{type:p.ERROR,error:r}],Right:r=>r}):[{type:p.ERROR,error:new Error("Invalid selector")}]}};i=s([C(),m(0,f(d.TransactionDataSource))],i);export{i as TransactionContextLoader};
2
+ //# sourceMappingURL=TransactionContextLoader.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/transaction/domain/TransactionContextLoader.ts"],
4
+ "sourcesContent": ["import { isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { TransactionContext } from \"@/shared/model/TransactionContext\";\nimport type { TransactionDataSource } from \"@/transaction/data/TransactionDataSource\";\nimport { transactionTypes } from \"@/transaction/di/transactionTypes\";\n\n@injectable()\nexport class TransactionContextLoader implements ContextLoader {\n constructor(\n @inject(transactionTypes.TransactionDataSource)\n private transactionDataSource: TransactionDataSource,\n ) {}\n\n async load(transaction: TransactionContext): Promise<ClearSignContext[]> {\n if (!transaction.to || !transaction.data || transaction.data === \"0x\") {\n return [];\n }\n\n const selector = transaction.data.slice(0, 10);\n\n if (!isHexaString(selector)) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ];\n }\n\n const result = await this.transactionDataSource.getTransactionDescriptors({\n address: transaction.to,\n chainId: transaction.chainId,\n selector,\n });\n\n return result.caseOf({\n Left: (error): ClearSignContext[] => [\n {\n type: ClearSignContextType.ERROR,\n error,\n },\n ],\n Right: (contexts): ClearSignContext[] => contexts,\n });\n }\n}\n"],
5
+ "mappings": "iOAAA,OAAS,gBAAAA,MAAoB,kCAC7B,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YAGnC,OAEE,wBAAAC,MACK,kCAGP,OAAS,oBAAAC,MAAwB,oCAG1B,IAAMC,EAAN,KAAwD,CAC7D,YAEUC,EACR,CADQ,2BAAAA,CACP,CAEH,MAAM,KAAKC,EAA8D,CACvE,GAAI,CAACA,EAAY,IAAM,CAACA,EAAY,MAAQA,EAAY,OAAS,KAC/D,MAAO,CAAC,EAGV,MAAMC,EAAWD,EAAY,KAAK,MAAM,EAAG,EAAE,EAE7C,OAAKE,EAAaD,CAAQ,GASX,MAAM,KAAK,sBAAsB,0BAA0B,CACxE,QAASD,EAAY,GACrB,QAASA,EAAY,QACrB,SAAAC,CACF,CAAC,GAEa,OAAO,CACnB,KAAOE,GAA8B,CACnC,CACE,KAAMC,EAAqB,MAC3B,MAAAD,CACF,CACF,EACA,MAAQE,GAAiCA,CAC3C,CAAC,EAtBQ,CACL,CACE,KAAMD,EAAqB,MAC3B,MAAO,IAAI,MAAM,kBAAkB,CACrC,CACF,CAkBJ,CACF,EAtCaN,EAANQ,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAiB,qBAAqB,IAFrCZ",
6
+ "names": ["isHexaString", "inject", "injectable", "ClearSignContextType", "transactionTypes", "TransactionContextLoader", "transactionDataSource", "transaction", "selector", "isHexaString", "error", "ClearSignContextType", "contexts", "__decorateClass", "injectable", "__decorateParam", "inject", "transactionTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{Left as s,Right as c}from"purify-ts";import{ClearSignContextType as e}from"../../shared/model/ClearSignContext";import{TransactionContextLoader as i}from"../../transaction/domain/TransactionContextLoader";describe("TransactionContextLoader",()=>{const n=jest.fn(),r={getTransactionDescriptors:n},o=new i(r);beforeEach(()=>{jest.clearAllMocks()}),it("should return an empty array if no destination address is provided",async()=>{const t={},a=await o.load(t);expect(a).toEqual([])}),it("should return an empty array if data is undefined",async()=>{const t={to:"0x0"},a=await o.load(t);expect(a).toEqual([])}),it("should return an empty array if no data provided",async()=>{const t={to:"0x0",data:"0x"},a=await o.load(t);expect(a).toEqual([])}),it("should return an error if selector is invalid",async()=>{const t={to:"0x7",chainId:3,data:"0xzf68b302000000000000000000000000000000000000000000000000000000000002"},a=await o.load(t);expect(a).toEqual([{type:e.ERROR,error:new Error("Invalid selector")}])}),it("should return an error if data source fails",async()=>{n.mockResolvedValue(s(new Error("data source error")));const t={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002"},a=await o.load(t);expect(n).toHaveBeenCalledWith({address:"0x7",chainId:3,selector:"0xaf68b302"}),expect(a).toEqual([{type:e.ERROR,error:new Error("data source error")}])}),it("should return the contexts on success",async()=>{n.mockResolvedValue(c([{type:e.TRANSACTION_INFO,payload:"1234567890"},{type:e.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}]));const t={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002"},a=await o.load(t);expect(a).toEqual([{type:e.TRANSACTION_INFO,payload:"1234567890"},{type:e.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])})});
2
+ //# sourceMappingURL=TransactionContextLoader.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/transaction/domain/TransactionContextLoader.test.ts"],
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport type { TransactionContext } from \"@/shared/model/TransactionContext\";\nimport type { TransactionDataSource } from \"@/transaction/data/TransactionDataSource\";\nimport { TransactionContextLoader } from \"@/transaction/domain/TransactionContextLoader\";\n\ndescribe(\"TransactionContextLoader\", () => {\n const getTransactionDescriptorsMock = jest.fn();\n const mockTransactionDataSource: TransactionDataSource = {\n getTransactionDescriptors: getTransactionDescriptorsMock,\n };\n const loader = new TransactionContextLoader(mockTransactionDataSource);\n\n beforeEach(() => {\n jest.clearAllMocks();\n });\n\n it(\"should return an empty array if no destination address is provided\", async () => {\n // GIVEN\n const transaction = {} as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if data is undefined\", async () => {\n // GIVEN\n const transaction = { to: \"0x0\" } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if no data provided\", async () => {\n // GIVEN\n const transaction = { to: \"0x0\", data: \"0x\" } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an error if selector is invalid\", async () => {\n // GIVEN\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xzf68b302000000000000000000000000000000000000000000000000000000000002\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ]);\n });\n\n it(\"should return an error if data source fails\", async () => {\n // GIVEN\n getTransactionDescriptorsMock.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(getTransactionDescriptorsMock).toHaveBeenCalledWith({\n address: \"0x7\",\n chainId: 3,\n selector: \"0xaf68b302\",\n });\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"data source error\"),\n },\n ]);\n });\n\n it(\"should return the contexts on success\", async () => {\n // GIVEN\n getTransactionDescriptorsMock.mockResolvedValue(\n Right([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]);\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAE5B,OAAS,wBAAAC,MAA4B,kCAGrC,OAAS,4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rB,CACE,KAAMN,EAAqB,MAC3B,MAAO,IAAI,MAAM,mBAAmB,CACtC,CACF,CAAC,CACH,CAAC,EAED,GAAG,wCAAyC,SAAY,CAEtDE,EAA8B,kBAC5BH,EAAM,CACJ,CACE,KAAMC,EAAqB,iBAC3B,QAAS,YACX,EACA,CACE,KAAMA,EAAqB,8BAC3B,QAAS,UACX,CACF,CAAC,CACH,EACA,MAAMK,EAAc,CAClB,GAAI,MACJ,QAAS,EACT,KAAM,wEACR,EAGMC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CACrB,CACE,KAAMN,EAAqB,iBAC3B,QAAS,YACX,EACA,CACE,KAAMA,EAAqB,8BAC3B,QAAS,UACX,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["Left", "Right", "ClearSignContextType", "TransactionContextLoader", "getTransactionDescriptorsMock", "mockTransactionDataSource", "loader", "transaction", "result"]
7
+ }
@@ -0,0 +1,2 @@
1
+ var y=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var g=(a,t,e,r)=>{for(var o=r>1?void 0:r?D(t,e):t,s=a.length-1,n;s>=0;s--)(n=a[s])&&(o=(r?n(t,e,o):n(o))||o);return r&&o&&y(t,e,o),o},l=(a,t)=>(e,r)=>t(e,r,a);import p from"axios";import{inject as N,injectable as T}from"inversify";import{Left as i,Right as d}from"purify-ts";import{configTypes as $}from"../../config/di/configTypes";import f from"../../../package.json";let m=class{constructor(t){this.config=t}async getDomainNamePayload({domain:t,challenge:e}){try{const s=await p.request({method:"GET",url:`https://nft.api.live.ledger.com/v2/names/ethereum/1/forward/${t}?types=eoa&sources=ens&challenge=${e}`,headers:{"X-Ledger-Client-Version":`context-module/${f.version}`}});return s.data.signedDescriptor?.data?d(s.data.signedDescriptor.data):i(new Error("[ContextModule] HttpTrustedNameDataSource: error getting domain payload"))}catch{return i(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name"))}}async getTrustedNamePayload({address:t,challenge:e,sources:r,types:o}){try{r=r.filter(u=>u==="ens"||u==="crypto_assets_list");const n=(await p.request({method:"GET",url:`https://nft.api.live.ledger.com/v2/names/ethereum/1/reverse/${t}?types=${o.join(",")}&sources=${r.join(",")}&challenge=${e}`,headers:{"X-Ledger-Client-Version":`context-module/${f.version}`}})).data;if(!n?.signedDescriptor?.data)return i(new Error(`[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address ${t}`));const c=n.signedDescriptor.data;if(!n.signedDescriptor.signatures||typeof n.signedDescriptor.signatures[this.config.cal.mode]!="string")return d(c);const h=n.signedDescriptor.signatures[this.config.cal.mode];return d(this.formatTrustedName(c,h))}catch{return i(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name"))}}formatTrustedName(t,e){e.length%2!==0&&(e="0"+e);const r="15",o=(e.length/2).toString(16);return`${t}${r}${o}${e}`}};m=g([T(),l(0,N($.Config))],m);export{m as HttpTrustedNameDataSource};
2
+ //# sourceMappingURL=HttpTrustedNameDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/trusted-name/data/HttpTrustedNameDataSource.ts"],
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport type { ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport {\n GetDomainNameInfosParams,\n GetTrustedNameInfosParams,\n TrustedNameDataSource,\n} from \"@/trusted-name/data/TrustedNameDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { TrustedNameDto } from \"./TrustedNameDto\";\n\n@injectable()\nexport class HttpTrustedNameDataSource implements TrustedNameDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n public async getDomainNamePayload({\n domain,\n challenge,\n }: GetDomainNameInfosParams): Promise<Either<Error, string>> {\n try {\n const type = \"eoa\"; // Externally owned account\n const source = \"ens\"; // Ethereum name service\n const response = await axios.request<TrustedNameDto>({\n method: \"GET\",\n url: `https://nft.api.live.ledger.com/v2/names/ethereum/1/forward/${domain}?types=${type}&sources=${source}&challenge=${challenge}`,\n headers: {\n \"X-Ledger-Client-Version\": `context-module/${PACKAGE.version}`,\n },\n });\n\n return response.data.signedDescriptor?.data\n ? Right(response.data.signedDescriptor.data)\n : Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: error getting domain payload\",\n ),\n );\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name\",\n ),\n );\n }\n }\n\n public async getTrustedNamePayload({\n address,\n challenge,\n sources,\n types,\n }: GetTrustedNameInfosParams): Promise<Either<Error, string>> {\n try {\n // TODO remove that filtering once https://ledgerhq.atlassian.net/browse/BACK-8075 is done\n // For now we have to filter or trusted names won't work with the generic parser, because transaction\n // fields descriptors can contain unsupported sources.\n sources = sources.filter(\n (source) => source === \"ens\" || source === \"crypto_assets_list\",\n );\n const response = await axios.request<TrustedNameDto>({\n method: \"GET\",\n url: `https://nft.api.live.ledger.com/v2/names/ethereum/1/reverse/${address}?types=${types.join(\",\")}&sources=${sources.join(\",\")}&challenge=${challenge}`,\n headers: {\n \"X-Ledger-Client-Version\": `context-module/${PACKAGE.version}`,\n },\n });\n const trustedName = response.data;\n if (!trustedName?.signedDescriptor?.data) {\n return Left(\n new Error(\n `[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address ${address}`,\n ),\n );\n }\n const payload = trustedName.signedDescriptor.data;\n\n if (\n !trustedName.signedDescriptor.signatures ||\n typeof trustedName.signedDescriptor.signatures[this.config.cal.mode] !==\n \"string\"\n ) {\n // If we have no separated signature but a valid descriptor, it may mean the descriptor was\n // signed on-the-fly for dynamic sources such as ens\n return Right(payload);\n }\n\n const signature =\n trustedName.signedDescriptor.signatures[this.config.cal.mode]!;\n return Right(this.formatTrustedName(payload, signature));\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name\",\n ),\n );\n }\n }\n\n private formatTrustedName(payload: string, signature: string): string {\n // Ensure correct padding\n if (signature.length % 2 !== 0) {\n signature = \"0\" + signature;\n }\n // TLV encoding as according to trusted name documentation\n const signatureTag = \"15\";\n const signatureLength = (signature.length / 2).toString(16);\n return `${payload}${signatureTag}${signatureLength}${signature}`;\n }\n}\n"],
5
+ "mappings": "iOAAA,OAAOA,MAAW,QAClB,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAO5B,OAAOC,MAAa,qBAKb,IAAMC,EAAN,KAAiE,CACtE,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CAEH,MAAa,qBAAqB,CAChC,OAAAC,EACA,UAAAC,CACF,EAA6D,CAC3D,GAAI,CAGF,MAAMC,EAAW,MAAMC,EAAM,QAAwB,CACnD,OAAQ,MACR,IAAK,+DAA+DH,CAAM,oCAA8CC,CAAS,GACjI,QAAS,CACP,0BAA2B,kBAAkBG,EAAQ,OAAO,EAC9D,CACF,CAAC,EAED,OAAOF,EAAS,KAAK,kBAAkB,KACnCG,EAAMH,EAAS,KAAK,iBAAiB,IAAI,EACzCI,EACE,IAAI,MACF,yEACF,CACF,CACN,MAAiB,CACf,OAAOA,EACL,IAAI,MACF,wEACF,CACF,CACF,CACF,CAEA,MAAa,sBAAsB,CACjC,QAAAC,EACA,UAAAN,EACA,QAAAO,EACA,MAAAC,CACF,EAA8D,CAC5D,GAAI,CAIFD,EAAUA,EAAQ,OACfE,GAAWA,IAAW,OAASA,IAAW,oBAC7C,EAQA,MAAMC,GAPW,MAAMR,EAAM,QAAwB,CACnD,OAAQ,MACR,IAAK,+DAA+DI,CAAO,UAAUE,EAAM,KAAK,GAAG,CAAC,YAAYD,EAAQ,KAAK,GAAG,CAAC,cAAcP,CAAS,GACxJ,QAAS,CACP,0BAA2B,kBAAkBG,EAAQ,OAAO,EAC9D,CACF,CAAC,GAC4B,KAC7B,GAAI,CAACO,GAAa,kBAAkB,KAClC,OAAOL,EACL,IAAI,MACF,mFAAmFC,CAAO,EAC5F,CACF,EAEF,MAAMK,EAAUD,EAAY,iBAAiB,KAE7C,GACE,CAACA,EAAY,iBAAiB,YAC9B,OAAOA,EAAY,iBAAiB,WAAW,KAAK,OAAO,IAAI,IAAI,GACjE,SAIF,OAAON,EAAMO,CAAO,EAGtB,MAAMC,EACJF,EAAY,iBAAiB,WAAW,KAAK,OAAO,IAAI,IAAI,EAC9D,OAAON,EAAM,KAAK,kBAAkBO,EAASC,CAAS,CAAC,CACzD,MAAiB,CACf,OAAOP,EACL,IAAI,MACF,yEACF,CACF,CACF,CACF,CAEQ,kBAAkBM,EAAiBC,EAA2B,CAEhEA,EAAU,OAAS,IAAM,IAC3BA,EAAY,IAAMA,GAGpB,MAAMC,EAAe,KACfC,GAAmBF,EAAU,OAAS,GAAG,SAAS,EAAE,EAC1D,MAAO,GAAGD,CAAO,GAAGE,CAAY,GAAGC,CAAe,GAAGF,CAAS,EAChE,CACF,EAlGaf,EAANkB,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,IAFjBtB",
6
+ "names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "PACKAGE", "HttpTrustedNameDataSource", "config", "domain", "challenge", "response", "axios", "PACKAGE", "Right", "Left", "address", "sources", "types", "source", "trustedName", "payload", "signature", "signatureTag", "signatureLength", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import o from"axios";import{Left as s,Right as r}from"purify-ts";import{HttpTrustedNameDataSource as l}from"../../trusted-name/data/HttpTrustedNameDataSource";import n from"../../../package.json";jest.mock("axios");describe("HttpTrustedNameDataSource",()=>{let a;beforeAll(()=>{const e={cal:{url:"https://crypto-assets-service.api.ledger.com/v1",mode:"prod",branch:"main"}};a=new l(e),jest.clearAllMocks()}),describe("getDomainNamePayload",()=>{it("should call axios with the ledger client version header",async()=>{const e=`context-module/${n.version}`,t=jest.fn(()=>Promise.resolve({data:[]}));jest.spyOn(o,"request").mockImplementation(t),await a.getDomainNamePayload({challenge:"",domain:"hello.eth"}),expect(t).toHaveBeenCalledWith(expect.objectContaining({headers:{"X-Ledger-Client-Version":e}}))}),it("should throw an error when axios throws an error",async()=>{jest.spyOn(o,"request").mockRejectedValue(new Error);const e=await a.getDomainNamePayload({challenge:"",domain:"hello.eth"});expect(e).toEqual(s(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name")))}),it("should return an error when no payload is returned",async()=>{const e={data:{test:""}};jest.spyOn(o,"request").mockResolvedValue(e);const t=await a.getDomainNamePayload({challenge:"",domain:"hello.eth"});expect(t).toEqual(s(new Error("[ContextModule] HttpTrustedNameDataSource: error getting domain payload")))}),it("should return a payload",async()=>{const e={data:{signedDescriptor:{data:"payload"}}};jest.spyOn(o,"request").mockResolvedValue(e);const t=await a.getDomainNamePayload({challenge:"challenge",domain:"hello.eth"});expect(t).toEqual(r("payload"))})}),describe("getTrustedNamePayload",()=>{it("should call axios with the ledger client version header",async()=>{const e=`context-module/${n.version}`,t=jest.fn(()=>Promise.resolve({data:[]}));jest.spyOn(o,"request").mockImplementation(t),await a.getTrustedNamePayload({address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]}),expect(t).toHaveBeenCalledWith(expect.objectContaining({headers:{"X-Ledger-Client-Version":e}}))}),it("should throw an error when axios throws an error",async()=>{jest.spyOn(o,"request").mockRejectedValue(new Error);const e=await a.getTrustedNamePayload({address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(e).toEqual(s(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name")))}),it("should return an error when no payload is returned",async()=>{const e={data:{test:""}};jest.spyOn(o,"request").mockResolvedValue(e);const t=await a.getTrustedNamePayload({address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(t).toEqual(s(new Error("[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address 0x1234")))}),it("should return a payload",async()=>{const e={data:{signedDescriptor:{data:"payload"}}};jest.spyOn(o,"request").mockResolvedValue(e);const t=await a.getTrustedNamePayload({address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(t).toEqual(r("payload"))}),it("should return a payload with a signature",async()=>{const e={data:{signedDescriptor:{data:"payload",signatures:{prod:"12345"}}}};jest.spyOn(o,"request").mockResolvedValue(e);const t=await a.getTrustedNamePayload({address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(t).toEqual(r("payload153012345"))})})});
2
+ //# sourceMappingURL=HttpTrustedNameDataSource.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/trusted-name/data/HttpTrustedNameDataSource.test.ts"],
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { HttpTrustedNameDataSource } from \"@/trusted-name/data/HttpTrustedNameDataSource\";\nimport { type TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\njest.mock(\"axios\");\n\ndescribe(\"HttpTrustedNameDataSource\", () => {\n let datasource: TrustedNameDataSource;\n\n beforeAll(() => {\n const config = {\n cal: {\n url: \"https://crypto-assets-service.api.ledger.com/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n } as ContextModuleConfig;\n datasource = new HttpTrustedNameDataSource(config);\n jest.clearAllMocks();\n });\n\n describe(\"getDomainNamePayload\", () => {\n it(\"should call axios with the ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = jest.fn(() => Promise.resolve({ data: [] }));\n jest.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getDomainNamePayload({\n challenge: \"\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: { \"X-Ledger-Client-Version\": version },\n }),\n );\n });\n\n it(\"should throw an error when axios throws an error\", async () => {\n // GIVEN\n jest.spyOn(axios, \"request\").mockRejectedValue(new Error());\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n challenge: \"\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name\",\n ),\n ),\n );\n });\n\n it(\"should return an error when no payload is returned\", async () => {\n // GIVEN\n const response = { data: { test: \"\" } };\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n challenge: \"\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: error getting domain payload\",\n ),\n ),\n );\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const response = { data: { signedDescriptor: { data: \"payload\" } } };\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n challenge: \"challenge\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(Right(\"payload\"));\n });\n });\n\n describe(\"getTrustedNamePayload\", () => {\n it(\"should call axios with the ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = jest.fn(() => Promise.resolve({ data: [] }));\n jest.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getTrustedNamePayload({\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: { \"X-Ledger-Client-Version\": version },\n }),\n );\n });\n\n it(\"should throw an error when axios throws an error\", async () => {\n // GIVEN\n jest.spyOn(axios, \"request\").mockRejectedValue(new Error());\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name\",\n ),\n ),\n );\n });\n\n it(\"should return an error when no payload is returned\", async () => {\n // GIVEN\n const response = { data: { test: \"\" } };\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address 0x1234\",\n ),\n ),\n );\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const response = {\n data: {\n signedDescriptor: { data: \"payload\" },\n },\n };\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(Right(\"payload\"));\n });\n\n it(\"should return a payload with a signature\", async () => {\n // GIVEN\n const response = {\n data: {\n signedDescriptor: { data: \"payload\", signatures: { prod: \"12345\" } },\n },\n };\n jest.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(Right(\"payload153012345\"));\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAOA,MAAW,QAClB,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAG5B,OAAS,6BAAAC,MAAiC,gDAE1C,OAAOC,MAAa,qBAEpB,KAAK,KAAK,OAAO,EAEjB,SAAS,4BAA6B,IAAM,CAC1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EAED,GAAG,0BAA2B,SAAY,CAExC,MAAMS,EAAW,CACf,KAAM,CACJ,iBAAkB,CAAE,KAAM,SAAU,CACtC,CACF,EACA,KAAK,MAAMV,EAAO,SAAS,EAAE,kBAAkBU,CAAQ,EAGvD,MAAMD,EAAS,MAAMJ,EAAW,sBAAsB,CACpD,QAAS,SACT,UAAW,GACX,QAAS,CAAC,KAAK,EACf,MAAO,CAAC,KAAK,CACf,CAAC,EAGD,OAAOI,CAAM,EAAE,QAAQP,EAAM,SAAS,CAAC,CACzC,CAAC,EAED,GAAG,2CAA4C,SAAY,CAEzD,MAAMQ,EAAW,CACf,KAAM,CACJ,iBAAkB,CAAE,KAAM,UAAW,WAAY,CAAE,KAAM,OAAQ,CAAE,CACrE,CACF,EACA,KAAK,MAAMV,EAAO,SAAS,EAAE,kBAAkBU,CAAQ,EAGvD,MAAMD,EAAS,MAAMJ,EAAW,sBAAsB,CACpD,QAAS,SACT,UAAW,GACX,QAAS,CAAC,KAAK,EACf,MAAO,CAAC,KAAK,CACf,CAAC,EAGD,OAAOI,CAAM,EAAE,QAAQP,EAAM,kBAAkB,CAAC,CAClD,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["axios", "Left", "Right", "HttpTrustedNameDataSource", "PACKAGE", "datasource", "config", "version", "requestSpy", "result", "response"]
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=TrustedNameDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=TrustedNameDto.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ import{ContainerModule as o}from"inversify";import{HttpTrustedNameDataSource as r}from"../../trusted-name/data/HttpTrustedNameDataSource";import{trustedNameTypes as e}from"../../trusted-name/di/trustedNameTypes";import{TrustedNameContextLoader as a}from"../../trusted-name/domain/TrustedNameContextLoader";const N=()=>new o((t,m,d,u)=>{t(e.TrustedNameDataSource).to(r),t(e.TrustedNameContextLoader).to(a)});export{N as trustedNameModuleFactory};
2
+ //# sourceMappingURL=trustedNameModuleFactory.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/trusted-name/di/trustedNameModuleFactory.ts"],
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpTrustedNameDataSource } from \"@/trusted-name/data/HttpTrustedNameDataSource\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\nimport { TrustedNameContextLoader } from \"@/trusted-name/domain/TrustedNameContextLoader\";\n\nexport const trustedNameModuleFactory = () =>\n new ContainerModule((bind, _unbind, _isBound, _rebind) => {\n bind(trustedNameTypes.TrustedNameDataSource).to(HttpTrustedNameDataSource);\n bind(trustedNameTypes.TrustedNameContextLoader).to(\n TrustedNameContextLoader,\n );\n });\n"],
5
+ "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,6BAAAC,MAAiC,gDAC1C,OAAS,oBAAAC,MAAwB,qCACjC,OAAS,4BAAAC,MAAgC,iDAElC,MAAMC,EAA2B,IACtC,IAAIJ,EAAgB,CAACK,EAAMC,EAASC,EAAUC,IAAY,CACxDH,EAAKH,EAAiB,qBAAqB,EAAE,GAAGD,CAAyB,EACzEI,EAAKH,EAAiB,wBAAwB,EAAE,GAC9CC,CACF,CACF,CAAC",
6
+ "names": ["ContainerModule", "HttpTrustedNameDataSource", "trustedNameTypes", "TrustedNameContextLoader", "trustedNameModuleFactory", "bind", "_unbind", "_isBound", "_rebind"]
7
+ }
@@ -0,0 +1,2 @@
1
+ const e={TrustedNameDataSource:Symbol.for("TrustedNameDataSource"),TrustedNameContextLoader:Symbol.for("TrustedNameContextLoader")};export{e as trustedNameTypes};
2
+ //# sourceMappingURL=trustedNameTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/trusted-name/di/trustedNameTypes.ts"],
4
+ "sourcesContent": ["export const trustedNameTypes = {\n TrustedNameDataSource: Symbol.for(\"TrustedNameDataSource\"),\n TrustedNameContextLoader: Symbol.for(\"TrustedNameContextLoader\"),\n};\n"],
5
+ "mappings": "AAAO,MAAMA,EAAmB,CAC9B,sBAAuB,OAAO,IAAI,uBAAuB,EACzD,yBAA0B,OAAO,IAAI,0BAA0B,CACjE",
6
+ "names": ["trustedNameTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ var m=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var c=(i,t,a,e)=>{for(var r=e>1?void 0:e?p(t,a):t,o=i.length-1,l;o>=0;o--)(l=i[o])&&(r=(e?l(t,a,r):l(r))||r);return e&&r&&m(t,a,r),r},d=(i,t)=>(a,e)=>t(a,e,i);import{inject as u,injectable as y}from"inversify";import{ClearSignContextType as n}from"../../shared/model/ClearSignContext";import{trustedNameTypes as g}from"../../trusted-name/di/trustedNameTypes";let s=class{_dataSource;constructor(t){this._dataSource=t}async load(t){const{domain:a,challenge:e}=t;return a?this.isDomainValid(a)?[(await this._dataSource.getDomainNamePayload({domain:a,challenge:e})).caseOf({Left:o=>({type:n.ERROR,error:o}),Right:o=>({type:n.TRUSTED_NAME,payload:o})})]:[{type:n.ERROR,error:new Error("[ContextModule] TrustedNameLoader: invalid domain")}]:[]}async loadField(t){return t.type!==n.TRUSTED_NAME?null:(await this._dataSource.getTrustedNamePayload({address:t.address,challenge:t.challenge,types:t.types,sources:t.sources})).caseOf({Left:e=>({type:n.ERROR,error:e}),Right:e=>({type:n.TRUSTED_NAME,payload:e})})}isDomainValid(t){const a=t.length>0&&Number(t.length)<30,e=new RegExp("^[a-zA-Z0-9\\-\\_\\.]+$").test(t);return a&&e}};s=c([y(),d(0,u(g.TrustedNameDataSource))],s);export{s as TrustedNameContextLoader};
2
+ //# sourceMappingURL=TrustedNameContextLoader.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/trusted-name/domain/TrustedNameContextLoader.ts"],
4
+ "sourcesContent": ["import { inject, injectable } from \"inversify\";\n\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport {\n TransactionContext,\n TransactionFieldContext,\n} from \"@/shared/model/TransactionContext\";\nimport type { TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\n@injectable()\nexport class TrustedNameContextLoader implements ContextLoader {\n private _dataSource: TrustedNameDataSource;\n\n constructor(\n @inject(trustedNameTypes.TrustedNameDataSource)\n dataSource: TrustedNameDataSource,\n ) {\n this._dataSource = dataSource;\n }\n\n async load(\n transactionContext: TransactionContext,\n ): Promise<ClearSignContext[]> {\n const { domain, challenge } = transactionContext;\n\n if (!domain) {\n return [];\n }\n\n if (!this.isDomainValid(domain)) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ];\n }\n\n const payload = await this._dataSource.getDomainNamePayload({\n domain: domain,\n challenge: challenge,\n });\n\n return [\n payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error: error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: value,\n }),\n }),\n ];\n }\n\n async loadField(\n field: TransactionFieldContext,\n ): Promise<ClearSignContext | null> {\n if (field.type !== ClearSignContextType.TRUSTED_NAME) {\n return null;\n }\n const payload = await this._dataSource.getTrustedNamePayload({\n address: field.address,\n challenge: field.challenge,\n types: field.types,\n sources: field.sources,\n });\n return payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: value,\n }),\n });\n }\n\n private isDomainValid(domain: string) {\n const lengthIsValid = domain.length > 0 && Number(domain.length) < 30;\n const containsOnlyValidChars = new RegExp(\"^[a-zA-Z0-9\\\\-\\\\_\\\\.]+$\").test(\n domain,\n );\n\n return lengthIsValid && containsOnlyValidChars;\n }\n}\n"],
5
+ "mappings": "iOAAA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YAGnC,OAEE,wBAAAC,MACK,kCAMP,OAAS,oBAAAC,MAAwB,qCAG1B,IAAMC,EAAN,KAAwD,CACrD,YAER,YAEEC,EACA,CACA,KAAK,YAAcA,CACrB,CAEA,MAAM,KACJC,EAC6B,CAC7B,KAAM,CAAE,OAAAC,EAAQ,UAAAC,CAAU,EAAIF,EAE9B,OAAKC,EAIA,KAAK,cAAcA,CAAM,EAcvB,EALS,MAAM,KAAK,YAAY,qBAAqB,CAC1D,OAAQA,EACR,UAAWC,CACb,CAAC,GAGS,OAAO,CACb,KAAOC,IAA6B,CAClC,KAAMC,EAAqB,MAC3B,MAAOD,CACT,GACA,MAAQE,IAA6B,CACnC,KAAMD,EAAqB,aAC3B,QAASC,CACX,EACF,CAAC,CACH,EAxBS,CACL,CACE,KAAMD,EAAqB,MAC3B,MAAO,IAAI,MAAM,mDAAmD,CACtE,CACF,EATO,CAAC,CA6BZ,CAEA,MAAM,UACJE,EACkC,CAClC,OAAIA,EAAM,OAASF,EAAqB,aAC/B,MAEO,MAAM,KAAK,YAAY,sBAAsB,CAC3D,QAASE,EAAM,QACf,UAAWA,EAAM,UACjB,MAAOA,EAAM,MACb,QAASA,EAAM,OACjB,CAAC,GACc,OAAO,CACpB,KAAOH,IAA6B,CAClC,KAAMC,EAAqB,MAC3B,MAAAD,CACF,GACA,MAAQE,IAA6B,CACnC,KAAMD,EAAqB,aAC3B,QAASC,CACX,EACF,CAAC,CACH,CAEQ,cAAcJ,EAAgB,CACpC,MAAMM,EAAgBN,EAAO,OAAS,GAAK,OAAOA,EAAO,MAAM,EAAI,GAC7DO,EAAyB,IAAI,OAAO,yBAAyB,EAAE,KACnEP,CACF,EAEA,OAAOM,GAAiBC,CAC1B,CACF,EA/EaV,EAANW,EAAA,CADNC,EAAW,EAKPC,EAAA,EAAAC,EAAOC,EAAiB,qBAAqB,IAJrCf",
6
+ "names": ["inject", "injectable", "ClearSignContextType", "trustedNameTypes", "TrustedNameContextLoader", "dataSource", "transactionContext", "domain", "challenge", "error", "ClearSignContextType", "value", "field", "lengthIsValid", "containsOnlyValidChars", "__decorateClass", "injectable", "__decorateParam", "inject", "trustedNameTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{Left as l,Right as s}from"purify-ts";import{ClearSignContextType as o}from"../../shared/model/ClearSignContext";import{TrustedNameContextLoader as r}from"../../trusted-name/domain/TrustedNameContextLoader";describe("TrustedNameContextLoader",()=>{const t={getDomainNamePayload:jest.fn(),getTrustedNamePayload:jest.fn()};beforeEach(()=>{jest.restoreAllMocks(),jest.spyOn(t,"getDomainNamePayload").mockResolvedValue(s("payload"))}),describe("load function",()=>{it("should return an empty array when no domain or registry",()=>{const e={},n=new r(t),a=()=>n.load(e);expect(a()).resolves.toEqual([])}),it("should return an error when domain > max length",async()=>{const e={domain:"maxlength-maxlength-maxlength-maxlength-maxlength-maxlength"},a=await new r(t).load(e);expect(a).toEqual([{type:o.ERROR,error:new Error("[ContextModule] TrustedNameLoader: invalid domain")}])}),it("should return an error when domain is not valid",async()=>{const e={domain:"hello\u{1F44B}"},a=await new r(t).load(e);expect(a).toEqual([{type:o.ERROR,error:new Error("[ContextModule] TrustedNameLoader: invalid domain")}])}),it("should return a payload",async()=>{const e={domain:"hello.eth",challenge:"challenge"},a=await new r(t).load(e);expect(a).toEqual([{type:o.TRUSTED_NAME,payload:"payload"}])}),it("should return an error when unable to fetch the datasource",async()=>{const e={domain:"hello.eth",challenge:"challenge"};jest.spyOn(t,"getDomainNamePayload").mockResolvedValue(l(new Error("error")));const a=await new r(t).load(e);expect(a).toEqual([{type:o.ERROR,error:new Error("error")}])})}),describe("loadField function",()=>{it("should return an error when field type if not supported",async()=>{const e={type:o.TOKEN,chainId:7,address:"0x1234"},a=await new r(t).loadField(e);expect(a).toEqual(null)}),it("should return a payload",async()=>{const e={type:o.TRUSTED_NAME,chainId:7,address:"0x1234",challenge:"17",sources:["ens"],types:["eoa"]};jest.spyOn(t,"getTrustedNamePayload").mockResolvedValue(s("payload"));const a=await new r(t).loadField(e);expect(a).toEqual({type:o.TRUSTED_NAME,payload:"payload"})}),it("should return an error when unable to fetch the datasource",async()=>{const e={type:o.TRUSTED_NAME,chainId:7,address:"0x1234",challenge:"17",sources:["ens"],types:["eoa"]};jest.spyOn(t,"getTrustedNamePayload").mockResolvedValue(l(new Error("error")));const a=await new r(t).loadField(e);expect(a).toEqual({type:o.ERROR,error:new Error("error")})})})});
2
+ //# sourceMappingURL=TrustedNameContextLoader.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/trusted-name/domain/TrustedNameContextLoader.test.ts"],
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"@/shared/model/TransactionContext\";\nimport { type TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport { TrustedNameContextLoader } from \"@/trusted-name/domain/TrustedNameContextLoader\";\n\ndescribe(\"TrustedNameContextLoader\", () => {\n const mockTrustedNameDataSource: TrustedNameDataSource = {\n getDomainNamePayload: jest.fn(),\n getTrustedNamePayload: jest.fn(),\n };\n\n beforeEach(() => {\n jest.restoreAllMocks();\n jest\n .spyOn(mockTrustedNameDataSource, \"getDomainNamePayload\")\n .mockResolvedValue(Right(\"payload\"));\n });\n\n describe(\"load function\", () => {\n it(\"should return an empty array when no domain or registry\", () => {\n const transaction = {} as TransactionContext;\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const promise = () => loader.load(transaction);\n\n expect(promise()).resolves.toEqual([]);\n });\n\n it(\"should return an error when domain > max length\", async () => {\n const transaction = {\n domain: \"maxlength-maxlength-maxlength-maxlength-maxlength-maxlength\",\n } as TransactionContext;\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ]);\n });\n\n it(\"should return an error when domain is not valid\", async () => {\n const transaction = {\n domain: \"hello\uD83D\uDC4B\",\n } as TransactionContext;\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ]);\n });\n\n it(\"should return a payload\", async () => {\n const transaction = {\n domain: \"hello.eth\",\n challenge: \"challenge\",\n } as TransactionContext;\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.TRUSTED_NAME,\n payload: \"payload\",\n },\n ]);\n });\n\n it(\"should return an error when unable to fetch the datasource\", async () => {\n // GIVEN\n const transaction = {\n domain: \"hello.eth\",\n challenge: \"challenge\",\n } as TransactionContext;\n\n // WHEN\n jest\n .spyOn(mockTrustedNameDataSource, \"getDomainNamePayload\")\n .mockResolvedValue(Left(new Error(\"error\")));\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n { type: ClearSignContextType.ERROR, error: new Error(\"error\") },\n ]);\n });\n });\n\n describe(\"loadField function\", () => {\n it(\"should return an error when field type if not supported\", async () => {\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TOKEN,\n chainId: 7,\n address: \"0x1234\",\n };\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.loadField(field);\n\n expect(result).toEqual(null);\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TRUSTED_NAME,\n chainId: 7,\n address: \"0x1234\",\n challenge: \"17\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n };\n\n // WHEN\n jest\n .spyOn(mockTrustedNameDataSource, \"getTrustedNamePayload\")\n .mockResolvedValue(Right(\"payload\"));\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: \"payload\",\n });\n });\n\n it(\"should return an error when unable to fetch the datasource\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TRUSTED_NAME,\n chainId: 7,\n address: \"0x1234\",\n challenge: \"17\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n };\n\n // WHEN\n jest\n .spyOn(mockTrustedNameDataSource, \"getTrustedNamePayload\")\n .mockResolvedValue(Left(new Error(\"error\")));\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n });\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAE5B,OAAS,wBAAAC,MAA4B,kCAMrC,OAAS,4BAAAC,MAAgC,iDAEzC,SAAS,2BAA4B,IAAM,CACzC,MAAMC,EAAmD,CACvD,qBAAsB,KAAK,GAAG,EAC9B,sBAAuB,KAAK,GAAG,CACjC,EAEA,WAAW,IAAM,CACf,KAAK,gBAAgB,EACrB,KACG,MAAMA,EAA2B,sBAAsB,EACvD,kBAAkBH,EAAM,SAAS,CAAC,CACvC,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,GAAG,0DAA2D,IAAM,CA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,CAAC,CACH,CAAC,EAED,SAAS,qBAAsB,IAAM,CACnC,GAAG,0DAA2D,SAAY,CACxE,MAAMO,EAAiC,CACrC,KAAMP,EAAqB,MAC3B,QAAS,EACT,QAAS,QACX,EAGMM,EAAS,MADA,IAAIL,EAAyBC,CAAyB,EACzC,UAAUK,CAAK,EAE3C,OAAOD,CAAM,EAAE,QAAQ,IAAI,CAC7B,CAAC,EAED,GAAG,0BAA2B,SAAY,CAExC,MAAMC,EAAiC,CACrC,KAAMP,EAAqB,aAC3B,QAAS,EACT,QAAS,SACT,UAAW,KACX,QAAS,CAAC,KAAK,EACf,MAAO,CAAC,KAAK,CACf,EAGA,KACG,MAAME,EAA2B,uBAAuB,EACxD,kBAAkBH,EAAM,SAAS,CAAC,EAErC,MAAMO,EAAS,MADA,IAAIL,EAAyBC,CAAyB,EACzC,UAAUK,CAAK,EAG3C,OAAOD,CAAM,EAAE,QAAQ,CACrB,KAAMN,EAAqB,aAC3B,QAAS,SACX,CAAC,CACH,CAAC,EAED,GAAG,6DAA8D,SAAY,CAE3E,MAAMO,EAAiC,CACrC,KAAMP,EAAqB,aAC3B,QAAS,EACT,QAAS,SACT,UAAW,KACX,QAAS,CAAC,KAAK,EACf,MAAO,CAAC,KAAK,CACf,EAGA,KACG,MAAME,EAA2B,uBAAuB,EACxD,kBAAkBJ,EAAK,IAAI,MAAM,OAAO,CAAC,CAAC,EAE7C,MAAMQ,EAAS,MADA,IAAIL,EAAyBC,CAAyB,EACzC,UAAUK,CAAK,EAG3C,OAAOD,CAAM,EAAE,QAAQ,CACrB,KAAMN,EAAqB,MAC3B,MAAO,IAAI,MAAM,OAAO,CAC1B,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["Left", "Right", "ClearSignContextType", "TrustedNameContextLoader", "mockTrustedNameDataSource", "transaction", "loader", "promise", "result", "field"]
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=FiltersDto.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ var y=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var u=(a,e,t,n)=>{for(var i=n>1?void 0:n?g(e,t):e,r=a.length-1,s;r>=0;r--)(s=a[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&y(e,t,i),i},m=(a,e)=>(t,n)=>e(t,n,a);import h from"axios";import C from"crypto-js/sha224";import{inject as _,injectable as F}from"inversify";import{Left as l,Right as M}from"purify-ts";import{configTypes as D}from"../../config/di/configTypes";import I from"../../../package.json";let d=class{constructor(e){this.config=e}async getTypedDataFilters({chainId:e,address:t,schema:n,version:i}){let r;try{const s=await h.request({method:"GET",url:`${this.config.cal.url}/dapps`,params:{contracts:t,chain_id:e,output:"descriptors_eip712",descriptors_eip712_version:i,descriptors_eip712:"<set>",ref:`branch:${this.config.cal.branch}`},headers:{"X-Ledger-Client-Version":`context-module/${I.version}`}}),p=C(JSON.stringify(this.sortTypes(n)).replace(" ","")).toString();t=t.toLowerCase();const f=s.data?.[0]?.descriptors_eip712?.[t]?.[p];if(!f)return l(new Error(`[ContextModule] HttpTypedDataDataSource: no typed data filters for address ${t} on chain ${e} for schema ${p}`));if(!f.schema||!Array.isArray(f.instructions))return l(new Error(`[ContextModule] HttpTypedDataDataSource: no message info for address ${t} on chain ${e} for schema ${p}`));const c=[];for(const o of f.instructions)if(this.isInstructionContractInfo(o,this.config.cal.mode))r={displayName:o.display_name,signature:o.signatures[this.config.cal.mode],filtersCount:o.field_mappers_count};else if(i==="v1"&&this.isInstructionFieldV1(o,this.config.cal.mode))c.push({type:"raw",displayName:o.display_name,path:o.field_path,signature:o.signatures[this.config.cal.mode]});else if(this.isInstructionFieldV2(o,this.config.cal.mode))c.push({type:o.format,displayName:o.display_name,path:o.field_path,signature:o.signatures[this.config.cal.mode]});else if(this.isInstructionFieldV2WithCoinRef(o,this.config.cal.mode))c.push({type:o.format,displayName:o.display_name,path:o.field_path,signature:o.signatures[this.config.cal.mode],tokenIndex:o.coin_ref});else return l(new Error(`[ContextModule] HttpTypedDataDataSource: invalid typed data field for address ${t} on chain ${e} for schema ${p}`));return r?M({messageInfo:r,filters:c}):l(new Error(`[ContextModule] HttpTypedDataDataSource: no message info for address ${t} on chain ${e} for schema ${p}`))}catch{return l(new Error("[ContextModule] HttpTypedDataDataSource: Failed to fetch typed data informations"))}}isInstructionFieldV1(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"}isInstructionFieldV2(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"&&typeof e.format=="string"&&["raw","datetime"].includes(e.format)&&e.coin_ref===void 0}isInstructionFieldV2WithCoinRef(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"&&typeof e.format=="string"&&["token","amount"].includes(e.format)&&typeof e.coin_ref=="number"}isInstructionContractInfo(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_mappers_count=="number"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"&&e.field_path===void 0}sortTypes(e){return Object.fromEntries(Object.entries(e).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>[t,n.map(i=>({name:i.name,type:i.type}))]))}};d=u([F(),m(0,_(D.Config))],d);export{d as HttpTypedDataDataSource};
2
+ //# sourceMappingURL=HttpTypedDataDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/typed-data/data/HttpTypedDataDataSource.ts"],
4
+ "sourcesContent": ["import axios from \"axios\";\nimport SHA224 from \"crypto-js/sha224\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport type {\n ContextModuleCalMode,\n ContextModuleConfig,\n} from \"@/config/model/ContextModuleConfig\";\nimport type {\n TypedDataFilter,\n TypedDataMessageInfo,\n} from \"@/shared/model/TypedDataClearSignContext\";\nimport type { TypedDataSchema } from \"@/shared/model/TypedDataContext\";\nimport PACKAGE from \"@root/package.json\";\n\nimport type {\n FiltersDto,\n InstructionContractInfo,\n InstructionField,\n InstructionFieldV1,\n InstructionFieldV2,\n InstructionFieldV2WithCoinRef,\n} from \"./FiltersDto\";\nimport {\n GetTypedDataFiltersParams,\n GetTypedDataFiltersResult,\n TypedDataDataSource,\n} from \"./TypedDataDataSource\";\n\n@injectable()\nexport class HttpTypedDataDataSource implements TypedDataDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n public async getTypedDataFilters({\n chainId,\n address,\n schema,\n version,\n }: GetTypedDataFiltersParams): Promise<\n Either<Error, GetTypedDataFiltersResult>\n > {\n let messageInfo: TypedDataMessageInfo | undefined = undefined;\n\n try {\n const response = await axios.request<FiltersDto[]>({\n method: \"GET\",\n url: `${this.config.cal.url}/dapps`,\n params: {\n contracts: address,\n chain_id: chainId,\n output: \"descriptors_eip712\",\n descriptors_eip712_version: version,\n descriptors_eip712: \"<set>\",\n ref: `branch:${this.config.cal.branch}`,\n },\n headers: {\n \"X-Ledger-Client-Version\": `context-module/${PACKAGE.version}`,\n },\n });\n\n // Try to get the filters JSON descriptor, from address and schema hash\n const schemaHash = SHA224(\n JSON.stringify(this.sortTypes(schema)).replace(\" \", \"\"),\n ).toString();\n address = address.toLowerCase();\n const filtersJson =\n response.data?.[0]?.descriptors_eip712?.[address]?.[schemaHash];\n if (!filtersJson) {\n return Left(\n new Error(\n `[ContextModule] HttpTypedDataDataSource: no typed data filters for address ${address} on chain ${chainId} for schema ${schemaHash}`,\n ),\n );\n }\n\n // Parse the message type, if available\n if (!filtersJson.schema || !Array.isArray(filtersJson.instructions)) {\n return Left(\n new Error(\n `[ContextModule] HttpTypedDataDataSource: no message info for address ${address} on chain ${chainId} for schema ${schemaHash}`,\n ),\n );\n }\n\n // Parse all the filters\n const filters: TypedDataFilter[] = [];\n for (const field of filtersJson.instructions) {\n if (this.isInstructionContractInfo(field, this.config.cal.mode)) {\n messageInfo = {\n displayName: field.display_name,\n signature: field.signatures[this.config.cal.mode],\n filtersCount: field.field_mappers_count,\n };\n } else if (\n version === \"v1\" &&\n this.isInstructionFieldV1(field, this.config.cal.mode)\n ) {\n filters.push({\n type: \"raw\",\n displayName: field.display_name,\n path: field.field_path,\n signature: field.signatures[this.config.cal.mode],\n });\n } else if (this.isInstructionFieldV2(field, this.config.cal.mode)) {\n filters.push({\n type: field.format,\n displayName: field.display_name,\n path: field.field_path,\n signature: field.signatures[this.config.cal.mode],\n });\n } else if (\n this.isInstructionFieldV2WithCoinRef(field, this.config.cal.mode)\n ) {\n filters.push({\n type: field.format,\n displayName: field.display_name,\n path: field.field_path,\n signature: field.signatures[this.config.cal.mode],\n tokenIndex: field.coin_ref,\n });\n } else {\n return Left(\n new Error(\n `[ContextModule] HttpTypedDataDataSource: invalid typed data field for address ${address} on chain ${chainId} for schema ${schemaHash}`,\n ),\n );\n }\n }\n\n if (!messageInfo) {\n return Left(\n new Error(\n `[ContextModule] HttpTypedDataDataSource: no message info for address ${address} on chain ${chainId} for schema ${schemaHash}`,\n ),\n );\n }\n\n return Right({ messageInfo, filters });\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTypedDataDataSource: Failed to fetch typed data informations\",\n ),\n );\n }\n }\n\n private isInstructionFieldV1(\n data: InstructionField,\n mode: ContextModuleCalMode,\n ): data is InstructionFieldV1 & {\n signatures: { [key in ContextModuleCalMode]: string };\n } {\n // NOTE: Currently the backend return the same structure for V1 and V2,\n // so we can't distinguish them here, but we can still check the required fields\n return (\n typeof data === \"object\" &&\n typeof data.display_name === \"string\" &&\n typeof data.field_path === \"string\" &&\n typeof data.signatures === \"object\" &&\n typeof data.signatures[mode] === \"string\"\n );\n }\n\n private isInstructionFieldV2(\n data: InstructionField,\n mode: ContextModuleCalMode,\n ): data is InstructionFieldV2 & {\n signatures: { [key in ContextModuleCalMode]: string };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.display_name === \"string\" &&\n typeof data.field_path === \"string\" &&\n typeof data.signatures === \"object\" &&\n typeof data.signatures[mode] === \"string\" &&\n typeof data.format === \"string\" &&\n [\"raw\", \"datetime\"].includes(data.format) &&\n data.coin_ref === undefined\n );\n }\n\n private isInstructionFieldV2WithCoinRef(\n data: InstructionField,\n mode: ContextModuleCalMode,\n ): data is InstructionFieldV2WithCoinRef & {\n signatures: { [key in ContextModuleCalMode]: string };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.display_name === \"string\" &&\n typeof data.field_path === \"string\" &&\n typeof data.signatures === \"object\" &&\n typeof data.signatures[mode] === \"string\" &&\n typeof data.format === \"string\" &&\n [\"token\", \"amount\"].includes(data.format) &&\n typeof data.coin_ref === \"number\"\n );\n }\n\n private isInstructionContractInfo(\n data: InstructionField,\n mode: ContextModuleCalMode,\n ): data is InstructionContractInfo & {\n signatures: { [key in ContextModuleCalMode]: string };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.display_name === \"string\" &&\n typeof data.field_mappers_count === \"number\" &&\n typeof data.signatures === \"object\" &&\n typeof data.signatures[mode] === \"string\" &&\n data.field_path === undefined\n );\n }\n\n private sortTypes(types: TypedDataSchema): TypedDataSchema {\n return Object.fromEntries(\n Object.entries(types)\n .sort(([aKey], [bKey]) => aKey.localeCompare(bKey))\n .map(([key, value]) => [\n key,\n value.map((v) => ({ name: v.name, type: v.type })),\n ]),\n );\n }\n}\n"],
5
+ "mappings": "iOAAA,OAAOA,MAAW,QAClB,OAAOC,MAAY,mBACnB,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAU5B,OAAOC,MAAa,qBA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EQ,gCACNA,EACAC,EAGA,CACA,OACE,OAAOD,GAAS,UAChB,OAAOA,EAAK,cAAiB,UAC7B,OAAOA,EAAK,YAAe,UAC3B,OAAOA,EAAK,YAAe,UAC3B,OAAOA,EAAK,WAAWC,CAAI,GAAM,UACjC,OAAOD,EAAK,QAAW,UACvB,CAAC,QAAS,QAAQ,EAAE,SAASA,EAAK,MAAM,GACxC,OAAOA,EAAK,UAAa,QAE7B,CAEQ,0BACNA,EACAC,EAGA,CACA,OACE,OAAOD,GAAS,UAChB,OAAOA,EAAK,cAAiB,UAC7B,OAAOA,EAAK,qBAAwB,UACpC,OAAOA,EAAK,YAAe,UAC3B,OAAOA,EAAK,WAAWC,CAAI,GAAM,UACjCD,EAAK,aAAe,MAExB,CAEQ,UAAUE,EAAyC,CACzD,OAAO,OAAO,YACZ,OAAO,QAAQA,CAAK,EACjB,KAAK,CAAC,CAACC,CAAI,EAAG,CAACC,CAAI,IAAMD,EAAK,cAAcC,CAAI,CAAC,EACjD,IAAI,CAAC,CAACC,EAAKC,CAAK,IAAM,CACrBD,EACAC,EAAM,IAAKC,IAAO,CAAE,KAAMA,EAAE,KAAM,KAAMA,EAAE,IAAK,EAAE,CACnD,CAAC,CACL,CACF,CACF,EAtMaxB,EAANyB,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,IAFjB7B",
6
+ "names": ["axios", "SHA224", "inject", "injectable", "Left", "Right", "configTypes", "PACKAGE", "HttpTypedDataDataSource", "config", "chainId", "address", "schema", "version", "messageInfo", "response", "axios", "PACKAGE", "schemaHash", "SHA224", "filtersJson", "Left", "filters", "field", "Right", "data", "mode", "types", "aKey", "bKey", "key", "value", "v", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import t from"axios";import{Right as c}from"purify-ts";import{HttpTypedDataDataSource as r}from"../../typed-data/data/HttpTypedDataDataSource";import b from"../../../package.json";jest.mock("axios");const f=d=>[{descriptors_eip712:{"0x000000000022d473030f116ddee9f6b43ac78ba3":{"4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3":{schema:{DutchOutput:[{name:"token",type:"address"},{name:"startAmount",type:"uint256"},{name:"endAmount",type:"uint256"},{name:"recipient",type:"address"}],EIP712Domain:[{name:"name",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],ExclusiveDutchOrder:[{name:"info",type:"OrderInfo"},{name:"decayStartTime",type:"uint256"},{name:"decayEndTime",type:"uint256"},{name:"exclusiveFiller",type:"address"},{name:"exclusivityOverrideBps",type:"uint256"},{name:"inputToken",type:"address"},{name:"inputStartAmount",type:"uint256"},{name:"inputEndAmount",type:"uint256"},{name:"outputs",type:"DutchOutput[]"}],OrderInfo:[{name:"reactor",type:"address"},{name:"swapper",type:"address"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"},{name:"additionalValidationContract",type:"address"},{name:"additionalValidationData",type:"bytes"}],PermitWitnessTransferFrom:[{name:"permitted",type:"TokenPermissions"},{name:"spender",type:"address"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"},{name:"witness",type:"ExclusiveDutchOrder"}],TokenPermissions:[{name:"token",type:"address"},{name:"amount",type:"uint256"}]},instructions:d}}}}];describe("HttpTypedDataDataSource",()=>{let d;const s={PermitSingle:[{name:"details",type:"PermitDetails"},{name:"spender",type:"address"},{name:"sigDeadline",type:"uint256"}],PermitDetails:[{type:"address",name:"token"},{name:"amount",type:"uint160"},{name:"expiration",type:"uint48"},{name:"nonce",type:"uint48"}],EIP712Domain:[{name:"name",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}]};beforeAll(()=>{const a={cal:{url:"https://crypto-assets-service.api.ledger.com/v1",mode:"prod"}};d=new r(a),jest.clearAllMocks()}),it("should call axios with the ledger client version header",async()=>{const a=`context-module/${b.version}`,e=jest.fn(()=>Promise.resolve({data:[]}));jest.spyOn(t,"request").mockImplementation(e),await d.getTypedDataFilters({chainId:1,address:"0x00",version:"v2",schema:{}}),expect(e).toHaveBeenCalledWith(expect.objectContaining({headers:{"X-Ledger-Client-Version":a}}))}),it("should return V2 filters when axios response is correct",async()=>{const a=f([{display_name:"Permit2",field_mappers_count:4,descriptor:"b7000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3045065726d697432",signatures:{prod:"304402201675b7d8507b40de5136c386815afdad8012cb8e3f0e0a126c758d6fbb3f6b0f0220595cbfeeab7591d0eebe40f0e4ea8ea53beeaf89ee50b7faf97f97bdf36abbce"},type:"message"},{display_name:"Amount allowance",format:"token",field_path:"details.token",coin_ref:0,descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e746f6b656e416d6f756e7420616c6c6f77616e6365",signatures:{prod:"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53"},type:"field"},{display_name:"Amount allowance",format:"amount",field_path:"details.amount",coin_ref:0,descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e616d6f756e74416d6f756e7420616c6c6f77616e6365",signatures:{prod:"30450221008f9e2f33b35872e63b2024a6d4938525c6e72364604da2d5e21b3d7fa44cac8a02207d4fe42c9d3994a322dae99adc2c56157435c177c51831103fdaf3cef12bb19f"},type:"field"},{display_name:"Approve to spender",format:"raw",field_path:"spender",descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df37370656e646572417070726f766520746f207370656e646572",signatures:{prod:"3045022100dddb92141e3b3f21dafb60c8d5093e28b25a8dc4f926ed501b6d2021203f68bc02201abca405540e72b5b70120a428967b776edb8a88ebd9b1d7aa320c3df602027f"},type:"field"},{display_name:"Approval expire",format:"datetime",field_path:"details.expiration",descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e65787069726174696f6e417070726f76616c20657870697265",signatures:{prod:"3044022060a11c1b15d07e7172e2e68a4e4aa5cbd3b5af900907634b1bce58000eab9fb502201e40963d9e2b00948ce16d3817756329e11a81e8b14b762adff68db4b3a4b8ff"},type:"field"}]);jest.spyOn(t,"request").mockResolvedValue({data:a});const e=await d.getTypedDataFilters({chainId:1,address:"0x000000000022D473030F116DDEE9F6B43AC78BA3",version:"v2",schema:s});expect(e).toEqual(c({messageInfo:{displayName:"Permit2",filtersCount:4,signature:"304402201675b7d8507b40de5136c386815afdad8012cb8e3f0e0a126c758d6fbb3f6b0f0220595cbfeeab7591d0eebe40f0e4ea8ea53beeaf89ee50b7faf97f97bdf36abbce"},filters:[{type:"token",displayName:"Amount allowance",path:"details.token",tokenIndex:0,signature:"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53"},{type:"amount",displayName:"Amount allowance",path:"details.amount",tokenIndex:0,signature:"30450221008f9e2f33b35872e63b2024a6d4938525c6e72364604da2d5e21b3d7fa44cac8a02207d4fe42c9d3994a322dae99adc2c56157435c177c51831103fdaf3cef12bb19f"},{type:"raw",displayName:"Approve to spender",path:"spender",signature:"3045022100dddb92141e3b3f21dafb60c8d5093e28b25a8dc4f926ed501b6d2021203f68bc02201abca405540e72b5b70120a428967b776edb8a88ebd9b1d7aa320c3df602027f"},{type:"datetime",displayName:"Approval expire",path:"details.expiration",signature:"3044022060a11c1b15d07e7172e2e68a4e4aa5cbd3b5af900907634b1bce58000eab9fb502201e40963d9e2b00948ce16d3817756329e11a81e8b14b762adff68db4b3a4b8ff"}]}))}),it("should return V1 filters when axios response is correct",async()=>{const a=f([{display_name:"Permit2",field_mappers_count:4,descriptor:"b7000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3045065726d697432",signatures:{prod:"304402201675b7d8507b40de5136c386815afdad8012cb8e3f0e0a126c758d6fbb3f6b0f0220595cbfeeab7591d0eebe40f0e4ea8ea53beeaf89ee50b7faf97f97bdf36abbce"},type:"message"},{display_name:"Amount allowance",format:"token",field_path:"details.token",coin_ref:0,descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e746f6b656e416d6f756e7420616c6c6f77616e6365",signatures:{prod:"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53"},type:"field"},{display_name:"Amount allowance",format:"amount",field_path:"details.amount",coin_ref:0,descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e616d6f756e74416d6f756e7420616c6c6f77616e6365",signatures:{prod:"30450221008f9e2f33b35872e63b2024a6d4938525c6e72364604da2d5e21b3d7fa44cac8a02207d4fe42c9d3994a322dae99adc2c56157435c177c51831103fdaf3cef12bb19f"},type:"field"},{display_name:"Approve to spender",format:"raw",field_path:"spender",descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df37370656e646572417070726f766520746f207370656e646572",signatures:{prod:"3045022100dddb92141e3b3f21dafb60c8d5093e28b25a8dc4f926ed501b6d2021203f68bc02201abca405540e72b5b70120a428967b776edb8a88ebd9b1d7aa320c3df602027f"},type:"field"},{display_name:"Approval expire",format:"datetime",field_path:"details.expiration",descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e65787069726174696f6e417070726f76616c20657870697265",signatures:{prod:"3044022060a11c1b15d07e7172e2e68a4e4aa5cbd3b5af900907634b1bce58000eab9fb502201e40963d9e2b00948ce16d3817756329e11a81e8b14b762adff68db4b3a4b8ff"},type:"field"}]);jest.spyOn(t,"request").mockResolvedValue({data:a});const e=await d.getTypedDataFilters({chainId:1,address:"0x000000000022d473030f116ddee9f6b43ac78ba3",version:"v1",schema:s});expect(e).toEqual(c({messageInfo:{displayName:"Permit2",filtersCount:4,signature:"304402201675b7d8507b40de5136c386815afdad8012cb8e3f0e0a126c758d6fbb3f6b0f0220595cbfeeab7591d0eebe40f0e4ea8ea53beeaf89ee50b7faf97f97bdf36abbce"},filters:[{type:"raw",displayName:"Amount allowance",path:"details.token",signature:"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53"},{type:"raw",displayName:"Amount allowance",path:"details.amount",signature:"30450221008f9e2f33b35872e63b2024a6d4938525c6e72364604da2d5e21b3d7fa44cac8a02207d4fe42c9d3994a322dae99adc2c56157435c177c51831103fdaf3cef12bb19f"},{type:"raw",displayName:"Approve to spender",path:"spender",signature:"3045022100dddb92141e3b3f21dafb60c8d5093e28b25a8dc4f926ed501b6d2021203f68bc02201abca405540e72b5b70120a428967b776edb8a88ebd9b1d7aa320c3df602027f"},{type:"raw",displayName:"Approval expire",path:"details.expiration",signature:"3044022060a11c1b15d07e7172e2e68a4e4aa5cbd3b5af900907634b1bce58000eab9fb502201e40963d9e2b00948ce16d3817756329e11a81e8b14b762adff68db4b3a4b8ff"}]}))}),it("should return an error when data is empty",async()=>{jest.spyOn(t,"request").mockResolvedValue({data:void 0});const a=await d.getTypedDataFilters({chainId:1,address:"0x000000000022d473030f116ddee9f6b43ac78ba3",version:"v1",schema:s});expect(a.isLeft()).toEqual(!0),expect(a.extract()).toEqual(new Error("[ContextModule] HttpTypedDataDataSource: no typed data filters for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3"))}),it("should return an error when schema is not found",async()=>{const a=f([]);jest.spyOn(t,"request").mockResolvedValue({data:a});const e=await d.getTypedDataFilters({chainId:1,address:"0x000000000022d473030f116ddee9f6b43ac78ba3",version:"v1",schema:s});expect(e.isLeft()).toEqual(!0),expect(e.extract()).toEqual(new Error("[ContextModule] HttpTypedDataDataSource: no message info for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3"))}),it("should return an error when schema is undefined",async()=>{const a=f(void 0);jest.spyOn(t,"request").mockResolvedValue({data:a});const e=await d.getTypedDataFilters({chainId:1,address:"0x000000000022d473030f116ddee9f6b43ac78ba3",version:"v1",schema:s});expect(e.isLeft()).toEqual(!0),expect(e.extract()).toEqual(new Error("[ContextModule] HttpTypedDataDataSource: no message info for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3"))}),it("should return an error if no message info is found",async()=>{const a=f([{display_name:"Amount allowance",format:"token",field_path:"details.token",coin_ref:0,descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e746f6b656e416d6f756e7420616c6c6f77616e6365",signatures:{prod:"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53"},type:"field"}]);jest.spyOn(t,"request").mockResolvedValue({data:a});const e=await d.getTypedDataFilters({chainId:1,address:"0x000000000022d473030f116ddee9f6b43ac78ba3",version:"v1",schema:s});expect(e.isLeft()).toEqual(!0),expect(e.extract()).toEqual(new Error("[ContextModule] HttpTypedDataDataSource: no message info for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3"))}),it("should return an error if message info display name is missing",async()=>{const a=f([{field_mappers_count:4,descriptor:"b7000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3045065726d697432",signatures:{prod:"304402201675b7d8507b40de5136c386815afdad8012cb8e3f0e0a126c758d6fbb3f6b0f0220595cbfeeab7591d0eebe40f0e4ea8ea53beeaf89ee50b7faf97f97bdf36abbce"},type:"message"}]);jest.spyOn(t,"request").mockResolvedValue({data:a});const e=await d.getTypedDataFilters({chainId:1,address:"0x000000000022d473030f116ddee9f6b43ac78ba3",version:"v1",schema:s});expect(e.isLeft()).toEqual(!0),expect(e.extract()).toEqual(new Error("[ContextModule] HttpTypedDataDataSource: invalid typed data field for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3"))}),it("should return an error if field path is invalid",async()=>{const a=f([{display_name:"Amount allowance",format:"token",coin_ref:0,descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e746f6b656e416d6f756e7420616c6c6f77616e6365",signatures:{prod:"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53"},type:"field"}]);jest.spyOn(t,"request").mockResolvedValue({data:a});const e=await d.getTypedDataFilters({chainId:1,address:"0x000000000022d473030f116ddee9f6b43ac78ba3",version:"v1",schema:s});expect(e.isLeft()).toEqual(!0),expect(e.extract()).toEqual(new Error("[ContextModule] HttpTypedDataDataSource: invalid typed data field for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3"))}),it("should return an error if field display_name is invalid",async()=>{const a=f([{format:"token",field_path:"details.token",coin_ref:0,descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e746f6b656e416d6f756e7420616c6c6f77616e6365",signatures:{prod:"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53"},type:"field"}]);jest.spyOn(t,"request").mockResolvedValue({data:a});const e=await d.getTypedDataFilters({chainId:1,address:"0x000000000022d473030f116ddee9f6b43ac78ba3",version:"v1",schema:s});expect(e.isLeft()).toEqual(!0),expect(e.extract()).toEqual(new Error("[ContextModule] HttpTypedDataDataSource: invalid typed data field for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3"))}),it("should return an error if field signatures.prod is missing",async()=>{const a=f([{display_name:"Amount allowance",format:"token",field_path:"details.token",coin_ref:0,descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e746f6b656e416d6f756e7420616c6c6f77616e6365",signatures:{test:"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53"},type:"field"}]);jest.spyOn(t,"request").mockResolvedValue({data:a});const e=await d.getTypedDataFilters({chainId:1,address:"0x000000000022d473030f116ddee9f6b43ac78ba3",version:"v1",schema:s});expect(e.isLeft()).toEqual(!0),expect(e.extract()).toEqual(new Error("[ContextModule] HttpTypedDataDataSource: invalid typed data field for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3"))}),it("should return an error on token fileds with coin ref to null",async()=>{const a=f([{display_name:"Amount allowance",format:"token",field_path:"details.token",coin_ref:null,descriptor:"48000000000000a4b1000000000022d473030f116ddee9f6b43ac78ba34d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df364657461696c732e746f6b656e416d6f756e7420616c6c6f77616e6365",signatures:{prod:"30440220238723d4ddd47baf829d547802a2017476bf68e03d0b920fd46aa543de81d5b902206123218eae82c5f898454c45262e5b0b839dc9d84b2b0926fe14e8218b5b0d53"},type:"field"}]);jest.spyOn(t,"request").mockResolvedValue({data:a});const e=await d.getTypedDataFilters({chainId:1,address:"0x000000000022d473030f116ddee9f6b43ac78ba3",version:"v2",schema:s});expect(e.isLeft()).toEqual(!0),expect(e.extract()).toEqual(new Error("[ContextModule] HttpTypedDataDataSource: invalid typed data field for address 0x000000000022d473030f116ddee9f6b43ac78ba3 on chain 1 for schema 4d593149e876e739220f3b5ede1b38a0213d76c4705b1547c4323df3"))}),it("should return an error when axios throws an error",async()=>{jest.spyOn(t,"request").mockRejectedValue(new Error("error"));const a=await d.getTypedDataFilters({chainId:1,address:"0x000000000022d473030f116ddee9f6b43ac78ba3",version:"v1",schema:s});expect(a.isLeft()).toEqual(!0)})});export{f as buildDescriptor};
2
+ //# sourceMappingURL=HttpTypedDataDataSource.test.js.map