@ledgerhq/context-module 1.1.0 → 1.3.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 (380) hide show
  1. package/lib/cjs/index.js.map +1 -1
  2. package/lib/cjs/package.json +8 -7
  3. package/lib/cjs/src/ContextModule.js +1 -1
  4. package/lib/cjs/src/ContextModule.js.map +1 -1
  5. package/lib/cjs/src/ContextModuleBuilder.js +1 -1
  6. package/lib/cjs/src/ContextModuleBuilder.js.map +3 -3
  7. package/lib/cjs/src/ContextModuleBuilder.test.js +1 -1
  8. package/lib/cjs/src/ContextModuleBuilder.test.js.map +3 -3
  9. package/lib/cjs/src/DefaultContextModule.js +1 -1
  10. package/lib/cjs/src/DefaultContextModule.js.map +3 -3
  11. package/lib/cjs/src/DefaultContextModule.test.js +1 -1
  12. package/lib/cjs/src/DefaultContextModule.test.js.map +3 -3
  13. package/lib/cjs/src/config/model/ContextModuleConfig.js +1 -1
  14. package/lib/cjs/src/config/model/ContextModuleConfig.js.map +1 -1
  15. package/lib/cjs/src/di.js +1 -1
  16. package/lib/cjs/src/di.js.map +3 -3
  17. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js +1 -1
  18. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +2 -2
  19. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
  20. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +2 -2
  21. package/lib/cjs/src/index.js +1 -1
  22. package/lib/cjs/src/index.js.map +2 -2
  23. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js +1 -1
  24. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js.map +2 -2
  25. package/lib/cjs/src/nft/domain/NftContextLoader.test.js +1 -1
  26. package/lib/cjs/src/nft/domain/NftContextLoader.test.js.map +2 -2
  27. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.js +2 -0
  28. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.js.map +7 -0
  29. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.test.js +2 -0
  30. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.test.js.map +7 -0
  31. package/lib/cjs/src/pki/data/PkiCertificateDataSource.js +2 -0
  32. package/lib/cjs/src/pki/data/PkiCertificateDataSource.js.map +7 -0
  33. package/lib/cjs/src/pki/data/pkiDataSourceTypes.js +2 -0
  34. package/lib/cjs/src/pki/data/pkiDataSourceTypes.js.map +7 -0
  35. package/lib/cjs/src/pki/di/pkiModuleFactory.js +2 -0
  36. package/lib/cjs/src/pki/di/pkiModuleFactory.js.map +7 -0
  37. package/lib/cjs/src/pki/di/pkiTypes.js +2 -0
  38. package/lib/cjs/src/pki/di/pkiTypes.js.map +7 -0
  39. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.js +2 -0
  40. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.js.map +7 -0
  41. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js +2 -0
  42. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +7 -0
  43. package/lib/cjs/src/pki/domain/PkiCertificateLoader.js +2 -0
  44. package/lib/cjs/src/pki/domain/PkiCertificateLoader.js.map +7 -0
  45. package/lib/cjs/src/pki/model/KeyId.js +2 -0
  46. package/lib/cjs/src/pki/model/KeyId.js.map +7 -0
  47. package/lib/cjs/src/pki/model/KeyUsage.js +2 -0
  48. package/lib/cjs/src/pki/model/KeyUsage.js.map +7 -0
  49. package/lib/cjs/src/pki/model/PkiCertificate.js +2 -0
  50. package/lib/cjs/src/pki/model/PkiCertificate.js.map +7 -0
  51. package/lib/cjs/src/pki/model/PkiCertificateInfo.js +2 -0
  52. package/lib/cjs/src/pki/model/PkiCertificateInfo.js.map +7 -0
  53. package/lib/cjs/src/shared/model/ClearSignContext.js +1 -1
  54. package/lib/cjs/src/shared/model/ClearSignContext.js.map +2 -2
  55. package/lib/cjs/src/shared/model/GenericPath.js +1 -1
  56. package/lib/cjs/src/shared/model/GenericPath.js.map +1 -1
  57. package/lib/cjs/src/shared/model/SignatureTags.js +2 -0
  58. package/lib/cjs/src/shared/model/SignatureTags.js.map +7 -0
  59. package/lib/cjs/src/shared/model/TransactionContext.js +1 -1
  60. package/lib/cjs/src/shared/model/TransactionContext.js.map +1 -1
  61. package/lib/cjs/src/shared/model/TransactionSubset.js +1 -1
  62. package/lib/cjs/src/shared/model/TransactionSubset.js.map +1 -1
  63. package/lib/cjs/src/shared/utils/HexStringUtils.js +1 -1
  64. package/lib/cjs/src/shared/utils/HexStringUtils.js.map +3 -3
  65. package/lib/cjs/src/shared/utils/HexStringUtils.test.js +2 -0
  66. package/lib/cjs/src/shared/utils/HexStringUtils.test.js.map +7 -0
  67. package/lib/cjs/src/shared/utils/KeyUsageMapper.js +2 -0
  68. package/lib/cjs/src/shared/utils/KeyUsageMapper.js.map +7 -0
  69. package/lib/cjs/src/shared/utils/KeyUsageMapper.test.js +2 -0
  70. package/lib/cjs/src/shared/utils/KeyUsageMapper.test.js.map +7 -0
  71. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js +1 -1
  72. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js.map +2 -2
  73. package/lib/cjs/src/token/domain/TokenContextLoader.test.js +1 -1
  74. package/lib/cjs/src/token/domain/TokenContextLoader.test.js.map +2 -2
  75. package/lib/cjs/src/transaction/data/CalldataDto.js +1 -1
  76. package/lib/cjs/src/transaction/data/CalldataDto.js.map +1 -1
  77. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js +1 -1
  78. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js.map +3 -3
  79. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js +1 -1
  80. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js.map +3 -3
  81. package/lib/cjs/src/transaction/data/TransactionDataSource.js +1 -1
  82. package/lib/cjs/src/transaction/data/TransactionDataSource.js.map +1 -1
  83. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js +1 -1
  84. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js.map +2 -2
  85. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js +1 -1
  86. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js.map +2 -2
  87. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  88. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +2 -2
  89. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
  90. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js.map +2 -2
  91. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
  92. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +2 -2
  93. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  94. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js.map +2 -2
  95. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
  96. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +2 -2
  97. package/lib/cjs/src/uniswap/constants/plugin.js +2 -0
  98. package/lib/cjs/src/uniswap/constants/plugin.js.map +7 -0
  99. package/lib/cjs/src/uniswap/constants/uniswap.js +2 -0
  100. package/lib/cjs/src/uniswap/constants/uniswap.js.map +7 -0
  101. package/lib/cjs/src/uniswap/constants/weth.js +2 -0
  102. package/lib/cjs/src/uniswap/constants/weth.js.map +7 -0
  103. package/lib/cjs/src/uniswap/data/AbiDecoderDataSource.js +2 -0
  104. package/lib/cjs/src/uniswap/data/AbiDecoderDataSource.js.map +7 -0
  105. package/lib/cjs/src/uniswap/data/CommandDecoderDataSource.js +2 -0
  106. package/lib/cjs/src/uniswap/data/CommandDecoderDataSource.js.map +7 -0
  107. package/lib/cjs/src/uniswap/data/DefaultCommandDecoderDataSource.js +2 -0
  108. package/lib/cjs/src/uniswap/data/DefaultCommandDecoderDataSource.js.map +7 -0
  109. package/lib/cjs/src/uniswap/data/DefaultCommandDecoderDataSource.test.js +2 -0
  110. package/lib/cjs/src/uniswap/data/DefaultCommandDecoderDataSource.test.js.map +7 -0
  111. package/lib/cjs/src/uniswap/data/EthersAbiDecoderDataSource.js +2 -0
  112. package/lib/cjs/src/uniswap/data/EthersAbiDecoderDataSource.js.map +7 -0
  113. package/lib/cjs/src/uniswap/data/EthersAbiDecoderDataSource.test.js +2 -0
  114. package/lib/cjs/src/uniswap/data/EthersAbiDecoderDataSource.test.js.map +7 -0
  115. package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js +2 -0
  116. package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js.map +7 -0
  117. package/lib/cjs/src/uniswap/di/uniswapTypes.js +2 -0
  118. package/lib/cjs/src/uniswap/di/uniswapTypes.js.map +7 -0
  119. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js +2 -0
  120. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js.map +7 -0
  121. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js +2 -0
  122. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js.map +7 -0
  123. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.js +2 -0
  124. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.js.map +7 -0
  125. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.test.js +2 -0
  126. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.test.js.map +7 -0
  127. package/lib/cjs/src/web3-check/data/Web3CheckDataSource.js +2 -0
  128. package/lib/cjs/src/web3-check/data/Web3CheckDataSource.js.map +7 -0
  129. package/lib/cjs/src/web3-check/data/Web3CheckDto.js +2 -0
  130. package/lib/cjs/src/web3-check/data/Web3CheckDto.js.map +7 -0
  131. package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js +2 -0
  132. package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js.map +7 -0
  133. package/lib/cjs/src/web3-check/di/web3CheckTypes.js +2 -0
  134. package/lib/cjs/src/web3-check/di/web3CheckTypes.js.map +7 -0
  135. package/lib/cjs/src/web3-check/domain/DefaultWeb3CheckLoader.js +2 -0
  136. package/lib/cjs/src/web3-check/domain/DefaultWeb3CheckLoader.js.map +7 -0
  137. package/lib/cjs/src/web3-check/domain/DefaultWeb3CheckLoader.test.js +2 -0
  138. package/lib/cjs/src/web3-check/domain/DefaultWeb3CheckLoader.test.js.map +7 -0
  139. package/lib/cjs/src/web3-check/domain/Web3CheckContextLoader.js +2 -0
  140. package/lib/cjs/src/web3-check/domain/Web3CheckContextLoader.js.map +7 -0
  141. package/lib/cjs/src/web3-check/domain/web3CheckTypes.js +2 -0
  142. package/lib/cjs/src/web3-check/domain/web3CheckTypes.js.map +7 -0
  143. package/lib/esm/package.json +8 -7
  144. package/lib/esm/src/ContextModuleBuilder.js +1 -1
  145. package/lib/esm/src/ContextModuleBuilder.js.map +3 -3
  146. package/lib/esm/src/ContextModuleBuilder.test.js +1 -1
  147. package/lib/esm/src/ContextModuleBuilder.test.js.map +3 -3
  148. package/lib/esm/src/DefaultContextModule.js +1 -1
  149. package/lib/esm/src/DefaultContextModule.js.map +3 -3
  150. package/lib/esm/src/DefaultContextModule.test.js +1 -1
  151. package/lib/esm/src/DefaultContextModule.test.js.map +3 -3
  152. package/lib/esm/src/di.js +1 -1
  153. package/lib/esm/src/di.js.map +3 -3
  154. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js +1 -1
  155. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +2 -2
  156. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
  157. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +2 -2
  158. package/lib/esm/src/index.js +1 -1
  159. package/lib/esm/src/index.js.map +2 -2
  160. package/lib/esm/src/nft/data/HttpNftDataSource.test.js +1 -1
  161. package/lib/esm/src/nft/data/HttpNftDataSource.test.js.map +2 -2
  162. package/lib/esm/src/nft/domain/NftContextLoader.test.js +1 -1
  163. package/lib/esm/src/nft/domain/NftContextLoader.test.js.map +2 -2
  164. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.js +2 -0
  165. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.js.map +7 -0
  166. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.test.js +2 -0
  167. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.test.js.map +7 -0
  168. package/lib/esm/src/pki/data/PkiCertificateDataSource.js +1 -0
  169. package/lib/esm/src/pki/data/PkiCertificateDataSource.js.map +7 -0
  170. package/lib/esm/src/pki/data/pkiDataSourceTypes.js +1 -0
  171. package/lib/esm/src/pki/data/pkiDataSourceTypes.js.map +7 -0
  172. package/lib/esm/src/pki/di/pkiModuleFactory.js +2 -0
  173. package/lib/esm/src/pki/di/pkiModuleFactory.js.map +7 -0
  174. package/lib/esm/src/pki/di/pkiTypes.js +2 -0
  175. package/lib/esm/src/pki/di/pkiTypes.js.map +7 -0
  176. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.js +2 -0
  177. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.js.map +7 -0
  178. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js +2 -0
  179. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +7 -0
  180. package/lib/esm/src/pki/domain/PkiCertificateLoader.js +1 -0
  181. package/lib/esm/src/pki/domain/PkiCertificateLoader.js.map +7 -0
  182. package/lib/esm/src/pki/model/KeyId.js +2 -0
  183. package/lib/esm/src/pki/model/KeyId.js.map +7 -0
  184. package/lib/esm/src/pki/model/KeyUsage.js +2 -0
  185. package/lib/esm/src/pki/model/KeyUsage.js.map +7 -0
  186. package/lib/esm/src/pki/model/PkiCertificate.js +1 -0
  187. package/lib/esm/src/pki/model/PkiCertificate.js.map +7 -0
  188. package/lib/esm/src/pki/model/PkiCertificateInfo.js +1 -0
  189. package/lib/esm/src/pki/model/PkiCertificateInfo.js.map +7 -0
  190. package/lib/esm/src/shared/model/ClearSignContext.js +1 -1
  191. package/lib/esm/src/shared/model/ClearSignContext.js.map +2 -2
  192. package/lib/esm/src/shared/model/GenericPath.js.map +1 -1
  193. package/lib/esm/src/shared/model/SignatureTags.js +2 -0
  194. package/lib/esm/src/shared/model/SignatureTags.js.map +7 -0
  195. package/lib/esm/src/shared/utils/HexStringUtils.js +1 -1
  196. package/lib/esm/src/shared/utils/HexStringUtils.js.map +3 -3
  197. package/lib/esm/src/shared/utils/HexStringUtils.test.js +2 -0
  198. package/lib/esm/src/shared/utils/HexStringUtils.test.js.map +7 -0
  199. package/lib/esm/src/shared/utils/KeyUsageMapper.js +2 -0
  200. package/lib/esm/src/shared/utils/KeyUsageMapper.js.map +7 -0
  201. package/lib/esm/src/shared/utils/KeyUsageMapper.test.js +2 -0
  202. package/lib/esm/src/shared/utils/KeyUsageMapper.test.js.map +7 -0
  203. package/lib/esm/src/token/data/HttpTokenDataSource.test.js +1 -1
  204. package/lib/esm/src/token/data/HttpTokenDataSource.test.js.map +2 -2
  205. package/lib/esm/src/token/domain/TokenContextLoader.test.js +1 -1
  206. package/lib/esm/src/token/domain/TokenContextLoader.test.js.map +2 -2
  207. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js +1 -1
  208. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js.map +3 -3
  209. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js +1 -1
  210. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js.map +3 -3
  211. package/lib/esm/src/transaction/domain/TransactionContextLoader.js +1 -1
  212. package/lib/esm/src/transaction/domain/TransactionContextLoader.js.map +2 -2
  213. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js +1 -1
  214. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js.map +2 -2
  215. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  216. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +2 -2
  217. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
  218. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js.map +2 -2
  219. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
  220. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +2 -2
  221. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  222. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js.map +2 -2
  223. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
  224. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +2 -2
  225. package/lib/esm/src/uniswap/constants/plugin.js +2 -0
  226. package/lib/esm/src/uniswap/constants/plugin.js.map +7 -0
  227. package/lib/esm/src/uniswap/constants/uniswap.js +2 -0
  228. package/lib/esm/src/uniswap/constants/uniswap.js.map +7 -0
  229. package/lib/esm/src/uniswap/constants/weth.js +2 -0
  230. package/lib/esm/src/uniswap/constants/weth.js.map +7 -0
  231. package/lib/esm/src/uniswap/data/AbiDecoderDataSource.js +1 -0
  232. package/lib/esm/src/uniswap/data/AbiDecoderDataSource.js.map +7 -0
  233. package/lib/esm/src/uniswap/data/CommandDecoderDataSource.js +1 -0
  234. package/lib/esm/src/uniswap/data/CommandDecoderDataSource.js.map +7 -0
  235. package/lib/esm/src/uniswap/data/DefaultCommandDecoderDataSource.js +2 -0
  236. package/lib/esm/src/uniswap/data/DefaultCommandDecoderDataSource.js.map +7 -0
  237. package/lib/esm/src/uniswap/data/DefaultCommandDecoderDataSource.test.js +2 -0
  238. package/lib/esm/src/uniswap/data/DefaultCommandDecoderDataSource.test.js.map +7 -0
  239. package/lib/esm/src/uniswap/data/EthersAbiDecoderDataSource.js +2 -0
  240. package/lib/esm/src/uniswap/data/EthersAbiDecoderDataSource.js.map +7 -0
  241. package/lib/esm/src/uniswap/data/EthersAbiDecoderDataSource.test.js +2 -0
  242. package/lib/esm/src/uniswap/data/EthersAbiDecoderDataSource.test.js.map +7 -0
  243. package/lib/esm/src/uniswap/di/uniswapModuleFactory.js +2 -0
  244. package/lib/esm/src/uniswap/di/uniswapModuleFactory.js.map +7 -0
  245. package/lib/esm/src/uniswap/di/uniswapTypes.js +2 -0
  246. package/lib/esm/src/uniswap/di/uniswapTypes.js.map +7 -0
  247. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js +2 -0
  248. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js.map +7 -0
  249. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js +2 -0
  250. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js.map +7 -0
  251. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.js +2 -0
  252. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.js.map +7 -0
  253. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.test.js +2 -0
  254. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.test.js.map +7 -0
  255. package/lib/esm/src/web3-check/data/Web3CheckDataSource.js +1 -0
  256. package/lib/esm/src/web3-check/data/Web3CheckDataSource.js.map +7 -0
  257. package/lib/esm/src/web3-check/data/Web3CheckDto.js +1 -0
  258. package/lib/esm/src/web3-check/data/Web3CheckDto.js.map +7 -0
  259. package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js +2 -0
  260. package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js.map +7 -0
  261. package/lib/esm/src/web3-check/di/web3CheckTypes.js +2 -0
  262. package/lib/esm/src/web3-check/di/web3CheckTypes.js.map +7 -0
  263. package/lib/esm/src/web3-check/domain/DefaultWeb3CheckLoader.js +2 -0
  264. package/lib/esm/src/web3-check/domain/DefaultWeb3CheckLoader.js.map +7 -0
  265. package/lib/esm/src/web3-check/domain/DefaultWeb3CheckLoader.test.js +2 -0
  266. package/lib/esm/src/web3-check/domain/DefaultWeb3CheckLoader.test.js.map +7 -0
  267. package/lib/esm/src/web3-check/domain/Web3CheckContextLoader.js +1 -0
  268. package/lib/esm/src/web3-check/domain/Web3CheckContextLoader.js.map +7 -0
  269. package/lib/esm/src/web3-check/domain/web3CheckTypes.js +1 -0
  270. package/lib/esm/src/web3-check/domain/web3CheckTypes.js.map +7 -0
  271. package/lib/types/src/ContextModule.d.ts +2 -0
  272. package/lib/types/src/ContextModule.d.ts.map +1 -1
  273. package/lib/types/src/ContextModuleBuilder.d.ts +16 -1
  274. package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -1
  275. package/lib/types/src/DefaultContextModule.d.ts +5 -1
  276. package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
  277. package/lib/types/src/config/model/ContextModuleConfig.d.ts +6 -0
  278. package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -1
  279. package/lib/types/src/di.d.ts.map +1 -1
  280. package/lib/types/src/index.d.ts +7 -0
  281. package/lib/types/src/index.d.ts.map +1 -1
  282. package/lib/types/src/pki/data/HttpPkiCertificateDataSource.d.ts +12 -0
  283. package/lib/types/src/pki/data/HttpPkiCertificateDataSource.d.ts.map +1 -0
  284. package/lib/types/src/pki/data/HttpPkiCertificateDataSource.test.d.ts +2 -0
  285. package/lib/types/src/pki/data/HttpPkiCertificateDataSource.test.d.ts.map +1 -0
  286. package/lib/types/src/pki/data/PkiCertificateDataSource.d.ts +7 -0
  287. package/lib/types/src/pki/data/PkiCertificateDataSource.d.ts.map +1 -0
  288. package/lib/types/src/pki/data/pkiDataSourceTypes.d.ts +23 -0
  289. package/lib/types/src/pki/data/pkiDataSourceTypes.d.ts.map +1 -0
  290. package/lib/types/src/pki/di/pkiModuleFactory.d.ts +3 -0
  291. package/lib/types/src/pki/di/pkiModuleFactory.d.ts.map +1 -0
  292. package/lib/types/src/pki/di/pkiTypes.d.ts +5 -0
  293. package/lib/types/src/pki/di/pkiTypes.d.ts.map +1 -0
  294. package/lib/types/src/pki/domain/DefaultPkiCertificateLoader.d.ts +10 -0
  295. package/lib/types/src/pki/domain/DefaultPkiCertificateLoader.d.ts.map +1 -0
  296. package/lib/types/src/pki/domain/DefaultPkiCertificateLoader.test.d.ts +2 -0
  297. package/lib/types/src/pki/domain/DefaultPkiCertificateLoader.test.d.ts.map +1 -0
  298. package/lib/types/src/pki/domain/PkiCertificateLoader.d.ts +6 -0
  299. package/lib/types/src/pki/domain/PkiCertificateLoader.d.ts.map +1 -0
  300. package/lib/types/src/pki/model/KeyId.d.ts +14 -0
  301. package/lib/types/src/pki/model/KeyId.d.ts.map +1 -0
  302. package/lib/types/src/pki/model/KeyUsage.d.ts +15 -0
  303. package/lib/types/src/pki/model/KeyUsage.d.ts.map +1 -0
  304. package/lib/types/src/pki/model/PkiCertificate.d.ts +5 -0
  305. package/lib/types/src/pki/model/PkiCertificate.d.ts.map +1 -0
  306. package/lib/types/src/pki/model/PkiCertificateInfo.d.ts +7 -0
  307. package/lib/types/src/pki/model/PkiCertificateInfo.d.ts.map +1 -0
  308. package/lib/types/src/shared/model/ClearSignContext.d.ts +25 -13
  309. package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -1
  310. package/lib/types/src/shared/model/GenericPath.d.ts +2 -2
  311. package/lib/types/src/shared/model/GenericPath.d.ts.map +1 -1
  312. package/lib/types/src/shared/model/SignatureTags.d.ts +3 -0
  313. package/lib/types/src/shared/model/SignatureTags.d.ts.map +1 -0
  314. package/lib/types/src/shared/model/TransactionContext.d.ts +3 -1
  315. package/lib/types/src/shared/model/TransactionContext.d.ts.map +1 -1
  316. package/lib/types/src/shared/model/TransactionSubset.d.ts +2 -0
  317. package/lib/types/src/shared/model/TransactionSubset.d.ts.map +1 -1
  318. package/lib/types/src/shared/utils/HexStringUtils.d.ts +1 -0
  319. package/lib/types/src/shared/utils/HexStringUtils.d.ts.map +1 -1
  320. package/lib/types/src/shared/utils/HexStringUtils.test.d.ts +2 -0
  321. package/lib/types/src/shared/utils/HexStringUtils.test.d.ts.map +1 -0
  322. package/lib/types/src/shared/utils/KeyUsageMapper.d.ts +6 -0
  323. package/lib/types/src/shared/utils/KeyUsageMapper.d.ts.map +1 -0
  324. package/lib/types/src/shared/utils/KeyUsageMapper.test.d.ts +2 -0
  325. package/lib/types/src/shared/utils/KeyUsageMapper.test.d.ts.map +1 -0
  326. package/lib/types/src/transaction/data/CalldataDto.d.ts +15 -4
  327. package/lib/types/src/transaction/data/CalldataDto.d.ts.map +1 -1
  328. package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts +8 -4
  329. package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts.map +1 -1
  330. package/lib/types/src/transaction/data/TransactionDataSource.d.ts +2 -1
  331. package/lib/types/src/transaction/data/TransactionDataSource.d.ts.map +1 -1
  332. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts.map +1 -1
  333. package/lib/types/src/uniswap/constants/plugin.d.ts +3 -0
  334. package/lib/types/src/uniswap/constants/plugin.d.ts.map +1 -0
  335. package/lib/types/src/uniswap/constants/uniswap.d.ts +21 -0
  336. package/lib/types/src/uniswap/constants/uniswap.d.ts.map +1 -0
  337. package/lib/types/src/uniswap/constants/weth.d.ts +20 -0
  338. package/lib/types/src/uniswap/constants/weth.d.ts.map +1 -0
  339. package/lib/types/src/uniswap/data/AbiDecoderDataSource.d.ts +5 -0
  340. package/lib/types/src/uniswap/data/AbiDecoderDataSource.d.ts.map +1 -0
  341. package/lib/types/src/uniswap/data/CommandDecoderDataSource.d.ts +6 -0
  342. package/lib/types/src/uniswap/data/CommandDecoderDataSource.d.ts.map +1 -0
  343. package/lib/types/src/uniswap/data/DefaultCommandDecoderDataSource.d.ts +14 -0
  344. package/lib/types/src/uniswap/data/DefaultCommandDecoderDataSource.d.ts.map +1 -0
  345. package/lib/types/src/uniswap/data/DefaultCommandDecoderDataSource.test.d.ts +2 -0
  346. package/lib/types/src/uniswap/data/DefaultCommandDecoderDataSource.test.d.ts.map +1 -0
  347. package/lib/types/src/uniswap/data/EthersAbiDecoderDataSource.d.ts +5 -0
  348. package/lib/types/src/uniswap/data/EthersAbiDecoderDataSource.d.ts.map +1 -0
  349. package/lib/types/src/uniswap/data/EthersAbiDecoderDataSource.test.d.ts +2 -0
  350. package/lib/types/src/uniswap/data/EthersAbiDecoderDataSource.test.d.ts.map +1 -0
  351. package/lib/types/src/uniswap/di/uniswapModuleFactory.d.ts +3 -0
  352. package/lib/types/src/uniswap/di/uniswapModuleFactory.d.ts.map +1 -0
  353. package/lib/types/src/uniswap/di/uniswapTypes.d.ts +6 -0
  354. package/lib/types/src/uniswap/di/uniswapTypes.d.ts.map +1 -0
  355. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts +105 -0
  356. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts.map +1 -0
  357. package/lib/types/src/uniswap/domain/UniswapContextLoader.test.d.ts +2 -0
  358. package/lib/types/src/uniswap/domain/UniswapContextLoader.test.d.ts.map +1 -0
  359. package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.d.ts +14 -0
  360. package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.d.ts.map +1 -0
  361. package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.test.d.ts +2 -0
  362. package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.test.d.ts.map +1 -0
  363. package/lib/types/src/web3-check/data/Web3CheckDataSource.d.ts +6 -0
  364. package/lib/types/src/web3-check/data/Web3CheckDataSource.d.ts.map +1 -0
  365. package/lib/types/src/web3-check/data/Web3CheckDto.d.ts +20 -0
  366. package/lib/types/src/web3-check/data/Web3CheckDto.d.ts.map +1 -0
  367. package/lib/types/src/web3-check/di/web3CheckModuleFactory.d.ts +3 -0
  368. package/lib/types/src/web3-check/di/web3CheckModuleFactory.d.ts.map +1 -0
  369. package/lib/types/src/web3-check/di/web3CheckTypes.d.ts +5 -0
  370. package/lib/types/src/web3-check/di/web3CheckTypes.d.ts.map +1 -0
  371. package/lib/types/src/web3-check/domain/DefaultWeb3CheckLoader.d.ts +10 -0
  372. package/lib/types/src/web3-check/domain/DefaultWeb3CheckLoader.d.ts.map +1 -0
  373. package/lib/types/src/web3-check/domain/DefaultWeb3CheckLoader.test.d.ts +2 -0
  374. package/lib/types/src/web3-check/domain/DefaultWeb3CheckLoader.test.d.ts.map +1 -0
  375. package/lib/types/src/web3-check/domain/Web3CheckContextLoader.d.ts +6 -0
  376. package/lib/types/src/web3-check/domain/Web3CheckContextLoader.d.ts.map +1 -0
  377. package/lib/types/src/web3-check/domain/web3CheckTypes.d.ts +35 -0
  378. package/lib/types/src/web3-check/domain/web3CheckTypes.d.ts.map +1 -0
  379. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  380. package/package.json +11 -10
