@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,2 @@
1
+ "use strict";var e=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var c=(n,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of o(t))!b.call(n,a)&&a!==i&&e(n,a,{get:()=>t[a],enumerable:!(r=s(t,a))||r.enumerable});return n};var d=n=>c(e({},"__esModule",{value:!0}),n);var g={};module.exports=d(g);
2
+ //# sourceMappingURL=TransactionSubset.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/shared/model/TransactionSubset.ts"],
4
+ "sourcesContent": ["export type TransactionSubset = {\n chainId: number;\n to?: string;\n data?: string;\n};\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["TransactionSubset_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var p=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var d=(t,e)=>{for(var r in e)p(t,r,{get:e[r],enumerable:!0})},i=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of y(e))!s.call(t,a)&&a!==r&&p(t,a,{get:()=>e[a],enumerable:!(n=o(e,a))||n.enumerable});return t};var T=t=>i(p({},"__esModule",{value:!0}),t);var D={};d(D,{VERIFYING_CONTRACT_TOKEN_INDEX:()=>g});module.exports=T(D);const g=255;0&&(module.exports={VERIFYING_CONTRACT_TOKEN_INDEX});
2
+ //# sourceMappingURL=TypedDataClearSignContext.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/shared/model/TypedDataClearSignContext.ts"],
4
+ "sourcesContent": ["// The general informations for a typed message\nexport type TypedDataMessageInfo = {\n displayName: string;\n filtersCount: number;\n signature: string;\n};\n\n// Token index and descriptor. Needed for tokens that are referenced by a typed message\nexport type TypedDataTokenIndex = number;\nexport type TypedDataToken = string;\n// Special token index value when the referenced token is the verifying contract\nexport const VERIFYING_CONTRACT_TOKEN_INDEX = 255;\n\n// Typed message filters, to select fields to display, and provide formatting informations\nexport type TypedDataFilterPath = string;\nexport type TypedDataFilter =\n | {\n type: \"datetime\" | \"raw\";\n displayName: string;\n path: TypedDataFilterPath;\n signature: string;\n }\n | {\n type: \"amount\" | \"token\";\n displayName: string;\n tokenIndex: TypedDataTokenIndex;\n path: TypedDataFilterPath;\n signature: string;\n };\n\n// Clear signing context for a typed message\nexport type TypedDataClearSignContextSuccess = {\n type: \"success\";\n messageInfo: TypedDataMessageInfo;\n filters: Record<TypedDataFilterPath, TypedDataFilter>;\n tokens: Record<TypedDataTokenIndex, TypedDataToken>;\n};\nexport type TypedDataClearSignContextError = {\n type: \"error\";\n error: Error;\n};\nexport type TypedDataClearSignContext =\n | TypedDataClearSignContextSuccess\n | TypedDataClearSignContextError;\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oCAAAE,IAAA,eAAAC,EAAAH,GAWO,MAAME,EAAiC",
6
+ "names": ["TypedDataClearSignContext_exports", "__export", "VERIFYING_CONTRACT_TOKEN_INDEX", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var i=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var d=(a,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of y(e))!s.call(a,t)&&t!==n&&i(a,t,{get:()=>e[t],enumerable:!(r=p(e,t))||r.enumerable});return a};var l=a=>d(i({},"__esModule",{value:!0}),a);var o={};module.exports=l(o);
2
+ //# sourceMappingURL=TypedDataContext.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/shared/model/TypedDataContext.ts"],
4
+ "sourcesContent": ["// The schema of a typed message\nexport type TypedDataSchema = Record<\n string,\n Array<{ name: string; type: string }>\n>;\n\n// The extracted message values, with their path\nexport type TypedDataFieldValues = Array<{ path: string; value: Uint8Array }>;\n\n// Context needed to fetch the clear signing context of a typed message\nexport type TypedDataContext = {\n verifyingContract: string;\n chainId: number;\n version: \"v1\" | \"v2\";\n schema: TypedDataSchema;\n fieldsValues: TypedDataFieldValues;\n};\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["TypedDataContext_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var g=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var l=(r,t)=>{for(var e in t)g(r,e,{get:t[e],enumerable:!0})},x=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of o(t))!a.call(r,i)&&i!==e&&g(r,i,{get:()=>t[i],enumerable:!(n=s(t,i))||n.enumerable});return r};var c=r=>x(g({},"__esModule",{value:!0}),r);var S={};l(S,{HexStringUtils:()=>h});module.exports=c(S);class h{static stringToHex(t){let e="";for(let n=0;n<t.length;n++){const i=t.charCodeAt(n).toString(16);e+=i.padStart(2,"0")}return e}}0&&(module.exports={HexStringUtils});
2
+ //# sourceMappingURL=HexStringUtils.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/shared/utils/HexStringUtils.ts"],
4
+ "sourcesContent": ["export class HexStringUtils {\n static stringToHex(str: string): string {\n let hexString = \"\";\n for (let i = 0; i < str.length; i++) {\n const hex = str.charCodeAt(i).toString(16);\n hexString += hex.padStart(2, \"0\"); // Ensure each hex code is at least 2 characters long\n }\n return hexString;\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,CAAe,CAC1B,OAAO,YAAYE,EAAqB,CACtC,IAAIC,EAAY,GAChB,QAASC,EAAI,EAAGA,EAAIF,EAAI,OAAQE,IAAK,CACnC,MAAMC,EAAMH,EAAI,WAAWE,CAAC,EAAE,SAAS,EAAE,EACzCD,GAAaE,EAAI,SAAS,EAAG,GAAG,CAClC,CACA,OAAOF,CACT,CACF",
6
+ "names": ["HexStringUtils_exports", "__export", "HexStringUtils", "__toCommonJS", "str", "hexString", "i", "hex"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var x=Object.create;var s=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var M=(r,t)=>{for(var e in t)s(r,e,{get:t[e],enumerable:!0})},p=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of T(t))!E.call(r,o)&&o!==e&&s(r,o,{get:()=>t[o],enumerable:!(n=m(t,o))||n.enumerable});return r};var g=(r,t,e)=>(e=r!=null?x(y(r)):{},p(t||!r||!r.__esModule?s(e,"default",{value:r,enumerable:!0}):e,r)),P=r=>p(s({},"__esModule",{value:!0}),r),l=(r,t,e,n)=>{for(var o=n>1?void 0:n?m(t,e):t,i=r.length-1,d;i>=0;i--)(d=r[i])&&(o=(n?d(t,e,o):d(o))||o);return n&&o&&s(t,e,o),o},u=(r,t)=>(e,n)=>t(e,n,r);var $={};M($,{HttpTokenDataSource:()=>a});module.exports=P($);var h=g(require("axios")),f=require("inversify"),c=require("purify-ts"),k=require("../../config/di/configTypes"),C=g(require("../../../package.json"));let a=class{constructor(t){this.config=t}async getTokenInfosPayload({chainId:t,address:e}){try{const o=(await h.default.request({method:"GET",url:`${this.config.cal.url}/tokens`,params:{contract_address:e,chain_id:t,output:"descriptor,ticker",ref:`branch:${this.config.cal.branch}`},headers:{"X-Ledger-Client-Version":`context-module/${C.default.version}`}})).data?.[0];if(!o||!o.ticker||!o.descriptor||!o.descriptor.data||!o.descriptor.signatures||typeof o.descriptor.signatures[this.config.cal.mode]!="string")return(0,c.Left)(new Error(`[ContextModule] HttpTokenDataSource: no token metadata for address ${e} on chain ${t}`));const i=o.ticker.length.toString(16).padStart(2,"0");return(0,c.Right)([i,o.descriptor.data,o.descriptor.signatures[this.config.cal.mode]].join(""))}catch{return(0,c.Left)(new Error("[ContextModule] HttpTokenDataSource: Failed to fetch token informations"))}}};a=l([(0,f.injectable)(),u(0,(0,f.inject)(k.configTypes.Config))],a);0&&(module.exports={HttpTokenDataSource});
2
+ //# sourceMappingURL=HttpTokenDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/token/data/HttpTokenDataSource.ts"],
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport type { ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { GetTokenInfosParams, TokenDataSource } from \"./TokenDataSource\";\nimport { TokenDto } from \"./TokenDto\";\n\n@injectable()\nexport class HttpTokenDataSource implements TokenDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n public async getTokenInfosPayload({\n chainId,\n address,\n }: GetTokenInfosParams): Promise<Either<Error, string>> {\n try {\n const response = await axios.request<TokenDto[]>({\n method: \"GET\",\n url: `${this.config.cal.url}/tokens`,\n params: {\n contract_address: address,\n chain_id: chainId,\n output: \"descriptor,ticker\",\n ref: `branch:${this.config.cal.branch}`,\n },\n headers: {\n \"X-Ledger-Client-Version\": `context-module/${PACKAGE.version}`,\n },\n });\n const tokenInfos = response.data?.[0];\n\n if (\n !tokenInfos ||\n !tokenInfos.ticker ||\n !tokenInfos.descriptor ||\n !tokenInfos.descriptor.data ||\n !tokenInfos.descriptor.signatures ||\n typeof tokenInfos.descriptor.signatures[this.config.cal.mode] !==\n \"string\"\n ) {\n return Left(\n new Error(\n `[ContextModule] HttpTokenDataSource: no token metadata for address ${address} on chain ${chainId}`,\n ),\n );\n }\n\n // 1 byte for the length of the ticker\n const tickerLengthBuff = tokenInfos.ticker.length\n .toString(16)\n .padStart(2, \"0\");\n\n return Right(\n [\n tickerLengthBuff,\n tokenInfos.descriptor.data,\n tokenInfos.descriptor.signatures[this.config.cal.mode],\n ].join(\"\"),\n );\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTokenDataSource: Failed to fetch token informations\",\n ),\n );\n }\n }\n}\n"],
5
+ "mappings": "qtBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkB,oBAClBC,EAAmC,qBACnCC,EAAoC,qBAEpCC,EAA4B,mCAE5BC,EAAoB,iCAMb,IAAMC,EAAN,KAAqD,CAC1D,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CACH,MAAa,qBAAqB,CAChC,QAAAC,EACA,QAAAC,CACF,EAAwD,CACtD,GAAI,CAcF,MAAMC,GAbW,MAAM,EAAAC,QAAM,QAAoB,CAC/C,OAAQ,MACR,IAAK,GAAG,KAAK,OAAO,IAAI,GAAG,UAC3B,OAAQ,CACN,iBAAkBF,EAClB,SAAUD,EACV,OAAQ,oBACR,IAAK,UAAU,KAAK,OAAO,IAAI,MAAM,EACvC,EACA,QAAS,CACP,0BAA2B,kBAAkB,EAAAI,QAAQ,OAAO,EAC9D,CACF,CAAC,GAC2B,OAAO,CAAC,EAEpC,GACE,CAACF,GACD,CAACA,EAAW,QACZ,CAACA,EAAW,YACZ,CAACA,EAAW,WAAW,MACvB,CAACA,EAAW,WAAW,YACvB,OAAOA,EAAW,WAAW,WAAW,KAAK,OAAO,IAAI,IAAI,GAC1D,SAEF,SAAO,QACL,IAAI,MACF,sEAAsED,CAAO,aAAaD,CAAO,EACnG,CACF,EAIF,MAAMK,EAAmBH,EAAW,OAAO,OACxC,SAAS,EAAE,EACX,SAAS,EAAG,GAAG,EAElB,SAAO,SACL,CACEG,EACAH,EAAW,WAAW,KACtBA,EAAW,WAAW,WAAW,KAAK,OAAO,IAAI,IAAI,CACvD,EAAE,KAAK,EAAE,CACX,CACF,MAAiB,CACf,SAAO,QACL,IAAI,MACF,yEACF,CACF,CACF,CACF,CACF,EA5DaJ,EAANQ,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,cAAY,MAAM,IAFjBT",
6
+ "names": ["HttpTokenDataSource_exports", "__export", "HttpTokenDataSource", "__toCommonJS", "import_axios", "import_inversify", "import_purify_ts", "import_configTypes", "import_package", "HttpTokenDataSource", "config", "chainId", "address", "tokenInfos", "axios", "PACKAGE", "tickerLengthBuff", "__decorateClass", "__decorateParam"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var u=Object.create;var d=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var m=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var h=(t,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of k(e))!x.call(t,r)&&r!==o&&d(t,r,{get:()=>e[r],enumerable:!(s=p(e,r))||s.enumerable});return t};var c=(t,e,o)=>(o=t!=null?u(m(t)):{},h(e||!t||!t.__esModule?d(o,"default",{value:t,enumerable:!0}):o,t));var a=c(require("axios")),n=require("purify-ts"),i=require("../../token/data/HttpTokenDataSource"),l=c(require("../../../package.json"));jest.mock("axios");describe("HttpTokenDataSource",()=>{let t;beforeAll(()=>{const e={cal:{url:"https://crypto-assets-service.api.ledger.com/v1",mode:"prod",branch:"main"}};t=new i.HttpTokenDataSource(e),jest.clearAllMocks()}),it("should call axios with the ledger client version header",async()=>{const e=`context-module/${l.default.version}`,o=jest.fn(()=>Promise.resolve({data:[]}));jest.spyOn(a.default,"request").mockImplementation(o),await t.getTokenInfosPayload({address:"0x00",chainId:1}),expect(o).toHaveBeenCalledWith(expect.objectContaining({headers:{"X-Ledger-Client-Version":e}}))}),it("should return a string when axios response is correct",async()=>{const e={ticker:"USDC",descriptor:{data:"55534443000000000800000001",signatures:{prod:"0123"}}};jest.spyOn(a.default,"request").mockResolvedValue({data:[e]});const o=await t.getTokenInfosPayload({address:"0x00",chainId:1});expect(o.extract()).toEqual("04555344430000000008000000010123")}),it("should return an error when data is empty",async()=>{jest.spyOn(a.default,"request").mockResolvedValue({data:void 0});const e=await t.getTokenInfosPayload({address:"0x00",chainId:1});expect(e).toEqual((0,n.Left)(new Error("[ContextModule] HttpTokenDataSource: no token metadata for address 0x00 on chain 1")))}),it("should return undefined when no signature",async()=>{jest.spyOn(a.default,"request").mockResolvedValue({data:[{}]});const e=await t.getTokenInfosPayload({address:"0x00",chainId:1});expect(e).toEqual((0,n.Left)(new Error("[ContextModule] HttpTokenDataSource: no token metadata for address 0x00 on chain 1")))}),it("should return undefined when no ticker",async()=>{const e={ticker:"USDC",descriptor:{data:"55534443000000000800000001",signatures:{test:"0123"}}};jest.spyOn(a.default,"request").mockResolvedValue({data:[e]});const o=await t.getTokenInfosPayload({address:"0x00",chainId:1});expect(o).toEqual((0,n.Left)(new Error("[ContextModule] HttpTokenDataSource: no token metadata for address 0x00 on chain 1")))}),it("should return undefined when no decimals",async()=>{jest.spyOn(a.default,"request").mockResolvedValue({data:[{live_signature:"0x0",ticker:"USDC"}]});const e=await t.getTokenInfosPayload({address:"0x00",chainId:1});expect(e).toEqual((0,n.Left)(new Error("[ContextModule] HttpTokenDataSource: no token metadata for address 0x00 on chain 1")))}),it("should return an error when axios throws an error",async()=>{jest.spyOn(a.default,"request").mockRejectedValue(new Error);const e=await t.getTokenInfosPayload({address:"0x00",chainId:1});expect(e).toEqual((0,n.Left)(new Error("[ContextModule] HttpTokenDataSource: Failed to fetch token informations")))})});
2
+ //# sourceMappingURL=HttpTokenDataSource.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/token/data/HttpTokenDataSource.test.ts"],
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { Left } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { HttpTokenDataSource } from \"@/token/data/HttpTokenDataSource\";\nimport { type TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { type TokenDto } from \"@/token/data/TokenDto\";\nimport PACKAGE from \"@root/package.json\";\n\njest.mock(\"axios\");\n\ndescribe(\"HttpTokenDataSource\", () => {\n let datasource: TokenDataSource;\n\n beforeAll(() => {\n const config = {\n cal: {\n url: \"https://crypto-assets-service.api.ledger.com/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n } as ContextModuleConfig;\n datasource = new HttpTokenDataSource(config);\n jest.clearAllMocks();\n });\n\n it(\"should call axios with the ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = jest.fn(() => Promise.resolve({ data: [] }));\n jest.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getTokenInfosPayload({ address: \"0x00\", chainId: 1 });\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: { \"X-Ledger-Client-Version\": version },\n }),\n );\n });\n\n it(\"should return a string when axios response is correct\", async () => {\n // GIVEN\n const tokenDTO: TokenDto = {\n ticker: \"USDC\",\n descriptor: {\n data: \"55534443000000000800000001\",\n signatures: {\n prod: \"0123\",\n },\n },\n };\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: [tokenDTO] });\n\n // WHEN\n const result = await datasource.getTokenInfosPayload({\n address: \"0x00\",\n chainId: 1,\n });\n\n // THEN\n expect(result.extract()).toEqual(\"04555344430000000008000000010123\");\n });\n\n it(\"should return an error when data is empty\", async () => {\n // GIVEN\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: undefined });\n\n // WHEN\n const result = await datasource.getTokenInfosPayload({\n address: \"0x00\",\n chainId: 1,\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTokenDataSource: no token metadata for address 0x00 on chain 1\",\n ),\n ),\n );\n });\n\n it(\"should return undefined when no signature\", async () => {\n // GIVEN\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: [{}] });\n\n // WHEN\n const result = await datasource.getTokenInfosPayload({\n address: \"0x00\",\n chainId: 1,\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTokenDataSource: no token metadata for address 0x00 on chain 1\",\n ),\n ),\n );\n });\n\n it(\"should return undefined when no ticker\", async () => {\n // GIVEN\n const tokenDTO: TokenDto = {\n ticker: \"USDC\",\n descriptor: {\n data: \"55534443000000000800000001\",\n signatures: {\n test: \"0123\",\n },\n },\n };\n jest.spyOn(axios, \"request\").mockResolvedValue({ data: [tokenDTO] });\n\n // WHEN\n const result = await datasource.getTokenInfosPayload({\n address: \"0x00\",\n chainId: 1,\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTokenDataSource: no token metadata for address 0x00 on chain 1\",\n ),\n ),\n );\n });\n\n it(\"should return undefined when no decimals\", async () => {\n // GIVEN\n jest\n .spyOn(axios, \"request\")\n .mockResolvedValue({ data: [{ live_signature: \"0x0\", ticker: \"USDC\" }] });\n\n // WHEN\n const result = await datasource.getTokenInfosPayload({\n address: \"0x00\",\n chainId: 1,\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTokenDataSource: no token metadata for address 0x00 on chain 1\",\n ),\n ),\n );\n });\n\n it(\"should return an error when axios throws an error\", async () => {\n // GIVEN\n jest.spyOn(axios, \"request\").mockRejectedValue(new Error());\n\n // WHEN\n const result = await datasource.getTokenInfosPayload({\n address: \"0x00\",\n chainId: 1,\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTokenDataSource: Failed to fetch token informations\",\n ),\n ),\n );\n });\n});\n"],
5
+ "mappings": "wdAAA,IAAAA,EAAkB,oBAClBC,EAAqB,qBAGrBC,EAAoC,4CAGpCC,EAAoB,iCAEpB,KAAK,KAAK,OAAO,EAEjB,SAAS,sBAAuB,IAAM,CACpC,IAAIC,EAEJ,UAAU,IAAM,CACd,MAAMC,EAAS,CACb,IAAK,CACH,IAAK,kDACL,KAAM,OACN,OAAQ,MACV,CACF,EACAD,EAAa,IAAI,sBAAoBC,CAAM,EAC3C,KAAK,cAAc,CACrB,CAAC,EAED,GAAG,0DAA2D,SAAY,CAExE,MAAMC,EAAU,kBAAkB,EAAAC,QAAQ,OAAO,GAC3CC,EAAa,KAAK,GAAG,IAAM,QAAQ,QAAQ,CAAE,KAAM,CAAC,CAAE,CAAC,CAAC,EAC9D,KAAK,MAAM,EAAAC,QAAO,SAAS,EAAE,mBAAmBD,CAAU,EAG1D,MAAMJ,EAAW,qBAAqB,CAAE,QAAS,OAAQ,QAAS,CAAE,CAAC,EAGrE,OAAOI,CAAU,EAAE,qBACjB,OAAO,iBAAiB,CACtB,QAAS,CAAE,0BAA2BF,CAAQ,CAChD,CAAC,CACH,CACF,CAAC,EAED,GAAG,wDAAyD,SAAY,CAEtE,MAAMI,EAAqB,CACzB,OAAQ,OACR,WAAY,CACV,KAAM,6BACN,WAAY,CACV,KAAM,MACR,CACF,CACF,EACA,KAAK,MAAM,EAAAD,Q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ME,EAAS,MAAMP,EAAW,qBAAqB,CACnD,QAAS,OACT,QAAS,CACX,CAAC,EAGD,OAAOO,CAAM,EAAE,WACb,QACE,IAAI,MACF,oFACF,CACF,CACF,CACF,CAAC,EAED,GAAG,oDAAqD,SAAY,CAElE,KAAK,MAAM,EAAAF,QAAO,SAAS,EAAE,kBAAkB,IAAI,KAAO,EAG1D,MAAME,EAAS,MAAMP,EAAW,qBAAqB,CACnD,QAAS,OACT,QAAS,CACX,CAAC,EAGD,OAAOO,CAAM,EAAE,WACb,QACE,IAAI,MACF,yEACF,CACF,CACF,CACF,CAAC,CACH,CAAC",
6
+ "names": ["import_axios", "import_purify_ts", "import_HttpTokenDataSource", "import_package", "datasource", "config", "version", "PACKAGE", "requestSpy", "axios", "tokenDTO", "result"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var a=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var p=(r,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of i(e))!m.call(r,o)&&o!==n&&a(r,o,{get:()=>e[o],enumerable:!(t=s(e,o))||t.enumerable});return r};var f=r=>p(a({},"__esModule",{value:!0}),r);var d={};module.exports=f(d);
2
+ //# sourceMappingURL=TokenDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/token/data/TokenDataSource.ts"],
4
+ "sourcesContent": ["import { type Either } from \"purify-ts\";\n\nexport type GetTokenInfosParams = {\n address: string;\n chainId: number;\n};\n\nexport interface TokenDataSource {\n getTokenInfosPayload(\n params: GetTokenInfosParams,\n ): Promise<Either<Error, string>>;\n}\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["TokenDataSource_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var n=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var k=(r,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of p(t))!g.call(r,e)&&e!==o&&n(r,e,{get:()=>t[e],enumerable:!(s=i(t,e))||s.enumerable});return r};var a=r=>k(n({},"__esModule",{value:!0}),r);var T={};module.exports=a(T);
2
+ //# sourceMappingURL=TokenDto.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/token/data/TokenDto.ts"],
4
+ "sourcesContent": ["export type TokenSignatures =\n | {\n prod: string;\n test?: string;\n }\n | {\n prod?: string;\n test: string;\n };\n\nexport type TokenDescriptor = {\n data: string;\n signatures: TokenSignatures;\n};\n\nexport type TokenDto = {\n ticker: string;\n descriptor: TokenDescriptor;\n};\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["TokenDto_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var a=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var c=(o,t)=>{for(var e in t)a(o,e,{get:t[e],enumerable:!0})},f=(o,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of u(t))!T.call(o,r)&&r!==e&&a(o,r,{get:()=>t[r],enumerable:!(n=k(t,r))||n.enumerable});return o};var s=o=>f(a({},"__esModule",{value:!0}),o);var C={};c(C,{tokenModuleFactory:()=>x});module.exports=s(C);var i=require("inversify"),p=require("../../token/data/HttpTokenDataSource"),m=require("../../token/di/tokenTypes"),d=require("../../token/domain/TokenContextLoader");const x=()=>new i.ContainerModule((o,t,e,n)=>{o(m.tokenTypes.TokenDataSource).to(p.HttpTokenDataSource),o(m.tokenTypes.TokenContextLoader).to(d.TokenContextLoader)});0&&(module.exports={tokenModuleFactory});
2
+ //# sourceMappingURL=tokenModuleFactory.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/token/di/tokenModuleFactory.ts"],
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpTokenDataSource } from \"@/token/data/HttpTokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\nimport { TokenContextLoader } from \"@/token/domain/TokenContextLoader\";\n\nexport const tokenModuleFactory = () =>\n new ContainerModule((bind, _unbind, _isBound, _rebind) => {\n bind(tokenTypes.TokenDataSource).to(HttpTokenDataSource);\n bind(tokenTypes.TokenContextLoader).to(TokenContextLoader);\n });\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,qBAEhCC,EAAoC,4CACpCC,EAA2B,iCAC3BC,EAAmC,6CAE5B,MAAML,EAAqB,IAChC,IAAI,kBAAgB,CAACM,EAAMC,EAASC,EAAUC,IAAY,CACxDH,EAAK,aAAW,eAAe,EAAE,GAAG,qBAAmB,EACvDA,EAAK,aAAW,kBAAkB,EAAE,GAAG,oBAAkB,CAC3D,CAAC",
6
+ "names": ["tokenModuleFactory_exports", "__export", "tokenModuleFactory", "__toCommonJS", "import_inversify", "import_HttpTokenDataSource", "import_tokenTypes", "import_TokenContextLoader", "bind", "_unbind", "_isBound", "_rebind"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var r=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var c=(e,o)=>{for(var n in o)r(e,n,{get:o[n],enumerable:!0})},x=(e,o,n,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of T(o))!S.call(e,t)&&t!==n&&r(e,t,{get:()=>o[t],enumerable:!(a=k(o,t))||a.enumerable});return e};var y=e=>x(r({},"__esModule",{value:!0}),e);var d={};c(d,{tokenTypes:()=>b});module.exports=y(d);const b={TokenDataSource:Symbol.for("TokenDataSource"),TokenContextLoader:Symbol.for("TokenContextLoader")};0&&(module.exports={tokenTypes});
2
+ //# sourceMappingURL=tokenTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/token/di/tokenTypes.ts"],
4
+ "sourcesContent": ["export const tokenTypes = {\n TokenDataSource: Symbol.for(\"TokenDataSource\"),\n TokenContextLoader: Symbol.for(\"TokenContextLoader\"),\n};\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAa,CACxB,gBAAiB,OAAO,IAAI,iBAAiB,EAC7C,mBAAoB,OAAO,IAAI,oBAAoB,CACrD",
6
+ "names": ["tokenTypes_exports", "__export", "tokenTypes", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var s=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var C=(o,e)=>{for(var t in e)s(o,t,{get:e[t],enumerable:!0})},T=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of f(e))!g.call(o,a)&&a!==t&&s(o,a,{get:()=>e[a],enumerable:!(r=u(e,a))||r.enumerable});return o};var h=o=>T(s({},"__esModule",{value:!0}),o),S=(o,e,t,r)=>{for(var a=r>1?void 0:r?u(e,t):e,c=o.length-1,p;c>=0;c--)(p=o[c])&&(a=(r?p(e,t,a):p(a))||a);return r&&a&&s(e,t,a),a},x=(o,e)=>(t,r)=>e(t,r,o);var I={};C(I,{ERC20_SUPPORTED_SELECTORS:()=>d,TokenContextLoader:()=>i});module.exports=h(I);var m=require("@ledgerhq/device-management-kit"),l=require("inversify"),n=require("../../shared/model/ClearSignContext"),y=require("../../token/di/tokenTypes");var d=(t=>(t.Approve="0x095ea7b3",t.Transfer="0xa9059cbb",t))(d||{});const O=Object.values(d);let i=class{_dataSource;constructor(e){this._dataSource=e}async load(e){if(!e.to||!e.data||e.data==="0x")return[];const t=e.data.slice(0,10);return(0,m.isHexaString)(t)?this.isSelectorSupported(t)?[(await this._dataSource.getTokenInfosPayload({address:e.to,chainId:e.chainId})).caseOf({Left:a=>({type:n.ClearSignContextType.ERROR,error:a}),Right:a=>({type:n.ClearSignContextType.TOKEN,payload:a})})]:[]:[{type:n.ClearSignContextType.ERROR,error:new Error("Invalid selector")}]}async loadField(e){return e.type!==n.ClearSignContextType.TOKEN?null:(await this._dataSource.getTokenInfosPayload({address:e.address,chainId:e.chainId})).caseOf({Left:r=>({type:n.ClearSignContextType.ERROR,error:r}),Right:r=>({type:n.ClearSignContextType.TOKEN,payload:r})})}isSelectorSupported(e){return Object.values(O).includes(e)}};i=S([(0,l.injectable)(),x(0,(0,l.inject)(y.tokenTypes.TokenDataSource))],i);0&&(module.exports={ERC20_SUPPORTED_SELECTORS,TokenContextLoader});
2
+ //# sourceMappingURL=TokenContextLoader.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/token/domain/TokenContextLoader.ts"],
4
+ "sourcesContent": ["import { HexaString, isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport {\n TransactionContext,\n TransactionFieldContext,\n} from \"@/shared/model/TransactionContext\";\nimport type { TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\n\nexport enum ERC20_SUPPORTED_SELECTORS {\n Approve = \"0x095ea7b3\",\n Transfer = \"0xa9059cbb\",\n}\n\nconst SUPPORTED_SELECTORS: HexaString[] = Object.values(\n ERC20_SUPPORTED_SELECTORS,\n);\n\n@injectable()\nexport class TokenContextLoader implements ContextLoader {\n private _dataSource: TokenDataSource;\n\n constructor(@inject(tokenTypes.TokenDataSource) dataSource: TokenDataSource) {\n this._dataSource = dataSource;\n }\n\n async load(transaction: TransactionContext): Promise<ClearSignContext[]> {\n if (!transaction.to || !transaction.data || transaction.data === \"0x\") {\n return [];\n }\n\n const selector = transaction.data.slice(0, 10);\n\n if (!isHexaString(selector)) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ];\n }\n\n if (!this.isSelectorSupported(selector)) {\n return [];\n }\n\n const payload = await this._dataSource.getTokenInfosPayload({\n address: transaction.to,\n chainId: transaction.chainId,\n });\n\n return [\n payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TOKEN,\n payload: value,\n }),\n }),\n ];\n }\n\n async loadField(\n field: TransactionFieldContext,\n ): Promise<ClearSignContext | null> {\n if (field.type !== ClearSignContextType.TOKEN) {\n return null;\n }\n const payload = await this._dataSource.getTokenInfosPayload({\n address: field.address,\n chainId: field.chainId,\n });\n return payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TOKEN,\n payload: value,\n }),\n });\n }\n\n private isSelectorSupported(selector: HexaString) {\n return Object.values(SUPPORTED_SELECTORS).includes(selector);\n }\n}\n"],
5
+ "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,EAAA,uBAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAAyC,2CACzCC,EAAmC,qBAGnCC,EAGO,2CAMPC,EAA2B,iCAEpB,IAAKC,OACVA,EAAA,QAAU,aACVA,EAAA,SAAW,aAFDA,OAAA,IAKZ,MAAMC,EAAoC,OAAO,OAC/CD,CACF,EAGO,IAAME,EAAN,KAAkD,CAC/C,YAER,YAAgDC,EAA6B,CAC3E,KAAK,YAAcA,CACrB,CAEA,MAAM,KAAKC,EAA8D,CACvE,GAAI,CAACA,EAAY,IAAM,CAACA,EAAY,MAAQA,EAAY,OAAS,KAC/D,MAAO,CAAC,EAGV,MAAMC,EAAWD,EAAY,KAAK,MAAM,EAAG,EAAE,EAE7C,SAAK,gBAAaC,CAAQ,EASrB,KAAK,oBAAoBA,CAAQ,EAS/B,EALS,MAAM,KAAK,YAAY,qBAAqB,CAC1D,QAASD,EAAY,GACrB,QAASA,EAAY,OACvB,CAAC,GAGS,OAAO,CACb,KAAOE,IAA6B,CAClC,KAAM,uBAAqB,MAC3B,MAAAA,CACF,GACA,MAAQC,IAA6B,CACnC,KAAM,uBAAqB,MAC3B,QAASA,CACX,EACF,CAAC,CACH,EAnBS,CAAC,EATD,CACL,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,kBAAkB,CACrC,CACF,CAwBJ,CAEA,MAAM,UACJC,EACkC,CAClC,OAAIA,EAAM,OAAS,uBAAqB,MAC/B,MAEO,MAAM,KAAK,YAAY,qBAAqB,CAC1D,QAASA,EAAM,QACf,QAASA,EAAM,OACjB,CAAC,GACc,OAAO,CACpB,KAAOF,IAA6B,CAClC,KAAM,uBAAqB,MAC3B,MAAAA,CACF,GACA,MAAQC,IAA6B,CACnC,KAAM,uBAAqB,MAC3B,QAASA,CACX,EACF,CAAC,CACH,CAEQ,oBAAoBF,EAAsB,CAChD,OAAO,OAAO,OAAOJ,CAAmB,EAAE,SAASI,CAAQ,CAC7D,CACF,EAvEaH,EAANO,EAAA,IADN,cAAW,EAIGC,EAAA,eAAO,aAAW,eAAe,IAHnCR",
6
+ "names": ["TokenContextLoader_exports", "__export", "ERC20_SUPPORTED_SELECTORS", "TokenContextLoader", "__toCommonJS", "import_device_management_kit", "import_inversify", "import_ClearSignContext", "import_tokenTypes", "ERC20_SUPPORTED_SELECTORS", "SUPPORTED_SELECTORS", "TokenContextLoader", "dataSource", "transaction", "selector", "error", "value", "field", "__decorateClass", "__decorateParam"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var n=require("purify-ts"),o=require("../../shared/model/ClearSignContext"),s=require("../../token/domain/TokenContextLoader");describe("TokenContextLoader",()=>{const r={getTokenInfosPayload:jest.fn()},a=new s.TokenContextLoader(r);beforeEach(()=>{jest.restoreAllMocks(),jest.spyOn(r,"getTokenInfosPayload").mockImplementation(({address:t})=>Promise.resolve((0,n.Right)(`payload-${t}`)))}),describe("load function",()=>{it("should return an empty array if transaction dest is undefined",async()=>{const t={to:void 0,data:"0x01"},e=await a.load(t);expect(e).toEqual([])}),it("should return an empty array if transaction data is undefined",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:void 0},e=await a.load(t);expect(e).toEqual([])}),it("should return an empty array if transaction data is empty",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x"},e=await a.load(t);expect(e).toEqual([])}),it("should return an empty array if the selector is not supported",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x095ea7b20000000000000"},e=await a.load(t);expect(e).toEqual([])}),it("should return an error when transaction data is not a valid hex string",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"notahexstring"},e=await a.load(t);expect(e).toEqual([{type:o.ClearSignContextType.ERROR,error:new Error("Invalid selector")}])}),it("should return an error when datasource returns an error",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x095ea7b30000000000",chainId:1};jest.spyOn(r,"getTokenInfosPayload").mockResolvedValue((0,n.Left)(new Error("error")));const e=await a.load(t);expect(e).toEqual([{type:o.ClearSignContextType.ERROR,error:new Error("error")}])}),it("should return a correct response",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x095ea7b30000000000",chainId:1},e=await a.load(t);expect(e).toEqual([{type:o.ClearSignContextType.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"}])})}),describe("loadField function",()=>{it("should return an error when field type if not supported",async()=>{const t={type:o.ClearSignContextType.NFT,chainId:7,address:"0x1234"},e=await a.loadField(t);expect(e).toEqual(null)}),it("should return a payload",async()=>{const t={type:o.ClearSignContextType.TOKEN,chainId:7,address:"0x1234"};jest.spyOn(r,"getTokenInfosPayload").mockResolvedValue((0,n.Right)("payload"));const e=await a.loadField(t);expect(e).toEqual({type:o.ClearSignContextType.TOKEN,payload:"payload"})}),it("should return an error when unable to fetch the datasource",async()=>{const t={type:o.ClearSignContextType.TOKEN,chainId:7,address:"0x1234"};jest.spyOn(r,"getTokenInfosPayload").mockResolvedValue((0,n.Left)(new Error("error")));const e=await a.loadField(t);expect(e).toEqual({type:o.ClearSignContextType.ERROR,error:new Error("error")})})})});
2
+ //# sourceMappingURL=TokenContextLoader.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/token/domain/TokenContextLoader.test.ts"],
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"@/shared/model/TransactionContext\";\nimport { type TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { TokenContextLoader } from \"@/token/domain/TokenContextLoader\";\n\ndescribe(\"TokenContextLoader\", () => {\n const mockTokenDataSource: TokenDataSource = {\n getTokenInfosPayload: jest.fn(),\n };\n const loader = new TokenContextLoader(mockTokenDataSource);\n\n beforeEach(() => {\n jest.restoreAllMocks();\n jest\n .spyOn(mockTokenDataSource, \"getTokenInfosPayload\")\n .mockImplementation(({ address }) =>\n Promise.resolve(Right(`payload-${address}`)),\n );\n });\n\n describe(\"load function\", () => {\n it(\"should return an empty array if transaction dest is undefined\", async () => {\n // GIVEN\n const transaction = { to: undefined, data: \"0x01\" } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if transaction data is undefined\", async () => {\n // GIVEN\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: undefined,\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if transaction data is empty\", async () => {\n // GIVEN\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if the selector is not supported\", async () => {\n // GIVEN\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x095ea7b20000000000000\",\n } as unknown as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an error when transaction data is not a valid hex string\", async () => {\n // GIVEN\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"notahexstring\",\n } as unknown as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ]);\n });\n\n it(\"should return an error when datasource returns an error\", async () => {\n // GIVEN\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x095ea7b30000000000\",\n chainId: 1,\n } as TransactionContext;\n jest\n .spyOn(mockTokenDataSource, \"getTokenInfosPayload\")\n .mockResolvedValue(Left(new Error(\"error\")));\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n { type: ClearSignContextType.ERROR, error: new Error(\"error\") },\n ]);\n });\n\n it(\"should return a correct response\", async () => {\n // GIVEN\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x095ea7b30000000000\",\n chainId: 1,\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n ]);\n });\n });\n\n describe(\"loadField function\", () => {\n it(\"should return an error when field type if not supported\", async () => {\n const field: TransactionFieldContext = {\n type: ClearSignContextType.NFT,\n chainId: 7,\n address: \"0x1234\",\n };\n\n const result = await loader.loadField(field);\n\n expect(result).toEqual(null);\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TOKEN,\n chainId: 7,\n address: \"0x1234\",\n };\n\n // WHEN\n jest\n .spyOn(mockTokenDataSource, \"getTokenInfosPayload\")\n .mockResolvedValue(Right(\"payload\"));\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.TOKEN,\n payload: \"payload\",\n });\n });\n\n it(\"should return an error when unable to fetch the datasource\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TOKEN,\n chainId: 7,\n address: \"0x1234\",\n };\n\n // WHEN\n jest\n .spyOn(mockTokenDataSource, \"getTokenInfosPayload\")\n .mockResolvedValue(Left(new Error(\"error\")));\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n });\n });\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAA4B,qBAE5BC,EAAqC,2CAMrCC,EAAmC,6CAEnC,SAAS,qBAAsB,IAAM,CACnC,MAAMC,EAAuC,CAC3C,qBAAsB,KAAK,GAAG,CAChC,EACMC,EAAS,IAAI,qBAAmBD,CAAmB,EAEzD,WAAW,IAAM,CACf,KAAK,gBAAgB,EACrB,KACG,MAAMA,EAAqB,sBAAsB,EACjD,mBAAmB,CAAC,CAAE,QAAAE,CAAQ,IAC7B,QAAQ,WAAQ,SAAM,WAAWA,CAAO,EAAE,CAAC,CAC7C,CACJ,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,GAAG,gEAAiE,SAAY,CAE9E,MAAMC,EAAc,CAAE,GAAI,OAAW,KAAM,M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,MAAMD,EAAc,CAClB,GAAI,6CACJ,KAAM,uBACN,QAAS,CACX,EAGMC,EAAS,MAAMH,EAAO,KAAKE,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CACrB,CACE,KAAM,uBAAqB,MAC3B,QAAS,oDACX,CACF,CAAC,CACH,CAAC,CACH,CAAC,EAED,SAAS,qBAAsB,IAAM,CACnC,GAAG,0DAA2D,SAAY,CACxE,MAAMC,EAAiC,CACrC,KAAM,uBAAqB,IAC3B,QAAS,EACT,QAAS,QACX,EAEMD,EAAS,MAAMH,EAAO,UAAUI,CAAK,EAE3C,OAAOD,CAAM,EAAE,QAAQ,IAAI,CAC7B,CAAC,EAED,GAAG,0BAA2B,SAAY,CAExC,MAAMC,EAAiC,CACrC,KAAM,uBAAqB,MAC3B,QAAS,EACT,QAAS,QACX,EAGA,KACG,MAAML,EAAqB,sBAAsB,EACjD,qBAAkB,SAAM,SAAS,CAAC,EACrC,MAAMI,EAAS,MAAMH,EAAO,UAAUI,CAAK,EAG3C,OAAOD,CAAM,EAAE,QAAQ,CACrB,KAAM,uBAAqB,MAC3B,QAAS,SACX,CAAC,CACH,CAAC,EAED,GAAG,6DAA8D,SAAY,CAE3E,MAAMC,EAAiC,CACrC,KAAM,uBAAqB,MAC3B,QAAS,EACT,QAAS,QACX,EAGA,KACG,MAAML,EAAqB,sBAAsB,EACjD,qBAAkB,QAAK,IAAI,MAAM,OAAO,CAAC,CAAC,EAC7C,MAAMI,EAAS,MAAMH,EAAO,UAAUI,CAAK,EAG3C,OAAOD,CAAM,EAAE,QAAQ,CACrB,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,OAAO,CAC1B,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_purify_ts", "import_ClearSignContext", "import_TokenContextLoader", "mockTokenDataSource", "loader", "address", "transaction", "result", "field"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var l=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var n=(t,a,p,r)=>{if(a&&typeof a=="object"||typeof a=="function")for(let e of o(a))!s.call(t,e)&&e!==p&&l(t,e,{get:()=>a[e],enumerable:!(r=i(a,e))||r.enumerable});return t};var c=t=>n(l({},"__esModule",{value:!0}),t);var d={};module.exports=c(d);
2
+ //# sourceMappingURL=CalldataDto.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/transaction/data/CalldataDto.ts"],
4
+ "sourcesContent": ["export interface CalldataDto {\n descriptors_calldata: {\n [address: string]: {\n [selector: string]: CalldataDescriptor;\n };\n };\n}\n\nexport type CalldataDescriptor = CalldataDescriptorV1; // For now only V1 descriptors are supported\n\nexport interface CalldataDescriptorV1 {\n type: \"calldata\";\n version: \"v1\";\n transaction_info: CalldataTransactionInfoV1;\n enums: CalldataEnumV1[];\n fields: CalldataFieldV1[];\n}\n\nexport type CalldataTransactionDescriptor = {\n data: string;\n signatures: CalldataSignatures;\n};\n\nexport type CalldataSignatures =\n | {\n prod: string;\n test?: string;\n }\n | {\n prod?: string;\n test: string;\n };\n\nexport interface CalldataTransactionInfoV1 {\n descriptor: CalldataTransactionDescriptor;\n}\n\nexport interface CalldataEnumV1 {\n descriptor: string;\n}\n\nexport interface CalldataFieldV1 {\n descriptor: string;\n param: CalldataDescriptorParam;\n}\n\nexport type CalldataDescriptorParam =\n | CalldataDescriptorParamRawV1\n | CalldataDescriptorParamAmountV1\n | CalldataDescriptorParamTokenAmountV1\n | CalldataDescriptorParamNFTV1\n | CalldataDescriptorParamDatetimeV1\n | CalldataDescriptorParamDurationV1\n | CalldataDescriptorParamUnitV1\n | CalldataDescriptorParamEnumV1\n | CalldataDescriptorParamTrustedNameV1;\n\nexport interface CalldataDescriptorParamRawV1 {\n type: \"RAW\";\n value: CalldataDescriptorValueV1;\n}\n\nexport interface CalldataDescriptorParamAmountV1 {\n type: \"AMOUNT\";\n value: CalldataDescriptorValueV1;\n}\n\nexport interface CalldataDescriptorParamTokenAmountV1 {\n type: \"TOKEN_AMOUNT\";\n value: CalldataDescriptorValueV1;\n token?: CalldataDescriptorValueV1;\n}\n\nexport interface CalldataDescriptorParamNFTV1 {\n type: \"NFT\";\n value: CalldataDescriptorValueV1;\n collection: CalldataDescriptorValueV1;\n}\n\nexport interface CalldataDescriptorParamDatetimeV1 {\n type: \"DATETIME\";\n value: CalldataDescriptorValueV1;\n}\n\nexport interface CalldataDescriptorParamDurationV1 {\n type: \"DURATION\";\n value: CalldataDescriptorValueV1;\n}\n\nexport interface CalldataDescriptorParamUnitV1 {\n type: \"UNIT\";\n value: CalldataDescriptorValueV1;\n}\n\nexport interface CalldataDescriptorParamEnumV1 {\n type: \"ENUM\";\n value: CalldataDescriptorValueV1;\n}\n\nexport interface CalldataDescriptorParamTrustedNameV1 {\n type: \"TRUSTED_NAME\";\n value: CalldataDescriptorValueV1;\n types: string[];\n sources: string[];\n}\n\nexport interface CalldataDescriptorValueV1 {\n binary_path:\n | CalldataDescriptorContainerPathV1\n | CalldataDescriptorPathElementsV1;\n type_family: CalldataDescriptorTypeFamilyV1;\n type_size?: number;\n}\n\nexport interface CalldataDescriptorContainerPathV1 {\n type: \"CONTAINER\";\n value: CalldataDescriptorContainerPathTypeV1;\n}\n\nexport interface CalldataDescriptorPathElementsV1 {\n type: \"DATA\";\n elements: CalldataDescriptorPathElementV1[];\n}\n\nexport type CalldataDescriptorPathElementV1 =\n | CalldataDescriptorPathElementTupleV1\n | CalldataDescriptorPathElementArrayV1\n | CalldataDescriptorPathElementRefV1\n | CalldataDescriptorPathElementLeafV1\n | CalldataDescriptorPathElementSliceV1;\n\nexport interface CalldataDescriptorPathElementTupleV1 {\n type: \"TUPLE\";\n offset: number;\n}\n\nexport interface CalldataDescriptorPathElementArrayV1 {\n type: \"ARRAY\";\n start?: number;\n length?: number;\n weight: number;\n}\n\nexport interface CalldataDescriptorPathElementRefV1 {\n type: \"REF\";\n}\n\nexport interface CalldataDescriptorPathElementLeafV1 {\n type: \"LEAF\";\n leaf_type: CalldataDescriptorPathLeafTypeV1;\n}\n\nexport interface CalldataDescriptorPathElementSliceV1 {\n type: \"SLICE\";\n start?: number;\n end?: number;\n}\n\nexport type CalldataDescriptorContainerPathTypeV1 = \"FROM\" | \"TO\" | \"VALUE\";\nexport type CalldataDescriptorPathLeafTypeV1 =\n | \"ARRAY_LEAF\"\n | \"TUPLE_LEAF\"\n | \"STATIC_LEAF\"\n | \"DYNAMIC_LEAF\";\nexport type CalldataDescriptorTypeFamilyV1 =\n | \"UINT\"\n | \"INT\"\n | \"UFIXED\"\n | \"FIXED\"\n | \"ADDRESS\"\n | \"BOOL\"\n | \"BYTES\"\n | \"STRING\";\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["CalldataDto_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var _=Object.create;var c=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,M=Object.prototype.hasOwnProperty;var v=(n,e)=>{for(var t in e)c(n,t,{get:e[t],enumerable:!0})},C=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of N(e))!M.call(n,o)&&o!==t&&c(n,o,{get:()=>e[o],enumerable:!(r=u(e,o))||r.enumerable});return n};var m=(n,e,t)=>(t=n!=null?_(S(n)):{},C(e||!n||!n.__esModule?c(t,"default",{value:n,enumerable:!0}):t,n)),I=n=>C(c({},"__esModule",{value:!0}),n),h=(n,e,t,r)=>{for(var o=r>1?void 0:r?u(e,t):e,i=n.length-1,l;i>=0;i--)(l=n[i])&&(o=(r?l(e,t,o):l(o))||o);return r&&o&&c(e,t,o),o},T=(n,e)=>(t,r)=>e(t,r,n);var P={};v(P,{HttpTransactionDataSource:()=>f});module.exports=I(P);var g=m(require("axios")),y=require("inversify"),p=require("purify-ts"),E=require("../../config/di/configTypes"),s=require("../../shared/model/ClearSignContext"),d=m(require("../../../package.json"));let f=class{constructor(e){this.config=e}async getTransactionDescriptors({chainId:e,address:t,selector:r}){let o;try{o=(await g.default.request({method:"GET",url:`${this.config.cal.url}/dapps`,params:{output:"descriptors_calldata",chain_id:e,contracts:t,ref:`branch:${this.config.cal.branch}`},headers:{"X-Ledger-Client-Version":`context-module/${d.default.version}`}})).data?.[0]}catch(a){return(0,p.Left)(new Error(`[ContextModule] HttpTransactionDataSource: Failed to fetch transaction informations: ${a}`))}if(!o)return(0,p.Left)(new Error(`[ContextModule] HttpTransactionDataSource: No generic descriptor for contract ${t}`));t=t.toLowerCase(),r=`0x${r.slice(2).toLowerCase()}`;const i=o.descriptors_calldata?.[t]?.[r];if(!i)return(0,p.Left)(new Error(`[ContextModule] HttpTransactionDataSource: Invalid response for contract ${t} and selector ${r}`));if(!this.isCalldataDescriptorV1(i,this.config.cal.mode))return(0,p.Left)(new Error(`[ContextModule] HttpTransactionDataSource: Failed to decode transaction descriptor for contract ${t} and selector ${r}`));const l=i.transaction_info.descriptor.data,A=i.transaction_info.descriptor.signatures[this.config.cal.mode],D={type:s.ClearSignContextType.TRANSACTION_INFO,payload:this.formatTransactionInfo(l,A)},V=i.enums.map(a=>({type:s.ClearSignContextType.ENUM,payload:a.descriptor})),b=i.fields.map(a=>({type:s.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:a.descriptor,reference:this.getReference(a.param)}));return(0,p.Right)([D,...V,...b])}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:s.ClearSignContextType.TOKEN,valuePath:this.toGenericPath(e.token.binary_path)};if(e.type==="NFT")return{type:s.ClearSignContextType.NFT,valuePath:this.toGenericPath(e.collection.binary_path)};if(e.type==="TRUSTED_NAME")return{type:s.ClearSignContextType.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"))}};f=h([(0,y.injectable)(),T(0,(0,y.inject)(E.configTypes.Config))],f);0&&(module.exports={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": "qtBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkB,oBAClBC,EAAmC,qBACnCC,EAAoC,qBAEpCC,EAA4B,mCAK5BC,EAIO,2CAEPC,EAAoB,iCAqBb,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,MAAM,EAAAC,QAAM,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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,QACzB,MAAM,QAAQA,EAAK,YAAY,QAAQ,GACvCA,EAAK,YAAY,SAAS,MAAOX,GAAM,KAAK,gBAAgBA,CAAC,CAAC,EAEtE,CAEQ,gBAAgBW,EAAgD,CACtE,OACE,OAAOA,GAAS,WACfA,EAAK,OAAS,OACZA,EAAK,OAAS,SAAW,OAAOA,EAAK,QAAW,UAChDA,EAAK,OAAS,SACb,OAAOA,EAAK,QAAW,WACtB,OAAOA,EAAK,MAAU,KACrB,OAAOA,EAAK,OAAU,YACvB,OAAOA,EAAK,OAAW,KACtB,OAAOA,EAAK,QAAW,WAC1BA,EAAK,OAAS,QACb,OAAOA,EAAK,WAAc,UAC1B,CAAC,aAAc,aAAc,cAAe,cAAc,EAAE,SAC1DA,EAAK,SACP,GACDA,EAAK,OAAS,UACZ,OAAOA,EAAK,MAAU,KACrB,OAAOA,EAAK,OAAU,YACvB,OAAOA,EAAK,IAAQ,KAAe,OAAOA,EAAK,KAAQ,UAEhE,CACF,EA9QazB,EAAN4B,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,cAAY,MAAM,IAFjB7B",
6
+ "names": ["HttpTransactionDataSource_exports", "__export", "HttpTransactionDataSource", "__toCommonJS", "import_axios", "import_inversify", "import_purify_ts", "import_configTypes", "import_ClearSignContext", "import_package", "HttpTransactionDataSource", "config", "chainId", "address", "selector", "calldata", "axios", "PACKAGE", "error", "calldataDescriptor", "infoData", "infoSignature", "info", "enums", "e", "fields", "field", "infoSignatureTag", "infoSignatureLength", "param", "path", "element", "itemSize", "rest", "leafType", "data", "mode", "f", "__decorateClass", "__decorateParam"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var A=Object.create;var m=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var O=(t,d,o,s)=>{if(d&&typeof d=="object"||typeof d=="function")for(let i of C(d))!F.call(t,i)&&i!==o&&m(t,i,{get:()=>d[i],enumerable:!(s=w(d,i))||s.enumerable});return t};var T=(t,d,o)=>(o=t!=null?A(_(t)):{},O(d||!t||!t.__esModule?m(o,"default",{value:t,enumerable:!0}):o,t));var c=T(require("axios")),r=require("purify-ts"),D=require("../../transaction/data/HttpTransactionDataSource"),E=T(require("../../../package.json"));jest.mock("axios");describe("HttpTransactionDataSource",()=>{let t,d,o,s,i,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 D.HttpTransactionDataSource(a),d={descriptor:{data:"0001000108000000000000000102147d2768de32b0b80b7a3454c06bdac94a69ddc7a9030469328dec04207d5e9ed0004b8035b164edd9d78c37415ad6b1d123be4943d0abd5a50035cae3050857697468647261770604416176650708416176652044414f081068747470733a2f2f616176652e636f6d0a045fc4ba9c",signatures:{test:"3045022100eb67599abfd9c7360b07599a2a2cb769c6e3f0f74e1e52444d788c8f577a16d20220402e92b0adbf97d890fa2f9654bc30c7bd70dacabe870f160e6842d9eb73d36f"}}},o=[{descriptor:"0001000401000501010606737461626c65"},{descriptor:"00010004010005010206087661726961626c65"}],b=f("FROM","UFIXED","AMOUNT","06"),u=f("TO","FIXED","DATETIME","07"),y=f("TO","BOOL","UNIT","08"),x=f("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"},i={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 f(a,e,n,h){return{param:{value:{binary_path:{type:"CONTAINER",value:a},type_family:e,type_size:32},type:n},descriptor:h}}function l(a,e,n){return{descriptors_calldata:{"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9":{"0x69328dec":{type:"calldata",version:"v1",transaction_info:a,enums:e,fields:n}}}}}it("should call axios with the ledger client version header",async()=>{const a=`context-module/${E.default.version}`,e=jest.fn(()=>Promise.resolve({data:[]}));jest.spyOn(c.default,"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(c.default,"request").mockRejectedValue(new Error);const a=await t.getTransactionDescriptors({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(a).toEqual((0,r.Left)(new Error("[ContextModule] HttpTransactionDataSource: Failed to fetch transaction informations: Error")))}),it("should return an error when no payload is returned",async()=>{const a={data:{test:""}};jest.spyOn(c.default,"request").mockResolvedValue(a);const e=await t.getTransactionDescriptors({chainId:1,address:"0x0abc",selector:"0x01ff"});expect(e).toEqual((0,r.Left)(new Error("[ContextModule] HttpTransactionDataSource: No generic descriptor for contract 0x0abc")))}),it("should return an error when selector is not found",async()=>{const a=l(d,o,[s]);jest.spyOn(c.default,"request").mockResolvedValue({data:[a]});const e=await t.getTransactionDescriptors({chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x01fe"});expect(e).toEqual((0,r.Left)(new Error("[ContextModule] HttpTransactionDataSource: Invalid response for contract 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9 and selector 0x01fe")))}),it("Calldata with fields references and enums",async()=>{const a=l(d,o,[s,i,p]);jest.spyOn(c.default,"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:i.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=l(d,[],[b,u,y,x]);jest.spyOn(c.default,"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:d,enums:o,fields:[s]}}}};jest.spyOn(c.default,"request").mockResolvedValue({data:[a]});const e=await t.getTransactionDescriptors({chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e).toEqual((0,r.Left)(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=l({descriptor:{data:"1234",signatures:{prod:"1234"}}},o,[s]);jest.spyOn(c.default,"request").mockResolvedValue({data:[a]});const e=await t.getTransactionDescriptors({chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e).toEqual((0,r.Left)(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=l(d,["badEnum"],[s]);jest.spyOn(c.default,"request").mockResolvedValue({data:[a]});const e=await t.getTransactionDescriptors({chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e).toEqual((0,r.Left)(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=l(d,[],[{descriptor:3}]);jest.spyOn(c.default,"request").mockResolvedValue({data:[a]});const e=await t.getTransactionDescriptors({chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(e).toEqual((0,r.Left)(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=l(d,[],[{param:{value:{binary_path:"TO",type_family:"UNKNOWN",type_size:20},type:"DATETIME"},descriptor:"000100010c546f20726563697069667"}]);jest.spyOn(c.default,"request").mockResolvedValue({data:[e]});const n=await t.getTransactionDescriptors({chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(n).toEqual((0,r.Left)(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=l(d,[],[{param:{value:{binary_path:"UNKNOWN",type_family:"ADDRESS",type_size:20},type:"DATETIME"},descriptor:"000100010c546f20726563697069667"}]);jest.spyOn(c.default,"request").mockResolvedValue({data:[e]});const n=await t.getTransactionDescriptors({chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(n).toEqual((0,r.Left)(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=l(d,[],[{param:{value:{binary_path:{elements:[{type:"UNKNOWN"}]},type_family:"ADDRESS",type_size:20},type:"DATETIME"},descriptor:"000100010c546f20726563697069667"}]);jest.spyOn(c.default,"request").mockResolvedValue({data:[e]});const n=await t.getTransactionDescriptors({chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(n).toEqual((0,r.Left)(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=l(d,[],[{param:{value:{binary_path:"TO",type_family:"ADDRESS",type_size:20},type:"UNKNOWN"},descriptor:"000100010c546f20726563697069667"}]);jest.spyOn(c.default,"request").mockResolvedValue({data:[e]});const n=await t.getTransactionDescriptors({chainId:1,address:"0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9",selector:"0x69328dec"});expect(n).toEqual((0,r.Left)(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": "wdAAA,IAAAA,EAAkB,oBAClBC,EAAqB,qBAQrBC,EAA0C,wDAE1CC,EAAoB,iCAEpB,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,IAAI,4BAA0BU,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,C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WAAY,iCACd,CAC8D,CAAC,EAC/D,KAAK,MAAM,EAAAoB,QAAO,SAAS,EAAE,kBAAkB,CAAE,KAAM,CAACG,CAAW,CAAE,CAAC,EAGtE,MAAMF,EAAS,MAAMtB,EAAW,0BAA0B,CACxD,QAAS,EACT,QAAS,6CACT,SAAU,YACZ,CAAC,EAGD,OAAOsB,CAAM,EAAE,WACb,QACE,IAAI,MACF,oKACF,CACF,CACF,CACF,CAAC,EAED,GAAG,oEAAqE,SAAY,CAalF,MAAME,EAAcR,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,MAAM,EAAAoB,QAAO,SAAS,EAAE,kBAAkB,CAAE,KAAM,CAACG,CAAW,CAAE,CAAC,EAGtE,MAAMF,EAAS,MAAMtB,EAAW,0BAA0B,CACxD,QAAS,EACT,QAAS,6CACT,SAAU,YACZ,CAAC,EAGD,OAAOsB,CAAM,EAAE,WACb,QACE,IAAI,MACF,oKACF,CACF,CACF,CACF,CAAC,CACH,CAAC",
6
+ "names": ["import_axios", "import_purify_ts", "import_HttpTransactionDataSource", "import_package", "datasource", "transactionInfo", "enums", "fieldToken", "fieldTrustedName", "fieldNft", "fieldAmount", "fieldDatetime", "fieldUnit", "fieldDuration", "config", "createFieldWithoutReference", "binary_path", "type_family", "type", "descriptor", "createCalldata", "fields", "version", "PACKAGE", "requestSpy", "axios", "result", "response", "calldataDTO"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var s=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var p=(t,r,o,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of n(r))!c.call(t,e)&&e!==o&&s(t,e,{get:()=>r[e],enumerable:!(a=i(r,e))||a.enumerable});return t};var m=t=>p(s({},"__esModule",{value:!0}),t);var S={};module.exports=m(S);
2
+ //# sourceMappingURL=TransactionDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/transaction/data/TransactionDataSource.ts"],
4
+ "sourcesContent": ["import { type HexaString } from \"@ledgerhq/device-management-kit\";\nimport { type Either } from \"purify-ts\";\n\nimport { type ClearSignContextSuccess } from \"@/shared/model/ClearSignContext\";\n\nexport type GetTransactionDescriptorsParams = {\n address: string;\n chainId: number;\n selector: HexaString;\n};\n\nexport interface TransactionDataSource {\n getTransactionDescriptors(\n params: GetTransactionDescriptorsParams,\n ): Promise<Either<Error, ClearSignContextSuccess[]>>;\n}\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["TransactionDataSource_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var e=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var T=(o,t)=>{for(var r in t)e(o,r,{get:t[r],enumerable:!0})},f=(o,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of d(t))!u.call(o,n)&&n!==r&&e(o,n,{get:()=>t[n],enumerable:!(a=p(t,n))||a.enumerable});return o};var x=o=>f(e({},"__esModule",{value:!0}),o);var _={};T(_,{transactionModuleFactory:()=>C});module.exports=x(_);var c=require("inversify"),s=require("../../transaction/data/HttpTransactionDataSource"),i=require("../../transaction/di/transactionTypes"),m=require("../../transaction/domain/TransactionContextLoader");const C=()=>new c.ContainerModule((o,t,r,a)=>{o(i.transactionTypes.TransactionDataSource).to(s.HttpTransactionDataSource),o(i.transactionTypes.TransactionContextLoader).to(m.TransactionContextLoader)});0&&(module.exports={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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,qBAEhCC,EAA0C,wDAC1CC,EAAiC,6CACjCC,EAAyC,yDAElC,MAAML,EAA2B,IACtC,IAAI,kBAAgB,CAACM,EAAMC,EAASC,EAAUC,IAAY,CACxDH,EAAK,mBAAiB,qBAAqB,EAAE,GAAG,2BAAyB,EACzEA,EAAK,mBAAiB,wBAAwB,EAAE,GAC9C,0BACF,CACF,CAAC",
6
+ "names": ["transactionModuleFactory_exports", "__export", "transactionModuleFactory", "__toCommonJS", "import_inversify", "import_HttpTransactionDataSource", "import_transactionTypes", "import_TransactionContextLoader", "bind", "_unbind", "_isBound", "_rebind"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var r=Object.defineProperty;var e=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var T=(a,o)=>{for(var n in o)r(a,n,{get:o[n],enumerable:!0})},S=(a,o,n,c)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of s(o))!i.call(a,t)&&t!==n&&r(a,t,{get:()=>o[t],enumerable:!(c=e(o,t))||c.enumerable});return a};var x=a=>S(r({},"__esModule",{value:!0}),a);var b={};T(b,{transactionTypes:()=>y});module.exports=x(b);const y={TransactionDataSource:Symbol.for("TransactionDataSource"),TransactionContextLoader:Symbol.for("TransactionContextLoader")};0&&(module.exports={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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAmB,CAC9B,sBAAuB,OAAO,IAAI,uBAAuB,EACzD,yBAA0B,OAAO,IAAI,0BAA0B,CACjE",
6
+ "names": ["transactionTypes_exports", "__export", "transactionTypes", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var n=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var g=(e,t)=>{for(var a in t)n(e,a,{get:t[a],enumerable:!0})},D=(e,t,a,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of d(t))!x.call(e,r)&&r!==a&&n(e,r,{get:()=>t[r],enumerable:!(o=l(t,r))||o.enumerable});return e};var R=e=>D(n({},"__esModule",{value:!0}),e),u=(e,t,a,o)=>{for(var r=o>1?void 0:o?l(t,a):t,s=e.length-1,m;s>=0;s--)(m=e[s])&&(r=(o?m(t,a,r):m(r))||r);return o&&r&&n(t,a,r),r},S=(e,t)=>(a,o)=>t(a,o,e);var y={};g(y,{TransactionContextLoader:()=>i});module.exports=R(y);var f=require("@ledgerhq/device-management-kit"),c=require("inversify"),p=require("../../shared/model/ClearSignContext"),C=require("../../transaction/di/transactionTypes");let i=class{constructor(t){this.transactionDataSource=t}async load(t){if(!t.to||!t.data||t.data==="0x")return[];const a=t.data.slice(0,10);return(0,f.isHexaString)(a)?(await this.transactionDataSource.getTransactionDescriptors({address:t.to,chainId:t.chainId,selector:a})).caseOf({Left:r=>[{type:p.ClearSignContextType.ERROR,error:r}],Right:r=>r}):[{type:p.ClearSignContextType.ERROR,error:new Error("Invalid selector")}]}};i=u([(0,c.injectable)(),S(0,(0,c.inject)(C.transactionTypes.TransactionDataSource))],i);0&&(module.exports={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": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA6B,2CAC7BC,EAAmC,qBAGnCC,EAGO,2CAGPC,EAAiC,6CAG1B,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,SAAK,gBAAaC,CAAQ,GASX,MAAM,KAAK,sBAAsB,0BAA0B,CACxE,QAASD,EAAY,GACrB,QAASA,EAAY,QACrB,SAAAC,CACF,CAAC,GAEa,OAAO,CACnB,KAAOC,GAA8B,CACnC,CACE,KAAM,uBAAqB,MAC3B,MAAAA,CACF,CACF,EACA,MAAQC,GAAiCA,CAC3C,CAAC,EAtBQ,CACL,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,kBAAkB,CACrC,CACF,CAkBJ,CACF,EAtCaL,EAANM,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,mBAAiB,qBAAqB,IAFrCP",
6
+ "names": ["TransactionContextLoader_exports", "__export", "TransactionContextLoader", "__toCommonJS", "import_device_management_kit", "import_inversify", "import_ClearSignContext", "import_transactionTypes", "TransactionContextLoader", "transactionDataSource", "transaction", "selector", "error", "contexts", "__decorateClass", "__decorateParam"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var r=require("purify-ts"),o=require("../../shared/model/ClearSignContext"),s=require("../../transaction/domain/TransactionContextLoader");describe("TransactionContextLoader",()=>{const n=jest.fn(),c={getTransactionDescriptors:n},e=new s.TransactionContextLoader(c);beforeEach(()=>{jest.clearAllMocks()}),it("should return an empty array if no destination address is provided",async()=>{const t={},a=await e.load(t);expect(a).toEqual([])}),it("should return an empty array if data is undefined",async()=>{const t={to:"0x0"},a=await e.load(t);expect(a).toEqual([])}),it("should return an empty array if no data provided",async()=>{const t={to:"0x0",data:"0x"},a=await e.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 e.load(t);expect(a).toEqual([{type:o.ClearSignContextType.ERROR,error:new Error("Invalid selector")}])}),it("should return an error if data source fails",async()=>{n.mockResolvedValue((0,r.Left)(new Error("data source error")));const t={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002"},a=await e.load(t);expect(n).toHaveBeenCalledWith({address:"0x7",chainId:3,selector:"0xaf68b302"}),expect(a).toEqual([{type:o.ClearSignContextType.ERROR,error:new Error("data source error")}])}),it("should return the contexts on success",async()=>{n.mockResolvedValue((0,r.Right)([{type:o.ClearSignContextType.TRANSACTION_INFO,payload:"1234567890"},{type:o.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}]));const t={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002"},a=await e.load(t);expect(a).toEqual([{type:o.ClearSignContextType.TRANSACTION_INFO,payload:"1234567890"},{type:o.ClearSignContextType.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,IAAAA,EAA4B,qBAE5BC,EAAqC,2CAGrCC,EAAyC,yDAEzC,SAAS,2BAA4B,IAAM,CACzC,MAAMC,EAAgC,KAAK,GAAG,EACxCC,EAAmD,CACvD,0BAA2BD,CAC7B,EACME,EAAS,IAAI,2BAAyBD,CAAyB,EAErE,WAAW,IAAM,CACf,KAAK,cAAc,CACrB,CAAC,EAED,GAAG,qEAAsE,SAAY,CAEnF,MAAME,EAAc,CAAC,EAGfC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,EAED,GAAG,oDAAqD,SAAY,CAElE,MAAMD,EAAc,CAAE,GAAI,KAAM,EAG1BC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,EAED,GAAG,mDAAoD,SAAY,CAEjE,MAAMD,EAAc,CAAE,GAAI,MAAO,KAAM,IAAK,EAGtCC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,EAED,GAAG,gDAAiD,SAAY,CAE9D,MAAMD,EAAc,CAClB,GAAI,MACJ,QAAS,EACT,KAAM,wEACR,EAGMC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CACrB,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,kBAAkB,CACrC,CACF,CAAC,CACH,CAAC,EAED,GAAG,8CAA+C,SAAY,CAE5DJ,EAA8B,qBAC5B,QAAK,IAAI,MAAM,mBAAmB,CAAC,CACrC,EACA,MAAMG,EAAc,CAClB,GAAI,MACJ,QAAS,EACT,KAAM,wEACR,EAGMC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOH,CAA6B,EAAE,qBAAqB,CACzD,QAAS,MACT,QAAS,EACT,SAAU,YACZ,CAAC,EACD,OAAOI,CAAM,EAAE,QAAQ,CACrB,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,mBAAmB,CACtC,CACF,CAAC,CACH,CAAC,EAED,GAAG,wCAAyC,SAAY,CAEtDJ,EAA8B,qBAC5B,SAAM,CACJ,CACE,KAAM,uBAAqB,iBAC3B,QAAS,YACX,EACA,CACE,KAAM,uBAAqB,8BAC3B,QAAS,UACX,CACF,CAAC,CACH,EACA,MAAMG,EAAc,CAClB,GAAI,MACJ,QAAS,EACT,KAAM,wEACR,EAGMC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CACrB,CACE,KAAM,uBAAqB,iBAC3B,QAAS,YACX,EACA,CACE,KAAM,uBAAqB,8BAC3B,QAAS,UACX,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_purify_ts", "import_ClearSignContext", "import_TransactionContextLoader", "getTransactionDescriptorsMock", "mockTransactionDataSource", "loader", "transaction", "result"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var C=Object.create;var m=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var P=(r,e)=>{for(var t in e)m(r,t,{get:e[t],enumerable:!0})},h=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of E(e))!v.call(r,o)&&o!==t&&m(r,o,{get:()=>e[o],enumerable:!(n=f(e,o))||n.enumerable});return r};var y=(r,e,t)=>(t=r!=null?C(x(r)):{},h(e||!r||!r.__esModule?m(t,"default",{value:r,enumerable:!0}):t,r)),w=r=>h(m({},"__esModule",{value:!0}),r),D=(r,e,t,n)=>{for(var o=n>1?void 0:n?f(e,t):e,i=r.length-1,s;i>=0;i--)(s=r[i])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&m(e,t,o),o},N=(r,e)=>(t,n)=>e(t,n,r);var G={};P(G,{HttpTrustedNameDataSource:()=>d});module.exports=w(G);var u=y(require("axios")),c=require("inversify"),a=require("purify-ts"),T=require("../../config/di/configTypes"),g=y(require("../../../package.json"));let d=class{constructor(e){this.config=e}async getDomainNamePayload({domain:e,challenge:t}){try{const i=await u.default.request({method:"GET",url:`https://nft.api.live.ledger.com/v2/names/ethereum/1/forward/${e}?types=eoa&sources=ens&challenge=${t}`,headers:{"X-Ledger-Client-Version":`context-module/${g.default.version}`}});return i.data.signedDescriptor?.data?(0,a.Right)(i.data.signedDescriptor.data):(0,a.Left)(new Error("[ContextModule] HttpTrustedNameDataSource: error getting domain payload"))}catch{return(0,a.Left)(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name"))}}async getTrustedNamePayload({address:e,challenge:t,sources:n,types:o}){try{n=n.filter(p=>p==="ens"||p==="crypto_assets_list");const s=(await u.default.request({method:"GET",url:`https://nft.api.live.ledger.com/v2/names/ethereum/1/reverse/${e}?types=${o.join(",")}&sources=${n.join(",")}&challenge=${t}`,headers:{"X-Ledger-Client-Version":`context-module/${g.default.version}`}})).data;if(!s?.signedDescriptor?.data)return(0,a.Left)(new Error(`[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address ${e}`));const l=s.signedDescriptor.data;if(!s.signedDescriptor.signatures||typeof s.signedDescriptor.signatures[this.config.cal.mode]!="string")return(0,a.Right)(l);const $=s.signedDescriptor.signatures[this.config.cal.mode];return(0,a.Right)(this.formatTrustedName(l,$))}catch{return(0,a.Left)(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name"))}}formatTrustedName(e,t){t.length%2!==0&&(t="0"+t);const n="15",o=(t.length/2).toString(16);return`${e}${n}${o}${t}`}};d=D([(0,c.injectable)(),N(0,(0,c.inject)(T.configTypes.Config))],d);0&&(module.exports={HttpTrustedNameDataSource});
2
+ //# sourceMappingURL=HttpTrustedNameDataSource.js.map