@ledgerhq/context-module 0.0.0-signer-eth-plugin-fix-20250331141239 → 0.0.0-test-recursive-stack-20251002122259

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 (636) hide show
  1. package/README.md +17 -5
  2. package/lib/cjs/package.json +12 -12
  3. package/lib/cjs/src/ContextModule.js +1 -1
  4. package/lib/cjs/src/ContextModule.js.map +1 -1
  5. package/lib/cjs/src/ContextModuleBuilder.js +1 -1
  6. package/lib/cjs/src/ContextModuleBuilder.js.map +3 -3
  7. package/lib/cjs/src/ContextModuleBuilder.test.js +1 -1
  8. package/lib/cjs/src/ContextModuleBuilder.test.js.map +3 -3
  9. package/lib/cjs/src/DefaultContextModule.js +1 -1
  10. package/lib/cjs/src/DefaultContextModule.js.map +3 -3
  11. package/lib/cjs/src/DefaultContextModule.test.js +1 -1
  12. package/lib/cjs/src/DefaultContextModule.test.js.map +3 -3
  13. package/lib/cjs/src/calldata/data/CalldataDescriptorDataSource.js +2 -0
  14. package/lib/cjs/src/calldata/data/CalldataDescriptorDataSource.js.map +7 -0
  15. package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.js +2 -0
  16. package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.js.map +7 -0
  17. package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.test.js +2 -0
  18. package/lib/cjs/src/calldata/data/HttpCalldataDescriptorDataSource.test.js.map +7 -0
  19. package/lib/cjs/src/calldata/data/dto/CalldataDto.js +2 -0
  20. package/lib/cjs/src/calldata/data/dto/CalldataDto.js.map +7 -0
  21. package/lib/cjs/src/calldata/di/calldataModuleFactory.js +2 -0
  22. package/lib/cjs/src/calldata/di/calldataModuleFactory.js.map +7 -0
  23. package/lib/cjs/src/calldata/di/calldataTypes.js +2 -0
  24. package/lib/cjs/src/calldata/di/calldataTypes.js.map +7 -0
  25. package/lib/cjs/src/calldata/domain/CalldataContextLoader.js +2 -0
  26. package/lib/cjs/src/calldata/domain/CalldataContextLoader.js.map +7 -0
  27. package/lib/cjs/src/calldata/domain/CalldataContextLoader.test.js +2 -0
  28. package/lib/cjs/src/calldata/domain/CalldataContextLoader.test.js.map +7 -0
  29. package/lib/cjs/src/config/di/configModuleFactory.js +1 -1
  30. package/lib/cjs/src/config/di/configModuleFactory.js.map +3 -3
  31. package/lib/cjs/src/config/di/configTypes.js +1 -1
  32. package/lib/cjs/src/config/di/configTypes.js.map +2 -2
  33. package/lib/cjs/src/config/model/ContextModuleBuildArgs.js +2 -0
  34. package/lib/cjs/src/config/model/ContextModuleBuildArgs.js.map +7 -0
  35. package/lib/cjs/src/config/model/ContextModuleConfig.js +1 -1
  36. package/lib/cjs/src/config/model/ContextModuleConfig.js.map +1 -1
  37. package/lib/cjs/src/di.js +1 -1
  38. package/lib/cjs/src/di.js.map +3 -3
  39. package/lib/cjs/src/dynamic-network/data/DynamicNetworkDataSource.js +2 -0
  40. package/lib/cjs/src/dynamic-network/data/DynamicNetworkDataSource.js.map +7 -0
  41. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.js +2 -0
  42. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.js.map +7 -0
  43. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js +2 -0
  44. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js.map +7 -0
  45. package/lib/cjs/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.js +2 -0
  46. package/lib/cjs/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.js.map +7 -0
  47. package/lib/cjs/src/dynamic-network/di/dynamicNetworkModuleFactory.js +2 -0
  48. package/lib/cjs/src/dynamic-network/di/dynamicNetworkModuleFactory.js.map +7 -0
  49. package/lib/cjs/src/dynamic-network/di/dynamicNetworkTypes.js +2 -0
  50. package/lib/cjs/src/dynamic-network/di/dynamicNetworkTypes.js.map +7 -0
  51. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.js +2 -0
  52. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +7 -0
  53. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js +2 -0
  54. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +7 -0
  55. package/lib/cjs/src/dynamic-network/model/DynamicNetworkConfiguration.js +2 -0
  56. package/lib/cjs/src/dynamic-network/model/DynamicNetworkConfiguration.js.map +7 -0
  57. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js +1 -1
  58. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js.map +3 -3
  59. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js +1 -1
  60. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +3 -3
  61. package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js +1 -1
  62. package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js.map +3 -3
  63. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js +1 -1
  64. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js.map +3 -3
  65. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
  66. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +3 -3
  67. package/lib/cjs/src/index.js +1 -1
  68. package/lib/cjs/src/index.js.map +2 -2
  69. package/lib/cjs/src/nft/data/HttpNftDataSource.js +1 -1
  70. package/lib/cjs/src/nft/data/HttpNftDataSource.js.map +3 -3
  71. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js +1 -1
  72. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js.map +3 -3
  73. package/lib/cjs/src/nft/di/nftModuleFactory.js +1 -1
  74. package/lib/cjs/src/nft/di/nftModuleFactory.js.map +3 -3
  75. package/lib/cjs/src/nft/di/nftTypes.js +1 -1
  76. package/lib/cjs/src/nft/di/nftTypes.js.map +2 -2
  77. package/lib/cjs/src/nft/domain/NftContextFieldLoader.js +2 -0
  78. package/lib/cjs/src/nft/domain/NftContextFieldLoader.js.map +7 -0
  79. package/lib/cjs/src/nft/domain/NftContextFieldLoader.test.js +2 -0
  80. package/lib/cjs/src/nft/domain/NftContextFieldLoader.test.js.map +7 -0
  81. package/lib/cjs/src/nft/domain/NftContextLoader.js +1 -1
  82. package/lib/cjs/src/nft/domain/NftContextLoader.js.map +3 -3
  83. package/lib/cjs/src/nft/domain/NftContextLoader.test.js +1 -1
  84. package/lib/cjs/src/nft/domain/NftContextLoader.test.js.map +3 -3
  85. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.js +1 -1
  86. package/lib/cjs/src/pki/data/HttpPkiCertificateDataSource.js.map +3 -3
  87. package/lib/cjs/src/pki/di/pkiModuleFactory.js +1 -1
  88. package/lib/cjs/src/pki/di/pkiModuleFactory.js.map +3 -3
  89. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.js.map +2 -2
  90. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js +1 -1
  91. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +3 -3
  92. package/lib/cjs/src/pki/model/PkiCertificateInfo.js +1 -1
  93. package/lib/cjs/src/pki/model/PkiCertificateInfo.js.map +1 -1
  94. package/lib/cjs/src/proxy/data/HttpProxyDataSource.js +2 -0
  95. package/lib/cjs/src/proxy/data/HttpProxyDataSource.js.map +7 -0
  96. package/lib/cjs/src/proxy/data/HttpProxyDataSource.test.js +2 -0
  97. package/lib/cjs/src/proxy/data/HttpProxyDataSource.test.js.map +7 -0
  98. package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.js +2 -0
  99. package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.js.map +7 -0
  100. package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.test.js +2 -0
  101. package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.test.js.map +7 -0
  102. package/lib/cjs/src/proxy/data/ProxyDataSource.js +2 -0
  103. package/lib/cjs/src/proxy/data/ProxyDataSource.js.map +7 -0
  104. package/lib/cjs/src/proxy/data/dto/ProxyDelegateCallDto.js +2 -0
  105. package/lib/cjs/src/proxy/data/dto/ProxyDelegateCallDto.js.map +7 -0
  106. package/lib/cjs/src/proxy/data/dto/ProxyImplementationAddressDto.js +2 -0
  107. package/lib/cjs/src/proxy/data/dto/ProxyImplementationAddressDto.js.map +7 -0
  108. package/lib/cjs/src/proxy/data/dto/SafeProxyImplementationAddressDto.js +2 -0
  109. package/lib/cjs/src/proxy/data/dto/SafeProxyImplementationAddressDto.js.map +7 -0
  110. package/lib/cjs/src/proxy/di/proxyModuleFactory.js +2 -0
  111. package/lib/cjs/src/proxy/di/proxyModuleFactory.js.map +7 -0
  112. package/lib/cjs/src/proxy/di/proxyModuleFactory.test.js +2 -0
  113. package/lib/cjs/src/proxy/di/proxyModuleFactory.test.js.map +7 -0
  114. package/lib/cjs/src/proxy/di/proxyTypes.js +2 -0
  115. package/lib/cjs/src/proxy/di/proxyTypes.js.map +7 -0
  116. package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.js +2 -0
  117. package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.js.map +7 -0
  118. package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.test.js +2 -0
  119. package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.test.js.map +7 -0
  120. package/lib/cjs/src/proxy/model/ProxyDelegateCall.js +2 -0
  121. package/lib/cjs/src/proxy/model/ProxyDelegateCall.js.map +7 -0
  122. package/lib/cjs/src/shared/constant/HttpHeaders.js +2 -0
  123. package/lib/cjs/src/shared/constant/HttpHeaders.js.map +7 -0
  124. package/lib/cjs/src/shared/domain/ContextFieldLoader.js +2 -0
  125. package/lib/cjs/src/shared/domain/ContextFieldLoader.js.map +7 -0
  126. package/lib/cjs/src/shared/domain/ContextLoader.js +1 -1
  127. package/lib/cjs/src/shared/domain/ContextLoader.js.map +1 -1
  128. package/lib/cjs/src/shared/model/ClearSignContext.js +1 -1
  129. package/lib/cjs/src/shared/model/ClearSignContext.js.map +3 -3
  130. package/lib/cjs/src/shared/model/SolanaTransactionContext.js +2 -0
  131. package/lib/cjs/src/shared/model/SolanaTransactionContext.js.map +7 -0
  132. package/lib/cjs/src/shared/model/TransactionSubset.js +1 -1
  133. package/lib/cjs/src/shared/model/TransactionSubset.js.map +1 -1
  134. package/lib/cjs/src/shared/model/TypedDataClearSignContext.js +1 -1
  135. package/lib/cjs/src/shared/model/TypedDataClearSignContext.js.map +3 -3
  136. package/lib/cjs/src/shared/model/TypedDataContext.js +1 -1
  137. package/lib/cjs/src/shared/model/TypedDataContext.js.map +1 -1
  138. package/lib/cjs/src/shared/utils/KeyUsageMapper.js +1 -1
  139. package/lib/cjs/src/shared/utils/KeyUsageMapper.js.map +2 -2
  140. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js +2 -0
  141. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +7 -0
  142. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +2 -0
  143. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +7 -0
  144. package/lib/cjs/src/solana/data/SolanaDataSource.js +2 -0
  145. package/lib/cjs/src/solana/data/SolanaDataSource.js.map +7 -0
  146. package/lib/cjs/src/solana/di/SolanaContextModuleFactory.js +2 -0
  147. package/lib/cjs/src/solana/di/SolanaContextModuleFactory.js.map +7 -0
  148. package/lib/cjs/src/solana/di/solanaContextTypes.js +2 -0
  149. package/lib/cjs/src/solana/di/solanaContextTypes.js.map +7 -0
  150. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.js +2 -0
  151. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.js.map +7 -0
  152. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.test.js +2 -0
  153. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.test.js.map +7 -0
  154. package/lib/cjs/src/solana/domain/SolanaContextLoader.js +2 -0
  155. package/lib/cjs/src/solana/domain/SolanaContextLoader.js.map +7 -0
  156. package/lib/cjs/src/solana/domain/solanaContextTypes.js +2 -0
  157. package/lib/cjs/src/solana/domain/solanaContextTypes.js.map +7 -0
  158. package/lib/cjs/src/token/data/HttpTokenDataSource.js +1 -1
  159. package/lib/cjs/src/token/data/HttpTokenDataSource.js.map +3 -3
  160. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js +1 -1
  161. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js.map +3 -3
  162. package/lib/cjs/src/token/di/tokenModuleFactory.js +1 -1
  163. package/lib/cjs/src/token/di/tokenModuleFactory.js.map +3 -3
  164. package/lib/cjs/src/token/di/tokenTypes.js +1 -1
  165. package/lib/cjs/src/token/di/tokenTypes.js.map +2 -2
  166. package/lib/cjs/src/token/domain/TokenContextFieldLoader.js +2 -0
  167. package/lib/cjs/src/token/domain/TokenContextFieldLoader.js.map +7 -0
  168. package/lib/cjs/src/token/domain/TokenContextFieldLoader.test.js +2 -0
  169. package/lib/cjs/src/token/domain/TokenContextFieldLoader.test.js.map +7 -0
  170. package/lib/cjs/src/token/domain/TokenContextLoader.js +1 -1
  171. package/lib/cjs/src/token/domain/TokenContextLoader.js.map +3 -3
  172. package/lib/cjs/src/token/domain/TokenContextLoader.test.js +1 -1
  173. package/lib/cjs/src/token/domain/TokenContextLoader.test.js.map +3 -3
  174. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
  175. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js.map +3 -3
  176. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  177. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +3 -3
  178. package/lib/cjs/src/trusted-name/data/TrustedNameDataSource.js +1 -1
  179. package/lib/cjs/src/trusted-name/data/TrustedNameDataSource.js.map +1 -1
  180. package/lib/cjs/src/trusted-name/data/TrustedNameDto.js +1 -1
  181. package/lib/cjs/src/trusted-name/data/TrustedNameDto.js.map +1 -1
  182. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js +1 -1
  183. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js.map +3 -3
  184. package/lib/cjs/src/trusted-name/di/trustedNameTypes.js +1 -1
  185. package/lib/cjs/src/trusted-name/di/trustedNameTypes.js.map +2 -2
  186. package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.js +2 -0
  187. package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.js.map +7 -0
  188. package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js +2 -0
  189. package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js.map +7 -0
  190. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
  191. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js.map +3 -3
  192. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
  193. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +3 -3
  194. package/lib/cjs/src/typed-data/data/FiltersDto.js +1 -1
  195. package/lib/cjs/src/typed-data/data/FiltersDto.js.map +1 -1
  196. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
  197. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js.map +3 -3
  198. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  199. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
  200. package/lib/cjs/src/typed-data/data/TypedDataDataSource.js +1 -1
  201. package/lib/cjs/src/typed-data/data/TypedDataDataSource.js.map +1 -1
  202. package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js +1 -1
  203. package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js.map +3 -3
  204. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js +1 -1
  205. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +3 -3
  206. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
  207. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +3 -3
  208. package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js +1 -1
  209. package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js.map +3 -3
  210. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js +1 -1
  211. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js.map +3 -3
  212. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
  213. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js.map +3 -3
  214. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.js +1 -1
  215. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.js.map +3 -3
  216. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.test.js +1 -1
  217. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.test.js.map +3 -3
  218. package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js +1 -1
  219. package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js.map +3 -3
  220. package/lib/esm/package.json +12 -12
  221. package/lib/esm/src/ContextModuleBuilder.js +1 -1
  222. package/lib/esm/src/ContextModuleBuilder.js.map +3 -3
  223. package/lib/esm/src/ContextModuleBuilder.test.js +1 -1
  224. package/lib/esm/src/ContextModuleBuilder.test.js.map +3 -3
  225. package/lib/esm/src/DefaultContextModule.js +1 -1
  226. package/lib/esm/src/DefaultContextModule.js.map +3 -3
  227. package/lib/esm/src/DefaultContextModule.test.js +1 -1
  228. package/lib/esm/src/DefaultContextModule.test.js.map +3 -3
  229. package/lib/esm/src/calldata/data/CalldataDescriptorDataSource.js +1 -0
  230. package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.js +2 -0
  231. package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.js.map +7 -0
  232. package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.test.js +2 -0
  233. package/lib/esm/src/calldata/data/HttpCalldataDescriptorDataSource.test.js.map +7 -0
  234. package/lib/esm/src/calldata/di/calldataModuleFactory.js +2 -0
  235. package/lib/esm/src/calldata/di/calldataModuleFactory.js.map +7 -0
  236. package/lib/esm/src/calldata/di/calldataTypes.js +2 -0
  237. package/lib/esm/src/calldata/di/calldataTypes.js.map +7 -0
  238. package/lib/esm/src/calldata/domain/CalldataContextLoader.js +2 -0
  239. package/lib/esm/src/calldata/domain/CalldataContextLoader.js.map +7 -0
  240. package/lib/esm/src/calldata/domain/CalldataContextLoader.test.js +2 -0
  241. package/lib/esm/src/calldata/domain/CalldataContextLoader.test.js.map +7 -0
  242. package/lib/esm/src/config/di/configModuleFactory.js +1 -1
  243. package/lib/esm/src/config/di/configModuleFactory.js.map +3 -3
  244. package/lib/esm/src/config/di/configTypes.js +1 -1
  245. package/lib/esm/src/config/di/configTypes.js.map +2 -2
  246. package/lib/esm/src/config/model/ContextModuleBuildArgs.js +1 -0
  247. package/lib/esm/src/di.js +1 -1
  248. package/lib/esm/src/di.js.map +3 -3
  249. package/lib/esm/src/dynamic-network/data/DynamicNetworkDataSource.js +1 -0
  250. package/lib/esm/src/dynamic-network/data/DynamicNetworkDataSource.js.map +7 -0
  251. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.js +2 -0
  252. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.js.map +7 -0
  253. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js +2 -0
  254. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js.map +7 -0
  255. package/lib/esm/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.js +1 -0
  256. package/lib/esm/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.js.map +7 -0
  257. package/lib/esm/src/dynamic-network/di/dynamicNetworkModuleFactory.js +2 -0
  258. package/lib/esm/src/dynamic-network/di/dynamicNetworkModuleFactory.js.map +7 -0
  259. package/lib/esm/src/dynamic-network/di/dynamicNetworkTypes.js +2 -0
  260. package/lib/esm/src/dynamic-network/di/dynamicNetworkTypes.js.map +7 -0
  261. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js +2 -0
  262. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +7 -0
  263. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js +2 -0
  264. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +7 -0
  265. package/lib/esm/src/dynamic-network/model/DynamicNetworkConfiguration.js +1 -0
  266. package/lib/esm/src/dynamic-network/model/DynamicNetworkConfiguration.js.map +7 -0
  267. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js +1 -1
  268. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js.map +3 -3
  269. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js +1 -1
  270. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +3 -3
  271. package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js +1 -1
  272. package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js.map +3 -3
  273. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js +1 -1
  274. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js.map +3 -3
  275. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
  276. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +3 -3
  277. package/lib/esm/src/index.js +1 -1
  278. package/lib/esm/src/index.js.map +2 -2
  279. package/lib/esm/src/nft/data/HttpNftDataSource.js +1 -1
  280. package/lib/esm/src/nft/data/HttpNftDataSource.js.map +3 -3
  281. package/lib/esm/src/nft/data/HttpNftDataSource.test.js +1 -1
  282. package/lib/esm/src/nft/data/HttpNftDataSource.test.js.map +3 -3
  283. package/lib/esm/src/nft/di/nftModuleFactory.js +1 -1
  284. package/lib/esm/src/nft/di/nftModuleFactory.js.map +3 -3
  285. package/lib/esm/src/nft/di/nftTypes.js +1 -1
  286. package/lib/esm/src/nft/di/nftTypes.js.map +2 -2
  287. package/lib/esm/src/nft/domain/NftContextFieldLoader.js +2 -0
  288. package/lib/esm/src/nft/domain/NftContextFieldLoader.js.map +7 -0
  289. package/lib/esm/src/nft/domain/NftContextFieldLoader.test.js +2 -0
  290. package/lib/esm/src/nft/domain/NftContextFieldLoader.test.js.map +7 -0
  291. package/lib/esm/src/nft/domain/NftContextLoader.js +1 -1
  292. package/lib/esm/src/nft/domain/NftContextLoader.js.map +3 -3
  293. package/lib/esm/src/nft/domain/NftContextLoader.test.js +1 -1
  294. package/lib/esm/src/nft/domain/NftContextLoader.test.js.map +3 -3
  295. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.js +1 -1
  296. package/lib/esm/src/pki/data/HttpPkiCertificateDataSource.js.map +3 -3
  297. package/lib/esm/src/pki/di/pkiModuleFactory.js +1 -1
  298. package/lib/esm/src/pki/di/pkiModuleFactory.js.map +3 -3
  299. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.js.map +2 -2
  300. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js +1 -1
  301. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +3 -3
  302. package/lib/esm/src/proxy/data/HttpProxyDataSource.js +2 -0
  303. package/lib/esm/src/proxy/data/HttpProxyDataSource.js.map +7 -0
  304. package/lib/esm/src/proxy/data/HttpProxyDataSource.test.js +2 -0
  305. package/lib/esm/src/proxy/data/HttpProxyDataSource.test.js.map +7 -0
  306. package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.js +2 -0
  307. package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.js.map +7 -0
  308. package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.test.js +2 -0
  309. package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.test.js.map +7 -0
  310. package/lib/esm/src/proxy/data/ProxyDataSource.js +1 -0
  311. package/lib/esm/src/proxy/data/ProxyDataSource.js.map +7 -0
  312. package/lib/esm/src/proxy/data/dto/ProxyDelegateCallDto.js +1 -0
  313. package/lib/esm/src/proxy/data/dto/ProxyDelegateCallDto.js.map +7 -0
  314. package/lib/esm/src/proxy/data/dto/ProxyImplementationAddressDto.js +1 -0
  315. package/lib/esm/src/proxy/data/dto/ProxyImplementationAddressDto.js.map +7 -0
  316. package/lib/esm/src/proxy/data/dto/SafeProxyImplementationAddressDto.js +1 -0
  317. package/lib/esm/src/proxy/data/dto/SafeProxyImplementationAddressDto.js.map +7 -0
  318. package/lib/esm/src/proxy/di/proxyModuleFactory.js +2 -0
  319. package/lib/esm/src/proxy/di/proxyModuleFactory.js.map +7 -0
  320. package/lib/esm/src/proxy/di/proxyModuleFactory.test.js +2 -0
  321. package/lib/esm/src/proxy/di/proxyModuleFactory.test.js.map +7 -0
  322. package/lib/esm/src/proxy/di/proxyTypes.js +2 -0
  323. package/lib/esm/src/proxy/di/proxyTypes.js.map +7 -0
  324. package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.js +2 -0
  325. package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.js.map +7 -0
  326. package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.test.js +2 -0
  327. package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.test.js.map +7 -0
  328. package/lib/esm/src/proxy/model/ProxyDelegateCall.js +1 -0
  329. package/lib/esm/src/proxy/model/ProxyDelegateCall.js.map +7 -0
  330. package/lib/esm/src/shared/constant/HttpHeaders.js +2 -0
  331. package/lib/esm/src/shared/constant/HttpHeaders.js.map +7 -0
  332. package/lib/esm/src/shared/domain/ContextFieldLoader.js +1 -0
  333. package/lib/esm/src/shared/domain/ContextFieldLoader.js.map +7 -0
  334. package/lib/esm/src/shared/model/ClearSignContext.js +1 -1
  335. package/lib/esm/src/shared/model/ClearSignContext.js.map +3 -3
  336. package/lib/esm/src/shared/model/SolanaTransactionContext.js +1 -0
  337. package/lib/esm/src/shared/model/SolanaTransactionContext.js.map +7 -0
  338. package/lib/esm/src/shared/model/TypedDataClearSignContext.js +1 -1
  339. package/lib/esm/src/shared/model/TypedDataClearSignContext.js.map +3 -3
  340. package/lib/esm/src/shared/utils/KeyUsageMapper.js +1 -1
  341. package/lib/esm/src/shared/utils/KeyUsageMapper.js.map +2 -2
  342. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js +2 -0
  343. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +7 -0
  344. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +2 -0
  345. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +7 -0
  346. package/lib/esm/src/solana/data/SolanaDataSource.js +1 -0
  347. package/lib/esm/src/solana/data/SolanaDataSource.js.map +7 -0
  348. package/lib/esm/src/solana/di/SolanaContextModuleFactory.js +2 -0
  349. package/lib/esm/src/solana/di/SolanaContextModuleFactory.js.map +7 -0
  350. package/lib/esm/src/solana/di/solanaContextTypes.js +2 -0
  351. package/lib/esm/src/solana/di/solanaContextTypes.js.map +7 -0
  352. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.js +2 -0
  353. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.js.map +7 -0
  354. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.test.js +2 -0
  355. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.test.js.map +7 -0
  356. package/lib/esm/src/solana/domain/SolanaContextLoader.js +1 -0
  357. package/lib/esm/src/solana/domain/SolanaContextLoader.js.map +7 -0
  358. package/lib/esm/src/solana/domain/solanaContextTypes.js +1 -0
  359. package/lib/esm/src/solana/domain/solanaContextTypes.js.map +7 -0
  360. package/lib/esm/src/token/data/HttpTokenDataSource.js +1 -1
  361. package/lib/esm/src/token/data/HttpTokenDataSource.js.map +3 -3
  362. package/lib/esm/src/token/data/HttpTokenDataSource.test.js +1 -1
  363. package/lib/esm/src/token/data/HttpTokenDataSource.test.js.map +3 -3
  364. package/lib/esm/src/token/di/tokenModuleFactory.js +1 -1
  365. package/lib/esm/src/token/di/tokenModuleFactory.js.map +3 -3
  366. package/lib/esm/src/token/di/tokenTypes.js +1 -1
  367. package/lib/esm/src/token/di/tokenTypes.js.map +2 -2
  368. package/lib/esm/src/token/domain/TokenContextFieldLoader.js +2 -0
  369. package/lib/esm/src/token/domain/TokenContextFieldLoader.js.map +7 -0
  370. package/lib/esm/src/token/domain/TokenContextFieldLoader.test.js +2 -0
  371. package/lib/esm/src/token/domain/TokenContextFieldLoader.test.js.map +7 -0
  372. package/lib/esm/src/token/domain/TokenContextLoader.js +1 -1
  373. package/lib/esm/src/token/domain/TokenContextLoader.js.map +3 -3
  374. package/lib/esm/src/token/domain/TokenContextLoader.test.js +1 -1
  375. package/lib/esm/src/token/domain/TokenContextLoader.test.js.map +3 -3
  376. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
  377. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js.map +3 -3
  378. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  379. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +3 -3
  380. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js +1 -1
  381. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js.map +3 -3
  382. package/lib/esm/src/trusted-name/di/trustedNameTypes.js +1 -1
  383. package/lib/esm/src/trusted-name/di/trustedNameTypes.js.map +2 -2
  384. package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.js +2 -0
  385. package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.js.map +7 -0
  386. package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js +2 -0
  387. package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js.map +7 -0
  388. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
  389. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js.map +3 -3
  390. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
  391. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +3 -3
  392. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
  393. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js.map +3 -3
  394. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  395. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
  396. package/lib/esm/src/typed-data/di/typedDataModuleFactory.js +1 -1
  397. package/lib/esm/src/typed-data/di/typedDataModuleFactory.js.map +3 -3
  398. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js +1 -1
  399. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +3 -3
  400. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
  401. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +3 -3
  402. package/lib/esm/src/uniswap/di/uniswapModuleFactory.js +1 -1
  403. package/lib/esm/src/uniswap/di/uniswapModuleFactory.js.map +3 -3
  404. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js +1 -1
  405. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js.map +3 -3
  406. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
  407. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js.map +3 -3
  408. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.js +1 -1
  409. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.js.map +3 -3
  410. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.test.js +1 -1
  411. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.test.js.map +3 -3
  412. package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js +1 -1
  413. package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js.map +3 -3
  414. package/lib/types/src/ContextModule.d.ts +6 -4
  415. package/lib/types/src/ContextModule.d.ts.map +1 -1
  416. package/lib/types/src/ContextModuleBuilder.d.ts +29 -4
  417. package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -1
  418. package/lib/types/src/DefaultContextModule.d.ts +9 -3
  419. package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
  420. package/lib/types/src/{transaction/data/TransactionDataSource.d.ts → calldata/data/CalldataDescriptorDataSource.d.ts} +4 -4
  421. package/lib/types/src/calldata/data/CalldataDescriptorDataSource.d.ts.map +1 -0
  422. package/lib/types/src/{transaction/data/HttpTransactionDataSource.d.ts → calldata/data/HttpCalldataDescriptorDataSource.d.ts} +6 -5
  423. package/lib/types/src/calldata/data/HttpCalldataDescriptorDataSource.d.ts.map +1 -0
  424. package/lib/types/src/calldata/data/HttpCalldataDescriptorDataSource.test.d.ts +2 -0
  425. package/lib/types/src/calldata/data/HttpCalldataDescriptorDataSource.test.d.ts.map +1 -0
  426. package/lib/types/src/{transaction/data → calldata/data/dto}/CalldataDto.d.ts +10 -1
  427. package/lib/types/src/calldata/data/dto/CalldataDto.d.ts.map +1 -0
  428. package/lib/types/src/calldata/di/calldataModuleFactory.d.ts +3 -0
  429. package/lib/types/src/calldata/di/calldataModuleFactory.d.ts.map +1 -0
  430. package/lib/types/src/calldata/di/calldataTypes.d.ts +6 -0
  431. package/lib/types/src/calldata/di/calldataTypes.d.ts.map +1 -0
  432. package/lib/types/src/calldata/domain/CalldataContextLoader.d.ts +23 -0
  433. package/lib/types/src/calldata/domain/CalldataContextLoader.d.ts.map +1 -0
  434. package/lib/types/src/calldata/domain/CalldataContextLoader.test.d.ts +2 -0
  435. package/lib/types/src/calldata/domain/CalldataContextLoader.test.d.ts.map +1 -0
  436. package/lib/types/src/config/di/configModuleFactory.d.ts.map +1 -1
  437. package/lib/types/src/config/di/configTypes.d.ts +1 -0
  438. package/lib/types/src/config/di/configTypes.d.ts.map +1 -1
  439. package/lib/types/src/config/model/ContextModuleBuildArgs.d.ts +4 -0
  440. package/lib/types/src/config/model/ContextModuleBuildArgs.d.ts.map +1 -0
  441. package/lib/types/src/config/model/ContextModuleConfig.d.ts +14 -0
  442. package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -1
  443. package/lib/types/src/di.d.ts.map +1 -1
  444. package/lib/types/src/dynamic-network/data/DynamicNetworkDataSource.d.ts +6 -0
  445. package/lib/types/src/dynamic-network/data/DynamicNetworkDataSource.d.ts.map +1 -0
  446. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.d.ts +13 -0
  447. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.d.ts.map +1 -0
  448. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.d.ts +2 -0
  449. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.d.ts.map +1 -0
  450. package/lib/types/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.d.ts +14 -0
  451. package/lib/types/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.d.ts.map +1 -0
  452. package/lib/types/src/dynamic-network/di/dynamicNetworkModuleFactory.d.ts +3 -0
  453. package/lib/types/src/dynamic-network/di/dynamicNetworkModuleFactory.d.ts.map +1 -0
  454. package/lib/types/src/dynamic-network/di/dynamicNetworkTypes.d.ts +5 -0
  455. package/lib/types/src/dynamic-network/di/dynamicNetworkTypes.d.ts.map +1 -0
  456. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts +19 -0
  457. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts.map +1 -0
  458. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.test.d.ts +2 -0
  459. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.test.d.ts.map +1 -0
  460. package/lib/types/src/dynamic-network/model/DynamicNetworkConfiguration.d.ts +16 -0
  461. package/lib/types/src/dynamic-network/model/DynamicNetworkConfiguration.d.ts.map +1 -0
  462. package/lib/types/src/external-plugin/data/HttpExternalPluginDataSource.d.ts.map +1 -1
  463. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.d.ts +11 -4
  464. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.d.ts.map +1 -1
  465. package/lib/types/src/index.d.ts +42 -1
  466. package/lib/types/src/index.d.ts.map +1 -1
  467. package/lib/types/src/nft/data/HttpNftDataSource.d.ts +3 -0
  468. package/lib/types/src/nft/data/HttpNftDataSource.d.ts.map +1 -1
  469. package/lib/types/src/nft/di/nftModuleFactory.d.ts.map +1 -1
  470. package/lib/types/src/nft/di/nftTypes.d.ts +1 -0
  471. package/lib/types/src/nft/di/nftTypes.d.ts.map +1 -1
  472. package/lib/types/src/nft/domain/NftContextFieldLoader.d.ts +15 -0
  473. package/lib/types/src/nft/domain/NftContextFieldLoader.d.ts.map +1 -0
  474. package/lib/types/src/nft/domain/NftContextFieldLoader.test.d.ts +2 -0
  475. package/lib/types/src/nft/domain/NftContextFieldLoader.test.d.ts.map +1 -0
  476. package/lib/types/src/nft/domain/NftContextLoader.d.ts +10 -5
  477. package/lib/types/src/nft/domain/NftContextLoader.d.ts.map +1 -1
  478. package/lib/types/src/pki/data/HttpPkiCertificateDataSource.d.ts.map +1 -1
  479. package/lib/types/src/pki/domain/DefaultPkiCertificateLoader.d.ts.map +1 -1
  480. package/lib/types/src/pki/model/PkiCertificateInfo.d.ts +1 -2
  481. package/lib/types/src/pki/model/PkiCertificateInfo.d.ts.map +1 -1
  482. package/lib/types/src/proxy/data/HttpProxyDataSource.d.ts +13 -0
  483. package/lib/types/src/proxy/data/HttpProxyDataSource.d.ts.map +1 -0
  484. package/lib/types/src/proxy/data/HttpProxyDataSource.test.d.ts +2 -0
  485. package/lib/types/src/proxy/data/HttpProxyDataSource.test.d.ts.map +1 -0
  486. package/lib/types/src/proxy/data/HttpSafeProxyDataSource.d.ts +13 -0
  487. package/lib/types/src/proxy/data/HttpSafeProxyDataSource.d.ts.map +1 -0
  488. package/lib/types/src/proxy/data/HttpSafeProxyDataSource.test.d.ts +2 -0
  489. package/lib/types/src/proxy/data/HttpSafeProxyDataSource.test.d.ts.map +1 -0
  490. package/lib/types/src/proxy/data/ProxyDataSource.d.ts +17 -0
  491. package/lib/types/src/proxy/data/ProxyDataSource.d.ts.map +1 -0
  492. package/lib/types/src/proxy/data/dto/ProxyDelegateCallDto.d.ts +5 -0
  493. package/lib/types/src/proxy/data/dto/ProxyDelegateCallDto.d.ts.map +1 -0
  494. package/lib/types/src/proxy/data/dto/ProxyImplementationAddressDto.d.ts +6 -0
  495. package/lib/types/src/proxy/data/dto/ProxyImplementationAddressDto.d.ts.map +1 -0
  496. package/lib/types/src/proxy/data/dto/SafeProxyImplementationAddressDto.d.ts +10 -0
  497. package/lib/types/src/proxy/data/dto/SafeProxyImplementationAddressDto.d.ts.map +1 -0
  498. package/lib/types/src/proxy/di/proxyModuleFactory.d.ts +4 -0
  499. package/lib/types/src/proxy/di/proxyModuleFactory.d.ts.map +1 -0
  500. package/lib/types/src/proxy/di/proxyModuleFactory.test.d.ts +2 -0
  501. package/lib/types/src/proxy/di/proxyModuleFactory.test.d.ts.map +1 -0
  502. package/lib/types/src/proxy/di/proxyTypes.d.ts +5 -0
  503. package/lib/types/src/proxy/di/proxyTypes.d.ts.map +1 -0
  504. package/lib/types/src/proxy/domain/ProxyContextFieldLoader.d.ts +21 -0
  505. package/lib/types/src/proxy/domain/ProxyContextFieldLoader.d.ts.map +1 -0
  506. package/lib/types/src/proxy/domain/ProxyContextFieldLoader.test.d.ts +2 -0
  507. package/lib/types/src/proxy/domain/ProxyContextFieldLoader.test.d.ts.map +1 -0
  508. package/lib/types/src/proxy/model/ProxyDelegateCall.d.ts +7 -0
  509. package/lib/types/src/proxy/model/ProxyDelegateCall.d.ts.map +1 -0
  510. package/lib/types/src/shared/constant/HttpHeaders.d.ts +3 -0
  511. package/lib/types/src/shared/constant/HttpHeaders.d.ts.map +1 -0
  512. package/lib/types/src/shared/domain/ContextFieldLoader.d.ts +15 -0
  513. package/lib/types/src/shared/domain/ContextFieldLoader.d.ts.map +1 -0
  514. package/lib/types/src/shared/domain/ContextLoader.d.ts +13 -5
  515. package/lib/types/src/shared/domain/ContextLoader.d.ts.map +1 -1
  516. package/lib/types/src/shared/model/ClearSignContext.d.ts +29 -8
  517. package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -1
  518. package/lib/types/src/shared/model/SolanaTransactionContext.d.ts +11 -0
  519. package/lib/types/src/shared/model/SolanaTransactionContext.d.ts.map +1 -0
  520. package/lib/types/src/shared/model/TransactionSubset.d.ts +3 -2
  521. package/lib/types/src/shared/model/TransactionSubset.d.ts.map +1 -1
  522. package/lib/types/src/shared/model/TypedDataClearSignContext.d.ts +33 -1
  523. package/lib/types/src/shared/model/TypedDataClearSignContext.d.ts.map +1 -1
  524. package/lib/types/src/shared/model/TypedDataContext.d.ts +3 -0
  525. package/lib/types/src/shared/model/TypedDataContext.d.ts.map +1 -1
  526. package/lib/types/src/shared/utils/KeyUsageMapper.d.ts +1 -2
  527. package/lib/types/src/shared/utils/KeyUsageMapper.d.ts.map +1 -1
  528. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.d.ts +13 -0
  529. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.d.ts.map +1 -0
  530. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.test.d.ts +2 -0
  531. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.test.d.ts.map +1 -0
  532. package/lib/types/src/solana/data/SolanaDataSource.d.ts +12 -0
  533. package/lib/types/src/solana/data/SolanaDataSource.d.ts.map +1 -0
  534. package/lib/types/src/solana/di/SolanaContextModuleFactory.d.ts +3 -0
  535. package/lib/types/src/solana/di/SolanaContextModuleFactory.d.ts.map +1 -0
  536. package/lib/types/src/solana/di/solanaContextTypes.d.ts +5 -0
  537. package/lib/types/src/solana/di/solanaContextTypes.d.ts.map +1 -0
  538. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.d.ts +11 -0
  539. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.d.ts.map +1 -0
  540. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.test.d.ts +2 -0
  541. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.test.d.ts.map +1 -0
  542. package/lib/types/src/solana/domain/SolanaContextLoader.d.ts +5 -0
  543. package/lib/types/src/solana/domain/SolanaContextLoader.d.ts.map +1 -0
  544. package/lib/types/src/solana/domain/solanaContextTypes.d.ts +27 -0
  545. package/lib/types/src/solana/domain/solanaContextTypes.d.ts.map +1 -0
  546. package/lib/types/src/token/data/HttpTokenDataSource.d.ts.map +1 -1
  547. package/lib/types/src/token/di/tokenModuleFactory.d.ts.map +1 -1
  548. package/lib/types/src/token/di/tokenTypes.d.ts +1 -0
  549. package/lib/types/src/token/di/tokenTypes.d.ts.map +1 -1
  550. package/lib/types/src/token/domain/TokenContextFieldLoader.d.ts +14 -0
  551. package/lib/types/src/token/domain/TokenContextFieldLoader.d.ts.map +1 -0
  552. package/lib/types/src/token/domain/TokenContextFieldLoader.test.d.ts +2 -0
  553. package/lib/types/src/token/domain/TokenContextFieldLoader.test.d.ts.map +1 -0
  554. package/lib/types/src/token/domain/TokenContextLoader.d.ts +10 -5
  555. package/lib/types/src/token/domain/TokenContextLoader.d.ts.map +1 -1
  556. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts +7 -3
  557. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts.map +1 -1
  558. package/lib/types/src/trusted-name/data/TrustedNameDataSource.d.ts +7 -2
  559. package/lib/types/src/trusted-name/data/TrustedNameDataSource.d.ts.map +1 -1
  560. package/lib/types/src/trusted-name/data/TrustedNameDto.d.ts +4 -5
  561. package/lib/types/src/trusted-name/data/TrustedNameDto.d.ts.map +1 -1
  562. package/lib/types/src/trusted-name/di/trustedNameModuleFactory.d.ts.map +1 -1
  563. package/lib/types/src/trusted-name/di/trustedNameTypes.d.ts +1 -0
  564. package/lib/types/src/trusted-name/di/trustedNameTypes.d.ts.map +1 -1
  565. package/lib/types/src/trusted-name/domain/TrustedNameContextFieldLoader.d.ts +22 -0
  566. package/lib/types/src/trusted-name/domain/TrustedNameContextFieldLoader.d.ts.map +1 -0
  567. package/lib/types/src/trusted-name/domain/TrustedNameContextFieldLoader.test.d.ts +2 -0
  568. package/lib/types/src/trusted-name/domain/TrustedNameContextFieldLoader.test.d.ts.map +1 -0
  569. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts +14 -6
  570. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts.map +1 -1
  571. package/lib/types/src/typed-data/data/FiltersDto.d.ts +32 -2
  572. package/lib/types/src/typed-data/data/FiltersDto.d.ts.map +1 -1
  573. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts +3 -0
  574. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts.map +1 -1
  575. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts +1 -0
  576. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts.map +1 -1
  577. package/lib/types/src/typed-data/data/TypedDataDataSource.d.ts +2 -1
  578. package/lib/types/src/typed-data/data/TypedDataDataSource.d.ts.map +1 -1
  579. package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts +12 -1
  580. package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts.map +1 -1
  581. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts +11 -4
  582. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts.map +1 -1
  583. package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.d.ts.map +1 -1
  584. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  585. package/package.json +13 -13
  586. package/lib/cjs/src/shared/model/TransactionContext.js +0 -2
  587. package/lib/cjs/src/shared/model/TransactionContext.js.map +0 -7
  588. package/lib/cjs/src/transaction/data/CalldataDto.js +0 -2
  589. package/lib/cjs/src/transaction/data/CalldataDto.js.map +0 -7
  590. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js +0 -2
  591. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js.map +0 -7
  592. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js +0 -2
  593. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js.map +0 -7
  594. package/lib/cjs/src/transaction/data/TransactionDataSource.js +0 -2
  595. package/lib/cjs/src/transaction/data/TransactionDataSource.js.map +0 -7
  596. package/lib/cjs/src/transaction/di/transactionModuleFactory.js +0 -2
  597. package/lib/cjs/src/transaction/di/transactionModuleFactory.js.map +0 -7
  598. package/lib/cjs/src/transaction/di/transactionTypes.js +0 -2
  599. package/lib/cjs/src/transaction/di/transactionTypes.js.map +0 -7
  600. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js +0 -2
  601. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js.map +0 -7
  602. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js +0 -2
  603. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js.map +0 -7
  604. package/lib/esm/src/shared/model/TransactionContext.js +0 -1
  605. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js +0 -2
  606. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js.map +0 -7
  607. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js +0 -2
  608. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js.map +0 -7
  609. package/lib/esm/src/transaction/data/TransactionDataSource.js +0 -1
  610. package/lib/esm/src/transaction/di/transactionModuleFactory.js +0 -2
  611. package/lib/esm/src/transaction/di/transactionModuleFactory.js.map +0 -7
  612. package/lib/esm/src/transaction/di/transactionTypes.js +0 -2
  613. package/lib/esm/src/transaction/di/transactionTypes.js.map +0 -7
  614. package/lib/esm/src/transaction/domain/TransactionContextLoader.js +0 -2
  615. package/lib/esm/src/transaction/domain/TransactionContextLoader.js.map +0 -7
  616. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js +0 -2
  617. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js.map +0 -7
  618. package/lib/types/src/shared/model/TransactionContext.d.ts +0 -21
  619. package/lib/types/src/shared/model/TransactionContext.d.ts.map +0 -1
  620. package/lib/types/src/transaction/data/CalldataDto.d.ts.map +0 -1
  621. package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts.map +0 -1
  622. package/lib/types/src/transaction/data/HttpTransactionDataSource.test.d.ts +0 -2
  623. package/lib/types/src/transaction/data/HttpTransactionDataSource.test.d.ts.map +0 -1
  624. package/lib/types/src/transaction/data/TransactionDataSource.d.ts.map +0 -1
  625. package/lib/types/src/transaction/di/transactionModuleFactory.d.ts +0 -3
  626. package/lib/types/src/transaction/di/transactionModuleFactory.d.ts.map +0 -1
  627. package/lib/types/src/transaction/di/transactionTypes.d.ts +0 -5
  628. package/lib/types/src/transaction/di/transactionTypes.d.ts.map +0 -1
  629. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts +0 -10
  630. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts.map +0 -1
  631. package/lib/types/src/transaction/domain/TransactionContextLoader.test.d.ts +0 -2
  632. package/lib/types/src/transaction/domain/TransactionContextLoader.test.d.ts.map +0 -1
  633. /package/lib/esm/src/{shared/model/TransactionContext.js.map → calldata/data/CalldataDescriptorDataSource.js.map} +0 -0
  634. /package/lib/esm/src/{transaction/data → calldata/data/dto}/CalldataDto.js +0 -0
  635. /package/lib/esm/src/{transaction/data → calldata/data/dto}/CalldataDto.js.map +0 -0
  636. /package/lib/esm/src/{transaction/data/TransactionDataSource.js.map → config/model/ContextModuleBuildArgs.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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 array.every((item) => typeof item === \"string\" && isHexaString(item))\n );\n }\n}\n"],
5
- "mappings": "iOAAA,OACE,sBAAAA,EACA,oBAAAC,EAEA,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AC,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"]
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 { 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\nexport type UniswapContextInput = {\n to: HexaString;\n data: HexaString;\n selector: HexaString;\n chainId: number;\n};\n\nconst SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.EXTERNAL_PLUGIN,\n ClearSignContextType.TOKEN,\n];\n\n@injectable()\nexport class UniswapContextLoader\n implements ContextLoader<UniswapContextInput>\n{\n constructor(\n @inject(uniswapTypes.CommandDecoderDataSource)\n private commandDecoderDataSource: CommandDecoderDataSource,\n @inject(tokenTypes.TokenDataSource)\n private tokenDataSource: TokenDataSource,\n ) {}\n\n canHandle(\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ): input is UniswapContextInput {\n return (\n typeof input === \"object\" &&\n input !== null &&\n \"to\" in input &&\n \"data\" in input &&\n \"selector\" in input &&\n \"chainId\" in input &&\n typeof input.chainId === \"number\" &&\n isHexaString(input.data) &&\n input.data !== \"0x\" &&\n isHexaString(input.selector) &&\n input.selector === UNISWAP_EXECUTE_SELECTOR &&\n isHexaString(input.to) &&\n input.to === UNISWAP_UNIVERSAL_ROUTER_ADDRESS &&\n SUPPORTED_TYPES.every((type) => expectedTypes.includes(type))\n );\n }\n\n async load(input: UniswapContextInput): Promise<ClearSignContext[]> {\n const { data, chainId } = input;\n\n const externalPluginContext = this._buildUniswapPluginCommandData();\n const tokenContexts = await this._extractClearSignContexts(data, chainId);\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, false),\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 array.every((item) => typeof item === \"string\" && isHexaString(item))\n );\n }\n}\n"],
5
+ "mappings": "iOAAA,OACE,sBAAAA,EACA,oBAAAC,EAEA,sBAAAC,EACA,gBAAAC,MACK,kCACP,OAAS,aAAAC,MAAiB,SAC1B,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAS,SAAAC,EAAO,WAAAC,MAAe,YAG/B,OAEE,wBAAAC,MACK,kCAEP,OAAS,cAAAC,MAAkB,wBAC3B,OACE,uBAAAC,EACA,4BAAAC,MACK,6BACP,OACE,oBAAAC,EACA,uBAAAC,EACA,4BAAAC,EACA,yBAAAC,EACA,oCAAAC,MAEK,8BAEP,OAAS,gBAAAC,MAAoB,4BAS7B,MAAMC,EAA0C,CAC9CC,EAAqB,gBACrBA,EAAqB,KACvB,EAGO,IAAMC,EAAN,KAEP,CACE,YAEUC,EAEAC,EACR,CAHQ,8BAAAD,EAEA,qBAAAC,CACP,CAEH,UACEC,EACAC,EAC8B,CAC9B,OACE,OAAOD,GAAU,UACjBA,IAAU,MACV,OAAQA,GACR,SAAUA,GACV,aAAcA,GACd,YAAaA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EgB,IACCA,IAAcZ,EAAU,CAAC,GAAKa,IAAoBE,GAGnD,MAAO,GAITH,EAAYZ,EAAUA,EAAU,OAAS,CAAC,EAC1Ca,EAAkBE,CACpB,CAEA,MAAO,EACT,CASQ,mBAAmBC,EAAuC,CAChE,OACE,MAAM,QAAQA,CAAK,GACnBA,EAAM,MAAOC,GAAS,OAAOA,GAAS,UAAY5C,EAAa4C,CAAI,CAAC,CAExE,CACF,EA7PajD,EAANkD,EAAA,CADNC,EAAW,EAKPC,EAAA,EAAAC,EAAOC,EAAa,wBAAwB,GAE5CF,EAAA,EAAAC,EAAOE,EAAW,eAAe,IANzBvD",
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", "SUPPORTED_TYPES", "ClearSignContextType", "UniswapContextLoader", "commandDecoderDataSource", "tokenDataSource", "input", "expectedTypes", "isHexaString", "UNISWAP_EXECUTE_SELECTOR", "UNISWAP_UNIVERSAL_ROUTER_ADDRESS", "type", "data", "chainId", "externalPluginContext", "tokenContexts", "buffer", "ByteArrayBuilder", "UNISWAP_PLUGIN_NAME", "hexaStringToBuffer", "UNISWAP_PLUGIN_SIGNATURE", "bufferToHexaString", "calldata", "tx", "Interface", "UNISWAP_EXECUTE_ABI", "commands", "inputs", "decodedCommands", "addressesByCommand", "acc", "command", "index", "decoded", "uniqueAddresses", "addresses", "address", "either", "error", "payload", "hex", "Maybe", "bytes", "b", "hexBytes", "UNISWAP_COMMANDS", "Nothing", "lastAsset", "lastPoolVersion", "UNISWAP_SWAP_COMMANDS", "poolVersion", "array", "item", "__decorateClass", "injectable", "__decorateParam", "inject", "uniswapTypes", "tokenTypes"]
7
7
  }
@@ -1,2 +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([])})})})});
1
+ import{Interface as p}from"ethers";import{Left as y,Right as f}from"purify-ts";import{ClearSignContextType as r}from"../../shared/model/ClearSignContext";import{UNISWAP_EXECUTE_SELECTOR as c,UNISWAP_UNIVERSAL_ROUTER_ADDRESS as d,UniswapSupportedCommand as i}from"../../uniswap/constants/uniswap";import{DefaultCommandDecoderDataSource as u}from"../../uniswap/data/DefaultCommandDecoderDataSource";import{EthersAbiDecoderDataSource as b}from"../../uniswap/data/EthersAbiDecoderDataSource";import{UniswapContextLoader as x}from"./UniswapContextLoader";describe("UniswapContextLoader",()=>{const o={decode:vi.fn()},a={getTokenInfosPayload:vi.fn()};let n;describe("canHandle function",()=>{beforeEach(()=>{n=new x(new u(new b),a)});const e={data:"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000067a4855b",selector:c,chainId:1,to:d};it("should return true for valid input",()=>{expect(n.canHandle(e,[r.TOKEN,r.EXTERNAL_PLUGIN])).toBe(!0)}),it("should return false for invalid expected type",()=>{expect(n.canHandle(e,[r.NFT])).toBe(!1),expect(n.canHandle(e,[r.TOKEN])).toBe(!1),expect(n.canHandle(e,[r.EXTERNAL_PLUGIN])).toBe(!1)}),it.each([[null,"null input"],[void 0,"undefined input"],[{},"empty object"],["string","string input"],[123,"number input"],[{...e,data:void 0},"missing data"],[{...e,selector:void 0},"missing selector"],[{...e,chainId:void 0},"missing chainId"],[{...e,data:"invalid-hex"},"invalid data hex"],[{...e,data:"0x"},"empty data hex"],[{...e,selector:"invalid-hex"},"invalid selector hex"],[{...e,selector:"0x"},"empty selector hex"],[{...e,selector:"not-hex-at-all"},"non-hex selector"],[{...e,selector:0},"different selector"],[{...e,chainId:"1"},"string chainId"],[{...e,chainId:null},"null chainId"],[{...e,to:void 0},"missing to"],[{...e,to:"invalid-hex"},"invalid to hex"],[{...e,to:"0x"},"empty to hex"],[{...e,to:"0x0000000000000000000000000000000000000000"},"different to uniswap router address"]])("should return false for %s",(t,s)=>{expect(n.canHandle(t,[r.TOKEN])).toBe(!1)})}),describe("load",()=>{describe("with tokenDataSourceMock",()=>{beforeEach(()=>{vi.spyOn(a,"getTokenInfosPayload").mockImplementation(({address:e})=>Promise.resolve(f(`payload-${e}`))),n=new x(new u(new b),a)}),it("should return an empty array if the selector is not UNISWAP_EXECUTE_SELECTOR",async()=>{const e={to:d,selector:"0x00000000",data:"0x00000000",chainId:1},t=await n.load(e);expect(t).toEqual([])}),it("should return the external plugin context and the decoded contexts",async()=>{const e={chainId:1,data:"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000067a4855b000000000000000000000000000000000000000000000000000000000000000300060c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000a18f07d736b90be5500000000000000000000000000000000000000000000000000000000b0b8122abd8412900000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bb9f599ce614feb2e1bbe58f180f370d05b39344e002710c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000017cc6042605381c158d2adab487434bde79aa61c000000000000000000000000000000000000000000000000000000000000005b000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000b0b8122abd84129c001a053efc49d03b694742500f49aa09df2360bd7e297fa730c745e0d4320b42fc33fa01ca1c85a46c561f624830fffbae2441ba0f2d54eb5b0f17e0e3561d10db0b7ee",selector:c,to:d},t=await n.load(e);expect(t).toEqual([{type:r.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",selector:c,to:d},t=await n.load(e);expect(t).toEqual([{type:r.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(o,"decode").mockReturnValue([]);const t=await n.load(e);expect(t).toEqual([])}),it("should return an empty array if a command is not supported",async()=>{const e={chainId:1,data:"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000067a4bef600000000000000000000000000000000000000000000000000000000000000050b0105040c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000078e6708e70aed0f000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000059a16770000000000000000000000000000000000000000000000000078e6708e70aed0f00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f4c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000027213e28d7fda5c57fe9e5dd923818dbccf71c4700000000000000000000000000000000000000000000000000000000003938700000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006f939b43d65be049b7533907db08e80ba6969f450000000000000000000000000000000000000000000000000000000059682f0000000000000000000000000000000000000000000000000000000000000000400000000000000000000000006f939b43d65be049b7533907db08e80ba6969f4500000000000000000000000000000000000000000000000000000000000000000cc080a07c86dd5813ec1f3725c402f8bea6105546d1093c59676023b971f1d83f61bd4ea02a353bf3028cabcbe68c5dc8906752bafe55afc86b6344edb3ffd8a3650332e8",selector:c,to:d},t=await n.load(e);expect(t).toEqual([])})}),describe("with mocked ethers parseTransaction",()=>{beforeEach(()=>{vi.resetAllMocks(),n=new x(o,a)}),it("should return an array with contexts if 2 chain swaps are supported",async()=>{const e={to:d,data:c,chainId:66,selector:c};vi.spyOn(p.prototype,"parseTransaction").mockReturnValue({args:["0x0809",["0x0001","0x0002"]]}),vi.spyOn(o,"decode").mockReturnValueOnce(["0x01","0x04","0x02"]).mockReturnValueOnce(["0x02","0x03"]),vi.spyOn(a,"getTokenInfosPayload").mockImplementation(({address:l})=>Promise.resolve(f(`payload-${l}`)));const s=await n.load(e);expect(o.decode).toHaveBeenNthCalledWith(1,i.V2_SWAP_EXACT_IN,"0x0001",66),expect(o.decode).toHaveBeenNthCalledWith(2,i.V2_SWAP_EXACT_OUT,"0x0002",66),expect(a.getTokenInfosPayload).toHaveBeenNthCalledWith(1,{address:"0x01",chainId:66}),expect(a.getTokenInfosPayload).toHaveBeenNthCalledWith(2,{address:"0x04",chainId:66}),expect(a.getTokenInfosPayload).toHaveBeenNthCalledWith(3,{address:"0x02",chainId:66}),expect(a.getTokenInfosPayload).toHaveBeenNthCalledWith(4,{address:"0x03",chainId:66}),expect(s).toEqual([{type:r.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:c,chainId:66,selector:c};vi.spyOn(p.prototype,"parseTransaction").mockReturnValue({args:["0x0b0004",["0x0001","0x0002","0x0003"]]}),vi.spyOn(o,"decode").mockReturnValueOnce(["0x01"]).mockReturnValueOnce(["0x02","0x03"]).mockReturnValueOnce(["0x04"]),vi.spyOn(a,"getTokenInfosPayload").mockImplementation(({address:l})=>Promise.resolve(f(`payload-${l}`)));const s=await n.load(e);expect(o.decode).toHaveBeenNthCalledWith(1,i.WRAP_ETH,"0x0001",66),expect(a.getTokenInfosPayload).toHaveBeenNthCalledWith(1,{address:"0x01",chainId:66}),expect(a.getTokenInfosPayload).toHaveBeenNthCalledWith(2,{address:"0x02",chainId:66}),expect(a.getTokenInfosPayload).toHaveBeenNthCalledWith(3,{address:"0x03",chainId:66}),expect(a.getTokenInfosPayload).toHaveBeenNthCalledWith(4,{address:"0x04",chainId:66}),expect(s).toEqual([{type:r.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:c,chainId:66,selector:c};vi.spyOn(p.prototype,"parseTransaction").mockReturnValue({args:["0x0809",["0x0001","0x0002"]]}),vi.spyOn(o,"decode").mockReturnValueOnce(["0x01","0x02"]).mockReturnValueOnce(["0x02","0x03"]),vi.spyOn(a,"getTokenInfosPayload").mockResolvedValueOnce(y("error")).mockImplementation(({address:l})=>Promise.resolve(f(`payload-${l}`)));const s=await n.load(e);expect(o.decode).toHaveBeenNthCalledWith(1,i.V2_SWAP_EXACT_IN,"0x0001",66),expect(o.decode).toHaveBeenNthCalledWith(2,i.V2_SWAP_EXACT_OUT,"0x0002",66),expect(a.getTokenInfosPayload).toHaveBeenNthCalledWith(1,{address:"0x01",chainId:66}),expect(a.getTokenInfosPayload).toHaveBeenNthCalledWith(2,{address:"0x02",chainId:66}),expect(a.getTokenInfosPayload).toHaveBeenNthCalledWith(3,{address:"0x03",chainId:66}),expect(s).toEqual([{type:r.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:c,chainId:66,selector:c};vi.spyOn(p.prototype,"parseTransaction").mockReturnValue({args:["0x0809",["0x0001","0x0002"]]}),vi.spyOn(o,"decode").mockReturnValueOnce(["0x01","0x02"]),vi.spyOn(o,"decode").mockReturnValueOnce(["0x03","0x04"]);const s=await n.load(e);expect(o.decode).toHaveBeenNthCalledWith(1,i.V2_SWAP_EXACT_IN,"0x0001",66),expect(o.decode).toHaveBeenNthCalledWith(2,i.V2_SWAP_EXACT_OUT,"0x0002",66),expect(a.getTokenInfosPayload).not.toHaveBeenCalled(),expect(s).toEqual([])}),it("should return an empty array if no command are returned from parseTransaction",async()=>{const e={to:d,data:c,selector:c,chainId:1};vi.spyOn(p.prototype,"parseTransaction").mockReturnValue({args:[""]});const t=await n.load(e);expect(o.decode).not.toHaveBeenCalled(),expect(a.getTokenInfosPayload).not.toHaveBeenCalled(),expect(t).toEqual([])}),it("should return an empty array if no inputs are returned from parseTransaction",async()=>{const e={to:d,data:c,selector:c,chainId:1};vi.spyOn(p.prototype,"parseTransaction").mockReturnValue({args:["0x08",[]]}),vi.spyOn(o,"decode").mockReturnValue([]);const t=await n.load(e);expect(a.getTokenInfosPayload).not.toHaveBeenCalled(),expect(t).toEqual([])}),it("should return an empty array if parseTransaction throws an error",async()=>{const e={to:d,data:c,selector:c,chainId:1};vi.spyOn(p.prototype,"parseTransaction").mockImplementation(()=>{throw new Error});const t=await n.load(e);expect(o.decode).not.toHaveBeenCalled(),expect(a.getTokenInfosPayload).not.toHaveBeenCalled(),expect(t).toEqual([])}),it("should return an empty array if the swap is with multiple pool versions",async()=>{const e={to:d,data:c,chainId:66,selector:c};vi.spyOn(p.prototype,"parseTransaction").mockReturnValue({args:["0x080900",["0x00","0x01","0x02"]]}),vi.spyOn(o,"decode").mockReturnValue(["0x01","0x02"]);const s=await n.load(e);expect(o.decode).toHaveBeenNthCalledWith(1,i.V2_SWAP_EXACT_IN,"0x00",66),expect(o.decode).toHaveBeenNthCalledWith(2,i.V2_SWAP_EXACT_OUT,"0x01",66),expect(o.decode).toHaveBeenNthCalledWith(3,i.V3_SWAP_EXACT_IN,"0x02",66),expect(a.getTokenInfosPayload).not.toHaveBeenCalled(),expect(s).toEqual([])}),it("should return an empty array if the selector is not supported",async()=>{const e={to:d,data:"0x00000000",chainId:66,selector:c},t=await n.load(e);expect(o.decode).not.toHaveBeenCalled(),expect(a.getTokenInfosPayload).not.toHaveBeenCalled(),expect(t).toEqual([])}),it("should return an empty array if the length of the commands and inputs are different",async()=>{const e={to:d,data:c,chainId:66,selector:c};vi.spyOn(p.prototype,"parseTransaction").mockReturnValue({args:["0x0809",["0x0001"]]});const s=await n.load(e);expect(o.decode).not.toHaveBeenCalled(),expect(a.getTokenInfosPayload).not.toHaveBeenCalled(),expect(s).toEqual([])})})})});
2
2
  //# sourceMappingURL=UniswapContextLoader.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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,8BAAAC,MAAkC,4CAE3C,OAAS,wBAAAC,MAA4B,yBAErC,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA+C,CACnD,OAAQ,GAAG,GAAG,CAChB,EACMC,EAAsB,CAC1B,qBAAsB,GAAG,GAAG,CAC9B,EACA,IAAIC,EAEJ,SAAS,OAAQ,IAAM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,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"]
4
+ "sourcesContent": ["import { Interface, type TransactionDescription } from \"ethers\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\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 {\n type UniswapContextInput,\n UniswapContextLoader,\n} 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(\"canHandle function\", () => {\n beforeEach(() => {\n loader = new UniswapContextLoader(\n new DefaultCommandDecoderDataSource(new EthersAbiDecoderDataSource()),\n tokenDataSourceMock as unknown as HttpTokenDataSource,\n );\n });\n\n const validInput: UniswapContextInput = {\n data: \"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000067a4855b\",\n selector: UNISWAP_EXECUTE_SELECTOR,\n chainId: 1,\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n };\n\n it(\"should return true for valid input\", () => {\n expect(\n loader.canHandle(validInput, [\n ClearSignContextType.TOKEN,\n ClearSignContextType.EXTERNAL_PLUGIN,\n ]),\n ).toBe(true);\n });\n\n it(\"should return false for invalid expected type\", () => {\n expect(loader.canHandle(validInput, [ClearSignContextType.NFT])).toBe(\n false,\n );\n expect(loader.canHandle(validInput, [ClearSignContextType.TOKEN])).toBe(\n false,\n );\n expect(\n loader.canHandle(validInput, [ClearSignContextType.EXTERNAL_PLUGIN]),\n ).toBe(false);\n });\n\n it.each([\n [null, \"null input\"],\n [undefined, \"undefined input\"],\n [{}, \"empty object\"],\n [\"string\", \"string input\"],\n [123, \"number input\"],\n [{ ...validInput, data: undefined }, \"missing data\"],\n [{ ...validInput, selector: undefined }, \"missing selector\"],\n [{ ...validInput, chainId: undefined }, \"missing chainId\"],\n [{ ...validInput, data: \"invalid-hex\" }, \"invalid data hex\"],\n [{ ...validInput, data: \"0x\" }, \"empty data hex\"],\n [{ ...validInput, selector: \"invalid-hex\" }, \"invalid selector hex\"],\n [{ ...validInput, selector: \"0x\" }, \"empty selector hex\"],\n [{ ...validInput, selector: \"not-hex-at-all\" }, \"non-hex selector\"],\n [{ ...validInput, selector: 0x00000000 }, \"different selector\"],\n [{ ...validInput, chainId: \"1\" }, \"string chainId\"],\n [{ ...validInput, chainId: null }, \"null chainId\"],\n [{ ...validInput, to: undefined }, \"missing to\"],\n [{ ...validInput, to: \"invalid-hex\" }, \"invalid to hex\"],\n [{ ...validInput, to: \"0x\" }, \"empty to hex\"],\n [\n { ...validInput, to: \"0x0000000000000000000000000000000000000000\" },\n \"different to uniswap router address\",\n ],\n ])(\"should return false for %s\", (input, _description) => {\n expect(loader.canHandle(input, [ClearSignContextType.TOKEN])).toBe(false);\n });\n });\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 an empty array if the selector is not UNISWAP_EXECUTE_SELECTOR\", async () => {\n // GIVEN\n const input: UniswapContextInput = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n selector: \"0x00000000\" as const,\n data: \"0x00000000\" as const,\n chainId: 1,\n };\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([]);\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 input: UniswapContextInput = {\n chainId: 1,\n data: \"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000067a4855b000000000000000000000000000000000000000000000000000000000000000300060c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000a18f07d736b90be5500000000000000000000000000000000000000000000000000000000b0b8122abd8412900000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bb9f599ce614feb2e1bbe58f180f370d05b39344e002710c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000017cc6042605381c158d2adab487434bde79aa61c000000000000000000000000000000000000000000000000000000000000005b000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000b0b8122abd84129c001a053efc49d03b694742500f49aa09df2360bd7e297fa730c745e0d4320b42fc33fa01ca1c85a46c561f624830fffbae2441ba0f2d54eb5b0f17e0e3561d10db0b7ee\",\n selector: UNISWAP_EXECUTE_SELECTOR,\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n };\n\n // WHEN\n const result = await loader.load(input);\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 input = {\n chainId: 1,\n data: \"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000669b9ec100000000000000000000000000000000000000000000000000000000000000030a010c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000016000000000000000000000000055747be9f9f5beb232ad59fe7af013b81d95fd5e000000000000000000000000ffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000066c32b0d0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000ef1c6e67703c7bd7107eed8303fbe6ec2554bf6b00000000000000000000000000000000000000000000000000000000669b9ec100000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000410d756f55acf289e9754faf91bba0a704b5c7c0aa4b1dfd551115ccbe4c7f290234e1a14265e1da0bc872a23627d997fe37a689c290d519f7b8c9bdde1b79108e1b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000030ba49cbff5a00000000000000000000000000000000000000000000000089677c957272141800000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc200271055747be9f9f5beb232ad59fe7af013b81d95fd5e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000030ba49cbff5a000c001a0e406d9c91c8b46d959fcd31a28518a77bb248ebb316c5fab7b98335cce922f2aa0462cb970c32a8dbfe71c57b888c43b9ed04fce41d169dbfcc745445587adb771\",\n selector: UNISWAP_EXECUTE_SELECTOR,\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n } as UniswapContextInput;\n\n // WHEN\n const result = await loader.load(input);\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 input = {} as UniswapContextInput;\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValue([]);\n\n // WHEN\n const result = await loader.load(input);\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 input: UniswapContextInput = {\n chainId: 1,\n data: \"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000067a4bef600000000000000000000000000000000000000000000000000000000000000050b0105040c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000078e6708e70aed0f000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000059a16770000000000000000000000000000000000000000000000000078e6708e70aed0f00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002ba0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f4c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000027213e28d7fda5c57fe9e5dd923818dbccf71c4700000000000000000000000000000000000000000000000000000000003938700000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006f939b43d65be049b7533907db08e80ba6969f450000000000000000000000000000000000000000000000000000000059682f0000000000000000000000000000000000000000000000000000000000000000400000000000000000000000006f939b43d65be049b7533907db08e80ba6969f4500000000000000000000000000000000000000000000000000000000000000000cc080a07c86dd5813ec1f3725c402f8bea6105546d1093c59676023b971f1d83f61bd4ea02a353bf3028cabcbe68c5dc8906752bafe55afc86b6344edb3ffd8a3650332e8\",\n selector: UNISWAP_EXECUTE_SELECTOR,\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n };\n\n // WHEN\n const result = await loader.load(input);\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 input = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n chainId: 0x42,\n selector: UNISWAP_EXECUTE_SELECTOR,\n } as UniswapContextInput;\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\")\n .mockReturnValueOnce([\"0x01\", \"0x04\", \"0x02\"])\n .mockReturnValueOnce([\"0x02\", \"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(input);\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 input = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n chainId: 0x42,\n selector: UNISWAP_EXECUTE_SELECTOR,\n } as UniswapContextInput;\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\")\n .mockReturnValueOnce([\"0x01\"])\n .mockReturnValueOnce([\"0x02\", \"0x03\"])\n .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(input);\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 input = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n chainId: 0x42,\n selector: UNISWAP_EXECUTE_SELECTOR,\n } as UniswapContextInput;\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\")\n .mockReturnValueOnce([\"0x01\", \"0x02\"])\n .mockReturnValueOnce([\"0x02\", \"0x03\"]);\n vi.spyOn(tokenDataSourceMock, \"getTokenInfosPayload\")\n .mockResolvedValueOnce(Left(\"error\"))\n .mockImplementation(({ address }) =>\n Promise.resolve(Right(`payload-${address}`)),\n );\n\n // WHEN\n const result = await loader.load(input);\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 input = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n chainId: 0x42,\n selector: UNISWAP_EXECUTE_SELECTOR,\n } as UniswapContextInput;\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(input);\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 input: UniswapContextInput = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n selector: UNISWAP_EXECUTE_SELECTOR,\n chainId: 1,\n };\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [\"\"],\n } as TransactionDescription);\n\n // WHEN\n const result = await loader.load(input);\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 input: UniswapContextInput = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n selector: UNISWAP_EXECUTE_SELECTOR,\n chainId: 1,\n };\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockReturnValue({\n args: [\"0x08\", []],\n } as TransactionDescription);\n vi.spyOn(commandDecoderMock, \"decode\").mockReturnValue([]);\n\n // WHEN\n const result = await loader.load(input);\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 input: UniswapContextInput = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n selector: UNISWAP_EXECUTE_SELECTOR,\n chainId: 1,\n };\n vi.spyOn(Interface.prototype, \"parseTransaction\").mockImplementation(\n () => {\n throw new Error();\n },\n );\n\n // WHEN\n const result = await loader.load(input);\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 input: UniswapContextInput = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n chainId: 0x42,\n selector: UNISWAP_EXECUTE_SELECTOR,\n };\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(input);\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 input = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: \"0x00000000\",\n chainId: 0x42,\n selector: UNISWAP_EXECUTE_SELECTOR,\n } as UniswapContextInput;\n\n // WHEN\n const result = await loader.load(input);\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 input = {\n to: UNISWAP_UNIVERSAL_ROUTER_ADDRESS,\n data: UNISWAP_EXECUTE_SELECTOR,\n chainId: 0x42,\n selector: UNISWAP_EXECUTE_SELECTOR,\n } as UniswapContextInput;\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(input);\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,kCAErC,OACE,4BAAAC,EACA,oCAAAC,EACA,2BAAAC,MACK,8BAEP,OAAS,mCAAAC,MAAuC,iDAChD,OAAS,8BAAAC,MAAkC,4CAE3C,OAEE,wBAAAC,MACK,yBAEP,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA+C,CACnD,OAAQ,GAAG,GAAG,CAChB,EACMC,EAAsB,CAC1B,qBAAsB,GAAG,GAAG,CAC9B,EACA,IAAIC,EAEJ,SAAS,qBAAsB,IAAM,CACnC,WAAW,IAAM,CACfA,EAAS,IAAIH,EACX,IAAIF,EAAgC,IAAIC,CAA4B,EACpEG,CACF,CACF,CAAC,EAED,MAAME,EAAkC,CACtC,KAAM,6MACN,SAAUT,EACV,QAAS,EACT,GAAIC,CACN,EAEA,GAAG,qCAAsC,IAAM,CAC7C,OACEO,EAAO,UAAUC,EAAY,CAC3BV,EAAqB,MACrBA,EAAqB,eACvB,CAAC,CACH,EAAE,KAAK,EAAI,CACb,CAAC,EAED,GAAG,gDAAiD,IAAM,CACxD,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", "Left", "Right", "ClearSignContextType", "UNISWAP_EXECUTE_SELECTOR", "UNISWAP_UNIVERSAL_ROUTER_ADDRESS", "UniswapSupportedCommand", "DefaultCommandDecoderDataSource", "EthersAbiDecoderDataSource", "UniswapContextLoader", "commandDecoderMock", "tokenDataSourceMock", "loader", "validInput", "input", "_description", "address", "result"]
7
7
  }
@@ -1,2 +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};
1
+ var m=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var p=(n,e,i,r)=>{for(var t=r>1?void 0:r?l(e,i):e,o=n.length-1,c;o>=0;o--)(c=n[o])&&(t=(r?c(e,i,t):c(t))||t);return r&&t&&m(e,i,t),t},s=(n,e)=>(i,r)=>e(i,r,n);import u from"axios";import{inject as h,injectable as b}from"inversify";import{Left as C,Right as y}from"purify-ts";import{configTypes as g}from"../../config/di/configTypes";import{pkiTypes as D}from"../../pki/di/pkiTypes";import{KeyUsage as W}from"../../pki/model/KeyUsage";import{LEDGER_CLIENT_VERSION_HEADER as _,LEDGER_ORIGIN_TOKEN_HEADER as E}from"../../shared/constant/HttpHeaders";import x from"../../../package.json";let a=class{constructor(e,i){this.config=e;this._certificateLoader=i;if(!this.config.originToken)throw new Error("Origin token is required")}async getWeb3Checks(e){const{from:i,deviceModelId:r}=e;let t,o,c;this.isTypedDataContext(e)?(o={msg:{from:i,data:e.data}},c=`${this.config.web3checks.url}/ethereum/scan/eip-712`):(o={tx:{from:i,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:{[_]:`context-module/${x.version}`,[E]:this.config.originToken}})).data}catch{return C(new Error("[ContextModule] HttpWeb3CheckDataSource: Failed to fetch web3 checks informations"))}if(!this.isWeb3CheckDto(t))return C(new Error("[ContextModule] HttpWeb3CheckDataSource: Cannot exploit Web3 checks data received"));const f=await this._certificateLoader.loadCertificate({keyId:t.public_key_id,keyUsage:W.TxSimulationSigner,targetDevice:r}),d={publicKeyId:t.public_key_id,descriptor:t.descriptor,certificate:f};return y(d)}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"}};a=p([b(),s(0,h(g.Config)),s(1,h(D.PkiCertificateLoader))],a);export{a as HttpWeb3CheckDataSource};
2
2
  //# sourceMappingURL=HttpWeb3CheckDataSource.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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"]
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 LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\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 if (!this.config.originToken) {\n throw new Error(\"Origin token is required\");\n }\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 [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\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,uBACzB,OACE,gCAAAC,EACA,8BAAAC,MACK,gCAMP,OAAOC,MAAa,qBAMb,IAAMC,EAAN,KAA6D,CAClE,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,EAAI,YAAc,MAClB,OAAOA,EAAI,YAAc,QAE7B,CACF,EAjGalB,EAANmB,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,GACzBF,EAAA,EAAAC,EAAOE,EAAS,oBAAoB,IAH5BxB",
6
+ "names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "pkiTypes", "KeyUsage", "LEDGER_CLIENT_VERSION_HEADER", "LEDGER_ORIGIN_TOKEN_HEADER", "PACKAGE", "HttpWeb3CheckDataSource", "config", "_certificateLoader", "context", "from", "deviceModelId", "web3CheckDto", "requestDto", "url", "axios", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "LEDGER_ORIGIN_TOKEN_HEADER", "Left", "certificate", "KeyUsage", "result", "Right", "dto", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes", "pkiTypes"]
7
7
  }
@@ -1,2 +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")))})})});
1
+ import{DeviceModelId as n}from"@ledgerhq/device-management-kit";import c from"axios";import{Left as u,Right as d}from"purify-ts";import{LEDGER_CLIENT_VERSION_HEADER as p,LEDGER_ORIGIN_TOKEN_HEADER as l}from"../../shared/constant/HttpHeaders";import{HttpWeb3CheckDataSource as i}from"../../web3-check/data/HttpWeb3CheckDataSource";import k from"../../../package.json";vi.mock("axios");describe("HttpWeb3CheckDataSource",()=>{const r={web3checks:{url:"web3checksUrl"},originToken:"originToken"},e={loadCertificate:vi.fn()};beforeEach(()=>{vi.resetAllMocks()}),describe("getWeb3Checks",()=>{it("should return an object if the request is successful",async()=>{const t={deviceModelId:n.FLEX,from:"from",rawTx:"rawTx",chainId:1},o={public_key_id:"partner",descriptor:"descriptor"};vi.spyOn(c,"request").mockResolvedValueOnce({data:o}),vi.spyOn(e,"loadCertificate").mockResolvedValueOnce(void 0);const a=await new i(r,e).getWeb3Checks(t);expect(a).toEqual(d({publicKeyId:"partner",descriptor:"descriptor"}))}),it("should return an object if the typed data request is successful",async()=>{const t={deviceModelId:n.FLEX,from:"from",data:"typed data"},o={public_key_id:"partner",descriptor:"descriptor"};vi.spyOn(c,"request").mockResolvedValueOnce({data:o}),vi.spyOn(e,"loadCertificate").mockResolvedValueOnce(void 0);const a=await new i(r,e).getWeb3Checks(t);expect(a).toEqual(d({publicKeyId:"partner",descriptor:"descriptor"}))}),it("should return an object with a certificate if the request is successful",async()=>{const t={deviceModelId:n.FLEX,from:"from",rawTx:"rawTx",chainId:1},o={public_key_id:"partner",descriptor:"descriptor"};vi.spyOn(c,"request").mockResolvedValueOnce({data:o}),vi.spyOn(e,"loadCertificate").mockResolvedValueOnce({keyUsageNumber:11,payload:new Uint8Array([1])});const a=await new i(r,e).getWeb3Checks(t);expect(a).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:n.FLEX,from:"from",rawTx:"rawTx",chainId:1};vi.spyOn(c,"request").mockRejectedValue(new Error("error"));const s=await new i(r,e).getWeb3Checks(t);expect(s).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:n.FLEX,from:"from",rawTx:"rawTx",chainId:1},o={};vi.spyOn(c,"request").mockResolvedValue({data:o}),vi.spyOn(e,"loadCertificate").mockResolvedValue(void 0);const a=await new i(r,e).getWeb3Checks(t);expect(a).toEqual(u(new Error("[ContextModule] HttpWeb3CheckDataSource: Cannot exploit Web3 checks data received")))}),it("should throw an error if origin token is not provided",()=>{expect(()=>new i({...r,originToken:void 0},e)).toThrow("Origin token is required")}),it("should call axios with the correct headers",async()=>{const t={deviceModelId:n.FLEX,from:"from",rawTx:"rawTx",chainId:1};vi.spyOn(c,"request").mockResolvedValueOnce({data:{}}),await new i(r,e).getWeb3Checks(t),expect(c.request).toHaveBeenCalledWith(expect.objectContaining({headers:{[p]:`context-module/${k.version}`,[l]:r.originToken}}))})})});
2
2
  //# sourceMappingURL=HttpWeb3CheckDataSource.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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,C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pD,OAAOE,CAAM,EAAE,QACbN,EAAM,CACJ,YAAa,UACb,WAAY,aACZ,YAAa,CAAE,eAAgB,GAAI,QAAS,IAAI,WAAW,CAAC,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"]
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 {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\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\";\nimport PACKAGE from \"@root/package.json\";\n\nvi.mock(\"axios\");\n\ndescribe(\"HttpWeb3CheckDataSource\", () => {\n const config = {\n web3checks: {\n url: \"web3checksUrl\",\n },\n originToken: \"originToken\",\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 it(\"should throw an error if origin token is not provided\", () => {\n expect(\n () =>\n new HttpWeb3CheckDataSource(\n { ...config, originToken: undefined },\n certificateLoaderMock as unknown as PkiCertificateLoader,\n ),\n ).toThrow(\"Origin token is required\");\n });\n\n it(\"should call axios with the correct headers\", 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\").mockResolvedValueOnce({ data: {} });\n\n // WHEN\n const dataSource = new HttpWeb3CheckDataSource(\n config,\n certificateLoaderMock as unknown as PkiCertificateLoader,\n );\n await dataSource.getWeb3Checks(params);\n\n // THEN\n expect(axios.request).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: config.originToken,\n },\n }),\n );\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,iBAAAA,MAAqB,kCAC9B,OAAOC,MAAW,QAClB,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAI5B,OACE,gCAAAC,EACA,8BAAAC,MACK,gCACP,OAAS,2BAAAC,MAA+B,4CAIxC,OAAOC,MAAa,qBAEpB,GAAG,KAAK,OAAO,EAEf,SAAS,0BAA2B,IAAM,CACxC,MAAMC,EAAS,CACb,WAAY,CACV,IAAK,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eV,EAAc,KAC7B,KAAM,OACN,MAAO,QACP,QAAS,CACX,EACA,GAAG,MAAMC,EAAO,SAAS,EAAE,sBAAsB,CAAE,KAAM,CAAC,CAAE,CAAC,EAO7D,MAJmB,IAAIK,EACrBE,EACAC,CACF,EACiB,cAAcC,CAAM,EAGrC,OAAOT,EAAM,OAAO,EAAE,qBACpB,OAAO,iBAAiB,CACtB,QAAS,CACP,CAACG,CAA4B,EAAG,kBAAkBG,EAAQ,OAAO,GACjE,CAACF,CAA0B,EAAGG,EAAO,WACvC,CACF,CAAC,CACH,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["DeviceModelId", "axios", "Left", "Right", "LEDGER_CLIENT_VERSION_HEADER", "LEDGER_ORIGIN_TOKEN_HEADER", "HttpWeb3CheckDataSource", "PACKAGE", "config", "certificateLoaderMock", "params", "dto", "result"]
7
7
  }
@@ -1,2 +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};
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 h=()=>new t(({bind:e})=>{e(o.Web3CheckDataSource).to(r),e(o.Web3CheckContextLoader).to(c)});export{h as web3CheckModuleFactory};
2
2
  //# sourceMappingURL=web3CheckModuleFactory.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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"]
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpWeb3CheckDataSource } from \"@/web3-check/data/HttpWeb3CheckDataSource\";\nimport { DefaultWeb3CheckContextLoader } from \"@/web3-check/domain/DefaultWeb3CheckLoader\";\n\nimport { web3CheckTypes } from \"./web3CheckTypes\";\n\nexport const web3CheckModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(web3CheckTypes.Web3CheckDataSource).to(HttpWeb3CheckDataSource);\n bind(web3CheckTypes.Web3CheckContextLoader).to(\n DefaultWeb3CheckContextLoader,\n );\n });\n"],
5
+ "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,2BAAAC,MAA+B,4CACxC,OAAS,iCAAAC,MAAqC,6CAE9C,OAAS,kBAAAC,MAAsB,mBAExB,MAAMC,EAAyB,IACpC,IAAIJ,EAAgB,CAAC,CAAE,KAAAK,CAAK,IAAM,CAChCA,EAAKF,EAAe,mBAAmB,EAAE,GAAGF,CAAuB,EACnEI,EAAKF,EAAe,sBAAsB,EAAE,GAC1CD,CACF,CACF,CAAC",
6
+ "names": ["ContainerModule", "HttpWeb3CheckDataSource", "DefaultWeb3CheckContextLoader", "web3CheckTypes", "web3CheckModuleFactory", "bind"]
7
7
  }
@@ -1,12 +1,14 @@
1
- import { type ClearSignContext } from "./shared/model/ClearSignContext";
2
- import { type TransactionContext, type TransactionFieldContext } from "./shared/model/TransactionContext";
1
+ import { type ClearSignContext, type ClearSignContextType } from "./shared/model/ClearSignContext";
2
+ import { type SolanaTransactionContext } from "./shared/model/SolanaTransactionContext";
3
3
  import { type TypedDataClearSignContext } from "./shared/model/TypedDataClearSignContext";
4
4
  import { type TypedDataContext } from "./shared/model/TypedDataContext";
5
+ import { type SolanaTransactionContextResult } from "./solana/domain/solanaContextTypes";
5
6
  import { type Web3CheckContext } from "./web3-check/domain/web3CheckTypes";
6
7
  export interface ContextModule {
7
- getContext(field: TransactionFieldContext): Promise<ClearSignContext>;
8
- getContexts(transaction: TransactionContext): Promise<ClearSignContext[]>;
8
+ getContexts<TInput>(input: TInput, expectedTypes?: ClearSignContextType[]): Promise<ClearSignContext[]>;
9
+ getFieldContext<TInput>(field: TInput, expectedType: ClearSignContextType): Promise<ClearSignContext>;
9
10
  getTypedDataFilters(typedData: TypedDataContext): Promise<TypedDataClearSignContext>;
10
11
  getWeb3Checks(transactionContext: Web3CheckContext): Promise<ClearSignContext | null>;
12
+ getSolanaContext(transactionContext: SolanaTransactionContext): Promise<SolanaTransactionContextResult>;
11
13
  }
12
14
  //# sourceMappingURL=ContextModule.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContextModule.d.ts","sourceRoot":"","sources":["../../../src/ContextModule.ts"],"names":[],"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