@@ -0,0 +1,2 @@
1
+ import{UNISWAP_COMMANDS as i,UniswapSupportedCommand as s}from"../../uniswap/constants/uniswap";import{WETH_ADDRESS_BY_CHAIN_ID as l,WETHSupportedChainIds as r}from"../../uniswap/constants/weth";import{DefaultCommandDecoderDataSource as p}from"./DefaultCommandDecoderDataSource";import{EthersAbiDecoderDataSource as b}from"./EthersAbiDecoderDataSource";describe("DefaultCommandDecoderDataSource",()=>{const n={decode:vi.fn()};let c;describe("decode with mocked apiDecoder",()=>{beforeEach(()=>{c=new p(n)}),describe.each([[s.V2_SWAP_EXACT_IN],[s.V2_SWAP_EXACT_OUT]])("%s",a=>{it("should return the correct command data",()=>{const e="0x";vi.spyOn(n,"decode").mockReturnValueOnce(["0x","0x","0x",["0x0102030405060708090a0b0c0d0e0f1011121314"],!1]);const t=c.decode(a,e,1);expect(t).toEqual(["0x0102030405060708090a0b0c0d0e0f1011121314"])}),it("should return the correct command data with multiple addresses",()=>{const e="0x";vi.spyOn(n,"decode").mockReturnValueOnce(["0x","0x","0x",["0x0102030405060708090a0b0c0d0e0f1011121314","0x0102030405060708090a0b0c0d0e0f1011121315"],!1]);const t=c.decode(a,e,1);expect(t).toEqual(["0x0102030405060708090a0b0c0d0e0f1011121314","0x0102030405060708090a0b0c0d0e0f1011121315"])}),it("should return an empty array if an address is not valid",()=>{const e="0x";vi.spyOn(n,"decode").mockReturnValueOnce(["0x","0x","0x",["0x0102030405060708090a0b0c0d0e0f1011121314","invalid"],!1]);const t=c.decode(a,e,1);expect(t).toEqual([])}),it("should return an empty array if the addresses are not an array",()=>{const e="0x";vi.spyOn(n,"decode").mockReturnValueOnce(["0x","0x","0x","invalid",!1]);const t=c.decode(a,e,1);expect(t).toEqual([])}),it("should return an empty array if the addresses are not an array of hexa strings",()=>{const e="0x";vi.spyOn(n,"decode").mockReturnValueOnce(["0x","0x","0x",["invalid"],!1]);const t=c.decode(a,e,1);expect(t).toEqual([])})}),describe.each([[s.V3_SWAP_EXACT_IN],[s.V3_SWAP_EXACT_OUT]])("%s",a=>{it("should return the correct command data",()=>{const e="0x",d=["0102030405060708090a0b0c0d0e0f1011121314","0102030405060708090a0b0c0d0e0f1011121315"].reduce((u,x)=>u.length===0?`0x${x}`:`${u}999999${x}`,"");vi.spyOn(n,"decode").mockReturnValueOnce(["0x","0x","0x",d,!1]);const o=c.decode(a,e,1);expect(o).toEqual(["0x0102030405060708090a0b0c0d0e0f1011121314","0x0102030405060708090a0b0c0d0e0f1011121315"])}),it("should return the correct command data with multiple addresses",()=>{const e="0x",d=["0102030405060708090a0b0c0d0e0f1011121314","0102030405060708090a0b0c0d0e0f1011121315","0102030405060708090a0b0c0d0e0f1011121316","0102030405060708090a0b0c0d0e0f1011121317"].reduce((u,x)=>u.length===0?`0x${x}`:`${u}999999${x}`,"");vi.spyOn(n,"decode").mockReturnValueOnce(["0x","0x","0x",d,!1]);const o=c.decode(a,e,1);expect(o).toEqual(["0x0102030405060708090a0b0c0d0e0f1011121314","0x0102030405060708090a0b0c0d0e0f1011121315","0x0102030405060708090a0b0c0d0e0f1011121316","0x0102030405060708090a0b0c0d0e0f1011121317"])}),it("should return an empty array if the path is not valid",()=>{const e="0x";vi.spyOn(n,"decode").mockReturnValueOnce(["0x","0x","0x","invalid",!1]);const t=c.decode(a,e,1);expect(t).toEqual([])}),it("should return an empty array if the path is not a string",()=>{const e="0x";vi.spyOn(n,"decode").mockReturnValueOnce(["0x","0x","0x",123,!1]);const t=c.decode(a,e,1);expect(t).toEqual([])}),it("should return an empty array if the path is not a hexa string",()=>{const e="0x";vi.spyOn(n,"decode").mockReturnValueOnce(["0x","0x","0x","invalid",!1]);const t=c.decode(a,e,1);expect(t).toEqual([])}),it("should return an empty array if the path is too short",()=>{const e="0x",d=["0102030405060708090a0b0c0d0e0f1011121314","0102030405060708090a0b0c0d0e0f101112131"].reduce((u,x)=>u.length===0?`0x${x}`:`${u}999999${x}`,"");vi.spyOn(n,"decode").mockReturnValueOnce(["0x","0x","0x",d,!1]);const o=c.decode(a,e,1);expect(o).toEqual([])})}),describe.each([s.WRAP_ETH,s.UNWRAP_ETH])("%s",a=>{it.each([r.ARBITRUM_GOERLI,r.ARBITRUM_ONE,r.AVALANCHE_C_CHAIN,r.BASE,r.BASE_GOERLI,r.BLAST,r.BSC,r.ETHEREUM_GOERLI,r.ETHEREUM_MAINNET,r.ETHEREUM_SEPOLIA,r.OPTIMISM,r.OPTIMISM_GOERLI,r.POLYGON,r.POLYGON_MUMBAI])("should return the correct command data for chainId %s",e=>{const d=c.decode(a,"0x",e);expect(d).toEqual([l[e].toLowerCase()])}),it("should return an empty array if the chainId is not supported",()=>{const t=c.decode(s.WRAP_ETH,"0x",123);expect(t).toEqual([])})}),describe("SWEEP",()=>{it("should return the correct command data",()=>{const a="0x";vi.spyOn(n,"decode").mockReturnValueOnce(["0x0102030405060708090a0b0c0d0e0f1011121314","0x","0x","0x"]);const e=c.decode(s.SWEEP,a,1);expect(e).toEqual(["0x0102030405060708090a0b0c0d0e0f1011121314"])}),it("should return an empty array if the address is not valid",()=>{const a="0x";vi.spyOn(n,"decode").mockReturnValueOnce(["invalid","0x","0x","0x"]);const e=c.decode(s.SWEEP,a,1);expect(e).toEqual([])}),it("should return an empty array if the address is not a hexa string",()=>{const a="0x";vi.spyOn(n,"decode").mockReturnValueOnce([123,"0x","0x","0x"]);const e=c.decode(s.SWEEP,a,1);expect(e).toEqual([])})}),describe.each([s.PERMIT2_PERMIT,s.PERMIT2_TRANSFER_FROM,s.PERMIT2_PERMIT_BATCH,s.PERMIT2_TRANSFER_FROM_BATCH,s.PAY_PORTION,"invalid"])("%s",a=>{it("should return an empty array",()=>{const t=c.decode(a,"0x",1);expect(t).toEqual([])})})}),describe("decode with real apiDecoder",()=>{beforeEach(()=>{const a=new b;c=new p(a)}),describe("V3_SWAP_EXACT_IN -> PAY_PORTION -> UNWRAP_ETH",()=>{const a=["0x00","0x06","0x0c"],e=["0x00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000a18f07d736b90be5500000000000000000000000000000000000000000000000000000000b0b8122abd8412900000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bb9f599ce614feb2e1bbe58f180f370d05b39344e002710c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000017cc6042605381c158d2adab487434bde79aa61c000000000000000000000000000000000000000000000000000000000000005b","0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000b0b8122abd84129"];it("V3_SWAP_EXACT_IN",()=>{const t=a[0],d=e[0],o=c.decode(i[t],d,1);expect(o).toEqual(["0xb9f599ce614feb2e1bbe58f180f370d05b39344e","0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"])}),it("PAY_PORTION",()=>{const t=a[1],d=e[1],o=c.decode(i[t],d,1);expect(o).toEqual([])}),it("UNWRAP_ETH",()=>{const t=a[2],d=e[2],o=c.decode(i[t],d,1);expect(o).toEqual(["0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"])})}),describe("WRAP_ETH -> V3_SWAP_EXACT_OUT -> TRANSFERT -> SWEEP -> UNWRAP_ETH",()=>{const a=["0x0b","0x01","0x05","0x04","0x0c"],e=["0x0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000078e6708e70aed0f","0x00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000059a16770000000000000000000000000000000000000000000000000078e6708e70aed0f00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f4c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000027213e28d7fda5c57fe9e5dd923818dbccf71c470000000000000000000000000000000000000000000000000000000000393870","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006f939b43d65be049b7533907db08e80ba6969f450000000000000000000000000000000000000000000000000000000059682f00","0x0000000000000000000000006f939b43d65be049b7533907db08e80ba6969f450000000000000000000000000000000000000000000000000000000000000000"];it("WRAP_ETH",()=>{const t=a[0],d=e[0],o=c.decode(i[t],d,1);expect(o).toEqual(["0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"])}),it("V3_SWAP_EXACT_OUT",()=>{const t=a[1],d=e[1],o=c.decode(i[t],d,1);expect(o).toEqual(["0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"])}),it("TRANSFERT",()=>{const t=a[2],d=e[2],o=c.decode(i[t],d,1);expect(o).toEqual([])}),it("SWEEP",()=>{const t=a[3],d=e[3],o=c.decode(i[t],d,1);expect(o).toEqual(["0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"])}),it("UNWRAP_ETH",()=>{const t=a[4],d=e[4],o=c.decode(i[t],d,1);expect(o).toEqual(["0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"])})}),describe("V2_SWAP_EXACT_IN -> PAY_PORTION -> UNWRAP_ETH",()=>{const a=["0x08","0x06","0x0c"],e=["0x0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000003ebb8addda849d38caed0000000000000000000000000000000000000000000000000f238e04a7ccbf5100000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000003b991130eae3cca364406d718da22fa1c3e7c256000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c0000000000000000000000000000000000000000000000000000000000000019","0x00000000000000000000000002573c689ddedddd450e6c947f5bb67de70e80b50000000000000000000000000000000000000000000000000f19dda9c38a50c1"];it("V2_SWAP_EXACT_IN",()=>{const t=a[0],d=e[0],o=c.decode(i[t],d,1);expect(o).toEqual(["0x3b991130eae3cca364406d718da22fa1c3e7c256","0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"])}),it("PAY_PORTION",()=>{const t=a[1],d=e[1],o=c.decode(i[t],d,1);expect(o).toEqual([])}),it("UNWRAP_ETH",()=>{const t=a[2],d=e[2],o=c.decode(i[t],d,1);expect(o).toEqual(["0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"])})})})});
2
+ //# sourceMappingURL=DefaultCommandDecoderDataSource.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/uniswap/data/DefaultCommandDecoderDataSource.test.ts"],
4
+ "sourcesContent": ["import { type HexaString } from \"@ledgerhq/device-management-kit\";\n\nimport {\n UNISWAP_COMMANDS,\n UniswapSupportedCommand,\n} from \"@/uniswap/constants/uniswap\";\nimport {\n WETH_ADDRESS_BY_CHAIN_ID,\n WETHSupportedChainIds,\n} from \"@/uniswap/constants/weth\";\n\nimport { type AbiDecoderDataSource } from \"./AbiDecoderDataSource\";\nimport { DefaultCommandDecoderDataSource } from \"./DefaultCommandDecoderDataSource\";\nimport { EthersAbiDecoderDataSource } from \"./EthersAbiDecoderDataSource\";\n\ndescribe(\"DefaultCommandDecoderDataSource\", () => {\n const apiDecoderMock: AbiDecoderDataSource = {\n decode: vi.fn(),\n };\n let dataSource: DefaultCommandDecoderDataSource;\n\n describe(\"decode with mocked apiDecoder\", () => {\n beforeEach(() => {\n dataSource = new DefaultCommandDecoderDataSource(apiDecoderMock);\n });\n\n describe.each([\n [UniswapSupportedCommand.V2_SWAP_EXACT_IN],\n [UniswapSupportedCommand.V2_SWAP_EXACT_OUT],\n ])(\"%s\", (command) => {\n it(\"should return the correct command data\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x\",\n \"0x\",\n \"0x\",\n [\"0x0102030405060708090a0b0c0d0e0f1011121314\"],\n false,\n ]);\n\n // WHEN\n const result = dataSource.decode(command, input, 1);\n\n // THEN\n expect(result).toEqual([\"0x0102030405060708090a0b0c0d0e0f1011121314\"]);\n });\n\n it(\"should return the correct command data with multiple addresses\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x\",\n \"0x\",\n \"0x\",\n [\n \"0x0102030405060708090a0b0c0d0e0f1011121314\",\n \"0x0102030405060708090a0b0c0d0e0f1011121315\",\n ],\n false,\n ]);\n\n // WHEN\n const result = dataSource.decode(command, input, 1);\n\n // THEN\n expect(result).toEqual([\n \"0x0102030405060708090a0b0c0d0e0f1011121314\",\n \"0x0102030405060708090a0b0c0d0e0f1011121315\",\n ]);\n });\n\n it(\"should return an empty array if an address is not valid\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x\",\n \"0x\",\n \"0x\",\n [\"0x0102030405060708090a0b0c0d0e0f1011121314\", \"invalid\"],\n false,\n ]);\n\n // WHEN\n const result = dataSource.decode(command, input, 1);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if the addresses are not an array\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x\",\n \"0x\",\n \"0x\",\n \"invalid\",\n false,\n ]);\n\n // WHEN\n const result = dataSource.decode(command, input, 1);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if the addresses are not an array of hexa strings\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x\",\n \"0x\",\n \"0x\",\n [\"invalid\"],\n false,\n ]);\n\n // WHEN\n const result = dataSource.decode(command, input, 1);\n\n // THEN\n expect(result).toEqual([]);\n });\n });\n describe.each([\n [UniswapSupportedCommand.V3_SWAP_EXACT_IN],\n [UniswapSupportedCommand.V3_SWAP_EXACT_OUT],\n ])(\"%s\", (command) => {\n it(\"should return the correct command data\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n const addresses = [\n \"0102030405060708090a0b0c0d0e0f1011121314\",\n \"0102030405060708090a0b0c0d0e0f1011121315\",\n ];\n const path = addresses.reduce(\n (acc, address) =>\n acc.length === 0 ? `0x${address}` : `${acc}999999${address}`,\n \"\",\n );\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x\",\n \"0x\",\n \"0x\",\n path,\n false,\n ]);\n\n // WHEN\n const result = dataSource.decode(command, input, 1);\n\n // THEN\n expect(result).toEqual([\n \"0x0102030405060708090a0b0c0d0e0f1011121314\",\n \"0x0102030405060708090a0b0c0d0e0f1011121315\",\n ]);\n });\n\n it(\"should return the correct command data with multiple addresses\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n const addresses = [\n \"0102030405060708090a0b0c0d0e0f1011121314\",\n \"0102030405060708090a0b0c0d0e0f1011121315\",\n \"0102030405060708090a0b0c0d0e0f1011121316\",\n \"0102030405060708090a0b0c0d0e0f1011121317\",\n ];\n const path = addresses.reduce(\n (acc, address) =>\n acc.length === 0 ? `0x${address}` : `${acc}999999${address}`,\n \"\",\n );\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x\",\n \"0x\",\n \"0x\",\n path,\n false,\n ]);\n\n // WHEN\n const result = dataSource.decode(command, input, 1);\n\n // THEN\n expect(result).toEqual([\n \"0x0102030405060708090a0b0c0d0e0f1011121314\",\n \"0x0102030405060708090a0b0c0d0e0f1011121315\",\n \"0x0102030405060708090a0b0c0d0e0f1011121316\",\n \"0x0102030405060708090a0b0c0d0e0f1011121317\",\n ]);\n });\n\n it(\"should return an empty array if the path is not valid\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x\",\n \"0x\",\n \"0x\",\n \"invalid\",\n false,\n ]);\n\n // WHEN\n const result = dataSource.decode(command, input, 1);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if the path is not a string\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x\",\n \"0x\",\n \"0x\",\n 123,\n false,\n ]);\n\n // WHEN\n const result = dataSource.decode(command, input, 1);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if the path is not a hexa string\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x\",\n \"0x\",\n \"0x\",\n \"invalid\",\n false,\n ]);\n\n // WHEN\n const result = dataSource.decode(command, input, 1);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if the path is too short\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n\n const addresses = [\n \"0102030405060708090a0b0c0d0e0f1011121314\",\n \"0102030405060708090a0b0c0d0e0f101112131\", // 1 char missing\n ];\n const path = addresses.reduce(\n (acc, address) =>\n acc.length === 0 ? `0x${address}` : `${acc}999999${address}`,\n \"\",\n );\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x\",\n \"0x\",\n \"0x\",\n path,\n false,\n ]);\n\n // WHEN\n const result = dataSource.decode(command, input, 1);\n\n // THEN\n expect(result).toEqual([]);\n });\n });\n\n describe.each([\n UniswapSupportedCommand.WRAP_ETH,\n UniswapSupportedCommand.UNWRAP_ETH,\n ])(\"%s\", (command) => {\n it.each([\n WETHSupportedChainIds.ARBITRUM_GOERLI,\n WETHSupportedChainIds.ARBITRUM_ONE,\n WETHSupportedChainIds.AVALANCHE_C_CHAIN,\n WETHSupportedChainIds.BASE,\n WETHSupportedChainIds.BASE_GOERLI,\n WETHSupportedChainIds.BLAST,\n WETHSupportedChainIds.BSC,\n WETHSupportedChainIds.ETHEREUM_GOERLI,\n WETHSupportedChainIds.ETHEREUM_MAINNET,\n WETHSupportedChainIds.ETHEREUM_SEPOLIA,\n WETHSupportedChainIds.OPTIMISM,\n WETHSupportedChainIds.OPTIMISM_GOERLI,\n WETHSupportedChainIds.POLYGON,\n WETHSupportedChainIds.POLYGON_MUMBAI,\n ])(\"should return the correct command data for chainId %s\", (chainId) => {\n // GIVEN\n const input: HexaString = \"0x\";\n\n // WHEN\n const result = dataSource.decode(command, input, chainId);\n\n // THEN\n expect(result).toEqual([\n WETH_ADDRESS_BY_CHAIN_ID[chainId].toLowerCase(),\n ]);\n });\n\n it(\"should return an empty array if the chainId is not supported\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n\n // WHEN\n const result = dataSource.decode(\n UniswapSupportedCommand.WRAP_ETH,\n input,\n 123,\n );\n\n // THEN\n expect(result).toEqual([]);\n });\n });\n\n describe(\"SWEEP\", () => {\n it(\"should return the correct command data\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x0102030405060708090a0b0c0d0e0f1011121314\",\n \"0x\",\n \"0x\",\n \"0x\",\n ]);\n\n // WHEN\n const result = dataSource.decode(\n UniswapSupportedCommand.SWEEP,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([\"0x0102030405060708090a0b0c0d0e0f1011121314\"]);\n });\n\n it(\"should return an empty array if the address is not valid\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n \"invalid\",\n \"0x\",\n \"0x\",\n \"0x\",\n ]);\n\n // WHEN\n const result = dataSource.decode(\n UniswapSupportedCommand.SWEEP,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if the address is not a hexa string\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n vi.spyOn(apiDecoderMock, \"decode\").mockReturnValueOnce([\n 123,\n \"0x\",\n \"0x\",\n \"0x\",\n ]);\n\n // WHEN\n const result = dataSource.decode(\n UniswapSupportedCommand.SWEEP,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([]);\n });\n });\n\n describe.each([\n UniswapSupportedCommand.PERMIT2_PERMIT,\n UniswapSupportedCommand.PERMIT2_TRANSFER_FROM,\n UniswapSupportedCommand.PERMIT2_PERMIT_BATCH,\n UniswapSupportedCommand.PERMIT2_TRANSFER_FROM_BATCH,\n UniswapSupportedCommand.PAY_PORTION,\n \"invalid\" as UniswapSupportedCommand,\n ])(\"%s\", (command) => {\n it(\"should return an empty array\", () => {\n // GIVEN\n const input: HexaString = \"0x\";\n\n // WHEN\n const result = dataSource.decode(command, input, 1);\n\n // THEN\n expect(result).toEqual([]);\n });\n });\n });\n\n describe(\"decode with real apiDecoder\", () => {\n beforeEach(() => {\n const abiDecoder = new EthersAbiDecoderDataSource();\n dataSource = new DefaultCommandDecoderDataSource(abiDecoder);\n });\n\n describe(\"V3_SWAP_EXACT_IN -> PAY_PORTION -> UNWRAP_ETH\", () => {\n // https://etherscan.io/tx/0xc9821c32c1782d9ab6baf6f9ca4b2565bce11aaf5146a2d303215bda026f5e48\n const commands: HexaString[] = [\"0x00\", \"0x06\", \"0x0c\"];\n const inputs: HexaString[] = [\n \"0x00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000a18f07d736b90be5500000000000000000000000000000000000000000000000000000000b0b8122abd8412900000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bb9f599ce614feb2e1bbe58f180f370d05b39344e002710c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000\",\n \"0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000017cc6042605381c158d2adab487434bde79aa61c000000000000000000000000000000000000000000000000000000000000005b\",\n \"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000b0b8122abd84129\",\n ];\n\n it(\"V3_SWAP_EXACT_IN\", () => {\n // GIVEN\n const command = commands[0]!;\n const input = inputs[0]!;\n\n // WHEN\n const result = dataSource.decode(\n UNISWAP_COMMANDS[command] as UniswapSupportedCommand,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([\n \"0xb9f599ce614feb2e1bbe58f180f370d05b39344e\", // ERC20\n \"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\", // WETH\n ]);\n });\n\n it(\"PAY_PORTION\", () => {\n // GIVEN\n const command = commands[1]!;\n const input = inputs[1]!;\n\n // WHEN\n const result = dataSource.decode(\n UNISWAP_COMMANDS[command] as UniswapSupportedCommand,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"UNWRAP_ETH\", () => {\n // GIVEN\n const command = commands[2]!;\n const input = inputs[2]!;\n\n // WHEN\n const result = dataSource.decode(\n UNISWAP_COMMANDS[command] as UniswapSupportedCommand,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([\"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\"]); // WETH\n });\n });\n\n describe(\"WRAP_ETH -> V3_SWAP_EXACT_OUT -> TRANSFERT -> SWEEP -> UNWRAP_ETH\", () => {\n // https://etherscan.io/tx/0xa628c8b3da2ad984aed0354d8ca4b4c3c42941491dc4e0d6a5f423fd65e6c90a\n const commands: HexaString[] = [\"0x0b\", \"0x01\", \"0x05\", \"0x04\", \"0x0c\"];\n const inputs: HexaString[] = [\n \"0x0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000078e6708e70aed0f\",\n \"0x00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000059a16770000000000000000000000000000000000000000000000000078e6708e70aed0f00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f4c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000\",\n \"0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000027213e28d7fda5c57fe9e5dd923818dbccf71c470000000000000000000000000000000000000000000000000000000000393870\",\n \"0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006f939b43d65be049b7533907db08e80ba6969f450000000000000000000000000000000000000000000000000000000059682f00\",\n \"0x0000000000000000000000006f939b43d65be049b7533907db08e80ba6969f450000000000000000000000000000000000000000000000000000000000000000\",\n ];\n\n it(\"WRAP_ETH\", () => {\n // GIVEN\n const command = commands[0]!;\n const input = inputs[0]!;\n\n // WHEN\n const result = dataSource.decode(\n UNISWAP_COMMANDS[command] as UniswapSupportedCommand,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([\"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\"]); // WETH\n });\n\n it(\"V3_SWAP_EXACT_OUT\", () => {\n // GIVEN\n const command = commands[1]!;\n const input = inputs[1]!;\n\n // WHEN\n const result = dataSource.decode(\n UNISWAP_COMMANDS[command] as UniswapSupportedCommand,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([\n \"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48\", // USDC\n \"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\", // WETH\n ]);\n });\n\n it(\"TRANSFERT\", () => {\n // GIVEN\n const command = commands[2]!;\n const input = inputs[2]!;\n\n // WHEN\n const result = dataSource.decode(\n UNISWAP_COMMANDS[command] as UniswapSupportedCommand,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"SWEEP\", () => {\n // GIVEN\n const command = commands[3]!;\n const input = inputs[3]!;\n\n // WHEN\n const result = dataSource.decode(\n UNISWAP_COMMANDS[command] as UniswapSupportedCommand,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([\"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48\"]); // USDC\n });\n\n it(\"UNWRAP_ETH\", () => {\n // GIVEN\n const command = commands[4]!;\n const input = inputs[4]!;\n\n // WHEN\n const result = dataSource.decode(\n UNISWAP_COMMANDS[command] as UniswapSupportedCommand,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([\"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\"]); // WETH\n });\n });\n\n describe(\"V2_SWAP_EXACT_IN -> PAY_PORTION -> UNWRAP_ETH\", () => {\n // https://etherscan.io/tx/0x78bc5732213e09d9ead8cabc269b7c426b0301dfe543c37d0a920e25eaa9447f\n const commands: HexaString[] = [\"0x08\", \"0x06\", \"0x0c\"];\n const inputs: HexaString[] = [\n \"0x0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000003ebb8addda849d38caed0000000000000000000000000000000000000000000000000f238e04a7ccbf5100000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000003b991130eae3cca364406d718da22fa1c3e7c256000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\",\n \"0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c0000000000000000000000000000000000000000000000000000000000000019\",\n \"0x00000000000000000000000002573c689ddedddd450e6c947f5bb67de70e80b50000000000000000000000000000000000000000000000000f19dda9c38a50c1\",\n ];\n\n it(\"V2_SWAP_EXACT_IN\", () => {\n // GIVEN\n const command = commands[0]!;\n const input = inputs[0]!;\n\n // WHEN\n const result = dataSource.decode(\n UNISWAP_COMMANDS[command] as UniswapSupportedCommand,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([\n \"0x3b991130eae3cca364406d718da22fa1c3e7c256\", // ERC20\n \"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\", // WETH\n ]);\n });\n\n it(\"PAY_PORTION\", () => {\n // GIVEN\n const command = commands[1]!;\n const input = inputs[1]!;\n\n // WHEN\n const result = dataSource.decode(\n UNISWAP_COMMANDS[command] as UniswapSupportedCommand,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"UNWRAP_ETH\", () => {\n // GIVEN\n const command = commands[2]!;\n const input = inputs[2]!;\n\n // WHEN\n const result = dataSource.decode(\n UNISWAP_COMMANDS[command] as UniswapSupportedCommand,\n input,\n 1,\n );\n\n // THEN\n expect(result).toEqual([\"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\"]); // WETH\n });\n });\n });\n});\n"],
5
+ "mappings": "AAEA,OACE,oBAAAA,EACA,2BAAAC,MACK,8BACP,OACE,4BAAAC,EACA,yBAAAC,MACK,2BAGP,OAAS,mCAAAC,MAAuC,oCAChD,OAAS,8BAAAC,MAAkC,+BAE3C,SAAS,kCAAmC,IAAM,CAChD,MAAMC,EAAuC,CAC3C,OAAQ,GAAG,GAAG,CAChB,EACA,IAAIC,EAEJ,SAAS,gCAAiC,IAAM,CAC9C,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AAM,CAE3B,MAAMT,EAAUQ,EAAS,CAAC,EACpBP,EAAQQ,EAAO,CAAC,EAGhBP,EAASH,EAAW,OACxBP,EAAiBQ,CAAO,EACxBC,EACA,CACF,EAGA,OAAOC,CAAM,EAAE,QAAQ,CACrB,6CACA,4CACF,CAAC,CACH,CAAC,EAED,GAAG,cAAe,IAAM,CAEtB,MAAMF,EAAUQ,EAAS,CAAC,EACpBP,EAAQQ,EAAO,CAAC,EAGhBP,EAASH,EAAW,OACxBP,EAAiBQ,CAAO,EACxBC,EACA,CACF,EAGA,OAAOC,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,EAED,GAAG,aAAc,IAAM,CAErB,MAAMF,EAAUQ,EAAS,CAAC,EACpBP,EAAQQ,EAAO,CAAC,EAGhBP,EAASH,EAAW,OACxBP,EAAiBQ,CAAO,EACxBC,EACA,CACF,EAGA,OAAOC,CAAM,EAAE,QAAQ,CAAC,4CAA4C,CAAC,CACvE,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["UNISWAP_COMMANDS", "UniswapSupportedCommand", "WETH_ADDRESS_BY_CHAIN_ID", "WETHSupportedChainIds", "DefaultCommandDecoderDataSource", "EthersAbiDecoderDataSource", "apiDecoderMock", "dataSource", "command", "input", "result", "path", "acc", "address", "chainId", "abiDecoder", "commands", "inputs"]
7
+ }
@@ -0,0 +1,2 @@
1
+ var c=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var p=(i,o,t,e)=>{for(var r=e>1?void 0:e?f(o,t):o,m=i.length-1,d;m>=0;m--)(d=i[m])&&(r=(e?d(o,t,r):d(r))||r);return e&&r&&c(o,t,r),r};import{AbiCoder as l}from"ethers";import{injectable as u}from"inversify";let n=class{decode(o,t){try{return l.defaultAbiCoder().decode(o,t)}catch{return[]}}};n=p([u()],n);export{n as EthersAbiDecoderDataSource};
2
+ //# sourceMappingURL=EthersAbiDecoderDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/uniswap/data/EthersAbiDecoderDataSource.ts"],
4
+ "sourcesContent": ["import { AbiCoder } from \"ethers\";\nimport { injectable } from \"inversify\";\n\nimport { type AbiDecoderDataSource } from \"./AbiDecoderDataSource\";\n\n@injectable()\nexport class EthersAbiDecoderDataSource implements AbiDecoderDataSource {\n decode(types: string[], data: string): unknown[] {\n try {\n return AbiCoder.defaultAbiCoder().decode(types, data);\n } catch (_) {\n return [];\n }\n }\n}\n"],
5
+ "mappings": "wMAAA,OAAS,YAAAA,MAAgB,SACzB,OAAS,cAAAC,MAAkB,YAKpB,IAAMC,EAAN,KAAiE,CACtE,OAAOC,EAAiBC,EAAyB,CAC/C,GAAI,CACF,OAAOC,EAAS,gBAAgB,EAAE,OAAOF,EAAOC,CAAI,CACtD,MAAY,CACV,MAAO,CAAC,CACV,CACF,CACF,EARaF,EAANI,EAAA,CADNC,EAAW,GACCL",
6
+ "names": ["AbiCoder", "injectable", "EthersAbiDecoderDataSource", "types", "data", "AbiCoder", "__decorateClass", "injectable"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{EthersAbiDecoderDataSource as d}from"./EthersAbiDecoderDataSource";describe("EthersAbiDecoderDataSource",()=>{let t;beforeEach(()=>{t=new d}),it("should correctly decode valid ABI data",()=>{const c=["uint256","address"],e=t.decode(c,"0x000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000027213e28d7fda5c57fe9e5dd923818dbccf71c47");expect(e[0]).toEqual(10n),expect(e[1]).toEqual("0x27213E28D7fDA5c57Fe9e5dD923818DBCcf71c47")}),it("should return an empty array on decode failure",()=>{const c=["uint256"],e=t.decode(c,"0x1234");expect(e).toEqual([])})});
2
+ //# sourceMappingURL=EthersAbiDecoderDataSource.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/uniswap/data/EthersAbiDecoderDataSource.test.ts"],
4
+ "sourcesContent": ["import { EthersAbiDecoderDataSource } from \"./EthersAbiDecoderDataSource\";\n\ndescribe(\"EthersAbiDecoderDataSource\", () => {\n let decoder: EthersAbiDecoderDataSource;\n\n beforeEach(() => {\n decoder = new EthersAbiDecoderDataSource();\n });\n\n it(\"should correctly decode valid ABI data\", () => {\n const types = [\"uint256\", \"address\"];\n const data =\n \"0x\" +\n \"000000000000000000000000000000000000000000000000000000000000000a\" + // 10 as uint256\n \"00000000000000000000000027213e28d7fda5c57fe9e5dd923818dbccf71c47\"; // Address\n\n const result = decoder.decode(types, data);\n expect(result[0]).toEqual(10n);\n expect(result[1]).toEqual(\"0x27213E28D7fDA5c57Fe9e5dD923818DBCcf71c47\");\n });\n\n it(\"should return an empty array on decode failure\", () => {\n const types = [\"uint256\"];\n const invalidData = \"0x1234\"; // Invalid encoded data\n\n const result = decoder.decode(types, invalidData);\n expect(result).toEqual([]);\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,8BAAAA,MAAkC,+BAE3C,SAAS,6BAA8B,IAAM,CAC3C,IAAIC,EAEJ,WAAW,IAAM,CACfA,EAAU,IAAID,CAChB,CAAC,EAED,GAAG,yCAA0C,IAAM,CACjD,MAAME,EAAQ,CAAC,UAAW,SAAS,EAM7BC,EAASF,EAAQ,OAAOC,EAJ5B,oIAIuC,EACzC,OAAOC,EAAO,CAAC,CAAC,EAAE,QAAQ,GAAG,EAC7B,OAAOA,EAAO,CAAC,CAAC,EAAE,QAAQ,4CAA4C,CACxE,CAAC,EAED,GAAG,iDAAkD,IAAM,CACzD,MAAMD,EAAQ,CAAC,SAAS,EAGlBC,EAASF,EAAQ,OAAOC,EAFV,QAE4B,EAChD,OAAOC,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,CACH,CAAC",
6
+ "names": ["EthersAbiDecoderDataSource", "decoder", "types", "result"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{ContainerModule as r}from"inversify";import{DefaultCommandDecoderDataSource as t}from"../../uniswap/data/DefaultCommandDecoderDataSource";import{EthersAbiDecoderDataSource as a}from"../../uniswap/data/EthersAbiDecoderDataSource";import{UniswapContextLoader as m}from"../../uniswap/domain/UniswapContextLoader";import{uniswapTypes as e}from"./uniswapTypes";const f=()=>new r((o,n,i,d)=>{o(e.AbiDecoderDataSource).to(a),o(e.CommandDecoderDataSource).to(t),o(e.UniswapContextLoader).to(m)});export{f as uniswapModuleFactory};
2
+ //# sourceMappingURL=uniswapModuleFactory.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/uniswap/di/uniswapModuleFactory.ts"],
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { DefaultCommandDecoderDataSource } from \"@/uniswap/data/DefaultCommandDecoderDataSource\";\nimport { EthersAbiDecoderDataSource } from \"@/uniswap/data/EthersAbiDecoderDataSource\";\nimport { UniswapContextLoader } from \"@/uniswap/domain/UniswapContextLoader\";\n\nimport { uniswapTypes } from \"./uniswapTypes\";\n\nexport const uniswapModuleFactory = () =>\n new ContainerModule((bind, _unbind, _isBound, _rebind) => {\n bind(uniswapTypes.AbiDecoderDataSource).to(EthersAbiDecoderDataSource);\n bind(uniswapTypes.CommandDecoderDataSource).to(\n DefaultCommandDecoderDataSource,\n );\n bind(uniswapTypes.UniswapContextLoader).to(UniswapContextLoader);\n });\n"],
5
+ "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,mCAAAC,MAAuC,iDAChD,OAAS,8BAAAC,MAAkC,4CAC3C,OAAS,wBAAAC,MAA4B,wCAErC,OAAS,gBAAAC,MAAoB,iBAEtB,MAAMC,EAAuB,IAClC,IAAIL,EAAgB,CAACM,EAAMC,EAASC,EAAUC,IAAY,CACxDH,EAAKF,EAAa,oBAAoB,EAAE,GAAGF,CAA0B,EACrEI,EAAKF,EAAa,wBAAwB,EAAE,GAC1CH,CACF,EACAK,EAAKF,EAAa,oBAAoB,EAAE,GAAGD,CAAoB,CACjE,CAAC",
6
+ "names": ["ContainerModule", "DefaultCommandDecoderDataSource", "EthersAbiDecoderDataSource", "UniswapContextLoader", "uniswapTypes", "uniswapModuleFactory", "bind", "_unbind", "_isBound", "_rebind"]
7
+ }
@@ -0,0 +1,2 @@
1
+ const o={AbiDecoderDataSource:Symbol.for("AbiDecoderDataSource"),CommandDecoderDataSource:Symbol.for("CommandDecoderDataSource"),UniswapContextLoader:Symbol.for("UniswapContextLoader")};export{o as uniswapTypes};
2
+ //# sourceMappingURL=uniswapTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/uniswap/di/uniswapTypes.ts"],
4
+ "sourcesContent": ["export const uniswapTypes = {\n AbiDecoderDataSource: Symbol.for(\"AbiDecoderDataSource\"),\n CommandDecoderDataSource: Symbol.for(\"CommandDecoderDataSource\"),\n UniswapContextLoader: Symbol.for(\"UniswapContextLoader\"),\n};\n"],
5
+ "mappings": "AAAO,MAAMA,EAAe,CAC1B,qBAAsB,OAAO,IAAI,sBAAsB,EACvD,yBAA0B,OAAO,IAAI,0BAA0B,EAC/D,qBAAsB,OAAO,IAAI,sBAAsB,CACzD",
6
+ "names": ["uniswapTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ var P=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var g=(d,e,t,a)=>{for(var r=a>1?void 0:a?U(e,t):e,n=d.length-1,o;n>=0;n--)(o=d[n])&&(r=(a?o(e,t,r):o(r))||r);return a&&r&&P(e,t,r),r},u=(d,e)=>(t,a)=>e(t,a,d);import{bufferToHexaString as N,ByteArrayBuilder as E,hexaStringToBuffer as p,isHexaString as c}from"@ledgerhq/device-management-kit";import{Interface as I}from"ethers";import{inject as C,injectable as w}from"inversify";import{Maybe as x,Nothing as k}from"purify-ts";import{ClearSignContextType as S}from"../../shared/model/ClearSignContext";import{tokenTypes as H}from"../../token/di/tokenTypes";import{UNISWAP_PLUGIN_NAME as y,UNISWAP_PLUGIN_SIGNATURE as b}from"../../uniswap/constants/plugin";import{UNISWAP_COMMANDS as R,UNISWAP_EXECUTE_ABI as v,UNISWAP_EXECUTE_SELECTOR as D,UNISWAP_SWAP_COMMANDS as B,UNISWAP_UNIVERSAL_ROUTER_ADDRESS as M}from"../../uniswap/constants/uniswap";import{uniswapTypes as W}from"../../uniswap/di/uniswapTypes";let m=class{constructor(e,t){this.commandDecoderDataSource=e;this.tokenDataSource=t}async load(e){if(!e.data||!c(e.data))return[];if(e.data.slice(0,10)!==D)return[];const a=this._buildUniswapPluginCommandData(),r=await this._extractClearSignContexts(e.data,e.chainId);return r.length>0?[a,...r]:[]}_buildUniswapPluginCommandData(){const e=new E().add8BitUIntToData(y.length).addAsciiStringToData(y).addBufferToData(p(M)).addBufferToData(p(D)).addBufferToData(p(b)).build();return{type:S.EXTERNAL_PLUGIN,payload:N(e).slice(2)}}async _extractClearSignContexts(e,t){try{const r=new I(v).parseTransaction({data:e}),n=r?.args[0],o=r?.args[1];if(!c(n)||!this._isHexaStringArray(o))return[];const f=this._extractCommands(n).orDefault([]);if(n.length===0||o.length!==f.length)return[];const l=f.reduce((i,s,A)=>{const T=o[A],h=this.commandDecoderDataSource.decode(s,T,t);return i.push([s,h]),i},[]);if(!this._isChainingSwapSupported(l))return[];const _=[...new Set(l.flatMap(([,i])=>i))];return(await Promise.all(_.map(i=>this.tokenDataSource.getTokenInfosPayload({address:i,chainId:t})))).map(i=>i.caseOf({Left:s=>({type:S.ERROR,error:s}),Right:s=>({type:S.TOKEN,payload:s})}))}catch{return[]}}_extractCommands(e){return x.fromNullable(e.slice(2).match(/../g)).map(t=>t.map(a=>`0x${a}`)).map(t=>t.map(a=>R[a])).chain(t=>t.every(a=>a!==void 0)?x.of(t):k)}_isChainingSwapSupported(e){let t,a;for(const[r,n]of e){if(!B.includes(r))continue;const o=r.slice(0,2);if(t&&(t!==n[0]||a!==o))return!1;t=n[n.length-1],a=o}return!0}_isHexaStringArray(e){return Array.isArray(e)&&e.every(t=>typeof t=="string"&&c(t))}};m=g([w(),u(0,C(W.CommandDecoderDataSource)),u(1,C(H.TokenDataSource))],m);export{m as UniswapContextLoader};
2
+ //# sourceMappingURL=UniswapContextLoader.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/uniswap/domain/UniswapContextLoader.ts"],
4
+ "sourcesContent": ["import {\n bufferToHexaString,\n ByteArrayBuilder,\n HexaString,\n hexaStringToBuffer,\n isHexaString,\n} from \"@ledgerhq/device-management-kit\";\nimport { Interface } from \"ethers\";\nimport { inject, injectable } from \"inversify\";\nimport { Maybe, Nothing } from \"purify-ts\";\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 TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\nimport {\n UNISWAP_PLUGIN_NAME,\n UNISWAP_PLUGIN_SIGNATURE,\n} from \"@/uniswap/constants/plugin\";\nimport {\n UNISWAP_COMMANDS,\n UNISWAP_EXECUTE_ABI,\n UNISWAP_EXECUTE_SELECTOR,\n UNISWAP_SWAP_COMMANDS,\n UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n UniswapSupportedCommand,\n} from \"@/uniswap/constants/uniswap\";\nimport { type CommandDecoderDataSource } from \"@/uniswap/data/CommandDecoderDataSource\";\nimport { uniswapTypes } from \"@/uniswap/di/uniswapTypes\";\n\n@injectable()\nexport class UniswapContextLoader implements ContextLoader {\n constructor(\n @inject(uniswapTypes.CommandDecoderDataSource)\n private commandDecoderDataSource: CommandDecoderDataSource,\n @inject(tokenTypes.TokenDataSource)\n private tokenDataSource: TokenDataSource,\n ) {}\n\n async load(transaction: TransactionContext): Promise<ClearSignContext[]> {\n if (!transaction.data || !isHexaString(transaction.data)) {\n return [];\n }\n\n const selector = transaction.data.slice(0, 10);\n if (selector !== UNISWAP_EXECUTE_SELECTOR) {\n return [];\n }\n\n const externalPluginContext = this._buildUniswapPluginCommandData();\n const tokenContexts = await this._extractClearSignContexts(\n transaction.data,\n transaction.chainId,\n );\n\n if (tokenContexts.length > 0)\n return [externalPluginContext, ...tokenContexts];\n\n return [];\n }\n\n /**\n * Constructs the external plugin context for Uniswap external plugin command.\n *\n * @private\n * @returns {ClearSignContext} - The generated external plugin context.\n */\n private _buildUniswapPluginCommandData(): ClearSignContext {\n const buffer = new ByteArrayBuilder()\n .add8BitUIntToData(UNISWAP_PLUGIN_NAME.length)\n .addAsciiStringToData(UNISWAP_PLUGIN_NAME)\n .addBufferToData(hexaStringToBuffer(UNISWAP_UNIVERSAL_ROUTER_ADDRESS)!)\n .addBufferToData(hexaStringToBuffer(UNISWAP_EXECUTE_SELECTOR)!)\n .addBufferToData(hexaStringToBuffer(UNISWAP_PLUGIN_SIGNATURE)!)\n .build();\n\n return {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: bufferToHexaString(buffer).slice(2),\n };\n }\n\n /**\n * Extracts and decodes the clear sign contexts from a Uniswap calldata transaction.\n *\n * This function:\n * - Parses the calldata using the Uniswap `execute` function signature.\n * - Extracts and validates the `commands` and `inputs`.\n * - Decodes the commands and ensures they match the number of inputs.\n * - Extracts addresses used in the transaction and verifies if chaining swaps are supported.\n * - Fetches token information for unique addresses.\n * - Returns an array of `ClearSignContext` objects representing either token data or errors.\n *\n * @private\n * @param {HexaString} calldata - The raw calldata of the Uniswap transaction.\n * @param {number} chainId - The blockchain chain ID where the transaction is being executed.\n * @returns {Promise<ClearSignContext[]>} - A promise resolving to an array of clear sign contexts.\n */\n private async _extractClearSignContexts(\n calldata: HexaString,\n chainId: number,\n ): Promise<ClearSignContext[]> {\n try {\n const iface = new Interface(UNISWAP_EXECUTE_ABI);\n\n const tx = iface.parseTransaction({ data: calldata });\n const commands: unknown = tx?.args[0];\n const inputs: unknown = tx?.args[1];\n\n if (!isHexaString(commands) || !this._isHexaStringArray(inputs)) {\n return [];\n }\n\n const decodedCommands = this._extractCommands(commands).orDefault([]);\n if (commands.length === 0 || inputs.length !== decodedCommands.length) {\n // Invalid commands or inputs\n return [];\n }\n\n const addressesByCommand = decodedCommands.reduce(\n (acc, command, index) => {\n const input = inputs[index]!;\n const decoded: HexaString[] = this.commandDecoderDataSource.decode(\n command,\n input,\n chainId,\n );\n\n acc.push([command, decoded]);\n\n return acc;\n },\n [] as [UniswapSupportedCommand, HexaString[]][],\n );\n\n if (!this._isChainingSwapSupported(addressesByCommand)) {\n return [];\n }\n\n const uniqueAddresses = [\n ...new Set(addressesByCommand.flatMap(([, addresses]) => addresses)),\n ];\n\n const tokensPayload = await Promise.all(\n uniqueAddresses.map((address) =>\n this.tokenDataSource.getTokenInfosPayload({ address, chainId }),\n ),\n );\n\n return tokensPayload.map((either) =>\n either.caseOf<ClearSignContext>({\n Left: (error) => ({ type: ClearSignContextType.ERROR, error }),\n Right: (payload) => ({ type: ClearSignContextType.TOKEN, payload }),\n }),\n );\n } catch (_) {\n return [];\n }\n }\n\n /**\n * Extracts Uniswap-supported commands from a hexadecimal string.\n * Each command is represented by one byte (2 hex characters), and this function:\n * - Maps each command to a known Uniswap command.\n * - Returns `Nothing` if any extracted command is unsupported.\n *\n * @private\n * @param {HexaString} hex - A hexadecimal string representing commands.\n * @returns {Maybe<UniswapSupportedCommand[]>} - A `Maybe` containing an array of recognized commands, or `Nothing` if any command is unsupported.\n *\n * @example\n * // Valid command extraction\n * _extractCommands('0x0008');\n * // Returns: Just(['0x00', '0x08'])\n *\n * @example\n * // Contains an unsupported command (0x05 is not supported)\n * _extractCommands('0x0005');\n * // Returns: Nothing\n *\n * @example\n * // Empty or invalid input\n * _extractCommands('0x');\n * // Returns: Nothing\n */\n private _extractCommands(hex: HexaString): Maybe<UniswapSupportedCommand[]> {\n return Maybe.fromNullable(hex.slice(2).match(/../g))\n .map((bytes) => bytes.map((b) => `0x${b}` as HexaString))\n .map((hexBytes) => hexBytes.map((b) => UNISWAP_COMMANDS[b]))\n .chain((commands) =>\n commands.every((command) => command !== undefined)\n ? Maybe.of(commands as UniswapSupportedCommand[])\n : Nothing,\n );\n }\n\n /**\n * Checks if the provided swap commands can be chained together.\n * A valid chain requires that:\n * - The output asset of the previous swap matches the input asset of the next swap.\n * - The pool version remains consistent across swaps.\n *\n * @private\n * @param {Array<[UniswapSupportedCommand, HexaString[]]>} data - An array of tuples containing a swap command and associated addresses.\n * @returns {boolean} - Returns `true` if the swap commands form a valid chain, otherwise `false`.\n *\n * @example\n * // Valid chaining: same output/input asset and pool version\n * _isChainingSwapSupported([\n * ['0x08', ['0xABC', '0xDEF']],\n * ['0x08', ['0xDEF', '0x123']]\n * ]);\n * // Returns: true\n *\n * @example\n * // Invalid chaining: different pool versions\n * _isChainingSwapSupported([\n * ['0x08', ['0xABC', '0xDEF']],\n * ['0x01', ['0xDEF', '0x123']]\n * ]);\n * // Returns: false\n *\n * @example\n * // Invalid chaining: output does not match next input\n * _isChainingSwapSupported([\n * ['0x01A1', ['0xABC', '0xDEF']],\n * ['0x01B2', ['0xXYZ', '0x123']]\n * ]);\n * // Returns: false\n */\n private _isChainingSwapSupported(\n data: [UniswapSupportedCommand, HexaString[]][],\n ): boolean {\n let lastAsset: HexaString | undefined = undefined;\n let lastPoolVersion: string | undefined = undefined;\n\n for (const [command, addresses] of data) {\n if (!UNISWAP_SWAP_COMMANDS.includes(command)) continue; // Ignore non-swap commands\n\n const poolVersion = command.slice(0, 2);\n\n if (\n lastAsset &&\n (lastAsset !== addresses[0] || lastPoolVersion !== poolVersion)\n ) {\n // Invalid chaining, return empty array\n return false;\n }\n\n // update last asset and pool version\n lastAsset = addresses[addresses.length - 1];\n lastPoolVersion = poolVersion;\n }\n\n return true;\n }\n\n /**\n * Checks if a given value is an array of hexadecimal strings.\n *\n * @private\n * @param {unknown} array - The value to check.\n * @returns {array is HexaString[]} - `true` if the value is an array of hexadecimal strings, otherwise `false`.\n */\n private _isHexaStringArray(array: unknown): array is HexaString[] {\n return (\n Array.isArray(array) &&\n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UA,EAAM,IAAKC,GAAM,KAAKA,CAAC,EAAgB,CAAC,EACvD,IAAKC,GAAaA,EAAS,IAAKD,GAAME,EAAiBF,CAAC,CAAC,CAAC,EAC1D,MAAOlB,GACNA,EAAS,MAAOK,GAAYA,IAAY,MAAS,EAC7CW,EAAM,GAAGhB,CAAqC,EAC9CqB,CACN,CACJ,CAoCQ,yBACNC,EACS,CACT,IAAIC,EACAC,EAEJ,SAAW,CAACnB,EAASK,CAAS,IAAKY,EAAM,CACvC,GAAI,CAACG,EAAsB,SAASpB,CAAO,EAAG,SAE9C,MAAMqB,EAAcrB,EAAQ,MAAM,EAAG,CAAC,EAEtC,GACEkB,IACCA,IAAcb,EAAU,CAAC,GAAKc,IAAoBE,GAGnD,MAAO,GAITH,EAAYb,EAAUA,EAAU,OAAS,CAAC,EAC1Cc,EAAkBE,CACpB,CAEA,MAAO,EACT,CASQ,mBAAmBC,EAAuC,CAChE,OACE,MAAM,QAAQA,CAAK,GACnBA,EAAM,MAAOC,GAAS,OAAOA,GAAS,UAAY7C,EAAa6C,CAAI,CAAC,CAExE,CACF,EA/OajD,EAANkD,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAa,wBAAwB,GAE5CF,EAAA,EAAAC,EAAOE,EAAW,eAAe,IAJzBvD",
6
+ "names": ["bufferToHexaString", "ByteArrayBuilder", "hexaStringToBuffer", "isHexaString", "Interface", "inject", "injectable", "Maybe", "Nothing", "ClearSignContextType", "tokenTypes", "UNISWAP_PLUGIN_NAME", "UNISWAP_PLUGIN_SIGNATURE", "UNISWAP_COMMANDS", "UNISWAP_EXECUTE_ABI", "UNISWAP_EXECUTE_SELECTOR", "UNISWAP_SWAP_COMMANDS", "UNISWAP_UNIVERSAL_ROUTER_ADDRESS", "uniswapTypes", "UniswapContextLoader", "commandDecoderDataSource", "tokenDataSource", "transaction", "isHexaString", "UNISWAP_EXECUTE_SELECTOR", "externalPluginContext", "tokenContexts", "buffer", "ByteArrayBuilder", "UNISWAP_PLUGIN_NAME", "hexaStringToBuffer", "UNISWAP_UNIVERSAL_ROUTER_ADDRESS", "UNISWAP_PLUGIN_SIGNATURE", "ClearSignContextType", "bufferToHexaString", "calldata", "chainId", "tx", "Interface", "UNISWAP_EXECUTE_ABI", "commands", "inputs", "decodedCommands", "addressesByCommand", "acc", "command", "index", "input", "decoded", "uniqueAddresses", "addresses", "address", "either", "error", "payload", "hex", "Maybe", "bytes", "b", "hexBytes", "UNISWAP_COMMANDS", "Nothing", "data", "lastAsset", "lastPoolVersion", "UNISWAP_SWAP_COMMANDS", "poolVersion", "array", "item", "__decorateClass", "injectable", "__decorateParam", "inject", "uniswapTypes", "tokenTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{Interface as r}from"ethers";import{Left as b,Right as l}from"purify-ts";import{ClearSignContextType as p}from"../../shared/model/ClearSignContext";import{UNISWAP_EXECUTE_SELECTOR as f,UNISWAP_UNIVERSAL_ROUTER_ADDRESS as d,UniswapSupportedCommand as s}from"../../uniswap/constants/uniswap";import{DefaultCommandDecoderDataSource as y}from"../../uniswap/data/DefaultCommandDecoderDataSource";import{EthersAbiDecoderDataSource as u}from"../../uniswap/data/EthersAbiDecoderDataSource";import{UniswapContextLoader as x}from"./UniswapContextLoader";describe("UniswapContextLoader",()=>{const a={decode:vi.fn()},t={getTokenInfosPayload:vi.fn()};let n;describe("load",()=>{describe("with tokenDataSourceMock",()=>{beforeEach(()=>{vi.spyOn(t,"getTokenInfosPayload").mockImplementation(({address:e})=>Promise.resolve(l(`payload-${e}`))),n=new x(new y(new u),t)}),it("should return the external plugin context and the decoded contexts",async()=>{const e={chainId:1,data:"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000067a4855b000000000000000000000000000000000000000000000000000000000000000300060c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000a18f07d736b90be5500000000000000000000000000000000000000000000000000000000b0b8122abd8412900000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bb9f599ce614feb2e1bbe58f180f370d05b39344e002710c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000017cc6042605381c158d2adab487434bde79aa61c000000000000000000000000000000000000000000000000000000000000005b000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000b0b8122abd84129c001a053efc49d03b694742500f49aa09df2360bd7e297fa730c745e0d4320b42fc33fa01ca1c85a46c561f624830fffbae2441ba0f2d54eb5b0f17e0e3561d10db0b7ee"},o=await n.load(e);expect(o).toEqual([{type:p.EXTERNAL_PLUGIN,payload:"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935"},{type:"token",payload:"payload-0xb9f599ce614feb2e1bbe58f180f370d05b39344e"},{type:"token",payload:"payload-0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"}])}),it("should return the external plugin context and the decoded contexts with a permit",async()=>{const e={chainId:1,data:"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000669b9ec100000000000000000000000000000000000000000000000000000000000000030a010c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000016000000000000000000000000055747be9f9f5beb232ad59fe7af013b81d95fd5e000000000000000000000000ffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000066c32b0d0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000ef1c6e67703c7bd7107eed8303fbe6ec2554bf6b00000000000000000000000000000000000000000000000000000000669b9ec100000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000410d756f55acf289e9754faf91bba0a704b5c7c0aa4b1dfd551115ccbe4c7f290234e1a14265e1da0bc872a23627d997fe37a689c290d519f7b8c9bdde1b79108e1b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000030ba49cbff5a00000000000000000000000000000000000000000000000089677c957272141800000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc200271055747be9f9f5beb232ad59fe7af013b81d95fd5e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000030ba49cbff5a000c001a0e406d9c91c8b46d959fcd31a28518a77bb248ebb316c5fab7b98335cce922f2aa0462cb970c32a8dbfe71c57b888c43b9ed04fce41d169dbfcc745445587adb771"},o=await n.load(e);expect(o).toEqual([{type:p.EXTERNAL_PLUGIN,payload:"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935"},{type:"token",payload:"payload-0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"},{type:"token",payload:"payload-0x55747be9f9f5beb232ad59fe7af013b81d95fd5e"}])}),it("should return an empty array if the transaction is not supported",async()=>{const e={};vi.spyOn(a,"decode").mockReturnValue([]);const o=await n.load(e);expect(o).toEqual([])}),it("should return an empty array if a command is not supported",async()=>{const e={chainId:1,data:"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000067a4bef600000000000000000000000000000000000000000000000000000000000000050b0105040c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000078e6708e70aed0f000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000059a16770000000000000000000000000000000000000000000000000078e6708e70aed0f00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f4c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000027213e28d7fda5c57fe9e5dd923818dbccf71c4700000000000000000000000000000000000000000000000000000000003938700000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006f939b43d65be049b7533907db08e80ba6969f450000000000000000000000000000000000000000000000000000000059682f0000000000000000000000000000000000000000000000000000000000000000400000000000000000000000006f939b43d65be049b7533907db08e80ba6969f4500000000000000000000000000000000000000000000000000000000000000000cc080a07c86dd5813ec1f3725c402f8bea6105546d1093c59676023b971f1d83f61bd4ea02a353bf3028cabcbe68c5dc8906752bafe55afc86b6344edb3ffd8a3650332e8"},o=await n.load(e);expect(o).toEqual([])})}),describe("with mocked ethers parseTransaction",()=>{beforeEach(()=>{vi.resetAllMocks(),n=new x(a,t)}),it("should return an array with contexts if 2 chain swaps are supported",async()=>{const e={to:d,data:f,chainId:66};vi.spyOn(r.prototype,"parseTransaction").mockReturnValue({args:["0x0809",["0x0001","0x0002"]]}),vi.spyOn(a,"decode").mockReturnValueOnce(["0x01","0x04","0x02"]),vi.spyOn(a,"decode").mockReturnValueOnce(["0x02","0x03"]),vi.spyOn(t,"getTokenInfosPayload").mockImplementation(({address:i})=>Promise.resolve(l(`payload-${i}`)));const c=await n.load(e);expect(a.decode).toHaveBeenNthCalledWith(1,s.V2_SWAP_EXACT_IN,"0x0001",66),expect(a.decode).toHaveBeenNthCalledWith(2,s.V2_SWAP_EXACT_OUT,"0x0002",66),expect(t.getTokenInfosPayload).toHaveBeenNthCalledWith(1,{address:"0x01",chainId:66}),expect(t.getTokenInfosPayload).toHaveBeenNthCalledWith(2,{address:"0x04",chainId:66}),expect(t.getTokenInfosPayload).toHaveBeenNthCalledWith(3,{address:"0x02",chainId:66}),expect(t.getTokenInfosPayload).toHaveBeenNthCalledWith(4,{address:"0x03",chainId:66}),expect(c).toEqual([{type:p.EXTERNAL_PLUGIN,payload:"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935"},{type:"token",payload:"payload-0x01"},{type:"token",payload:"payload-0x04"},{type:"token",payload:"payload-0x02"},{type:"token",payload:"payload-0x03"}])}),it("should return an array with contexts if 1 chain swap with a non swap command",async()=>{const e={to:d,data:f,chainId:66};vi.spyOn(r.prototype,"parseTransaction").mockReturnValue({args:["0x0b0004",["0x0001","0x0002","0x0003"]]}),vi.spyOn(a,"decode").mockReturnValueOnce(["0x01"]),vi.spyOn(a,"decode").mockReturnValueOnce(["0x02","0x03"]),vi.spyOn(a,"decode").mockReturnValueOnce(["0x04"]),vi.spyOn(t,"getTokenInfosPayload").mockImplementation(({address:i})=>Promise.resolve(l(`payload-${i}`)));const c=await n.load(e);expect(a.decode).toHaveBeenNthCalledWith(1,s.WRAP_ETH,"0x0001",66),expect(t.getTokenInfosPayload).toHaveBeenNthCalledWith(1,{address:"0x01",chainId:66}),expect(t.getTokenInfosPayload).toHaveBeenNthCalledWith(2,{address:"0x02",chainId:66}),expect(t.getTokenInfosPayload).toHaveBeenNthCalledWith(3,{address:"0x03",chainId:66}),expect(t.getTokenInfosPayload).toHaveBeenNthCalledWith(4,{address:"0x04",chainId:66}),expect(c).toEqual([{type:p.EXTERNAL_PLUGIN,payload:"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935"},{type:"token",payload:"payload-0x01"},{type:"token",payload:"payload-0x02"},{type:"token",payload:"payload-0x03"},{type:"token",payload:"payload-0x04"}])}),it("should return an array with contexts if one token is not found",async()=>{const e={to:d,data:f,chainId:66};vi.spyOn(r.prototype,"parseTransaction").mockReturnValue({args:["0x0809",["0x0001","0x0002"]]}),vi.spyOn(a,"decode").mockReturnValueOnce(["0x01","0x02"]),vi.spyOn(a,"decode").mockReturnValueOnce(["0x02","0x03"]),vi.spyOn(t,"getTokenInfosPayload").mockResolvedValueOnce(b("error")),vi.spyOn(t,"getTokenInfosPayload").mockImplementation(({address:i})=>Promise.resolve(l(`payload-${i}`)));const c=await n.load(e);expect(a.decode).toHaveBeenNthCalledWith(1,s.V2_SWAP_EXACT_IN,"0x0001",66),expect(a.decode).toHaveBeenNthCalledWith(2,s.V2_SWAP_EXACT_OUT,"0x0002",66),expect(t.getTokenInfosPayload).toHaveBeenNthCalledWith(1,{address:"0x01",chainId:66}),expect(t.getTokenInfosPayload).toHaveBeenNthCalledWith(2,{address:"0x02",chainId:66}),expect(t.getTokenInfosPayload).toHaveBeenNthCalledWith(3,{address:"0x03",chainId:66}),expect(c).toEqual([{type:p.EXTERNAL_PLUGIN,payload:"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935"},{type:"error",error:"error"},{type:"token",payload:"payload-0x02"},{type:"token",payload:"payload-0x03"}])}),it("should return an empty array if the if 2 chain swaps are not supported",async()=>{const e={to:d,data:f,chainId:66};vi.spyOn(r.prototype,"parseTransaction").mockReturnValue({args:["0x0809",["0x0001","0x0002"]]}),vi.spyOn(a,"decode").mockReturnValueOnce(["0x01","0x02"]),vi.spyOn(a,"decode").mockReturnValueOnce(["0x03","0x04"]);const c=await n.load(e);expect(a.decode).toHaveBeenNthCalledWith(1,s.V2_SWAP_EXACT_IN,"0x0001",66),expect(a.decode).toHaveBeenNthCalledWith(2,s.V2_SWAP_EXACT_OUT,"0x0002",66),expect(t.getTokenInfosPayload).not.toHaveBeenCalled(),expect(c).toEqual([])}),it("should return an empty array if no command are returned from parseTransaction",async()=>{const e={to:d,data:f};vi.spyOn(r.prototype,"parseTransaction").mockReturnValue({args:[""]});const o=await n.load(e);expect(a.decode).not.toHaveBeenCalled(),expect(t.getTokenInfosPayload).not.toHaveBeenCalled(),expect(o).toEqual([])}),it("should return an empty array if no inputs are returned from parseTransaction",async()=>{const e={to:d,data:f};vi.spyOn(r.prototype,"parseTransaction").mockReturnValue({args:["0x08",[]]});const o=await n.load(e);expect(t.getTokenInfosPayload).not.toHaveBeenCalled(),expect(o).toEqual([])}),it("should return an empty array if parseTransaction throws an error",async()=>{const e={to:d,data:f};vi.spyOn(r.prototype,"parseTransaction").mockImplementation(()=>{throw new Error});const o=await n.load(e);expect(a.decode).not.toHaveBeenCalled(),expect(t.getTokenInfosPayload).not.toHaveBeenCalled(),expect(o).toEqual([])}),it("should return an empty array if the swap is with multiple pool versions",async()=>{const e={to:d,data:f,chainId:66};vi.spyOn(r.prototype,"parseTransaction").mockReturnValue({args:["0x080900",["0x00","0x01","0x02"]]}),vi.spyOn(a,"decode").mockReturnValue(["0x01","0x02"]);const c=await n.load(e);expect(a.decode).toHaveBeenNthCalledWith(1,s.V2_SWAP_EXACT_IN,"0x00",66),expect(a.decode).toHaveBeenNthCalledWith(2,s.V2_SWAP_EXACT_OUT,"0x01",66),expect(a.decode).toHaveBeenNthCalledWith(3,s.V3_SWAP_EXACT_IN,"0x02",66),expect(t.getTokenInfosPayload).not.toHaveBeenCalled(),expect(c).toEqual([])}),it("should return an empty array if the selector is not supported",async()=>{const e={to:d,data:"0x00000000",chainId:66},o=await n.load(e);expect(a.decode).not.toHaveBeenCalled(),expect(t.getTokenInfosPayload).not.toHaveBeenCalled(),expect(o).toEqual([])}),it("should return an empty array if the length of the commands and inputs are different",async()=>{const e={to:d,data:f,chainId:66};vi.spyOn(r.prototype,"parseTransaction").mockReturnValue({args:["0x0809",["0x0001"]]});const c=await n.load(e);expect(a.decode).not.toHaveBeenCalled(),expect(t.getTokenInfosPayload).not.toHaveBeenCalled(),expect(c).toEqual([])})})})});
2
+ //# sourceMappingURL=UniswapContextLoader.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/uniswap/domain/UniswapContextLoader.test.ts"],
4
+ "sourcesContent": ["import { Interface, type TransactionDescription } from \"ethers\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport { type TransactionContext } from \"@/shared/model/TransactionContext\";\nimport { type HttpTokenDataSource } from \"@/token/data/HttpTokenDataSource\";\nimport {\n UNISWAP_EXECUTE_SELECTOR,\n UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n UniswapSupportedCommand,\n} from \"@/uniswap/constants/uniswap\";\nimport { type CommandDecoderDataSource } from \"@/uniswap/data/CommandDecoderDataSource\";\nimport { DefaultCommandDecoderDataSource } from \"@/uniswap/data/DefaultCommandDecoderDataSource\";\nimport { EthersAbiDecoderDataSource } from \"@/uniswap/data/EthersAbiDecoderDataSource\";\n\nimport { UniswapContextLoader } from \"./UniswapContextLoader\";\n\ndescribe(\"UniswapContextLoader\", () => {\n const commandDecoderMock: CommandDecoderDataSource = {\n decode: vi.fn(),\n };\n const tokenDataSourceMock = {\n getTokenInfosPayload: vi.fn(),\n };\n let loader: UniswapContextLoader;\n\n describe(\"load\", () => {\n describe(\"with tokenDataSourceMock\", () => {\n beforeEach(() => {\n vi.spyOn(\n tokenDataSourceMock,\n \"getTokenInfosPayload\",\n ).mockImplementation(({ address }) =>\n Promise.resolve(Right(`payload-${address}`)),\n );\n loader = new UniswapContextLoader(\n new DefaultCommandDecoderDataSource(new EthersAbiDecoderDataSource()),\n tokenDataSourceMock as unknown as HttpTokenDataSource,\n );\n });\n\n it(\"should return the external plugin context and the decoded contexts\", async () => {\n // GIVEN\n // https://etherscan.io/getRawTx?tx=0xc9821c32c1782d9ab6baf6f9ca4b2565bce11aaf5146a2d303215bda026f5e48\n const transactionContext = {\n chainId: 1,\n data: \"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000067a4855b000000000000000000000000000000000000000000000000000000000000000300060c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000a18f07d736b90be5500000000000000000000000000000000000000000000000000000000b0b8122abd8412900000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bb9f599ce614feb2e1bbe58f180f370d05b39344e002710c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000017cc6042605381c158d2adab487434bde79aa61c000000000000000000000000000000000000000000000000000000000000005b000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000b0b8122abd84129c001a053efc49d03b694742500f49aa09df2360bd7e297fa730c745e0d4320b42fc33fa01ca1c85a46c561f624830fffbae2441ba0f2d54eb5b0f17e0e3561d10db0b7ee\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload:\n \"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935\",\n },\n {\n type: \"token\",\n payload: \"payload-0xb9f599ce614feb2e1bbe58f180f370d05b39344e\",\n }, // ERC20\n {\n type: \"token\",\n payload: \"payload-0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\",\n }, // WETH\n ]);\n });\n\n it(\"should return the external plugin context and the decoded contexts with a permit\", async () => {\n // GIVEN\n // https://etherscan.io/getRawTx?tx=0xc4df7ccc0527541d0e80856a8f38deedc48c84825e9355469ba02d873502ce2f\n // PERMIT2_PERMIT, V3_SWAP_EXACT_OUT, UNWRAP_ETH\n const transactionContext = {\n chainId: 1,\n data: \"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000669b9ec100000000000000000000000000000000000000000000000000000000000000030a010c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000016000000000000000000000000055747be9f9f5beb232ad59fe7af013b81d95fd5e000000000000000000000000ffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000066c32b0d0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000ef1c6e67703c7bd7107eed8303fbe6ec2554bf6b00000000000000000000000000000000000000000000000000000000669b9ec100000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000410d756f55acf289e9754faf91bba0a704b5c7c0aa4b1dfd551115ccbe4c7f290234e1a14265e1da0bc872a23627d997fe37a689c290d519f7b8c9bdde1b79108e1b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000030ba49cbff5a00000000000000000000000000000000000000000000000089677c957272141800000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc200271055747be9f9f5beb232ad59fe7af013b81d95fd5e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000030ba49cbff5a000c001a0e406d9c91c8b46d959fcd31a28518a77bb248ebb316c5fab7b98335cce922f2aa0462cb970c32a8dbfe71c57b888c43b9ed04fce41d169dbfcc745445587adb771\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload:\n \"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935\",\n },\n {\n type: \"token\",\n payload: \"payload-0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\",\n }, // WETH\n {\n type: \"token\",\n payload: \"payload-0x55747be9f9f5beb232ad59fe7af013b81d95fd5e\",\n }, // ERC20\n ]);\n });\n\n it(\"should return an empty array if the transaction is not supported\", async () => {\n // GIVEN\n const transactionContext = {} as TransactionContext;\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValue([]);\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if a command is not supported\", async () => {\n // GIVEN\n // https://etherscan.io/getRawTx?tx=0xa628c8b3da2ad984aed0354d8ca4b4c3c42941491dc4e0d6a5f423fd65e6c90a\n // The command 0x05 (TRANSFER) is not supported\n const transactionContext = {\n chainId: 1,\n data: \"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000067a4bef600000000000000000000000000000000000000000000000000000000000000050b0105040c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000078e6708e70aed0f000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000059a16770000000000000000000000000000000000000000000000000078e6708e70aed0f00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f4c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000027213e28d7fda5c57fe9e5dd923818dbccf71c4700000000000000000000000000000000000000000000000000000000003938700000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006f939b43d65be049b7533907db08e80ba6969f450000000000000000000000000000000000000000000000000000000059682f0000000000000000000000000000000000000000000000000000000000000000400000000000000000000000006f939b43d65be049b7533907db08e80ba6969f4500000000000000000000000000000000000000000000000000000000000000000cc080a07c86dd5813ec1f3725c402f8bea6105546d1093c59676023b971f1d83f61bd4ea02a353bf3028cabcbe68c5dc8906752bafe55afc86b6344edb3ffd8a3650332e8\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(result).toEqual([]);\n });\n });\n\n describe(\"with mocked ethers parseTransaction\", () => {\n beforeEach(() => {\n vi.resetAllMocks();\n loader = new UniswapContextLoader(\n commandDecoderMock,\n tokenDataSourceMock as unknown as HttpTokenDataSource,\n );\n });\n\n it(\"should return an array with contexts if 2 chain swaps are supported\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n chainId: 0x42,\n } as TransactionContext;\n const commands = `0x0809`; // V2_SWAP_EXACT_IN, V2_SWAP_EXACT_OUT\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [commands, [\"0x0001\", \"0x0002\"]],\n } as TransactionDescription);\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x01\",\n \"0x04\",\n \"0x02\",\n ]);\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x02\",\n \"0x03\",\n ]);\n vi.spyOn(\n tokenDataSourceMock,\n \"getTokenInfosPayload\",\n ).mockImplementation(({ address }) =>\n Promise.resolve(Right(`payload-${address}`)),\n );\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 1,\n UniswapSupportedCommand.V2_SWAP_EXACT_IN,\n \"0x0001\",\n 0x42,\n );\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 2,\n UniswapSupportedCommand.V2_SWAP_EXACT_OUT,\n \"0x0002\",\n 0x42,\n );\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(1, { address: \"0x01\", chainId: 0x42 });\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(2, { address: \"0x04\", chainId: 0x42 });\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(3, { address: \"0x02\", chainId: 0x42 });\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(4, { address: \"0x03\", chainId: 0x42 });\n expect(result).toEqual([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload:\n \"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935\",\n },\n {\n type: \"token\",\n payload: \"payload-0x01\",\n },\n {\n type: \"token\",\n payload: \"payload-0x04\",\n },\n {\n type: \"token\",\n payload: \"payload-0x02\",\n },\n {\n type: \"token\",\n payload: \"payload-0x03\",\n },\n ]);\n });\n\n it(\"should return an array with contexts if 1 chain swap with a non swap command\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n chainId: 0x42,\n } as TransactionContext;\n const commands = `0x0b0004`; // WRAP_ETH, V3_SWAP_EXACT_IN, SWEEP\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [commands, [\"0x0001\", \"0x0002\", \"0x0003\"]],\n } as TransactionDescription);\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValueOnce([\"0x01\"]);\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x02\",\n \"0x03\",\n ]);\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValueOnce([\"0x04\"]);\n vi.spyOn(\n tokenDataSourceMock,\n \"getTokenInfosPayload\",\n ).mockImplementation(({ address }) =>\n Promise.resolve(Right(`payload-${address}`)),\n );\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 1,\n UniswapSupportedCommand.WRAP_ETH,\n \"0x0001\",\n 0x42,\n );\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(1, { address: \"0x01\", chainId: 0x42 });\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(2, { address: \"0x02\", chainId: 0x42 });\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(3, { address: \"0x03\", chainId: 0x42 });\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(4, { address: \"0x04\", chainId: 0x42 });\n expect(result).toEqual([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload:\n \"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935\",\n },\n {\n type: \"token\",\n payload: \"payload-0x01\",\n },\n {\n type: \"token\",\n payload: \"payload-0x02\",\n },\n {\n type: \"token\",\n payload: \"payload-0x03\",\n },\n {\n type: \"token\",\n payload: \"payload-0x04\",\n },\n ]);\n });\n\n it(\"should return an array with contexts if one token is not found\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n chainId: 0x42,\n } as TransactionContext;\n const commands = `0x0809`; // V2_SWAP_EXACT_IN, V2_SWAP_EXACT_OUT\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [commands, [\"0x0001\", \"0x0002\"]],\n } as TransactionDescription);\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x01\",\n \"0x02\",\n ]);\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x02\",\n \"0x03\",\n ]);\n vi.spyOn(\n tokenDataSourceMock,\n \"getTokenInfosPayload\",\n ).mockResolvedValueOnce(Left(\"error\"));\n vi.spyOn(\n tokenDataSourceMock,\n \"getTokenInfosPayload\",\n ).mockImplementation(({ address }) =>\n Promise.resolve(Right(`payload-${address}`)),\n );\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 1,\n UniswapSupportedCommand.V2_SWAP_EXACT_IN,\n \"0x0001\",\n 0x42,\n );\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 2,\n UniswapSupportedCommand.V2_SWAP_EXACT_OUT,\n \"0x0002\",\n 0x42,\n );\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(1, { address: \"0x01\", chainId: 0x42 });\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(2, { address: \"0x02\", chainId: 0x42 });\n expect(\n tokenDataSourceMock.getTokenInfosPayload,\n ).toHaveBeenNthCalledWith(3, { address: \"0x03\", chainId: 0x42 });\n expect(result).toEqual([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload:\n \"07556e69737761703fc91a3afd70395cd496c647d5a6cc9d4b2b7fad3593564c3044022014391e8f355867a57fe88f6a5a4dbcb8bf8f888a9db3ff3449caf72d120396bd02200c13d9c3f79400fe0aa0434ac54d59b79503c9964a4abc3e8cd22763e0242935\",\n },\n {\n type: \"error\",\n error: \"error\",\n },\n {\n type: \"token\",\n payload: \"payload-0x02\",\n },\n {\n type: \"token\",\n payload: \"payload-0x03\",\n },\n ]);\n });\n\n it(\"should return an empty array if the if 2 chain swaps are not supported\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n chainId: 0x42,\n } as TransactionContext;\n const commands = `0x0809`; // V2_SWAP_EXACT_IN, V2_SWAP_EXACT_OUT\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [commands, [\"0x0001\", \"0x0002\"]],\n } as TransactionDescription);\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x01\",\n \"0x02\",\n ]);\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValueOnce([\n \"0x03\", // should be 0x02\n \"0x04\",\n ]);\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 1,\n UniswapSupportedCommand.V2_SWAP_EXACT_IN,\n \"0x0001\",\n 0x42,\n );\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 2,\n UniswapSupportedCommand.V2_SWAP_EXACT_OUT,\n \"0x0002\",\n 0x42,\n );\n expect(tokenDataSourceMock.getTokenInfosPayload).not.toHaveBeenCalled();\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if no command are returned from parseTransaction\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n } as TransactionContext;\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [\"\"],\n } as TransactionDescription);\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).not.toHaveBeenCalled();\n expect(tokenDataSourceMock.getTokenInfosPayload).not.toHaveBeenCalled();\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if no inputs are returned from parseTransaction\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n } as TransactionContext;\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [\"0x08\", []],\n } as TransactionDescription);\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(tokenDataSourceMock.getTokenInfosPayload).not.toHaveBeenCalled();\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if parseTransaction throws an error\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n } as TransactionContext;\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockImplementation(\n () => {\n throw new Error();\n },\n );\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).not.toHaveBeenCalled();\n expect(tokenDataSourceMock.getTokenInfosPayload).not.toHaveBeenCalled();\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if the swap is with multiple pool versions\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n chainId: 0x42,\n } as TransactionContext;\n const commands = `0x080900`; // V2_SWAP_EXACT_IN, V2_SWAP_EXACT_OUT, V3_SWAP_EXACT_IN\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [commands, [\"0x00\", \"0x01\", \"0x02\"]],\n } as TransactionDescription);\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValue([\n \"0x01\",\n \"0x02\",\n ]);\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 1,\n UniswapSupportedCommand.V2_SWAP_EXACT_IN,\n \"0x00\",\n 0x42,\n );\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 2,\n UniswapSupportedCommand.V2_SWAP_EXACT_OUT,\n \"0x01\",\n 0x42,\n );\n expect(commandDecoderMock.decode).toHaveBeenNthCalledWith(\n 3,\n UniswapSupportedCommand.V3_SWAP_EXACT_IN,\n \"0x02\",\n 0x42,\n );\n expect(tokenDataSourceMock.getTokenInfosPayload).not.toHaveBeenCalled();\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if the selector is not supported\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: \"0x00000000\",\n chainId: 0x42,\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).not.toHaveBeenCalled();\n expect(tokenDataSourceMock.getTokenInfosPayload).not.toHaveBeenCalled();\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if the length of the commands and inputs are different\", async () => {\n // GIVEN\n const transactionContext = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n chainId: 0x42,\n } as TransactionContext;\n const commands = `0x0809`; // V2_SWAP_EXACT_IN, V2_SWAP_EXACT_OUT\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [commands, [\"0x0001\"]],\n } as TransactionDescription);\n\n // WHEN\n const result = await loader.load(transactionContext);\n\n // THEN\n expect(commandDecoderMock.decode).not.toHaveBeenCalled();\n expect(tokenDataSourceMock.getTokenInfosPayload).not.toHaveBeenCalled();\n expect(result).toEqual([]);\n });\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,aAAAA,MAA8C,SACvD,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAE5B,OAAS,wBAAAC,MAA4B,kCAGrC,OACE,4BAAAC,EACA,oCAAAC,EACA,2BAAAC,MACK,8BAEP,OAAS,mCAAAC,MAAuC,iDAChD,OAAS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A,OAAOI,EAAmB,MAAM,EAAE,wBAChC,EACAJ,EAAwB,iBACxB,OACA,EACF,EACA,OAAOK,EAAoB,oBAAoB,EAAE,IAAI,iBAAiB,EACtE,OAAOI,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,EAED,GAAG,gEAAiE,SAAY,CAE9E,MAAMD,EAAqB,CACzB,GAAIT,EACJ,KAAM,aACN,QAAS,EACX,EAGMU,EAAS,MAAMH,EAAO,KAAKE,CAAkB,EAGnD,OAAOJ,EAAmB,MAAM,EAAE,IAAI,iBAAiB,EACvD,OAAOC,EAAoB,oBAAoB,EAAE,IAAI,iBAAiB,EACtE,OAAOI,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,EAED,GAAG,sFAAuF,SAAY,CAEpG,MAAMD,EAAqB,CACzB,GAAIT,EACJ,KAAMD,EACN,QAAS,EACX,EAEA,GAAG,MAAMJ,EAAU,UAAW,kBAAkB,EAAE,gBAAgB,CAChE,KAAM,CAFS,SAEE,CAAC,QAAQ,CAAC,CAC7B,CAA2B,EAG3B,MAAMe,EAAS,MAAMH,EAAO,KAAKE,CAAkB,EAGnD,OAAOJ,EAAmB,MAAM,EAAE,IAAI,iBAAiB,EACvD,OAAOC,EAAoB,oBAAoB,EAAE,IAAI,iBAAiB,EACtE,OAAOI,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["Interface", "Left", "Right", "ClearSignContextType", "UNISWAP_EXECUTE_SELECTOR", "UNISWAP_UNIVERSAL_ROUTER_ADDRESS", "UniswapSupportedCommand", "DefaultCommandDecoderDataSource", "EthersAbiDecoderDataSource", "UniswapContextLoader", "commandDecoderMock", "tokenDataSourceMock", "loader", "address", "transactionContext", "result"]
7
+ }
@@ -0,0 +1,2 @@
1
+ var m=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var p=(a,e,r,i)=>{for(var t=i>1?void 0:i?k(e,r):e,o=a.length-1,c;o>=0;o--)(c=a[o])&&(t=(i?c(e,r,t):c(t))||t);return i&&t&&m(e,r,t),t},s=(a,e)=>(r,i)=>e(r,i,a);import u from"axios";import{inject as C,injectable as b}from"inversify";import{Left as d,Right as y}from"purify-ts";import{configTypes as g}from"../../config/di/configTypes";import{pkiTypes as W}from"../../pki/di/pkiTypes";import{KeyUsage as x}from"../../pki/model/KeyUsage";import D from"../../../package.json";let n=class{constructor(e,r){this.config=e;this._certificateLoader=r}async getWeb3Checks(e){const{from:r,deviceModelId:i}=e;let t,o,c;this.isTypedDataContext(e)?(o={msg:{from:r,data:e.data}},c=`${this.config.web3checks.url}/ethereum/scan/eip-712`):(o={tx:{from:r,raw:e.rawTx},chain:e.chainId},c=`${this.config.web3checks.url}/ethereum/scan/tx`);try{t=(await u.request({method:"POST",url:c,data:o,headers:{"X-Ledger-Client-Version":`context-module/${D.version}`}})).data}catch{return d(new Error("[ContextModule] HttpWeb3CheckDataSource: Failed to fetch web3 checks informations"))}if(!this.isWeb3CheckDto(t))return d(new Error("[ContextModule] HttpWeb3CheckDataSource: Cannot exploit Web3 checks data received"));const h=await this._certificateLoader.loadCertificate({keyId:t.public_key_id,keyUsage:x.TxSimulationSigner,targetDevice:i}),l={publicKeyId:t.public_key_id,descriptor:t.descriptor,certificate:h};return y(l)}isTypedDataContext(e){return"data"in e}isWeb3CheckDto(e){return e!=null&&typeof e=="object"&&"public_key_id"in e&&e.public_key_id!=null&&typeof e.public_key_id=="string"&&"descriptor"in e&&e.descriptor!=null&&typeof e.descriptor=="string"}};n=p([b(),s(0,C(g.Config)),s(1,C(W.PkiCertificateLoader))],n);export{n as HttpWeb3CheckDataSource};
2
+ //# sourceMappingURL=HttpWeb3CheckDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/web3-check/data/HttpWeb3CheckDataSource.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 { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport {\n type Web3CheckContext,\n type Web3Checks,\n type Web3CheckTypedDataContext,\n} from \"@/web3-check/domain/web3CheckTypes\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { Web3CheckDataSource } from \"./Web3CheckDataSource\";\nimport { GetWeb3ChecksRequestDto, Web3CheckDto } from \"./Web3CheckDto\";\n\n@injectable()\nexport class HttpWeb3CheckDataSource implements Web3CheckDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly _certificateLoader: PkiCertificateLoader,\n ) {}\n\n async getWeb3Checks(\n context: Web3CheckContext,\n ): Promise<Either<Error, Web3Checks>> {\n const { from, deviceModelId } = context;\n let web3CheckDto: Web3CheckDto;\n let requestDto: GetWeb3ChecksRequestDto;\n let url: string;\n if (this.isTypedDataContext(context)) {\n requestDto = {\n msg: {\n from,\n data: context.data,\n },\n };\n url = `${this.config.web3checks.url}/ethereum/scan/eip-712`;\n } else {\n requestDto = {\n tx: {\n from,\n raw: context.rawTx,\n },\n chain: context.chainId,\n };\n url = `${this.config.web3checks.url}/ethereum/scan/tx`;\n }\n\n try {\n const response = await axios.request<Web3CheckDto>({\n method: \"POST\",\n url,\n data: requestDto,\n headers: {\n \"X-Ledger-Client-Version\": `context-module/${PACKAGE.version}`,\n },\n });\n web3CheckDto = response.data;\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpWeb3CheckDataSource: Failed to fetch web3 checks informations\",\n ),\n );\n }\n\n if (!this.isWeb3CheckDto(web3CheckDto)) {\n return Left(\n new Error(\n \"[ContextModule] HttpWeb3CheckDataSource: Cannot exploit Web3 checks data received\",\n ),\n );\n }\n\n const certificate = await this._certificateLoader.loadCertificate({\n keyId: web3CheckDto.public_key_id,\n keyUsage: KeyUsage.TxSimulationSigner,\n targetDevice: deviceModelId,\n });\n\n const result: Web3Checks = {\n publicKeyId: web3CheckDto.public_key_id,\n descriptor: web3CheckDto.descriptor,\n certificate,\n };\n\n return Right(result);\n }\n\n private isTypedDataContext(\n context: Web3CheckContext,\n ): context is Web3CheckTypedDataContext {\n return \"data\" in context;\n }\n\n private isWeb3CheckDto(dto: unknown): dto is Web3CheckDto {\n return (\n dto != null &&\n typeof dto == \"object\" &&\n \"public_key_id\" in dto &&\n dto.public_key_id != null &&\n typeof dto.public_key_id == \"string\" &&\n \"descriptor\" in dto &&\n dto.descriptor != null &&\n typeof dto.descriptor == \"string\"\n );\n }\n}\n"],
5
+ "mappings": "iOAAA,OAAOA,MAAW,QAClB,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAE5B,OAAS,YAAAC,MAAgB,oBAEzB,OAAS,YAAAC,MAAgB,uBAMzB,OAAOC,MAAa,qBAMb,IAAMC,EAAN,KAA6D,CAClE,YAC+CC,EAE5BC,EACjB,CAH6C,YAAAD,EAE5B,wBAAAC,CAChB,CAEH,MAAM,cACJC,EACoC,CACpC,KAAM,CAAE,KAAAC,EAAM,cAAAC,CAAc,EAAIF,EAChC,IAAIG,EACAC,EACAC,EACA,KAAK,mBAAmBL,CAAO,GACjCI,EAAa,CACX,IAAK,CACH,KAAAH,EACA,KAAMD,EAAQ,IAChB,CACF,EACAK,EAAM,GAAG,KAAK,OAAO,WAAW,GAAG,2BAEnCD,EAAa,CACX,GAAI,CACF,KAAAH,EACA,IAAKD,EAAQ,KACf,EACA,MAAOA,EAAQ,OACjB,EACAK,EAAM,GAAG,KAAK,OAAO,WAAW,GAAG,qBAGrC,GAAI,CASFF,GARiB,MAAMG,EAAM,QAAsB,CACjD,OAAQ,OACR,IAAAD,EACA,KAAMD,EACN,QAAS,CACP,0BAA2B,kBAAkBG,EAAQ,OAAO,EAC9D,CACF,CAAC,GACuB,IAC1B,MAAiB,CACf,OAAOC,EACL,IAAI,MACF,mFACF,CACF,CACF,CAEA,GAAI,CAAC,KAAK,eAAeL,CAAY,EACnC,OAAOK,EACL,IAAI,MACF,mFACF,CACF,EAGF,MAAMC,EAAc,MAAM,KAAK,mBAAmB,gBAAgB,CAChE,MAAON,EAAa,cACpB,SAAUO,EAAS,mBACnB,aAAcR,CAChB,CAAC,EAEKS,EAAqB,CACzB,YAAaR,EAAa,cAC1B,WAAYA,EAAa,WACzB,YAAAM,CACF,EAEA,OAAOG,EAAMD,CAAM,CACrB,CAEQ,mBACNX,EACsC,CACtC,MAAO,SAAUA,CACnB,CAEQ,eAAea,EAAmC,CACxD,OACEA,GAAO,MACP,OAAOA,GAAO,UACd,kBAAmBA,GACnBA,EAAI,eAAiB,MACrB,OAAOA,EAAI,eAAiB,UAC5B,eAAgBA,GAChBA,EAAI,YAAc,MAClB,OAAOA,EAAI,YAAc,QAE7B,CACF,EA5FahB,EAANiB,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,GACzBF,EAAA,EAAAC,EAAOE,EAAS,oBAAoB,IAH5BtB",
6
+ "names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "pkiTypes", "KeyUsage", "PACKAGE", "HttpWeb3CheckDataSource", "config", "_certificateLoader", "context", "from", "deviceModelId", "web3CheckDto", "requestDto", "url", "axios", "PACKAGE", "Left", "certificate", "KeyUsage", "result", "Right", "dto", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes", "pkiTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{DeviceModelId as i}from"@ledgerhq/device-management-kit";import s from"axios";import{Left as u,Right as d}from"purify-ts";import{HttpWeb3CheckDataSource as n}from"../../web3-check/data/HttpWeb3CheckDataSource";vi.mock("axios");describe("HttpWeb3CheckDataSource",()=>{const a={web3checks:{url:"web3checksUrl"}},e={loadCertificate:vi.fn()};beforeEach(()=>{vi.resetAllMocks()}),describe("getWeb3Checks",()=>{it("should return an object if the request is successful",async()=>{const t={deviceModelId:i.FLEX,from:"from",rawTx:"rawTx",chainId:1},o={public_key_id:"partner",descriptor:"descriptor"};vi.spyOn(s,"request").mockResolvedValueOnce({data:o}),vi.spyOn(e,"loadCertificate").mockResolvedValueOnce(void 0);const r=await new n(a,e).getWeb3Checks(t);expect(r).toEqual(d({publicKeyId:"partner",descriptor:"descriptor"}))}),it("should return an object if the typed data request is successful",async()=>{const t={deviceModelId:i.FLEX,from:"from",data:"typed data"},o={public_key_id:"partner",descriptor:"descriptor"};vi.spyOn(s,"request").mockResolvedValueOnce({data:o}),vi.spyOn(e,"loadCertificate").mockResolvedValueOnce(void 0);const r=await new n(a,e).getWeb3Checks(t);expect(r).toEqual(d({publicKeyId:"partner",descriptor:"descriptor"}))}),it("should return an object with a certificate if the request is successful",async()=>{const t={deviceModelId:i.FLEX,from:"from",rawTx:"rawTx",chainId:1},o={public_key_id:"partner",descriptor:"descriptor"};vi.spyOn(s,"request").mockResolvedValueOnce({data:o}),vi.spyOn(e,"loadCertificate").mockResolvedValueOnce({keyUsageNumber:11,payload:new Uint8Array([1])});const r=await new n(a,e).getWeb3Checks(t);expect(r).toEqual(d({publicKeyId:"partner",descriptor:"descriptor",certificate:{keyUsageNumber:11,payload:new Uint8Array([1])}}))}),it("should return an error if the request fails",async()=>{const t={deviceModelId:i.FLEX,from:"from",rawTx:"rawTx",chainId:1};vi.spyOn(s,"request").mockRejectedValue(new Error("error"));const c=await new n(a,e).getWeb3Checks(t);expect(c).toEqual(u(new Error("[ContextModule] HttpWeb3CheckDataSource: Failed to fetch web3 checks informations")))}),it("should return an error if the response is invalid",async()=>{const t={deviceModelId:i.FLEX,from:"from",rawTx:"rawTx",chainId:1},o={};vi.spyOn(s,"request").mockResolvedValue({data:o}),vi.spyOn(e,"loadCertificate").mockResolvedValue(void 0);const r=await new n(a,e).getWeb3Checks(t);expect(r).toEqual(u(new Error("[ContextModule] HttpWeb3CheckDataSource: Cannot exploit Web3 checks data received")))})})});
2
+ //# sourceMappingURL=HttpWeb3CheckDataSource.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/web3-check/data/HttpWeb3CheckDataSource.test.ts"],
4
+ "sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport axios from \"axios\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { HttpWeb3CheckDataSource } from \"@/web3-check/data/HttpWeb3CheckDataSource\";\nimport { type Web3CheckDto } from \"@/web3-check/data/Web3CheckDto\";\nimport type { Web3CheckTypedData } from \"@/web3-check/domain/web3CheckTypes\";\nimport { type Web3CheckContext } from \"@/web3-check/domain/web3CheckTypes\";\n\nvi.mock(\"axios\");\n\ndescribe(\"HttpWeb3CheckDataSource\", () => {\n const config = {\n web3checks: {\n url: \"web3checksUrl\",\n },\n } as ContextModuleConfig;\n const certificateLoaderMock = {\n loadCertificate: vi.fn(),\n };\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"getWeb3Checks\", () => {\n it(\"should return an object if the request is successful\", async () => {\n // GIVEN\n const params: Web3CheckContext = {\n deviceModelId: DeviceModelId.FLEX,\n from: \"from\",\n rawTx: \"rawTx\",\n chainId: 1,\n };\n const dto: Web3CheckDto = {\n public_key_id: \"partner\",\n descriptor: \"descriptor\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValueOnce({ data: dto });\n vi.spyOn(certificateLoaderMock, \"loadCertificate\").mockResolvedValueOnce(\n undefined,\n );\n\n // WHEN\n const dataSource = new HttpWeb3CheckDataSource(\n config,\n certificateLoaderMock as unknown as PkiCertificateLoader,\n );\n const result = await dataSource.getWeb3Checks(params);\n\n // THEN\n expect(result).toEqual(\n Right({\n publicKeyId: \"partner\",\n descriptor: \"descriptor\",\n }),\n );\n });\n\n it(\"should return an object if the typed data request is successful\", async () => {\n // GIVEN\n const params: Web3CheckContext = {\n deviceModelId: DeviceModelId.FLEX,\n from: \"from\",\n data: \"typed data\" as unknown as Web3CheckTypedData,\n };\n const dto: Web3CheckDto = {\n public_key_id: \"partner\",\n descriptor: \"descriptor\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValueOnce({ data: dto });\n vi.spyOn(certificateLoaderMock, \"loadCertificate\").mockResolvedValueOnce(\n undefined,\n );\n\n // WHEN\n const dataSource = new HttpWeb3CheckDataSource(\n config,\n certificateLoaderMock as unknown as PkiCertificateLoader,\n );\n const result = await dataSource.getWeb3Checks(params);\n\n // THEN\n expect(result).toEqual(\n Right({\n publicKeyId: \"partner\",\n descriptor: \"descriptor\",\n }),\n );\n });\n\n it(\"should return an object with a certificate if the request is successful\", async () => {\n // GIVEN\n const params: Web3CheckContext = {\n deviceModelId: DeviceModelId.FLEX,\n from: \"from\",\n rawTx: \"rawTx\",\n chainId: 1,\n };\n const dto: Web3CheckDto = {\n public_key_id: \"partner\",\n descriptor: \"descriptor\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValueOnce({ data: dto });\n vi.spyOn(certificateLoaderMock, \"loadCertificate\").mockResolvedValueOnce({\n keyUsageNumber: 11,\n payload: new Uint8Array([0x01]),\n });\n\n // WHEN\n const dataSource = new HttpWeb3CheckDataSource(\n config,\n certificateLoaderMock as unknown as PkiCertificateLoader,\n );\n const result = await dataSource.getWeb3Checks(params);\n\n // THEN\n expect(result).toEqual(\n Right({\n publicKeyId: \"partner\",\n descriptor: \"descriptor\",\n certificate: { keyUsageNumber: 11, payload: new Uint8Array([0x01]) },\n }),\n );\n });\n\n it(\"should return an error if the request fails\", async () => {\n // GIVEN\n const params: Web3CheckContext = {\n deviceModelId: DeviceModelId.FLEX,\n from: \"from\",\n rawTx: \"rawTx\",\n chainId: 1,\n };\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"error\"));\n\n // WHEN\n const dataSource = new HttpWeb3CheckDataSource(\n config,\n certificateLoaderMock as unknown as PkiCertificateLoader,\n );\n const result = await dataSource.getWeb3Checks(params);\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpWeb3CheckDataSource: Failed to fetch web3 checks informations\",\n ),\n ),\n );\n });\n\n it(\"should return an error if the response is invalid\", async () => {\n // GIVEN\n const params: Web3CheckContext = {\n deviceModelId: DeviceModelId.FLEX,\n from: \"from\",\n rawTx: \"rawTx\",\n chainId: 1,\n };\n const dto = {};\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: dto });\n vi.spyOn(certificateLoaderMock, \"loadCertificate\").mockResolvedValue(\n undefined,\n );\n\n // WHEN\n const dataSource = new HttpWeb3CheckDataSource(\n config,\n certificateLoaderMock as unknown as PkiCertificateLoader,\n );\n const result = await dataSource.getWeb3Checks(params);\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpWeb3CheckDataSource: Cannot exploit Web3 checks data received\",\n ),\n ),\n );\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,iBAAAA,MAAqB,kCAC9B,OAAOC,MAAW,QAClB,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAI5B,OAAS,2BAAAC,MAA+B,4CAKxC,GAAG,KAAK,OAAO,EAEf,SAAS,0BAA2B,IAAM,CACxC,MAAMC,EAAS,CACb,WAAY,CACV,IAAK,eACP,CACF,EACMC,EAAwB,CAC5B,gBAAiB,GAAG,GAAG,CACzB,EAEA,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,GAAG,uDAAwD,SAAY,CAErE,MAAMC,EAA2B,CAC/B,cAAeP,EAAc,KAC7B,KAAM,OACN,MAAO,QACP,QAAS,CACX,EACMQ,EAAoB,CACxB,cAAe,UAC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AAC,CAAI,CAAC,CAAE,CACrE,CAAC,CACH,CACF,CAAC,EAED,GAAG,8CAA+C,SAAY,CAE5D,MAAMI,EAA2B,CAC/B,cAAeP,EAAc,KAC7B,KAAM,OACN,MAAO,QACP,QAAS,CACX,EACA,GAAG,MAAMC,EAAO,SAAS,EAAE,kBAAkB,IAAI,MAAM,OAAO,CAAC,EAO/D,MAAMQ,EAAS,MAJI,IAAIL,EACrBC,EACAC,CACF,EACgC,cAAcC,CAAM,EAGpD,OAAOE,CAAM,EAAE,QACbP,EACE,IAAI,MACF,mFACF,CACF,CACF,CACF,CAAC,EAED,GAAG,oDAAqD,SAAY,CAElE,MAAMK,EAA2B,CAC/B,cAAeP,EAAc,KAC7B,KAAM,OACN,MAAO,QACP,QAAS,CACX,EACMQ,EAAM,CAAC,EACb,GAAG,MAAMP,EAAO,SAAS,EAAE,kBAAkB,CAAE,KAAMO,CAAI,CAAC,EAC1D,GAAG,MAAMF,EAAuB,iBAAiB,EAAE,kBACjD,MACF,EAOA,MAAMG,EAAS,MAJI,IAAIL,EACrBC,EACAC,CACF,EACgC,cAAcC,CAAM,EAGpD,OAAOE,CAAM,EAAE,QACbP,EACE,IAAI,MACF,mFACF,CACF,CACF,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["DeviceModelId", "axios", "Left", "Right", "HttpWeb3CheckDataSource", "config", "certificateLoaderMock", "params", "dto", "result"]
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=Web3CheckDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=Web3CheckDto.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ import{ContainerModule as t}from"inversify";import{HttpWeb3CheckDataSource as r}from"../../web3-check/data/HttpWeb3CheckDataSource";import{DefaultWeb3CheckContextLoader as c}from"../../web3-check/domain/DefaultWeb3CheckLoader";import{web3CheckTypes as o}from"./web3CheckTypes";const u=()=>new t((e,a,n,C)=>{e(o.Web3CheckDataSource).to(r),e(o.Web3CheckContextLoader).to(c)});export{u as web3CheckModuleFactory};
2
+ //# sourceMappingURL=web3CheckModuleFactory.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/web3-check/di/web3CheckModuleFactory.ts"],
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpWeb3CheckDataSource } from \"@/web3-check/data/HttpWeb3CheckDataSource\";\nimport { DefaultWeb3CheckContextLoader } from \"@/web3-check/domain/DefaultWeb3CheckLoader\";\n\nimport { web3CheckTypes } from \"./web3CheckTypes\";\n\nexport const web3CheckModuleFactory = () =>\n new ContainerModule((bind, _unbind, _isBound, _rebind) => {\n bind(web3CheckTypes.Web3CheckDataSource).to(HttpWeb3CheckDataSource);\n bind(web3CheckTypes.Web3CheckContextLoader).to(\n DefaultWeb3CheckContextLoader,\n );\n });\n"],
5
+ "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,2BAAAC,MAA+B,4CACxC,OAAS,iCAAAC,MAAqC,6CAE9C,OAAS,kBAAAC,MAAsB,mBAExB,MAAMC,EAAyB,IACpC,IAAIJ,EAAgB,CAACK,EAAMC,EAASC,EAAUC,IAAY,CACxDH,EAAKF,EAAe,mBAAmB,EAAE,GAAGF,CAAuB,EACnEI,EAAKF,EAAe,sBAAsB,EAAE,GAC1CD,CACF,CACF,CAAC",
6
+ "names": ["ContainerModule", "HttpWeb3CheckDataSource", "DefaultWeb3CheckContextLoader", "web3CheckTypes", "web3CheckModuleFactory", "bind", "_unbind", "_isBound", "_rebind"]
7
+ }
@@ -0,0 +1,2 @@
1
+ const e={Web3CheckDataSource:Symbol.for("Web3CheckDataSource"),Web3CheckContextLoader:Symbol.for("Web3CheckContextLoader")};export{e as web3CheckTypes};
2
+ //# sourceMappingURL=web3CheckTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/web3-check/di/web3CheckTypes.ts"],
4
+ "sourcesContent": ["export const web3CheckTypes = {\n Web3CheckDataSource: Symbol.for(\"Web3CheckDataSource\"),\n Web3CheckContextLoader: Symbol.for(\"Web3CheckContextLoader\"),\n};\n"],
5
+ "mappings": "AAAO,MAAMA,EAAiB,CAC5B,oBAAqB,OAAO,IAAI,qBAAqB,EACrD,uBAAwB,OAAO,IAAI,wBAAwB,CAC7D",
6
+ "names": ["web3CheckTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ var p=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var h=(o,e,c,t)=>{for(var r=t>1?void 0:t?b(e,c):e,i=o.length-1,m;i>=0;i--)(m=o[i])&&(r=(t?m(e,c,r):m(r))||r);return t&&r&&p(e,c,r),r},s=(o,e)=>(c,t)=>e(c,t,o);import{inject as C,injectable as k}from"inversify";import{web3CheckTypes as W}from"../../web3-check/di/web3CheckTypes";let a=class{_dataSource;constructor(e){this._dataSource=e}async load(e){return await this._dataSource.getWeb3Checks(e)}};a=h([k(),s(0,C(W.Web3CheckDataSource))],a);export{a as DefaultWeb3CheckContextLoader};
2
+ //# sourceMappingURL=DefaultWeb3CheckLoader.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/web3-check/domain/DefaultWeb3CheckLoader.ts"],
4
+ "sourcesContent": ["import { inject, injectable } from \"inversify\";\nimport { Either } from \"purify-ts\";\n\nimport { type Web3CheckDataSource } from \"@/web3-check/data/Web3CheckDataSource\";\nimport { web3CheckTypes } from \"@/web3-check/di/web3CheckTypes\";\n\nimport { Web3CheckContextLoader } from \"./Web3CheckContextLoader\";\nimport { Web3CheckContext, Web3Checks } from \"./web3CheckTypes\";\n\n@injectable()\nexport class DefaultWeb3CheckContextLoader implements Web3CheckContextLoader {\n private _dataSource: Web3CheckDataSource;\n\n constructor(\n @inject(web3CheckTypes.Web3CheckDataSource)\n dataSource: Web3CheckDataSource,\n ) {\n this._dataSource = dataSource;\n }\n\n async load(\n web3CheckContext: Web3CheckContext,\n ): Promise<Either<Error, Web3Checks>> {\n return await this._dataSource.getWeb3Checks(web3CheckContext);\n }\n}\n"],
5
+ "mappings": "iOAAA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YAInC,OAAS,kBAAAC,MAAsB,iCAMxB,IAAMC,EAAN,KAAsE,CACnE,YAER,YAEEC,EACA,CACA,KAAK,YAAcA,CACrB,CAEA,MAAM,KACJC,EACoC,CACpC,OAAO,MAAM,KAAK,YAAY,cAAcA,CAAgB,CAC9D,CACF,EAfaF,EAANG,EAAA,CADNC,EAAW,EAKPC,EAAA,EAAAC,EAAOC,EAAe,mBAAmB,IAJjCP",
6
+ "names": ["inject", "injectable", "web3CheckTypes", "DefaultWeb3CheckContextLoader", "dataSource", "web3CheckContext", "__decorateClass", "injectable", "__decorateParam", "inject", "web3CheckTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{DefaultWeb3CheckContextLoader as a}from"../../web3-check/domain/DefaultWeb3CheckLoader";describe("DefaultWeb3CheckLoader",()=>{describe("load",()=>{it("should call the dataSource with the correct params",async()=>{const e={getWeb3Checks:vi.fn()},t={from:"from",rawTx:"rawTx",chainId:1};await new a(e).load(t),expect(e.getWeb3Checks).toHaveBeenCalledWith({from:"from",rawTx:"rawTx",chainId:1})})})});
2
+ //# sourceMappingURL=DefaultWeb3CheckLoader.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/web3-check/domain/DefaultWeb3CheckLoader.test.ts"],
4
+ "sourcesContent": ["import { DefaultWeb3CheckContextLoader } from \"@/web3-check/domain/DefaultWeb3CheckLoader\";\nimport { type Web3CheckContext } from \"@/web3-check/domain/web3CheckTypes\";\n\ndescribe(\"DefaultWeb3CheckLoader\", () => {\n describe(\"load\", () => {\n it(\"should call the dataSource with the correct params\", async () => {\n // GIVEN\n const dataSource = {\n getWeb3Checks: vi.fn(),\n };\n const web3CheckContext = {\n from: \"from\",\n rawTx: \"rawTx\",\n chainId: 1,\n } as unknown as Web3CheckContext;\n\n // WHEN\n const loader = new DefaultWeb3CheckContextLoader(dataSource);\n await loader.load(web3CheckContext);\n\n // THEN\n expect(dataSource.getWeb3Checks).toHaveBeenCalledWith({\n from: \"from\",\n rawTx: \"rawTx\",\n chainId: 1,\n });\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,iCAAAA,MAAqC,6CAG9C,SAAS,yBAA0B,IAAM,CACvC,SAAS,OAAQ,IAAM,CACrB,GAAG,qDAAsD,SAAY,CAEnE,MAAMC,EAAa,CACjB,cAAe,GAAG,GAAG,CACvB,EACMC,EAAmB,CACvB,KAAM,OACN,MAAO,QACP,QAAS,CACX,EAIA,MADe,IAAIF,EAA8BC,CAAU,EAC9C,KAAKC,CAAgB,EAGlC,OAAOD,EAAW,aAAa,EAAE,qBAAqB,CACpD,KAAM,OACN,MAAO,QACP,QAAS,CACX,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["DefaultWeb3CheckContextLoader", "dataSource", "web3CheckContext"]
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=Web3CheckContextLoader.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=web3CheckTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -2,9 +2,11 @@ import { type ClearSignContext } from "./shared/model/ClearSignContext";
2
2
  import { type TransactionContext, type TransactionFieldContext } from "./shared/model/TransactionContext";
3
3
  import { type TypedDataClearSignContext } from "./shared/model/TypedDataClearSignContext";
4
4
  import { type TypedDataContext } from "./shared/model/TypedDataContext";
5
+ import { type Web3CheckContext } from "./web3-check/domain/web3CheckTypes";
5
6
  export interface ContextModule {
6
7
  getContext(field: TransactionFieldContext): Promise<ClearSignContext>;
7
8
  getContexts(transaction: TransactionContext): Promise<ClearSignContext[]>;
8
9
  getTypedDataFilters(typedData: TypedDataContext): Promise<TypedDataClearSignContext>;
10
+ getWeb3Checks(transactionContext: Web3CheckContext): Promise<ClearSignContext | null>;
9
11
  }
10
12
  //# sourceMappingURL=ContextModule.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContextModule.d.ts","sourceRoot":"","sources":["../../../src/ContextModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC7B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AAC1F,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAExE,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACtE,WAAW,CAAC,WAAW,EAAE,kBAAkB,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC1E,mBAAmB,CACjB,SAAS,EAAE,gBAAgB,GAC1B,OAAO,CAAC,yBAAyB,CAAC,CAAC;CACvC"}
1
+ {"version":3,"file":"ContextModule.d.ts","sourceRoot":"","sources":["../../../src/ContextModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,E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