@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/external-plugin/domain/ExternalPluginContextLoader.test.ts"],
4
- "sourcesContent": ["import { Interface } from \"ethers\";\nimport { Left, Right } from \"purify-ts\";\n\nimport ABI from \"@/external-plugin/__tests__/abi.json\";\nimport { type ExternalPluginDataSource } from \"@/external-plugin/data/ExternalPluginDataSource\";\nimport { ExternalPluginContextLoader } from \"@/external-plugin/domain/ExternalPluginContextLoader\";\nimport { type DappInfos } from \"@/external-plugin/model/DappInfos\";\nimport { type SelectorDetails } from \"@/external-plugin/model/SelectorDetails\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport { type TransactionContext } from \"@/shared/model/TransactionContext\";\nimport { type TokenDataSource } from \"@/token/data/TokenDataSource\";\n\nconst dappInfosBuilder = ({\n abi,\n selectorDetails,\n}: {\n abi?: object[];\n selectorDetails?: Partial<SelectorDetails>;\n}) => {\n return {\n abi: abi,\n selectorDetails: {\n erc20OfInterest: [],\n method: \"\",\n plugin: \"\",\n serializedData: \"123456\",\n signature: \"7890\",\n ...selectorDetails,\n },\n } as DappInfos;\n};\n\nconst transactionBuilder = (\n abi: object,\n functionName: string,\n params: unknown[],\n): TransactionContext => {\n const contract = new Interface(JSON.stringify(abi));\n const data = contract.encodeFunctionData(functionName, params);\n return {\n to: \"0x0\",\n data,\n } as TransactionContext;\n};\n\ndescribe(\"ExternalPluginContextLoader\", () => {\n const mockTokenDataSource: TokenDataSource = {\n getTokenInfosPayload: vi.fn(),\n };\n const mockExternalPluginDataSource: ExternalPluginDataSource = {\n getDappInfos: vi.fn(),\n };\n const loader = new ExternalPluginContextLoader(\n mockExternalPluginDataSource,\n mockTokenDataSource,\n );\n\n beforeEach(() => {\n vi.clearAllMocks();\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockImplementation(\n ({ address }) => Promise.resolve(Right(`payload-${address}`)),\n );\n });\n\n describe(\"load function\", async () => {\n it(\"should return an empty array if no destination address is provided\", async () => {\n // GIVEN\n const transaction = {} as TransactionContext;\n\n // WHEN\n const promise = () => loader.load(transaction);\n\n // THEN\n await expect(promise()).resolves.toEqual([]);\n });\n\n it(\"should return an empty array if data is undefined\", async () => {\n // GIVEN\n const transaction = { to: \"0x0\" } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if no data provided\", async () => {\n // GIVEN\n const transaction = { to: \"0x0\", data: \"0x\" } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if no dapp info is povided\", async () => {\n // GIVEN\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(undefined),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return e plugin if no erc20OfInterest is provided\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [],\n method: \"singleParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return a list of context responses when one erc20OfInterest is provided for a single parameter\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual(\n expect.arrayContaining([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n ]),\n );\n });\n\n it(\"should return a context response with only set external plugin when one erc20OfInterest is provided for a single parameter but no payload is feched\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return a list of context responses when two erc20OfInterest are provided for two parameters\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\", \"toToken\"],\n method: \"multipleParams\",\n },\n });\n const transaction = transactionBuilder(ABI, \"multipleParams\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual(\n expect.arrayContaining([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n ]),\n );\n });\n\n it(\"should return a list of context responses when one erc20OfInterest is an array\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\n \"fromToken.0\",\n \"fromToken.1\",\n \"fromToken.2\",\n \"fromToken.-1\",\n ],\n method: \"arrayParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"arrayParam\", [\n [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n \"0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n ],\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n // fromToken.2\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n // fromToken.-1\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return an error when a token datasource returns an error\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(new Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return an error when the abi is not conform\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: [{ fakeabi: \"notworking\" }],\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to parse abi\",\n ),\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should throw an error when the erc20OfInterest doest not exist in the transaction\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"notFound\"],\n method: \"singleParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to get address\",\n ),\n },\n ]);\n });\n\n it(\"should throw an error when an out-of-bounds element is present in erc20OfInterest\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken.3\"],\n method: \"arrayParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"arrayParam\", [\n [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n \"0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n ],\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new RangeError(\"out of result range\"),\n },\n ]);\n });\n\n it(\"should return a list of context responses when one erc20OfInterest is a complex struct\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\n \"complexStruct.address1\",\n \"complexStruct.param1.param2.0.param3.addresses.0\",\n \"complexStruct.param1.param2.0.param3.addresses.1\",\n \"complexStruct.param1.param2.0.param3.addresses.-1\",\n \"complexStruct.param1.param2.1.param3.addresses.0\",\n \"complexStruct.param1.param2.-1.param3.addresses.0\",\n ],\n method: \"complexStructParam\",\n },\n });\n const transaction = transactionBuilder(ABI, \"complexStructParam\", [\n {\n address1: \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n param1: {\n param2: [\n {\n param3: {\n addresses: [\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n \"0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n ],\n },\n },\n {\n param3: {\n addresses: [\"0xB8c77482e45F1F44dE1745F52C74426C631bDD52\"],\n },\n },\n ],\n },\n },\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return an error when datasource return a Left\", async () => {\n // GIVEN\n const transaction = transactionBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Left(new Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n ]);\n });\n\n it(\"should return an error when transaction data is not a valid hex string\", async () => {\n // GIVEN\n const transaction = {\n to: \"0x0\",\n data: \"notAHexString\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ]);\n });\n });\n});\n"],
5
- "mappings": "AAAA,OAAS,aAAAA,MAAiB,SAC1B,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAE5B,OAAOC,MAAS,uCAEhB,OAAS,+BAAAC,MAAmC,uDAG5C,OAAS,wBAAAC,MAA4B,kCAIrC,MAAMC,EAAmB,CAAC,CACxB,IAAAC,EACA,gBAAAC,CACF,KAIS,CACL,IAAKD,EACL,gBAAiB,CACf,gBAAiB,CAAC,EAClB,OAAQ,GACR,OAAQ,GACR,eAAgB,SAChB,UAAW,OACX,GAAGC,CACL,CACF,GAGIC,EAAqB,CACzBF,EACAG,EACAC,KAIO,CACL,GAAI,MACJ,KAJe,IAAIX,EAAU,KAAK,UAAUO,CAAG,CAAC,EAC5B,mBAAmBG,EAAcC,CAAM,CAI7D,GAGF,SAAS,8BAA+B,IAAM,CAC5C,MAAMC,EAAuC,CAC3C,qBAAsB,GAAG,GAAG,CAC9B,EACMC,EAAyD,CAC7D,aAAc,GAAG,GAAG,CACtB,EACMC,EAAS,IAAIV,EACjBS,EACAD,CACF,EAEA,WAAW,IAAM,CACf,GAAG,cAAc,EACjB,GAAG,MAAMA,EAAqB,sBAAsB,EAAE,mBACpD,CAAC,CAAE,QAAAG,CAAQ,IAAM,QAAQ,QAAQb,EAAM,WAAWa,CAAO,EAAE,CAAC,CAC9D,CACF,CAAC,EAED,SAAS,gBAAiB,SAAY,CACpC,GAAG,qEAAsE,SAAY,CAEnF,MAAMC,EAAc,CAAC,EAGfC,EAAU,IAAMH,EAAO,KAAKE,CAAW,EAG7C,MAAM,OAAOC,EAAQ,CAAC,EAAE,SAAS,QAAQ,CAAC,CAAC,CAC7C,CAAC,EAED,GAAG,oDAAqD,SAAY,CAElE,MAAMD,EAAc,CAAE,GAAI,KAAM,EAG1BE,EAAS,MAAMJ,EAAO,KAAKE,CAAW,EAG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M,eACR,EAGME,EAAS,MAAMJ,EAAO,KAAKE,CAAW,EAG5C,OAAOE,CAAM,EAAE,QAAQ,CACrB,CACE,KAAMb,EAAqB,MAC3B,MAAO,IAAI,MAAM,kBAAkB,CACrC,CACF,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["Interface", "Left", "Right", "ABI", "ExternalPluginContextLoader", "ClearSignContextType", "dappInfosBuilder", "abi", "selectorDetails", "transactionBuilder", "functionName", "params", "mockTokenDataSource", "mockExternalPluginDataSource", "loader", "address", "transaction", "promise", "result", "dappInfos"]
4
+ "sourcesContent": ["import { Interface } from \"ethers\";\nimport { Left, Right } from \"purify-ts\";\n\nimport ABI from \"@/external-plugin/__tests__/abi.json\";\nimport { type ExternalPluginDataSource } from \"@/external-plugin/data/ExternalPluginDataSource\";\nimport {\n type ExternalPluginContextInput,\n ExternalPluginContextLoader,\n} from \"@/external-plugin/domain/ExternalPluginContextLoader\";\nimport { type DappInfos } from \"@/external-plugin/model/DappInfos\";\nimport { type SelectorDetails } from \"@/external-plugin/model/SelectorDetails\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport { type TokenDataSource } from \"@/token/data/TokenDataSource\";\n\nconst dappInfosBuilder = ({\n abi,\n selectorDetails,\n}: {\n abi?: object[];\n selectorDetails?: Partial<SelectorDetails>;\n}) => {\n return {\n abi: abi,\n selectorDetails: {\n erc20OfInterest: [],\n method: \"\",\n plugin: \"\",\n serializedData: \"123456\",\n signature: \"7890\",\n ...selectorDetails,\n },\n } as DappInfos;\n};\n\nconst inputBuilder = (\n abi: object,\n functionName: string,\n params: unknown[],\n): ExternalPluginContextInput => {\n const contract = new Interface(JSON.stringify(abi));\n const data = contract.encodeFunctionData(functionName, params);\n return {\n to: \"0x0\",\n data: data as `0x${string}`,\n selector: data.slice(0, 10) as `0x${string}`,\n chainId: 1,\n };\n};\n\ndescribe(\"ExternalPluginContextLoader\", () => {\n const mockTokenDataSource: TokenDataSource = {\n getTokenInfosPayload: vi.fn(),\n };\n const mockExternalPluginDataSource: ExternalPluginDataSource = {\n getDappInfos: vi.fn(),\n };\n const loader = new ExternalPluginContextLoader(\n mockExternalPluginDataSource,\n mockTokenDataSource,\n );\n\n beforeEach(() => {\n vi.clearAllMocks();\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockImplementation(\n ({ address }) => Promise.resolve(Right(`payload-${address}`)),\n );\n });\n\n describe(\"canHandle function\", () => {\n const validInput: ExternalPluginContextInput = {\n to: \"0x1234567890123456789012345678901234567890\",\n data: \"0x095ea7b30000000000000000000000001234567890123456789012345678901234567890\",\n selector: \"0x095ea7b3\",\n chainId: 1,\n };\n\n it(\"should return true for valid input\", () => {\n expect(\n loader.canHandle(validInput, [\n ClearSignContextType.EXTERNAL_PLUGIN,\n ClearSignContextType.TOKEN,\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 ])(\"should return false for %s\", (input, _description) => {\n expect(\n loader.canHandle(input, [\n ClearSignContextType.EXTERNAL_PLUGIN,\n ClearSignContextType.TOKEN,\n ]),\n ).toBe(false);\n });\n\n it.each([\n [{ ...validInput, to: undefined }, \"missing to\"],\n [{ ...validInput, data: undefined }, \"missing data\"],\n [{ ...validInput, selector: undefined }, \"missing selector\"],\n [{ ...validInput, chainId: undefined }, \"missing chainId\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(\n loader.canHandle(input, [\n ClearSignContextType.EXTERNAL_PLUGIN,\n ClearSignContextType.TOKEN,\n ]),\n ).toBe(false);\n });\n\n it.each([\n [{ ...validInput, to: \"invalid-hex\" }, \"invalid to hex\"],\n [{ ...validInput, to: \"0x\" }, \"empty to hex\"],\n [{ ...validInput, data: \"invalid-hex\" }, \"invalid data hex\"],\n [{ ...validInput, data: \"0x\" }, \"empty data (0x)\"],\n [{ ...validInput, selector: \"invalid-hex\" }, \"invalid selector hex\"],\n [{ ...validInput, selector: \"0x\" }, \"empty selector hex\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(\n loader.canHandle(input, [\n ClearSignContextType.EXTERNAL_PLUGIN,\n ClearSignContextType.TOKEN,\n ]),\n ).toBe(false);\n });\n\n it.each([\n [{ ...validInput, chainId: \"1\" }, \"string chainId\"],\n [{ ...validInput, chainId: null }, \"null chainId\"],\n [{ ...validInput, chainId: undefined }, \"undefined chainId\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(\n loader.canHandle(input, [\n ClearSignContextType.EXTERNAL_PLUGIN,\n ClearSignContextType.TOKEN,\n ]),\n ).toBe(false);\n });\n });\n\n describe(\"load function\", () => {\n it(\"should return an empty array if no dapp info is provided\", async () => {\n // GIVEN\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(undefined),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return e plugin if no erc20OfInterest is provided\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [],\n method: \"singleParam\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\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: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return a list of context responses when one erc20OfInterest is provided for a single parameter\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual(\n expect.arrayContaining([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n ]),\n );\n });\n\n it(\"should return a context response with only set external plugin when one erc20OfInterest is provided for a single parameter but no payload is feched\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return a list of context responses when two erc20OfInterest are provided for two parameters\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\", \"toToken\"],\n method: \"multipleParams\",\n },\n });\n const input = inputBuilder(ABI, \"multipleParams\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual(\n expect.arrayContaining([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n ]),\n );\n });\n\n it(\"should return a list of context responses when one erc20OfInterest is an array\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\n \"fromToken.0\",\n \"fromToken.1\",\n \"fromToken.2\",\n \"fromToken.-1\",\n ],\n method: \"arrayParam\",\n },\n });\n const input = inputBuilder(ABI, \"arrayParam\", [\n [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n \"0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n ],\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n // fromToken.2\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n // fromToken.-1\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return an error when a token datasource returns an error\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(new Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return an error when the abi is not conform\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: [{ fakeabi: \"notworking\" }],\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to parse abi\",\n ),\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should throw an error when the erc20OfInterest doest not exist in the transaction\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"notFound\"],\n method: \"singleParam\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to get address\",\n ),\n },\n ]);\n });\n\n it(\"should throw an error when an out-of-bounds element is present in erc20OfInterest\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken.3\"],\n method: \"arrayParam\",\n },\n });\n const input = inputBuilder(ABI, \"arrayParam\", [\n [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n \"0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n ],\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new RangeError(\"out of result range\"),\n },\n ]);\n });\n\n it(\"should return a list of context responses when one erc20OfInterest is a complex struct\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\n \"complexStruct.address1\",\n \"complexStruct.param1.param2.0.param3.addresses.0\",\n \"complexStruct.param1.param2.0.param3.addresses.1\",\n \"complexStruct.param1.param2.0.param3.addresses.-1\",\n \"complexStruct.param1.param2.1.param3.addresses.0\",\n \"complexStruct.param1.param2.-1.param3.addresses.0\",\n ],\n method: \"complexStructParam\",\n },\n });\n const input = inputBuilder(ABI, \"complexStructParam\", [\n {\n address1: \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n param1: {\n param2: [\n {\n param3: {\n addresses: [\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n \"0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n ],\n },\n },\n {\n param3: {\n addresses: [\"0xB8c77482e45F1F44dE1745F52C74426C631bDD52\"],\n },\n },\n ],\n },\n },\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return an error when datasource return a Left\", async () => {\n // GIVEN\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Left(new Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n ]);\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,aAAAA,MAAiB,SAC1B,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAE5B,OAAOC,MAAS,uCAEhB,OAEE,+BAAAC,MACK,uDAGP,OAAS,wBAAAC,MAA4B,kCAGrC,MAAMC,EAAmB,CAAC,CACxB,IAAAC,EACA,gBAAAC,CACF,KAIS,CACL,IAAKD,EACL,gBAAiB,CACf,gBAAiB,CAAC,EAClB,OAAQ,GACR,OAAQ,GACR,eAAgB,SAChB,UAAW,OACX,GAAGC,CACL,CACF,GAGIC,EAAe,CACnBF,EACAG,EACAC,IAC+B,CAE/B,MAAMC,EADW,IAAIZ,EAAU,KAAK,UAAUO,CAAG,CAAC,EAC5B,mBAAmBG,EAAcC,CAAM,EAC7D,MAAO,CACL,GAAI,MACJ,KAAMC,EACN,SAAUA,EAAK,MAAM,EAAG,EAAE,EAC1B,QAAS,CACX,CACF,EAEA,SAAS,8BAA+B,IAAM,CAC5C,MAAMC,EAAuC,CAC3C,qBAAsB,GAAG,GAAG,CAC9B,EACMC,EAAyD,CAC7D,aAAc,GAAG,GAAG,CACtB,EACMC,EAAS,IAAIX,EACjBU,EACAD,CACF,EAEA,WAAW,IAAM,CACf,GAAG,cAAc,EACjB,GAAG,MAAMA,EAAqB,sBAAsB,EAAE,mBACpD,CAAC,CAAE,QAAAG,CAAQ,IAAM,QAAQ,QAAQd,EAAM,WAAWc,CAAO,EAAE,CAAC,CAC9D,CACF,CAAC,EAED,SAAS,qBAAsB,IAAM,CACnC,MAAMC,EAAyC,CAC7C,GAAI,6CACJ,KAAM,6EACN,SAAU,aACV,QAAS,CACX,EAEA,GAAG,qCAAsC,IAAM,CAC7C,OACEF,EAAO,UAAUE,EAAY,CAC3BZ,EAAqB,gBACrBA,EAAqB,KACvB,CAAC,CACH,EAAE,KAAK,EAAI,CACb,CAAC,EA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CACH,CAAC,EAED,GAAG,uDAAwD,SAAY,CAErE,MAAMa,EAAQT,EAAaN,EAAK,cAAe,CAC7C,4CACF,CAAC,EACD,GAAG,MAAMW,EAA8B,cAAc,EAAE,kBACrDb,EAAK,IAAI,MAAM,OAAO,CAAC,CACzB,EAGA,MAAMmB,EAAS,MAAML,EAAO,KAAKG,CAAK,EAGtC,OAAOE,CAAM,EAAE,QAAQ,CACrB,CACE,KAAMf,EAAqB,MAC3B,MAAO,IAAI,MAAM,OAAO,CAC1B,CACF,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["Interface", "Left", "Right", "ABI", "ExternalPluginContextLoader", "ClearSignContextType", "dappInfosBuilder", "abi", "selectorDetails", "inputBuilder", "functionName", "params", "data", "mockTokenDataSource", "mockExternalPluginDataSource", "loader", "address", "validInput", "input", "_description", "result", "dappInfos"]
7
7
  }
@@ -1,2 +1,2 @@
1
- export*from"./config/model/ContextModuleConfig";export*from"./ContextModule";export*from"./ContextModuleBuilder";export*from"./DefaultContextModule";export*from"./external-plugin/domain/ExternalPluginContextLoader";export*from"./nft/domain/NftContextLoader";export*from"./pki/domain/PkiCertificateLoader";export*from"./pki/model/KeyId";export*from"./pki/model/KeyUsage";export*from"./pki/model/PkiCertificate";export*from"./pki/model/PkiCertificateInfo";export*from"./shared/domain/ContextLoader";export*from"./shared/model/ClearSignContext";export*from"./shared/model/GenericPath";export*from"./shared/model/TransactionContext";export*from"./shared/model/TransactionSubset";export*from"./shared/model/TypedDataClearSignContext";export*from"./shared/model/TypedDataContext";export*from"./token/domain/TokenContextLoader";export*from"./trusted-name/domain/TrustedNameContextLoader";export*from"./web3-check/domain/Web3CheckContextLoader";export*from"./web3-check/domain/web3CheckTypes";
1
+ export*from"./calldata/data/CalldataDescriptorDataSource";export*from"./calldata/data/HttpCalldataDescriptorDataSource";export*from"./calldata/domain/CalldataContextLoader";export*from"./config/model/ContextModuleConfig";export*from"./ContextModule";export*from"./ContextModuleBuilder";export*from"./DefaultContextModule";export*from"./dynamic-network/data/DynamicNetworkDataSource";export*from"./dynamic-network/data/HttpDynamicNetworkDataSource";export*from"./dynamic-network/domain/DynamicNetworkContextLoader";export*from"./dynamic-network/model/DynamicNetworkConfiguration";export*from"./external-plugin/data/ExternalPluginDataSource";export*from"./external-plugin/data/HttpExternalPluginDataSource";export*from"./external-plugin/domain/ExternalPluginContextLoader";export*from"./nft/data/HttpNftDataSource";export*from"./nft/data/NftDataSource";export*from"./nft/domain/NftContextFieldLoader";export*from"./nft/domain/NftContextLoader";export*from"./pki/data/HttpPkiCertificateDataSource";export*from"./pki/data/PkiCertificateDataSource";export*from"./pki/domain/DefaultPkiCertificateLoader";export*from"./pki/domain/PkiCertificateLoader";export*from"./pki/model/KeyId";export*from"./pki/model/KeyUsage";export*from"./pki/model/PkiCertificate";export*from"./pki/model/PkiCertificateInfo";export*from"./proxy/data/HttpProxyDataSource";export*from"./proxy/data/HttpSafeProxyDataSource";export*from"./proxy/data/ProxyDataSource";export*from"./proxy/domain/ProxyContextFieldLoader";export*from"./shared/domain/ContextFieldLoader";export*from"./shared/domain/ContextLoader";export*from"./shared/model/ClearSignContext";export*from"./shared/model/GenericPath";export*from"./shared/model/TransactionSubset";export*from"./shared/model/TypedDataClearSignContext";export*from"./shared/model/TypedDataContext";export*from"./solana/data/HttpSolanaOwnerInfoDataSource";export*from"./solana/data/SolanaDataSource";export*from"./solana/domain/DefaultSolanaContextLoader";export*from"./solana/domain/SolanaContextLoader";export*from"./token/data/HttpTokenDataSource";export*from"./token/data/TokenDataSource";export*from"./token/domain/TokenContextFieldLoader";export*from"./token/domain/TokenContextLoader";export*from"./trusted-name/data/HttpTrustedNameDataSource";export*from"./trusted-name/data/TrustedNameDataSource";export*from"./trusted-name/domain/TrustedNameContextFieldLoader";export*from"./trusted-name/domain/TrustedNameContextLoader";export*from"./typed-data/data/HttpTypedDataDataSource";export*from"./typed-data/data/TypedDataDataSource";export*from"./typed-data/domain/DefaultTypedDataContextLoader";export*from"./typed-data/domain/TypedDataContextLoader";export*from"./uniswap/data/AbiDecoderDataSource";export*from"./uniswap/data/CommandDecoderDataSource";export*from"./uniswap/data/DefaultCommandDecoderDataSource";export*from"./uniswap/data/EthersAbiDecoderDataSource";export*from"./uniswap/domain/UniswapContextLoader";export*from"./web3-check/data/HttpWeb3CheckDataSource";export*from"./web3-check/data/Web3CheckDataSource";export*from"./web3-check/domain/DefaultWeb3CheckLoader";export*from"./web3-check/domain/Web3CheckContextLoader";export*from"./web3-check/domain/web3CheckTypes";
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/index.ts"],
4
- "sourcesContent": ["export * from \"./config/model/ContextModuleConfig\";\nexport * from \"./ContextModule\";\nexport * from \"./ContextModuleBuilder\";\nexport * from \"./DefaultContextModule\";\nexport * from \"./external-plugin/domain/ExternalPluginContextLoader\";\nexport * from \"./nft/domain/NftContextLoader\";\nexport * from \"./pki/domain/PkiCertificateLoader\";\nexport * from \"./pki/model/KeyId\";\nexport * from \"./pki/model/KeyUsage\";\nexport * from \"./pki/model/PkiCertificate\";\nexport * from \"./pki/model/PkiCertificateInfo\";\nexport * from \"./shared/domain/ContextLoader\";\nexport * from \"./shared/model/ClearSignContext\";\nexport * from \"./shared/model/GenericPath\";\nexport * from \"./shared/model/TransactionContext\";\nexport * from \"./shared/model/TransactionSubset\";\nexport * from \"./shared/model/TypedDataClearSignContext\";\nexport * from \"./shared/model/TypedDataContext\";\nexport * from \"./token/domain/TokenContextLoader\";\nexport * from \"./trusted-name/domain/TrustedNameContextLoader\";\nexport * from \"./web3-check/domain/Web3CheckContextLoader\";\nexport * from \"./web3-check/domain/web3CheckTypes\";\n"],
5
- "mappings": "AAAA,WAAc,qCACd,WAAc,kBACd,WAAc,yBACd,WAAc,yBACd,WAAc,uDACd,WAAc,gCACd,WAAc,oCACd,WAAc,oBACd,WAAc,uBACd,WAAc,6BACd,WAAc,iCACd,WAAc,gCACd,WAAc,kCACd,WAAc,6BACd,WAAc,oCACd,WAAc,mCACd,WAAc,2CACd,WAAc,kCACd,WAAc,oCACd,WAAc,iDACd,WAAc,6CACd,WAAc",
4
+ "sourcesContent": ["export * from \"./calldata/data/CalldataDescriptorDataSource\";\nexport * from \"./calldata/data/HttpCalldataDescriptorDataSource\";\nexport * from \"./calldata/domain/CalldataContextLoader\";\nexport * from \"./config/model/ContextModuleConfig\";\nexport * from \"./ContextModule\";\nexport * from \"./ContextModuleBuilder\";\nexport * from \"./DefaultContextModule\";\nexport * from \"./dynamic-network/data/DynamicNetworkDataSource\";\nexport * from \"./dynamic-network/data/HttpDynamicNetworkDataSource\";\nexport * from \"./dynamic-network/domain/DynamicNetworkContextLoader\";\nexport * from \"./dynamic-network/model/DynamicNetworkConfiguration\";\nexport * from \"./external-plugin/data/ExternalPluginDataSource\";\nexport * from \"./external-plugin/data/HttpExternalPluginDataSource\";\nexport * from \"./external-plugin/domain/ExternalPluginContextLoader\";\nexport * from \"./nft/data/HttpNftDataSource\";\nexport * from \"./nft/data/NftDataSource\";\nexport * from \"./nft/domain/NftContextFieldLoader\";\nexport * from \"./nft/domain/NftContextLoader\";\nexport * from \"./pki/data/HttpPkiCertificateDataSource\";\nexport * from \"./pki/data/PkiCertificateDataSource\";\nexport * from \"./pki/domain/DefaultPkiCertificateLoader\";\nexport * from \"./pki/domain/PkiCertificateLoader\";\nexport * from \"./pki/model/KeyId\";\nexport * from \"./pki/model/KeyUsage\";\nexport * from \"./pki/model/PkiCertificate\";\nexport * from \"./pki/model/PkiCertificateInfo\";\nexport * from \"./proxy/data/HttpProxyDataSource\";\nexport * from \"./proxy/data/HttpSafeProxyDataSource\";\nexport * from \"./proxy/data/ProxyDataSource\";\nexport * from \"./proxy/domain/ProxyContextFieldLoader\";\nexport * from \"./shared/domain/ContextFieldLoader\";\nexport * from \"./shared/domain/ContextLoader\";\nexport * from \"./shared/model/ClearSignContext\";\nexport * from \"./shared/model/GenericPath\";\nexport * from \"./shared/model/TransactionSubset\";\nexport * from \"./shared/model/TypedDataClearSignContext\";\nexport * from \"./shared/model/TypedDataContext\";\nexport * from \"./solana/data/HttpSolanaOwnerInfoDataSource\";\nexport * from \"./solana/data/SolanaDataSource\";\nexport * from \"./solana/domain/DefaultSolanaContextLoader\";\nexport * from \"./solana/domain/SolanaContextLoader\";\nexport * from \"./token/data/HttpTokenDataSource\";\nexport * from \"./token/data/TokenDataSource\";\nexport * from \"./token/domain/TokenContextFieldLoader\";\nexport * from \"./token/domain/TokenContextLoader\";\nexport * from \"./trusted-name/data/HttpTrustedNameDataSource\";\nexport * from \"./trusted-name/data/TrustedNameDataSource\";\nexport * from \"./trusted-name/domain/TrustedNameContextFieldLoader\";\nexport * from \"./trusted-name/domain/TrustedNameContextLoader\";\nexport * from \"./typed-data/data/HttpTypedDataDataSource\";\nexport * from \"./typed-data/data/TypedDataDataSource\";\nexport * from \"./typed-data/domain/DefaultTypedDataContextLoader\";\nexport * from \"./typed-data/domain/TypedDataContextLoader\";\nexport * from \"./uniswap/data/AbiDecoderDataSource\";\nexport * from \"./uniswap/data/CommandDecoderDataSource\";\nexport * from \"./uniswap/data/DefaultCommandDecoderDataSource\";\nexport * from \"./uniswap/data/EthersAbiDecoderDataSource\";\nexport * from \"./uniswap/domain/UniswapContextLoader\";\nexport * from \"./web3-check/data/HttpWeb3CheckDataSource\";\nexport * from \"./web3-check/data/Web3CheckDataSource\";\nexport * from \"./web3-check/domain/DefaultWeb3CheckLoader\";\nexport * from \"./web3-check/domain/Web3CheckContextLoader\";\nexport * from \"./web3-check/domain/web3CheckTypes\";\n"],
5
+ "mappings": "AAAA,WAAc,+CACd,WAAc,mDACd,WAAc,0CACd,WAAc,qCACd,WAAc,kBACd,WAAc,yBACd,WAAc,yBACd,WAAc,kDACd,WAAc,sDACd,WAAc,uDACd,WAAc,sDACd,WAAc,kDACd,WAAc,sDACd,WAAc,uDACd,WAAc,+BACd,WAAc,2BACd,WAAc,qCACd,WAAc,gCACd,WAAc,0CACd,WAAc,sCACd,WAAc,2CACd,WAAc,oCACd,WAAc,oBACd,WAAc,uBACd,WAAc,6BACd,WAAc,iCACd,WAAc,mCACd,WAAc,uCACd,WAAc,+BACd,WAAc,yCACd,WAAc,qCACd,WAAc,gCACd,WAAc,kCACd,WAAc,6BACd,WAAc,mCACd,WAAc,2CACd,WAAc,kCACd,WAAc,8CACd,WAAc,iCACd,WAAc,6CACd,WAAc,sCACd,WAAc,mCACd,WAAc,+BACd,WAAc,yCACd,WAAc,oCACd,WAAc,gDACd,WAAc,4CACd,WAAc,sDACd,WAAc,iDACd,WAAc,4CACd,WAAc,wCACd,WAAc,oDACd,WAAc,6CACd,WAAc,sCACd,WAAc,0CACd,WAAc,iDACd,WAAc,4CACd,WAAc,wCACd,WAAc,4CACd,WAAc,wCACd,WAAc,6CACd,WAAc,6CACd,WAAc",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- var u=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var d=(i,r,o,e)=>{for(var t=e>1?void 0:e?f(r,o):r,s=i.length-1,l;s>=0;s--)(l=i[s])&&(t=(e?l(r,o,t):l(t))||t);return e&&t&&u(r,o,t),t};import m from"axios";import{injectable as g}from"inversify";import{Left as a,Right as p}from"purify-ts";import c from"../../../package.json";let n=class{async getSetPluginPayload({chainId:r,address:o,selector:e}){try{const t=await m.request({method:"GET",url:`https://nft.api.live.ledger.com/v1/ethereum/${r}/contracts/${o}/plugin-selector/${e}`,headers:{"X-Ledger-Client-Version":`context-module/${c.version}`}});return t.data.payload?p(t.data.payload):a(new Error("[ContextModule] HttpNftDataSource: unexpected empty response"))}catch{return a(new Error("[ContextModule] HttpNftDataSource: Failed to fetch set plugin payload"))}}async getNftInfosPayload({chainId:r,address:o}){try{const e=await m.request({method:"GET",url:`https://nft.api.live.ledger.com/v1/ethereum/${r}/contracts/${o}`,headers:{"X-Ledger-Client-Version":`context-module/${c.version}`}});return e.data.payload?p(e.data.payload):a(new Error("[ContextModule] HttpNftDataSource: no nft metadata"))}catch{return a(new Error("[ContextModule] HttpNftDataSource: Failed to fetch nft informations"))}}};n=d([g()],n);export{n as HttpNftDataSource};
1
+ var E=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var l=(a,e,r,t)=>{for(var o=t>1?void 0:t?y(e,r):e,s=a.length-1,m;s>=0;s--)(m=a[s])&&(o=(t?m(e,r,o):m(o))||o);return t&&o&&E(e,r,o),o},c=(a,e)=>(r,t)=>e(r,t,a);import d from"axios";import{inject as h,injectable as P}from"inversify";import{Left as n,Right as f}from"purify-ts";import{configTypes as x}from"../../config/di/configTypes";import{LEDGER_CLIENT_VERSION_HEADER as u,LEDGER_ORIGIN_TOKEN_HEADER as p}from"../../shared/constant/HttpHeaders";import g from"../../../package.json";let i=class{constructor(e){this.config=e}async getSetPluginPayload({chainId:e,address:r,selector:t}){try{const o=await d.request({method:"GET",url:`${this.config.metadataServiceDomain.url}/v1/ethereum/${e}/contracts/${r}/plugin-selector/${t}`,headers:{[u]:`context-module/${g.version}`,[p]:this.config.originToken}});return o.data.payload?f(o.data.payload):n(new Error("[ContextModule] HttpNftDataSource: unexpected empty response"))}catch{return n(new Error("[ContextModule] HttpNftDataSource: Failed to fetch set plugin payload"))}}async getNftInfosPayload({chainId:e,address:r}){try{const t=await d.request({method:"GET",url:`${this.config.metadataServiceDomain.url}/v1/ethereum/${e}/contracts/${r}`,headers:{[u]:`context-module/${g.version}`,[p]:this.config.originToken}});return t.data.payload?f(t.data.payload):n(new Error("[ContextModule] HttpNftDataSource: no nft metadata"))}catch{return n(new Error("[ContextModule] HttpNftDataSource: Failed to fetch nft informations"))}}};i=l([P(),c(0,h(x.Config))],i);export{i as HttpNftDataSource};
2
2
  //# sourceMappingURL=HttpNftDataSource.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/nft/data/HttpNftDataSource.ts"],
4
- "sourcesContent": ["import axios from \"axios\";\nimport { injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport {\n GetNftInformationsParams,\n GetSetPluginPayloadParams,\n NftDataSource,\n} from \"@/nft/data/NftDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\n@injectable()\nexport class HttpNftDataSource implements NftDataSource {\n public async getSetPluginPayload({\n chainId,\n address,\n selector,\n }: GetSetPluginPayloadParams): Promise<Either<Error, string>> {\n try {\n const response = await axios.request<{ payload: string }>({\n method: \"GET\",\n url: `https://nft.api.live.ledger.com/v1/ethereum/${chainId}/contracts/${address}/plugin-selector/${selector}`,\n headers: {\n \"X-Ledger-Client-Version\": `context-module/${PACKAGE.version}`,\n },\n });\n\n return response.data.payload\n ? Right(response.data.payload)\n : Left(\n new Error(\n \"[ContextModule] HttpNftDataSource: unexpected empty response\",\n ),\n );\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpNftDataSource: Failed to fetch set plugin payload\",\n ),\n );\n }\n }\n\n public async getNftInfosPayload({\n chainId,\n address,\n }: GetNftInformationsParams): Promise<Either<Error, string>> {\n try {\n const response = await axios.request<{ payload: string }>({\n method: \"GET\",\n url: `https://nft.api.live.ledger.com/v1/ethereum/${chainId}/contracts/${address}`,\n headers: {\n \"X-Ledger-Client-Version\": `context-module/${PACKAGE.version}`,\n },\n });\n\n return response.data.payload\n ? Right(response.data.payload)\n : Left(new Error(\"[ContextModule] HttpNftDataSource: no nft metadata\"));\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpNftDataSource: Failed to fetch nft informations\",\n ),\n );\n }\n }\n}\n"],
5
- "mappings": "wMAAA,OAAOA,MAAW,QAClB,OAAS,cAAAC,MAAkB,YAC3B,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAOpC,OAAOC,MAAa,qBAGb,IAAMC,EAAN,KAAiD,CACtD,MAAa,oBAAoB,CAC/B,QAAAC,EACA,QAAAC,EACA,SAAAC,CACF,EAA8D,CAC5D,GAAI,CACF,MAAMC,EAAW,MAAMC,EAAM,QAA6B,CACxD,OAAQ,MACR,IAAK,+CAA+CJ,CAAO,cAAcC,CAAO,oBAAoBC,CAAQ,GAC5G,QAAS,CACP,0BAA2B,kBAAkBG,EAAQ,OAAO,EAC9D,CACF,CAAC,EAED,OAAOF,EAAS,KAAK,QACjBG,EAAMH,EAAS,KAAK,OAAO,EAC3BI,EACE,IAAI,MACF,8DACF,CACF,CACN,MAAiB,CACf,OAAOA,EACL,IAAI,MACF,uEACF,CACF,CACF,CACF,CAEA,MAAa,mBAAmB,CAC9B,QAAAP,EACA,QAAAC,CACF,EAA6D,CAC3D,GAAI,CACF,MAAME,EAAW,MAAMC,EAAM,QAA6B,CACxD,OAAQ,MACR,IAAK,+CAA+CJ,CAAO,cAAcC,CAAO,GAChF,QAAS,CACP,0BAA2B,kBAAkBI,EAAQ,OAAO,EAC9D,CACF,CAAC,EAED,OAAOF,EAAS,KAAK,QACjBG,EAAMH,EAAS,KAAK,OAAO,EAC3BI,EAAK,IAAI,MAAM,oDAAoD,CAAC,CAC1E,MAAiB,CACf,OAAOA,EACL,IAAI,MACF,qEACF,CACF,CACF,CACF,CACF,EAvDaR,EAANS,EAAA,CADNC,EAAW,GACCV",
6
- "names": ["axios", "injectable", "Left", "Right", "PACKAGE", "HttpNftDataSource", "chainId", "address", "selector", "response", "axios", "PACKAGE", "Right", "Left", "__decorateClass", "injectable"]
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport {\n GetNftInformationsParams,\n GetSetPluginPayloadParams,\n NftDataSource,\n} from \"@/nft/data/NftDataSource\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport PACKAGE from \"@root/package.json\";\n\n@injectable()\nexport class HttpNftDataSource implements NftDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n public async getSetPluginPayload({\n chainId,\n address,\n selector,\n }: GetSetPluginPayloadParams): Promise<Either<Error, string>> {\n try {\n const response = await axios.request<{ payload: string }>({\n method: \"GET\",\n url: `${this.config.metadataServiceDomain.url}/v1/ethereum/${chainId}/contracts/${address}/plugin-selector/${selector}`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n });\n\n return response.data.payload\n ? Right(response.data.payload)\n : Left(\n new Error(\n \"[ContextModule] HttpNftDataSource: unexpected empty response\",\n ),\n );\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpNftDataSource: Failed to fetch set plugin payload\",\n ),\n );\n }\n }\n\n public async getNftInfosPayload({\n chainId,\n address,\n }: GetNftInformationsParams): Promise<Either<Error, string>> {\n try {\n const response = await axios.request<{ payload: string }>({\n method: \"GET\",\n url: `${this.config.metadataServiceDomain.url}/v1/ethereum/${chainId}/contracts/${address}`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n });\n\n return response.data.payload\n ? Right(response.data.payload)\n : Left(new Error(\"[ContextModule] HttpNftDataSource: no nft metadata\"));\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpNftDataSource: Failed to fetch nft informations\",\n ),\n );\n }\n }\n}\n"],
5
+ "mappings": "iOAAA,OAAOA,MAAW,QAClB,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAO5B,OACE,gCAAAC,EACA,8BAAAC,MACK,gCACP,OAAOC,MAAa,qBAGb,IAAMC,EAAN,KAAiD,CACtD,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CAEH,MAAa,oBAAoB,CAC/B,QAAAC,EACA,QAAAC,EACA,SAAAC,CACF,EAA8D,CAC5D,GAAI,CACF,MAAMC,EAAW,MAAMC,EAAM,QAA6B,CACxD,OAAQ,MACR,IAAK,GAAG,KAAK,OAAO,sBAAsB,GAAG,gBAAgBJ,CAAO,cAAcC,CAAO,oBAAoBC,CAAQ,GACrH,QAAS,CACP,CAACG,CAA4B,EAAG,kBAAkBC,EAAQ,OAAO,GACjE,CAACC,CAA0B,EAAG,KAAK,OAAO,WAC5C,CACF,CAAC,EAED,OAAOJ,EAAS,KAAK,QACjBK,EAAML,EAAS,KAAK,OAAO,EAC3BM,EACE,IAAI,MACF,8DACF,CACF,CACN,MAAiB,CACf,OAAOA,EACL,IAAI,MACF,uEACF,CACF,CACF,CACF,CAEA,MAAa,mBAAmB,CAC9B,QAAAT,EACA,QAAAC,CACF,EAA6D,CAC3D,GAAI,CACF,MAAME,EAAW,MAAMC,EAAM,QAA6B,CACxD,OAAQ,MACR,IAAK,GAAG,KAAK,OAAO,sBAAsB,GAAG,gBAAgBJ,CAAO,cAAcC,CAAO,GACzF,QAAS,CACP,CAACI,CAA4B,EAAG,kBAAkBC,EAAQ,OAAO,GACjE,CAACC,CAA0B,EAAG,KAAK,OAAO,WAC5C,CACF,CAAC,EAED,OAAOJ,EAAS,KAAK,QACjBK,EAAML,EAAS,KAAK,OAAO,EAC3BM,EAAK,IAAI,MAAM,oDAAoD,CAAC,CAC1E,MAAiB,CACf,OAAOA,EACL,IAAI,MACF,qEACF,CACF,CACF,CACF,CACF,EA7DaX,EAANY,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,IAFjBhB",
6
+ "names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "LEDGER_CLIENT_VERSION_HEADER", "LEDGER_ORIGIN_TOKEN_HEADER", "PACKAGE", "HttpNftDataSource", "config", "chainId", "address", "selector", "response", "axios", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "LEDGER_ORIGIN_TOKEN_HEADER", "Right", "Left", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import o from"axios";import r from"../../../package.json";import{HttpNftDataSource as s}from"./HttpNftDataSource";vi.mock("axios");describe("HttpNftDataSource",()=>{let a;beforeAll(()=>{a=new s,vi.clearAllMocks()}),it("should call axios with the ledger client version header",async()=>{const e=`context-module/${r.version}`,t=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(o,"request").mockImplementation(t),await a.getNftInfosPayload({address:"0x00",chainId:1}),await a.getSetPluginPayload({address:"0x00",chainId:1,selector:"0x00"}),expect(t).toHaveBeenNthCalledWith(1,expect.objectContaining({headers:{"X-Ledger-Client-Version":e}})),expect(t).toHaveBeenNthCalledWith(2,expect.objectContaining({headers:{"X-Ledger-Client-Version":e}}))}),describe("getNftInfosPayload",()=>{it("should return an error when axios throws an error",async()=>{vi.spyOn(o,"request").mockRejectedValue(new Error("error"));const e=await a.getNftInfosPayload({address:"0x00",chainId:1});expect(e.extract()).toEqual(new Error("[ContextModule] HttpNftDataSource: Failed to fetch nft informations"))}),it("should return an error when the response is empty",async()=>{const e={data:{}};vi.spyOn(o,"request").mockResolvedValue(e);const t=await a.getNftInfosPayload({address:"0x00",chainId:1});expect(t.extract()).toEqual(new Error("[ContextModule] HttpNftDataSource: no nft metadata"))}),it("should return the payload",async()=>{const e={data:{payload:"payload"}};vi.spyOn(o,"request").mockResolvedValue(e);const t=await a.getNftInfosPayload({address:"0x00",chainId:1});expect(t.extract()).toEqual("payload")})}),describe("getSetPluginPayload",()=>{it("should return an error when axios throws an error",async()=>{vi.spyOn(o,"request").mockRejectedValue(new Error("error"));const e=await a.getSetPluginPayload({address:"0x00",chainId:1,selector:"0x00"});expect(e.extract()).toEqual(new Error("[ContextModule] HttpNftDataSource: Failed to fetch set plugin payload"))}),it("should return an error when the response is empty",async()=>{const e={data:{}};vi.spyOn(o,"request").mockResolvedValue(e);const t=await a.getSetPluginPayload({address:"0x00",chainId:1,selector:"0x00"});expect(t.extract()).toEqual(new Error("[ContextModule] HttpNftDataSource: unexpected empty response"))}),it("should return the payload",async()=>{const e={data:{payload:"payload"}};vi.spyOn(o,"request").mockResolvedValue(e);const t=await a.getSetPluginPayload({address:"0x00",chainId:1,selector:"0x00"});expect(t.extract()).toEqual("payload")})})});
1
+ import a from"axios";import{LEDGER_CLIENT_VERSION_HEADER as n,LEDGER_ORIGIN_TOKEN_HEADER as s}from"../../shared/constant/HttpHeaders";import i from"../../../package.json";import{HttpNftDataSource as l}from"./HttpNftDataSource";vi.mock("axios");const r={web3checks:{url:"web3checksUrl"},metadataServiceDomain:{url:"https://nft.api.live.ledger.com"},originToken:"originToken"};describe("HttpNftDataSource",()=>{let o;beforeAll(()=>{o=new l(r),vi.clearAllMocks()}),it("should call axios with the ledger client version and origin Token header",async()=>{const e=`context-module/${i.version}`,t=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(a,"request").mockImplementation(t),await o.getNftInfosPayload({address:"0x00",chainId:1}),await o.getSetPluginPayload({address:"0x00",chainId:1,selector:"0x00"}),expect(t).toHaveBeenNthCalledWith(1,expect.objectContaining({headers:{[n]:e,[s]:r.originToken}})),expect(t).toHaveBeenNthCalledWith(2,expect.objectContaining({headers:{[n]:e,[s]:r.originToken}}))}),describe("getNftInfosPayload",()=>{it("should return an error when axios throws an error",async()=>{vi.spyOn(a,"request").mockRejectedValue(new Error("error"));const e=await o.getNftInfosPayload({address:"0x00",chainId:1});expect(e.extract()).toEqual(new Error("[ContextModule] HttpNftDataSource: Failed to fetch nft informations"))}),it("should return an error when the response is empty",async()=>{const e={data:{}};vi.spyOn(a,"request").mockResolvedValue(e);const t=await o.getNftInfosPayload({address:"0x00",chainId:1});expect(t.extract()).toEqual(new Error("[ContextModule] HttpNftDataSource: no nft metadata"))}),it("should return the payload",async()=>{const e={data:{payload:"payload"}};vi.spyOn(a,"request").mockResolvedValue(e);const t=await o.getNftInfosPayload({address:"0x00",chainId:1});expect(t.extract()).toEqual("payload")})}),describe("getSetPluginPayload",()=>{it("should return an error when axios throws an error",async()=>{vi.spyOn(a,"request").mockRejectedValue(new Error("error"));const e=await o.getSetPluginPayload({address:"0x00",chainId:1,selector:"0x00"});expect(e.extract()).toEqual(new Error("[ContextModule] HttpNftDataSource: Failed to fetch set plugin payload"))}),it("should return an error when the response is empty",async()=>{const e={data:{}};vi.spyOn(a,"request").mockResolvedValue(e);const t=await o.getSetPluginPayload({address:"0x00",chainId:1,selector:"0x00"});expect(t.extract()).toEqual(new Error("[ContextModule] HttpNftDataSource: unexpected empty response"))}),it("should return the payload",async()=>{const e={data:{payload:"payload"}};vi.spyOn(a,"request").mockResolvedValue(e);const t=await o.getSetPluginPayload({address:"0x00",chainId:1,selector:"0x00"});expect(t.extract()).toEqual("payload")})})});
2
2
  //# sourceMappingURL=HttpNftDataSource.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/nft/data/HttpNftDataSource.test.ts"],
4
- "sourcesContent": ["import axios from \"axios\";\n\nimport PACKAGE from \"@root/package.json\";\n\nimport { HttpNftDataSource } from \"./HttpNftDataSource\";\nimport { type NftDataSource } from \"./NftDataSource\";\n\nvi.mock(\"axios\");\n\ndescribe(\"HttpNftDataSource\", () => {\n let datasource: NftDataSource;\n\n beforeAll(() => {\n datasource = new HttpNftDataSource();\n vi.clearAllMocks();\n });\n\n it(\"should call axios with the ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() => Promise.resolve({ data: [] }));\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getNftInfosPayload({ address: \"0x00\", chainId: 1 });\n await datasource.getSetPluginPayload({\n address: \"0x00\",\n chainId: 1,\n selector: \"0x00\",\n });\n\n // THEN\n expect(requestSpy).toHaveBeenNthCalledWith(\n 1,\n expect.objectContaining({\n headers: { \"X-Ledger-Client-Version\": version },\n }),\n );\n expect(requestSpy).toHaveBeenNthCalledWith(\n 2,\n expect.objectContaining({\n headers: { \"X-Ledger-Client-Version\": version },\n }),\n );\n });\n\n describe(\"getNftInfosPayload\", () => {\n it(\"should return an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"error\"));\n\n // WHEN\n const result = await datasource.getNftInfosPayload({\n address: \"0x00\",\n chainId: 1,\n });\n\n // THEN\n expect(result.extract()).toEqual(\n new Error(\n \"[ContextModule] HttpNftDataSource: Failed to fetch nft informations\",\n ),\n );\n });\n\n it(\"should return an error when the response is empty\", async () => {\n // GIVEN\n const response = { data: {} };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getNftInfosPayload({\n address: \"0x00\",\n chainId: 1,\n });\n\n // THEN\n expect(result.extract()).toEqual(\n new Error(\"[ContextModule] HttpNftDataSource: no nft metadata\"),\n );\n });\n\n it(\"should return the payload\", async () => {\n // GIVEN\n const response = { data: { payload: \"payload\" } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getNftInfosPayload({\n address: \"0x00\",\n chainId: 1,\n });\n\n // THEN\n expect(result.extract()).toEqual(\"payload\");\n });\n });\n\n describe(\"getSetPluginPayload\", () => {\n it(\"should return an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"error\"));\n\n // WHEN\n const result = await datasource.getSetPluginPayload({\n address: \"0x00\",\n chainId: 1,\n selector: \"0x00\",\n });\n\n // THEN\n expect(result.extract()).toEqual(\n new Error(\n \"[ContextModule] HttpNftDataSource: Failed to fetch set plugin payload\",\n ),\n );\n });\n\n it(\"should return an error when the response is empty\", async () => {\n // GIVEN\n const response = { data: {} };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getSetPluginPayload({\n address: \"0x00\",\n chainId: 1,\n selector: \"0x00\",\n });\n\n // THEN\n expect(result.extract()).toEqual(\n new Error(\n \"[ContextModule] HttpNftDataSource: unexpected empty response\",\n ),\n );\n });\n\n it(\"should return the payload\", async () => {\n // GIVEN\n const response = { data: { payload: \"payload\" } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getSetPluginPayload({\n address: \"0x00\",\n chainId: 1,\n selector: \"0x00\",\n });\n\n // THEN\n expect(result.extract()).toEqual(\"payload\");\n });\n });\n});\n"],
5
- "mappings": "AAAA,OAAOA,MAAW,QAElB,OAAOC,MAAa,qBAEpB,OAAS,qBAAAC,MAAyB,sBAGlC,GAAG,KAAK,OAAO,EAEf,SAAS,oBAAqB,IAAM,CAClC,IAAIC,EAEJ,UAAU,IAAM,CACdA,EAAa,IAAID,EACjB,GAAG,cAAc,CACnB,CAAC,EAED,GAAG,0DAA2D,SAAY,CAExE,MAAME,EAAU,kBAAkBH,EAAQ,OAAO,GAC3CI,EAAa,GAAG,GAAG,IAAM,QAAQ,QAAQ,CAAE,KAAM,CAAC,CAAE,CAAC,CAAC,EAC5D,GAAG,MAAML,EAAO,SAAS,EAAE,mBAAmBK,CAAU,EAGxD,MAAMF,EAAW,mBAAmB,CAAE,QAAS,OAAQ,QAAS,CAAE,CAAC,EACnE,MAAMA,EAAW,oBAAoB,CACnC,QAAS,OACT,QAAS,EACT,SAAU,MACZ,CAAC,EAGD,OAAOE,CAAU,EAAE,wBACjB,EACA,OAAO,iBAAiB,CACtB,QAAS,CAAE,0BAA2BD,CAAQ,CAChD,CAAC,CACH,EACA,OAAOC,CAAU,EAAE,wBACjB,EACA,OAAO,iBAAiB,CACtB,QAAS,CAAE,0BAA2BD,CAAQ,CAChD,CAAC,CACH,CACF,CAAC,EAED,SAAS,qBAAsB,IAAM,CACnC,GAAG,oDAAqD,SAAY,CAElE,GAAG,MAAMJ,EAAO,SAAS,EAAE,kBAAkB,IAAI,MAAM,OAAO,CAAC,EAG/D,M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AAQ,CAAC,EAAE,QACvB,IAAI,MACF,8DACF,CACF,CACF,CAAC,EAED,GAAG,4BAA6B,SAAY,CAE1C,MAAMC,EAAW,CAAE,KAAM,CAAE,QAAS,SAAU,CAAE,EAChD,GAAG,MAAMP,EAAO,SAAS,EAAE,kBAAkBO,CAAQ,EAGrD,MAAMD,EAAS,MAAMH,EAAW,oBAAoB,CAClD,QAAS,OACT,QAAS,EACT,SAAU,MACZ,CAAC,EAGD,OAAOG,EAAO,QAAQ,CAAC,EAAE,QAAQ,SAAS,CAC5C,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["axios", "PACKAGE", "HttpNftDataSource", "datasource", "version", "requestSpy", "result", "response"]
4
+ "sourcesContent": ["import axios from \"axios\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { HttpNftDataSource } from \"./HttpNftDataSource\";\nimport { type NftDataSource } from \"./NftDataSource\";\n\nvi.mock(\"axios\");\n\nconst config = {\n web3checks: {\n url: \"web3checksUrl\",\n },\n metadataServiceDomain: {\n url: \"https://nft.api.live.ledger.com\",\n },\n originToken: \"originToken\",\n} as ContextModuleConfig;\ndescribe(\"HttpNftDataSource\", () => {\n let datasource: NftDataSource;\n\n beforeAll(() => {\n datasource = new HttpNftDataSource(config);\n vi.clearAllMocks();\n });\n\n it(\"should call axios with the ledger client version and origin Token header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() => Promise.resolve({ data: [] }));\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getNftInfosPayload({ address: \"0x00\", chainId: 1 });\n await datasource.getSetPluginPayload({\n address: \"0x00\",\n chainId: 1,\n selector: \"0x00\",\n });\n\n // THEN\n expect(requestSpy).toHaveBeenNthCalledWith(\n 1,\n expect.objectContaining({\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: version,\n [LEDGER_ORIGIN_TOKEN_HEADER]: config.originToken,\n },\n }),\n );\n expect(requestSpy).toHaveBeenNthCalledWith(\n 2,\n expect.objectContaining({\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: version,\n [LEDGER_ORIGIN_TOKEN_HEADER]: config.originToken,\n },\n }),\n );\n });\n\n describe(\"getNftInfosPayload\", () => {\n it(\"should return an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"error\"));\n\n // WHEN\n const result = await datasource.getNftInfosPayload({\n address: \"0x00\",\n chainId: 1,\n });\n\n // THEN\n expect(result.extract()).toEqual(\n new Error(\n \"[ContextModule] HttpNftDataSource: Failed to fetch nft informations\",\n ),\n );\n });\n\n it(\"should return an error when the response is empty\", async () => {\n // GIVEN\n const response = { data: {} };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getNftInfosPayload({\n address: \"0x00\",\n chainId: 1,\n });\n\n // THEN\n expect(result.extract()).toEqual(\n new Error(\"[ContextModule] HttpNftDataSource: no nft metadata\"),\n );\n });\n\n it(\"should return the payload\", async () => {\n // GIVEN\n const response = { data: { payload: \"payload\" } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getNftInfosPayload({\n address: \"0x00\",\n chainId: 1,\n });\n\n // THEN\n expect(result.extract()).toEqual(\"payload\");\n });\n });\n\n describe(\"getSetPluginPayload\", () => {\n it(\"should return an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"error\"));\n\n // WHEN\n const result = await datasource.getSetPluginPayload({\n address: \"0x00\",\n chainId: 1,\n selector: \"0x00\",\n });\n\n // THEN\n expect(result.extract()).toEqual(\n new Error(\n \"[ContextModule] HttpNftDataSource: Failed to fetch set plugin payload\",\n ),\n );\n });\n\n it(\"should return an error when the response is empty\", async () => {\n // GIVEN\n const response = { data: {} };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getSetPluginPayload({\n address: \"0x00\",\n chainId: 1,\n selector: \"0x00\",\n });\n\n // THEN\n expect(result.extract()).toEqual(\n new Error(\n \"[ContextModule] HttpNftDataSource: unexpected empty response\",\n ),\n );\n });\n\n it(\"should return the payload\", async () => {\n // GIVEN\n const response = { data: { payload: \"payload\" } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getSetPluginPayload({\n address: \"0x00\",\n chainId: 1,\n selector: \"0x00\",\n });\n\n // THEN\n expect(result.extract()).toEqual(\"payload\");\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAOA,MAAW,QAGlB,OACE,gCAAAC,EACA,8BAAAC,MACK,gCACP,OAAOC,MAAa,qBAEpB,OAAS,qBAAAC,MAAyB,sBAGlC,GAAG,KAAK,OAAO,EAEf,MAAMC,EAAS,CACb,WAAY,CACV,IAAK,eACP,EACA,sBAAuB,CACrB,IAAK,iCACP,EACA,YAAa,aACf,EACA,SAAS,oBAAqB,IAAM,CAClC,IAAIC,EAEJ,UAAU,IAAM,CACdA,EAAa,IAAIF,EAAkBC,CAAM,EACzC,GAAG,cAAc,CACnB,CAAC,EAED,GAAG,2EAA4E,SAAY,CAEzF,MAAME,EAAU,kBAAkBJ,EAAQ,OAAO,GAC3CK,EAAa,GAAG,GAAG,IAAM,QAAQ,QAAQ,CAAE,KAAM,CAAC,CAAE,CAAC,CAAC,EAC5D,GAAG,MAAMR,EAAO,SAAS,EAAE,mBAAmBQ,CAAU,EAGxD,MAAMF,EAAW,mBAAmB,CAAE,QAAS,OAAQ,QAAS,CAAE,CAAC,EACnE,MAAMA,EAAW,oBAAoB,CACnC,QAAS,OACT,QAAS,EACT,SAAU,MACZ,CAAC,EAGD,OAAOE,CAAU,EAAE,wBACjB,EACA,OAAO,iBAAiB,CACt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EAAW,oBAAoB,CAClD,QAAS,OACT,QAAS,EACT,SAAU,MACZ,CAAC,EAGD,OAAOG,EAAO,QAAQ,CAAC,EAAE,QACvB,IAAI,MACF,uEACF,CACF,CACF,CAAC,EAED,GAAG,oDAAqD,SAAY,CAElE,MAAMC,EAAW,CAAE,KAAM,CAAC,CAAE,EAC5B,GAAG,MAAMV,EAAO,SAAS,EAAE,kBAAkBU,CAAQ,EAGrD,MAAMD,EAAS,MAAMH,EAAW,oBAAoB,CAClD,QAAS,OACT,QAAS,EACT,SAAU,MACZ,CAAC,EAGD,OAAOG,EAAO,QAAQ,CAAC,EAAE,QACvB,IAAI,MACF,8DACF,CACF,CACF,CAAC,EAED,GAAG,4BAA6B,SAAY,CAE1C,MAAMC,EAAW,CAAE,KAAM,CAAE,QAAS,SAAU,CAAE,EAChD,GAAG,MAAMV,EAAO,SAAS,EAAE,kBAAkBU,CAAQ,EAGrD,MAAMD,EAAS,MAAMH,EAAW,oBAAoB,CAClD,QAAS,OACT,QAAS,EACT,SAAU,MACZ,CAAC,EAGD,OAAOG,EAAO,QAAQ,CAAC,EAAE,QAAQ,SAAS,CAC5C,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["axios", "LEDGER_CLIENT_VERSION_HEADER", "LEDGER_ORIGIN_TOKEN_HEADER", "PACKAGE", "HttpNftDataSource", "config", "datasource", "version", "requestSpy", "result", "response"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ContainerModule as r}from"inversify";import{HttpNftDataSource as e}from"../../nft/data/HttpNftDataSource";import{nftTypes as o}from"../../nft/di/nftTypes";import{NftContextLoader as n}from"../../nft/domain/NftContextLoader";const c=()=>new r((t,f,a,m)=>{t(o.NftDataSource).to(e),t(o.NftContextLoader).to(n)});export{c as nftModuleFactory};
1
+ import{ContainerModule as r}from"inversify";import{HttpNftDataSource as e}from"../../nft/data/HttpNftDataSource";import{nftTypes as o}from"../../nft/di/nftTypes";import{NftContextFieldLoader as f}from"../../nft/domain/NftContextFieldLoader";import{NftContextLoader as a}from"../../nft/domain/NftContextLoader";const N=()=>new r(({bind:t})=>{t(o.NftDataSource).to(e),t(o.NftContextLoader).to(a),t(o.NftContextFieldLoader).to(f)});export{N as nftModuleFactory};
2
2
  //# sourceMappingURL=nftModuleFactory.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/nft/di/nftModuleFactory.ts"],
4
- "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpNftDataSource } from \"@/nft/data/HttpNftDataSource\";\nimport { nftTypes } from \"@/nft/di/nftTypes\";\nimport { NftContextLoader } from \"@/nft/domain/NftContextLoader\";\n\nexport const nftModuleFactory = () =>\n new ContainerModule((bind, _unbind, _isBound, _rebind) => {\n bind(nftTypes.NftDataSource).to(HttpNftDataSource);\n bind(nftTypes.NftContextLoader).to(NftContextLoader);\n });\n"],
5
- "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,qBAAAC,MAAyB,+BAClC,OAAS,YAAAC,MAAgB,oBACzB,OAAS,oBAAAC,MAAwB,gCAE1B,MAAMC,EAAmB,IAC9B,IAAIJ,EAAgB,CAACK,EAAMC,EAASC,EAAUC,IAAY,CACxDH,EAAKH,EAAS,aAAa,EAAE,GAAGD,CAAiB,EACjDI,EAAKH,EAAS,gBAAgB,EAAE,GAAGC,CAAgB,CACrD,CAAC",
6
- "names": ["ContainerModule", "HttpNftDataSource", "nftTypes", "NftContextLoader", "nftModuleFactory", "bind", "_unbind", "_isBound", "_rebind"]
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpNftDataSource } from \"@/nft/data/HttpNftDataSource\";\nimport { nftTypes } from \"@/nft/di/nftTypes\";\nimport { NftContextFieldLoader } from \"@/nft/domain/NftContextFieldLoader\";\nimport { NftContextLoader } from \"@/nft/domain/NftContextLoader\";\n\nexport const nftModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(nftTypes.NftDataSource).to(HttpNftDataSource);\n bind(nftTypes.NftContextLoader).to(NftContextLoader);\n bind(nftTypes.NftContextFieldLoader).to(NftContextFieldLoader);\n });\n"],
5
+ "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,qBAAAC,MAAyB,+BAClC,OAAS,YAAAC,MAAgB,oBACzB,OAAS,yBAAAC,MAA6B,qCACtC,OAAS,oBAAAC,MAAwB,gCAE1B,MAAMC,EAAmB,IAC9B,IAAIL,EAAgB,CAAC,CAAE,KAAAM,CAAK,IAAM,CAChCA,EAAKJ,EAAS,aAAa,EAAE,GAAGD,CAAiB,EACjDK,EAAKJ,EAAS,gBAAgB,EAAE,GAAGE,CAAgB,EACnDE,EAAKJ,EAAS,qBAAqB,EAAE,GAAGC,CAAqB,CAC/D,CAAC",
6
+ "names": ["ContainerModule", "HttpNftDataSource", "nftTypes", "NftContextFieldLoader", "NftContextLoader", "nftModuleFactory", "bind"]
7
7
  }
@@ -1,2 +1,2 @@
1
- const t={NftDataSource:Symbol.for("nftDataSource"),NftContextLoader:Symbol.for("nftContextLoader")};export{t as nftTypes};
1
+ const t={NftDataSource:Symbol.for("nftDataSource"),NftContextLoader:Symbol.for("nftContextLoader"),NftContextFieldLoader:Symbol.for("nftContextFieldLoader")};export{t as nftTypes};
2
2
  //# sourceMappingURL=nftTypes.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/nft/di/nftTypes.ts"],
4
- "sourcesContent": ["export const nftTypes = {\n NftDataSource: Symbol.for(\"nftDataSource\"),\n NftContextLoader: Symbol.for(\"nftContextLoader\"),\n};\n"],
5
- "mappings": "AAAO,MAAMA,EAAW,CACtB,cAAe,OAAO,IAAI,eAAe,EACzC,iBAAkB,OAAO,IAAI,kBAAkB,CACjD",
4
+ "sourcesContent": ["export const nftTypes = {\n NftDataSource: Symbol.for(\"nftDataSource\"),\n NftContextLoader: Symbol.for(\"nftContextLoader\"),\n NftContextFieldLoader: Symbol.for(\"nftContextFieldLoader\"),\n};\n"],
5
+ "mappings": "AAAO,MAAMA,EAAW,CACtB,cAAe,OAAO,IAAI,eAAe,EACzC,iBAAkB,OAAO,IAAI,kBAAkB,EAC/C,sBAAuB,OAAO,IAAI,uBAAuB,CAC3D",
6
6
  "names": ["nftTypes"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ var c=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var l=(r,t,a,e)=>{for(var n=e>1?void 0:e?f(t,a):t,i=r.length-1,d;i>=0;i--)(d=r[i])&&(n=(e?d(t,a,n):d(n))||n);return e&&n&&c(t,a,n),n},p=(r,t)=>(a,e)=>t(a,e,r);import{inject as m,injectable as y}from"inversify";import{nftTypes as u}from"../../nft/di/nftTypes";import{ClearSignContextType as s}from"../../shared/model/ClearSignContext";let o=class{constructor(t){this._dataSource=t}canHandle(t,a){return a===s.NFT&&typeof t=="object"&&t!==null&&"chainId"in t&&"address"in t}async loadField(t){return(await this._dataSource.getNftInfosPayload({address:t.address,chainId:t.chainId})).caseOf({Left:e=>({type:s.ERROR,error:e}),Right:e=>({type:s.NFT,payload:e})})}};o=l([y(),p(0,m(u.NftDataSource))],o);export{o as NftContextFieldLoader};
2
+ //# sourceMappingURL=NftContextFieldLoader.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/nft/domain/NftContextFieldLoader.ts"],
4
+ "sourcesContent": ["import { inject, injectable } from \"inversify\";\n\nimport * as NftDataSource from \"@/nft/data/NftDataSource\";\nimport { nftTypes } from \"@/nft/di/nftTypes\";\nimport { type ContextFieldLoader } from \"@/shared/domain/ContextFieldLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\n\ntype NftFieldInput = {\n chainId: number;\n address: string;\n};\n\n@injectable()\nexport class NftContextFieldLoader\n implements ContextFieldLoader<NftFieldInput>\n{\n constructor(\n @inject(nftTypes.NftDataSource)\n private _dataSource: NftDataSource.NftDataSource,\n ) {}\n\n canHandle(\n input: unknown,\n expectedType: ClearSignContextType,\n ): input is NftFieldInput {\n return (\n expectedType === ClearSignContextType.NFT &&\n typeof input === \"object\" &&\n input !== null &&\n \"chainId\" in input &&\n \"address\" in input\n );\n }\n\n async loadField(input: NftFieldInput): Promise<ClearSignContext> {\n const payload = await this._dataSource.getNftInfosPayload({\n address: input.address,\n chainId: input.chainId,\n });\n return payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.NFT,\n payload: value,\n }),\n });\n }\n}\n"],
5
+ "mappings": "iOAAA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YAGnC,OAAS,YAAAC,MAAgB,oBAEzB,OAEE,wBAAAC,MACK,kCAQA,IAAMC,EAAN,KAEP,CACE,YAEUC,EACR,CADQ,iBAAAA,CACP,CAEH,UACEC,EACAC,EACwB,CACxB,OACEA,IAAiBC,EAAqB,KACtC,OAAOF,GAAU,UACjBA,IAAU,MACV,YAAaA,GACb,YAAaA,CAEjB,CAEA,MAAM,UAAUA,EAAiD,CAK/D,OAJgB,MAAM,KAAK,YAAY,mBAAmB,CACxD,QAASA,EAAM,QACf,QAASA,EAAM,OACjB,CAAC,GACc,OAAO,CACpB,KAAOG,IAA6B,CAClC,KAAMD,EAAqB,MAC3B,MAAAC,CACF,GACA,MAAQC,IAA6B,CACnC,KAAMF,EAAqB,IAC3B,QAASE,CACX,EACF,CAAC,CACH,CACF,EArCaN,EAANO,EAAA,CADNC,EAAW,EAKPC,EAAA,EAAAC,EAAOC,EAAS,aAAa,IAJrBX",
6
+ "names": ["inject", "injectable", "nftTypes", "ClearSignContextType", "NftContextFieldLoader", "_dataSource", "input", "expectedType", "ClearSignContextType", "error", "value", "__decorateClass", "injectable", "__decorateParam", "inject", "nftTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{Left as r,Right as s}from"purify-ts";import{NftContextFieldLoader as c}from"../../nft/domain/NftContextFieldLoader";import{ClearSignContextType as l}from"../../shared/model/ClearSignContext";describe("NftContextFieldLoader",()=>{const t={getNftInfosPayload:vi.fn(),getSetPluginPayload:vi.fn()},d=new c(t),a={chainId:1,address:"0x1234567890abcdef"},n="0x123456789abcdef0";beforeEach(()=>{vi.resetAllMocks()}),describe("canHandle",()=>{it("should return true for valid NFT field",()=>{const e={chainId:1,address:"0x1234567890abcdef"};expect(d.canHandle(e,l.NFT)).toBe(!0)}),describe("should return false for invalid fields",()=>{const e=[{name:"null",value:null},{name:"undefined",value:void 0},{name:"string",value:"invalid"},{name:"number",value:123},{name:"boolean",value:!0},{name:"array",value:[]},{name:"empty object",value:{}},{name:"object missing chainId",value:{address:"0x123"}},{name:"object missing address",value:{chainId:1}}];test.each(e)("$name",({value:o})=>{expect(d.canHandle(o,l.NFT)).toBe(!1)})}),it("should return false for invalid expected type",()=>{expect(d.canHandle(a,l.TOKEN)).toBe(!1)})}),describe("loadField",()=>{it("should return error context when NFT data source fails",async()=>{const e=new Error("NFT data source error");vi.spyOn(t,"getNftInfosPayload").mockResolvedValue(r(e));const o=await d.loadField(a);expect(t.getNftInfosPayload).toHaveBeenCalledWith({address:a.address,chainId:a.chainId}),expect(o).toEqual({type:l.ERROR,error:e})}),it("should return NFT context when successful",async()=>{vi.spyOn(t,"getNftInfosPayload").mockResolvedValue(s(n));const e=await d.loadField(a);expect(t.getNftInfosPayload).toHaveBeenCalledWith({address:a.address,chainId:a.chainId}),expect(e).toEqual({type:l.NFT,payload:n})}),it("should handle different chain IDs and addresses correctly",async()=>{const e={...a,chainId:137,address:"0xdeadbeef"};vi.spyOn(t,"getNftInfosPayload").mockResolvedValue(s(n));const o=await d.loadField(e);expect(t.getNftInfosPayload).toHaveBeenCalledWith({address:"0xdeadbeef",chainId:137}),expect(o).toEqual({type:l.NFT,payload:n})}),it("should preserve error message from NFT data source",async()=>{const e=new Error("Network timeout error");vi.spyOn(t,"getNftInfosPayload").mockResolvedValue(r(e));const o=await d.loadField(a);expect(o).toEqual({type:l.ERROR,error:e})}),it("should handle empty NFT payload",async()=>{const e="";vi.spyOn(t,"getNftInfosPayload").mockResolvedValue(s(e));const o=await d.loadField(a);expect(o).toEqual({type:l.NFT,payload:e})})})});
2
+ //# sourceMappingURL=NftContextFieldLoader.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/nft/domain/NftContextFieldLoader.test.ts"],
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { type NftDataSource } from \"@/nft/data/NftDataSource\";\nimport { NftContextFieldLoader } from \"@/nft/domain/NftContextFieldLoader\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\n\ndescribe(\"NftContextFieldLoader\", () => {\n const mockNftDataSource: NftDataSource = {\n getNftInfosPayload: vi.fn(),\n getSetPluginPayload: vi.fn(),\n };\n const nftContextFieldLoader = new NftContextFieldLoader(mockNftDataSource);\n\n const mockTransactionField = {\n chainId: 1,\n address: \"0x1234567890abcdef\",\n };\n\n const mockNftPayload = \"0x123456789abcdef0\";\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"canHandle\", () => {\n it(\"should return true for valid NFT field\", () => {\n // GIVEN\n const validField = {\n chainId: 1,\n address: \"0x1234567890abcdef\",\n };\n\n // THEN\n expect(\n nftContextFieldLoader.canHandle(validField, ClearSignContextType.NFT),\n ).toBe(true);\n });\n\n describe(\"should return false for invalid fields\", () => {\n const invalidFields = [\n { name: \"null\", value: null },\n { name: \"undefined\", value: undefined },\n { name: \"string\", value: \"invalid\" },\n { name: \"number\", value: 123 },\n { name: \"boolean\", value: true },\n { name: \"array\", value: [] },\n { name: \"empty object\", value: {} },\n {\n name: \"object missing chainId\",\n value: { address: \"0x123\" },\n },\n {\n name: \"object missing address\",\n value: { chainId: 1 },\n },\n ];\n\n test.each(invalidFields)(\"$name\", ({ value }) => {\n expect(\n nftContextFieldLoader.canHandle(value, ClearSignContextType.NFT),\n ).toBe(false);\n });\n });\n\n it(\"should return false for invalid expected type\", () => {\n expect(\n nftContextFieldLoader.canHandle(\n mockTransactionField,\n ClearSignContextType.TOKEN,\n ),\n ).toBe(false);\n });\n });\n\n describe(\"loadField\", () => {\n it(\"should return error context when NFT data source fails\", async () => {\n // GIVEN\n const error = new Error(\"NFT data source error\");\n vi.spyOn(mockNftDataSource, \"getNftInfosPayload\").mockResolvedValue(\n Left(error),\n );\n\n // WHEN\n const result =\n await nftContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(mockNftDataSource.getNftInfosPayload).toHaveBeenCalledWith({\n address: mockTransactionField.address,\n chainId: mockTransactionField.chainId,\n });\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: error,\n });\n });\n\n it(\"should return NFT context when successful\", async () => {\n // GIVEN\n vi.spyOn(mockNftDataSource, \"getNftInfosPayload\").mockResolvedValue(\n Right(mockNftPayload),\n );\n\n // WHEN\n const result =\n await nftContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(mockNftDataSource.getNftInfosPayload).toHaveBeenCalledWith({\n address: mockTransactionField.address,\n chainId: mockTransactionField.chainId,\n });\n expect(result).toEqual({\n type: ClearSignContextType.NFT,\n payload: mockNftPayload,\n });\n });\n\n it(\"should handle different chain IDs and addresses correctly\", async () => {\n // GIVEN\n const customField = {\n ...mockTransactionField,\n chainId: 137,\n address: \"0xdeadbeef\",\n };\n vi.spyOn(mockNftDataSource, \"getNftInfosPayload\").mockResolvedValue(\n Right(mockNftPayload),\n );\n\n // WHEN\n const result = await nftContextFieldLoader.loadField(customField);\n\n // THEN\n expect(mockNftDataSource.getNftInfosPayload).toHaveBeenCalledWith({\n address: \"0xdeadbeef\",\n chainId: 137,\n });\n expect(result).toEqual({\n type: ClearSignContextType.NFT,\n payload: mockNftPayload,\n });\n });\n\n it(\"should preserve error message from NFT data source\", async () => {\n // GIVEN\n const specificError = new Error(\"Network timeout error\");\n vi.spyOn(mockNftDataSource, \"getNftInfosPayload\").mockResolvedValue(\n Left(specificError),\n );\n\n // WHEN\n const result =\n await nftContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: specificError,\n });\n });\n\n it(\"should handle empty NFT payload\", async () => {\n // GIVEN\n const emptyPayload = \"\";\n vi.spyOn(mockNftDataSource, \"getNftInfosPayload\").mockResolvedValue(\n Right(emptyPayload),\n );\n\n // WHEN\n const result =\n await nftContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.NFT,\n payload: emptyPayload,\n });\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAG5B,OAAS,yBAAAC,MAA6B,qCACtC,OAAS,wBAAAC,MAA4B,kCAErC,SAAS,wBAAyB,IAAM,CACtC,MAAMC,EAAmC,CACvC,mBAAoB,GAAG,GAAG,EAC1B,oBAAqB,GAAG,GAAG,CAC7B,EACMC,EAAwB,IAAIH,EAAsBE,CAAiB,EAEnEE,EAAuB,CAC3B,QAAS,EACT,QAAS,oBACX,EAEMC,EAAiB,qBAEvB,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,SAAS,YAAa,IAAM,CAC1B,GAAG,yCAA0C,IAAM,CAEjD,MAAMC,EAAa,CACjB,QAAS,EACT,QAAS,oBACX,EAGA,OACEH,EAAsB,UAAUG,EAAYL,EAAqB,GAAG,CACtE,EAAE,KAAK,EAAI,CACb,CAAC,EAED,SAAS,yCAA0C,IAAM,CACvD,MAAMM,EAAgB,CACpB,CAAE,KAAM,OAAQ,MAAO,IAAK,EAC5B,CAAE,KAAM,YAAa,MAAO,MAAU,EACtC,CAAE,KAAM,SAAU,MAAO,SAAU,EACnC,CAAE,KAAM,SAAU,MAAO,GAAI,EAC7B,CAAE,KAAM,UAAW,MAAO,EAAK,EAC/B,CAAE,KAAM,QAAS,MAAO,CAAC,CAAE,EAC3B,C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ACX,EACA,GAAG,MAAMF,EAAmB,oBAAoB,EAAE,kBAChDH,EAAMM,CAAc,CACtB,EAGA,MAAMK,EAAS,MAAMP,EAAsB,UAAUQ,CAAW,EAGhE,OAAOT,EAAkB,kBAAkB,EAAE,qBAAqB,CAChE,QAAS,aACT,QAAS,GACX,CAAC,EACD,OAAOQ,CAAM,EAAE,QAAQ,CACrB,KAAMT,EAAqB,IAC3B,QAASI,CACX,CAAC,CACH,CAAC,EAED,GAAG,qDAAsD,SAAY,CAEnE,MAAMO,EAAgB,IAAI,MAAM,uBAAuB,EACvD,GAAG,MAAMV,EAAmB,oBAAoB,EAAE,kBAChDJ,EAAKc,CAAa,CACpB,EAGA,MAAMF,EACJ,MAAMP,EAAsB,UAAUC,CAAoB,EAG5D,OAAOM,CAAM,EAAE,QAAQ,CACrB,KAAMT,EAAqB,MAC3B,MAAOW,CACT,CAAC,CACH,CAAC,EAED,GAAG,kCAAmC,SAAY,CAEhD,MAAMC,EAAe,GACrB,GAAG,MAAMX,EAAmB,oBAAoB,EAAE,kBAChDH,EAAMc,CAAY,CACpB,EAGA,MAAMH,EACJ,MAAMP,EAAsB,UAAUC,CAAoB,EAG5D,OAAOM,CAAM,EAAE,QAAQ,CACrB,KAAMT,EAAqB,IAC3B,QAASY,CACX,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["Left", "Right", "NftContextFieldLoader", "ClearSignContextType", "mockNftDataSource", "nftContextFieldLoader", "mockTransactionField", "mockNftPayload", "validField", "invalidFields", "value", "error", "result", "customField", "specificError", "emptyPayload"]
7
+ }
@@ -1,2 +1,2 @@
1
- var y=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var c=(i,e,r,t)=>{for(var n=t>1?void 0:t?x(e,r):e,a=i.length-1,l;a>=0;a--)(l=i[a])&&(n=(t?l(e,r,n):l(n))||n);return t&&n&&y(e,r,n),n},f=(i,e)=>(r,t)=>e(r,t,i);import{isHexaString as m}from"@ledgerhq/device-management-kit";import{inject as S,injectable as h}from"inversify";import{nftTypes as F}from"../../nft/di/nftTypes";import{ClearSignContextType as o}from"../../shared/model/ClearSignContext";var u=(a=>(a.Approve="0x095ea7b3",a.SetApprovalForAll="0xa22cb465",a.TransferFrom="0x23b872dd",a.SafeTransferFrom="0x42842e0e",a.SafeTransferFromWithData="0xb88d4fde",a))(u||{}),g=(t=>(t.SetApprovalForAll="0xa22cb465",t.SafeTransferFrom="0xf242432a",t.SafeBatchTransferFrom="0x2eb2c2d6",t))(g||{});const I=[...Object.values(u),...Object.values(g)];let d=class{_dataSource;constructor(e){this._dataSource=e}async load(e){const r=[];if(!e.to||!e.data||e.data==="0x")return[];const t=e.data.slice(0,10);if(!m(t))return[{type:o.ERROR,error:new Error("Invalid selector")}];if(!this.isSelectorSupported(t))return[];const a=(await this._dataSource.getSetPluginPayload({chainId:e.chainId,address:e.to,selector:t})).caseOf({Left:s=>({type:o.ERROR,error:s}),Right:s=>({type:o.PLUGIN,payload:s})});if(a.type===o.ERROR)return[a];r.push(a);const p=(await this._dataSource.getNftInfosPayload({chainId:e.chainId,address:e.to})).caseOf({Left:s=>({type:o.ERROR,error:s}),Right:s=>({type:o.NFT,payload:s})});return p.type===o.ERROR?[p]:(r.push(p),r)}async loadField(e){return e.type!==o.NFT?null:(await this._dataSource.getNftInfosPayload({address:e.address,chainId:e.chainId})).caseOf({Left:t=>({type:o.ERROR,error:t}),Right:t=>({type:o.NFT,payload:t})})}isSelectorSupported(e){return Object.values(I).includes(e)}};d=c([h(),f(0,S(F.NftDataSource))],d);export{d as NftContextLoader};
1
+ var S=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var d=(l,e,o,t)=>{for(var r=t>1?void 0:t?m(e,o):e,a=l.length-1,i;a>=0;a--)(i=l[a])&&(r=(t?i(e,o,r):i(r))||r);return t&&r&&S(e,o,r),r},u=(l,e)=>(o,t)=>e(o,t,l);import{isHexaString as x}from"@ledgerhq/device-management-kit";import{inject as h,injectable as I}from"inversify";import{nftTypes as b}from"../../nft/di/nftTypes";import{ClearSignContextType as n}from"../../shared/model/ClearSignContext";var g=(a=>(a.Approve="0x095ea7b3",a.SetApprovalForAll="0xa22cb465",a.TransferFrom="0x23b872dd",a.SafeTransferFrom="0x42842e0e",a.SafeTransferFromWithData="0xb88d4fde",a))(g||{}),y=(t=>(t.SetApprovalForAll="0xa22cb465",t.SafeTransferFrom="0xf242432a",t.SafeBatchTransferFrom="0x2eb2c2d6",t))(y||{});const N=[...Object.values(g),...Object.values(y)],v=[n.PLUGIN,n.NFT];let c=class{_dataSource;constructor(e){this._dataSource=e}canHandle(e,o){return typeof e=="object"&&e!==null&&"to"in e&&"selector"in e&&"chainId"in e&&typeof e.chainId=="number"&&x(e.to)&&e.to!=="0x"&&x(e.selector)&&this.isSelectorSupported(e.selector)&&v.every(t=>o.includes(t))}async load(e){const o=[],{to:t,selector:r,chainId:a}=e,f=(await this._dataSource.getSetPluginPayload({chainId:a,address:t,selector:r})).caseOf({Left:s=>({type:n.ERROR,error:s}),Right:s=>({type:n.PLUGIN,payload:s})});if(f.type===n.ERROR)return[f];o.push(f);const p=(await this._dataSource.getNftInfosPayload({chainId:a,address:t})).caseOf({Left:s=>({type:n.ERROR,error:s}),Right:s=>({type:n.NFT,payload:s})});return p.type===n.ERROR?[p]:(o.push(p),o)}isSelectorSupported(e){return Object.values(N).includes(e)}};c=d([I(),u(0,h(b.NftDataSource))],c);export{c as NftContextLoader};
2
2
  //# sourceMappingURL=NftContextLoader.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/nft/domain/NftContextLoader.ts"],
4
- "sourcesContent": ["import { HexaString, isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport type { NftDataSource } from \"@/nft/data/NftDataSource\";\nimport { nftTypes } from \"@/nft/di/nftTypes\";\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport {\n TransactionContext,\n TransactionFieldContext,\n} from \"@/shared/model/TransactionContext\";\n\nenum ERC721_SUPPORTED_SELECTOR {\n Approve = \"0x095ea7b3\",\n SetApprovalForAll = \"0xa22cb465\",\n TransferFrom = \"0x23b872dd\",\n SafeTransferFrom = \"0x42842e0e\",\n SafeTransferFromWithData = \"0xb88d4fde\",\n}\n\nenum ERC1155_SUPPORTED_SELECTOR {\n SetApprovalForAll = \"0xa22cb465\",\n SafeTransferFrom = \"0xf242432a\",\n SafeBatchTransferFrom = \"0x2eb2c2d6\",\n}\n\nconst SUPPORTED_SELECTORS: HexaString[] = [\n ...Object.values(ERC721_SUPPORTED_SELECTOR),\n ...Object.values(ERC1155_SUPPORTED_SELECTOR),\n];\n\n@injectable()\nexport class NftContextLoader implements ContextLoader {\n private _dataSource: NftDataSource;\n\n constructor(@inject(nftTypes.NftDataSource) dataSource: NftDataSource) {\n this._dataSource = dataSource;\n }\n\n async load(transaction: TransactionContext): Promise<ClearSignContext[]> {\n const responses: ClearSignContext[] = [];\n\n if (!transaction.to || !transaction.data || transaction.data === \"0x\") {\n return [];\n }\n\n const selector = transaction.data.slice(0, 10);\n\n if (!isHexaString(selector)) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ];\n }\n\n if (!this.isSelectorSupported(selector)) {\n return [];\n }\n\n // EXAMPLE:\n // https://nft.api.live.ledger.com/v1/ethereum/1/contracts/0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D/plugin-selector/0x095ea7b3\n const getPluginPayloadResponse = await this._dataSource.getSetPluginPayload(\n {\n chainId: transaction.chainId,\n address: transaction.to,\n selector,\n },\n );\n\n const pluginPayload = getPluginPayloadResponse.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.PLUGIN,\n payload: value,\n }),\n });\n\n if (pluginPayload.type === ClearSignContextType.ERROR) {\n return [pluginPayload];\n }\n\n responses.push(pluginPayload);\n\n const getNftInfosPayloadResponse =\n await this._dataSource.getNftInfosPayload({\n chainId: transaction.chainId,\n address: transaction.to,\n });\n\n const nftInfosPayload = getNftInfosPayloadResponse.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.NFT,\n payload: value,\n }),\n });\n\n if (nftInfosPayload.type === ClearSignContextType.ERROR) {\n return [nftInfosPayload];\n }\n\n responses.push(nftInfosPayload);\n\n return responses;\n }\n\n async loadField(\n field: TransactionFieldContext,\n ): Promise<ClearSignContext | null> {\n if (field.type !== ClearSignContextType.NFT) {\n return null;\n }\n const payload = await this._dataSource.getNftInfosPayload({\n address: field.address,\n chainId: field.chainId,\n });\n return payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.NFT,\n payload: value,\n }),\n });\n }\n\n private isSelectorSupported(selector: HexaString) {\n return Object.values(SUPPORTED_SELECTORS).includes(selector);\n }\n}\n"],
5
- "mappings": "iOAAA,OAAqB,gBAAAA,MAAoB,kCACzC,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YAGnC,OAAS,YAAAC,MAAgB,oBAEzB,OAEE,wBAAAC,MACK,kCAMP,IAAKC,OACHA,EAAA,QAAU,aACVA,EAAA,kBAAoB,aACpBA,EAAA,aAAe,aACfA,EAAA,iBAAmB,aACnBA,EAAA,yBAA2B,aALxBA,OAAA,IAQAC,OACHA,EAAA,kBAAoB,aACpBA,EAAA,iBAAmB,aACnBA,EAAA,sBAAwB,aAHrBA,OAAA,IAML,MAAMC,EAAoC,CACxC,GAAG,OAAO,OAAOF,CAAyB,EAC1C,GAAG,OAAO,OAAOC,CAA0B,CAC7C,EAGO,IAAME,EAAN,KAAgD,CAC7C,YAER,YAA4CC,EAA2B,CACrE,KAAK,Y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,MAAAE,CACF,GACA,MAAQC,IAA6B,CACnC,KAAMH,EAAqB,IAC3B,QAASG,CACX,EACF,CAAC,CACH,CAEQ,oBAAoBL,EAAsB,CAChD,OAAO,OAAO,OAAOL,CAAmB,EAAE,SAASK,CAAQ,CAC7D,CACF,EA3GaJ,EAANY,EAAA,CADNC,EAAW,EAIGC,EAAA,EAAAC,EAAOC,EAAS,aAAa,IAH/BhB",
6
- "names": ["isHexaString", "inject", "injectable", "nftTypes", "ClearSignContextType", "ERC721_SUPPORTED_SELECTOR", "ERC1155_SUPPORTED_SELECTOR", "SUPPORTED_SELECTORS", "NftContextLoader", "dataSource", "transaction", "responses", "selector", "isHexaString", "ClearSignContextType", "pluginPayload", "error", "value", "nftInfosPayload", "field", "__decorateClass", "injectable", "__decorateParam", "inject", "nftTypes"]
4
+ "sourcesContent": ["import { HexaString, isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport type { NftDataSource } from \"@/nft/data/NftDataSource\";\nimport { nftTypes } from \"@/nft/di/nftTypes\";\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\n\nexport type NftContextInput = {\n to: HexaString;\n selector: HexaString;\n chainId: number;\n};\n\nenum ERC721_SUPPORTED_SELECTOR {\n Approve = \"0x095ea7b3\",\n SetApprovalForAll = \"0xa22cb465\",\n TransferFrom = \"0x23b872dd\",\n SafeTransferFrom = \"0x42842e0e\",\n SafeTransferFromWithData = \"0xb88d4fde\",\n}\n\nenum ERC1155_SUPPORTED_SELECTOR {\n SetApprovalForAll = \"0xa22cb465\",\n SafeTransferFrom = \"0xf242432a\",\n SafeBatchTransferFrom = \"0x2eb2c2d6\",\n}\n\nconst SUPPORTED_SELECTORS: HexaString[] = [\n ...Object.values(ERC721_SUPPORTED_SELECTOR),\n ...Object.values(ERC1155_SUPPORTED_SELECTOR),\n];\n\nconst SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.PLUGIN,\n ClearSignContextType.NFT,\n];\n\n@injectable()\nexport class NftContextLoader implements ContextLoader<NftContextInput> {\n private _dataSource: NftDataSource;\n\n constructor(@inject(nftTypes.NftDataSource) dataSource: NftDataSource) {\n this._dataSource = dataSource;\n }\n\n canHandle(\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ): input is NftContextInput {\n return (\n typeof input === \"object\" &&\n input !== null &&\n \"to\" in input &&\n \"selector\" in input &&\n \"chainId\" in input &&\n typeof input.chainId === \"number\" &&\n isHexaString(input.to) &&\n input.to !== \"0x\" &&\n isHexaString(input.selector) &&\n this.isSelectorSupported(input.selector) &&\n SUPPORTED_TYPES.every((type) => expectedTypes.includes(type))\n );\n }\n\n async load(input: NftContextInput): Promise<ClearSignContext[]> {\n const responses: ClearSignContext[] = [];\n const { to, selector, chainId } = input;\n\n // EXAMPLE:\n // https://nft.api.live.ledger.com/v1/ethereum/1/contracts/0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D/plugin-selector/0x095ea7b3\n const getPluginPayloadResponse = await this._dataSource.getSetPluginPayload(\n {\n chainId,\n address: to,\n selector,\n },\n );\n\n const pluginPayload = getPluginPayloadResponse.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.PLUGIN,\n payload: value,\n }),\n });\n\n if (pluginPayload.type === ClearSignContextType.ERROR) {\n return [pluginPayload];\n }\n\n responses.push(pluginPayload);\n\n const getNftInfosPayloadResponse =\n await this._dataSource.getNftInfosPayload({\n chainId,\n address: to,\n });\n\n const nftInfosPayload = getNftInfosPayloadResponse.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.NFT,\n payload: value,\n }),\n });\n\n if (nftInfosPayload.type === ClearSignContextType.ERROR) {\n return [nftInfosPayload];\n }\n\n responses.push(nftInfosPayload);\n\n return responses;\n }\n\n private isSelectorSupported(selector: HexaString) {\n return Object.values(SUPPORTED_SELECTORS).includes(selector);\n }\n}\n"],
5
+ "mappings": "iOAAA,OAAqB,gBAAAA,MAAoB,kCACzC,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YAGnC,OAAS,YAAAC,MAAgB,oBAEzB,OAEE,wBAAAC,MACK,kCAQP,IAAKC,OACHA,EAAA,QAAU,aACVA,EAAA,kBAAoB,aACpBA,EAAA,aAAe,aACfA,EAAA,iBAAmB,aACnBA,EAAA,yBAA2B,aALxBA,OAAA,IAQAC,OACHA,EAAA,kBAAoB,aACpBA,EAAA,iBAAmB,aACnBA,EAAA,sBAAwB,aAHrBA,OAAA,IAML,MAAMC,EAAoC,CACxC,GAAG,OAAO,OAAOF,CAAyB,EAC1C,GAAG,OAAO,OAAOC,CAA0B,CAC7C,EAEME,EAA0C,CAC9CC,EAAqB,OACrBA,EAAqB,GACvB,EAGO,IAAMC,EAAN,KAAiE,CAC9D,YAER,YAA4CC,EAA2B,CACrE,KAAK,YAAcA,CACrB,CAEA,UACEC,EACAC,EAC0B,CAC1B,OACE,OAAOD,GAAU,UACjBA,IAAU,MACV,OAAQA,GACR,aAAcA,GACd,YAAaA,GACb,OAAOA,EAAM,SAAY,UACzBE,EAAaF,EAAM,EAAE,GACrBA,EAAM,KAAO,MACbE,EAAaF,EAAM,QAAQ,GAC3B,KAAK,oBAAoBA,EAAM,QAAQ,GACvCJ,EAAgB,MAAOO,GAASF,EAAc,SAASE,CAAI,CAAC,CAEhE,CAEA,MAAM,KAAKH,EAAqD,CAC9D,MAAMI,EAAgC,CAAC,EACjC,CAAE,GAAAC,EAAI,SAAAC,EAAU,QAAAC,CAAQ,EAAIP,EAY5BQ,GAR2B,MAAM,KAAK,YAAY,oBACtD,CACE,QAAAD,EACA,QAASF,EACT,SAAAC,CACF,CACF,GAE+C,OAAO,CACpD,KAAOG,IAA6B,CAClC,KAAMZ,EAAqB,MAC3B,MAAAY,CACF,GACA,MAAQC,IAA6B,CACnC,KAAMb,EAAqB,OAC3B,QAASa,CACX,EACF,CAAC,EAED,GAAIF,EAAc,OAASX,EAAqB,MAC9C,MAAO,CAACW,CAAa,EAGvBJ,EAAU,KAAKI,CAAa,EAQ5B,MAAMG,GALJ,MAAM,KAAK,YAAY,mBAAmB,CACxC,QAAAJ,EACA,QAASF,CACX,CAAC,GAEgD,OAAO,CACxD,KAAOI,IAA6B,CAClC,KAAMZ,EAAqB,MAC3B,MAAAY,CACF,GACA,MAAQC,IAA6B,CACnC,KAAMb,EAAqB,IAC3B,QAASa,CACX,EACF,CAAC,EAED,OAAIC,EAAgB,OAASd,EAAqB,MACzC,CAACc,CAAe,GAGzBP,EAAU,KAAKO,CAAe,EAEvBP,EACT,CAEQ,oBAAoBE,EAAsB,CAChD,OAAO,OAAO,OAAOX,CAAmB,EAAE,SAASW,CAAQ,CAC7D,CACF,EAtFaR,EAANc,EAAA,CADNC,EAAW,EAIGC,EAAA,EAAAC,EAAOC,EAAS,aAAa,IAH/BlB",
6
+ "names": ["isHexaString", "inject", "injectable", "nftTypes", "ClearSignContextType", "ERC721_SUPPORTED_SELECTOR", "ERC1155_SUPPORTED_SELECTOR", "SUPPORTED_SELECTORS", "SUPPORTED_TYPES", "ClearSignContextType", "NftContextLoader", "dataSource", "input", "expectedTypes", "isHexaString", "type", "responses", "to", "selector", "chainId", "pluginPayload", "error", "value", "nftInfosPayload", "__decorateClass", "injectable", "__decorateParam", "inject", "nftTypes"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{Left as c,Right as s}from"purify-ts";import{NftContextLoader as l}from"../../nft/domain/NftContextLoader";import{ClearSignContextType as o}from"../../shared/model/ClearSignContext";describe("NftContextLoader",()=>{const n=vi.fn(),r=vi.fn();let d,e;beforeEach(()=>{vi.restoreAllMocks(),d={getNftInfosPayload:n,getSetPluginPayload:r},e=new l(d)}),describe("load function",()=>{it("should return an empty array if no dest",async()=>{const t={to:void 0,data:"0x01"},a=await e.load(t);expect(a).toEqual([])}),it("should return an empty array if undefined data",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:void 0},a=await e.load(t);expect(a).toEqual([])}),it("should return an empty array if empty data",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x"},a=await e.load(t);expect(a).toEqual([])}),it("should return an empty array if selector not supported",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x095ea7b20000000000000"},a=await e.load(t);expect(a).toEqual([])}),it("should return an error when transaction data is not a valid hex string",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"notahexstring"},a=await e.load(t);expect(a).toEqual([{type:o.ERROR,error:new Error("Invalid selector")}])}),it("should return an error when datasource get plugin payload return a Left",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x095ea7b30000000000000"};r.mockResolvedValueOnce(c(new Error("error")));const a=await e.load(t);expect(a).toEqual([{type:o.ERROR,error:new Error("error")}])}),it("should return an error when datasource get nft infos payload return a Left",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x095ea7b30000000000000"};r.mockResolvedValueOnce(s("payload1")),n.mockResolvedValueOnce(c(new Error("error")));const a=await e.load(t);expect(a).toEqual([{type:o.ERROR,error:new Error("error")}])}),it("should return a response",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x095ea7b30000000000000"};r.mockResolvedValueOnce(s("payload1")),n.mockResolvedValueOnce(s("payload2"));const a=await e.load(t);expect(a).toEqual([{type:o.PLUGIN,payload:"payload1"},{type:o.NFT,payload:"payload2"}])})}),describe("loadField function",()=>{it("should return an error when field type if not supported",async()=>{const t={type:o.TOKEN,chainId:7,address:"0x1234"},a=await e.loadField(t);expect(a).toEqual(null)}),it("should return a payload",async()=>{const t={type:o.NFT,chainId:7,address:"0x1234"};n.mockResolvedValueOnce(s("payload"));const a=await e.loadField(t);expect(a).toEqual({type:o.NFT,payload:"payload"})}),it("should return an error when unable to fetch the datasource",async()=>{const t={type:o.NFT,chainId:7,address:"0x1234"};n.mockResolvedValueOnce(c(new Error("error")));const a=await e.loadField(t);expect(a).toEqual({type:o.ERROR,error:new Error("error")})})})});
1
+ import{Left as d,Right as l}from"purify-ts";import{NftContextLoader as i}from"../../nft/domain/NftContextLoader";import{ClearSignContextType as t}from"../../shared/model/ClearSignContext";describe("NftContextLoader",()=>{const r=vi.fn(),a=vi.fn();let c,o;beforeEach(()=>{vi.restoreAllMocks(),c={getNftInfosPayload:r,getSetPluginPayload:a},o=new i(c)}),describe("canHandle function",()=>{const e={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",selector:"0x095ea7b3",chainId:1};it("should return true for valid input",()=>{expect(o.canHandle(e,[t.NFT,t.PLUGIN])).toBe(!0)}),it("should return false for invalid expected type",()=>{expect(o.canHandle(e,[t.TOKEN])).toBe(!1),expect(o.canHandle(e,[t.PLUGIN])).toBe(!1),expect(o.canHandle(e,[t.NFT])).toBe(!1)}),it.each([[null,"null input"],[void 0,"undefined input"],[{},"empty object"],["string","string input"],[123,"number input"],[{...e,to:void 0},"missing to"],[{...e,selector:void 0},"missing selector"],[{...e,chainId:void 0},"missing chainId"],[{...e,to:"invalid-hex"},"invalid to hex"],[{...e,to:"0x"},"empty to hex"],[{...e,selector:"invalid-hex"},"invalid selector hex"],[{...e,selector:"0x"},"empty selector hex"],[{...e,selector:"0x00000000"},"different selector"],[{...e,chainId:"1"},"string chainId"],[{...e,chainId:null},"null chainId"]])("should return false for %s",(n,s)=>{expect(o.canHandle(n,[t.NFT,t.PLUGIN])).toBe(!1)})}),describe("load function",()=>{it("should return an error when datasource get plugin payload return a Left",async()=>{const e={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",selector:"0x095ea7b3",chainId:1};a.mockResolvedValueOnce(d(new Error("error")));const n=await o.load(e);expect(n).toEqual([{type:t.ERROR,error:new Error("error")}])}),it("should return an error when datasource get nft infos payload return a Left",async()=>{const e={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",selector:"0x095ea7b3",chainId:1};a.mockResolvedValueOnce(l("payload1")),r.mockResolvedValueOnce(d(new Error("error")));const n=await o.load(e);expect(n).toEqual([{type:t.ERROR,error:new Error("error")}])}),it("should return a response",async()=>{const e={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",selector:"0x095ea7b3",chainId:1};a.mockResolvedValueOnce(l("payload1")),r.mockResolvedValueOnce(l("payload2"));const n=await o.load(e);expect(n).toEqual([{type:t.PLUGIN,payload:"payload1"},{type:t.NFT,payload:"payload2"}])})})});
2
2
  //# sourceMappingURL=NftContextLoader.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/nft/domain/NftContextLoader.test.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { type NftDataSource } from \"@/nft/data/NftDataSource\";\nimport { NftContextLoader } from \"@/nft/domain/NftContextLoader\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"@/shared/model/TransactionContext\";\n\ndescribe(\"NftContextLoader\", () => {\n const spyGetNftInfosPayload = vi.fn();\n const spyGetPluginPayload = vi.fn();\n let mockDataSource: NftDataSource;\n let loader: NftContextLoader;\n\n beforeEach(() => {\n vi.restoreAllMocks();\n mockDataSource = {\n getNftInfosPayload: spyGetNftInfosPayload,\n getSetPluginPayload: spyGetPluginPayload,\n };\n loader = new NftContextLoader(mockDataSource);\n });\n\n describe(\"load function\", () => {\n it(\"should return an empty array if no dest\", async () => {\n const transaction = { to: undefined, data: \"0x01\" } as TransactionContext;\n\n const result = await loader.load(transaction);\n\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if undefined data\", async () => {\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: undefined,\n } as unknown as TransactionContext;\n\n const result = await loader.load(transaction);\n\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if empty data\", async () => {\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x\",\n } as unknown as TransactionContext;\n\n const result = await loader.load(transaction);\n\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if selector not supported\", async () => {\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x095ea7b20000000000000\",\n } as unknown as TransactionContext;\n\n const result = await loader.load(transaction);\n\n expect(result).toEqual([]);\n });\n\n it(\"should return an error when transaction data is not a valid hex string\", async () => {\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"notahexstring\",\n } as TransactionContext;\n\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ]);\n });\n\n it(\"should return an error when datasource get plugin payload return a Left\", async () => {\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x095ea7b30000000000000\",\n } as TransactionContext;\n spyGetPluginPayload.mockResolvedValueOnce(Left(new Error(\"error\")));\n\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n ]);\n });\n\n it(\"should return an error when datasource get nft infos payload return a Left\", async () => {\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x095ea7b30000000000000\",\n } as TransactionContext;\n spyGetPluginPayload.mockResolvedValueOnce(Right(\"payload1\"));\n spyGetNftInfosPayload.mockResolvedValueOnce(Left(new Error(\"error\")));\n\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n ]);\n });\n\n it(\"should return a response\", async () => {\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x095ea7b30000000000000\",\n } as TransactionContext;\n spyGetPluginPayload.mockResolvedValueOnce(Right(\"payload1\"));\n spyGetNftInfosPayload.mockResolvedValueOnce(Right(\"payload2\"));\n\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.PLUGIN,\n payload: \"payload1\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload2\",\n },\n ]);\n });\n });\n\n describe(\"loadField function\", () => {\n it(\"should return an error when field type if not supported\", async () => {\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TOKEN,\n chainId: 7,\n address: \"0x1234\",\n };\n\n const result = await loader.loadField(field);\n\n expect(result).toEqual(null);\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.NFT,\n chainId: 7,\n address: \"0x1234\",\n };\n\n // WHEN\n spyGetNftInfosPayload.mockResolvedValueOnce(Right(\"payload\"));\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.NFT,\n payload: \"payload\",\n });\n });\n\n it(\"should return an error when unable to fetch the datasource\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.NFT,\n chainId: 7,\n address: \"0x1234\",\n };\n\n // WHEN\n spyGetNftInfosPayload.mockResolvedValueOnce(Left(new Error(\"error\")));\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n });\n });\n });\n});\n"],
5
- "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAG5B,OAAS,oBAAAC,MAAwB,gCACjC,OAAS,wBAAAC,MAA4B,kCAMrC,SAAS,mBAAoB,IAAM,CACjC,MAAMC,EAAwB,GAAG,GAAG,EAC9BC,EAAsB,GAAG,GAAG,EAClC,IAAIC,EACAC,EAEJ,WAAW,IAAM,CACf,GAAG,gBAAgB,EACnBD,EAAiB,CACf,mBAAoBF,EACpB,oBAAqBC,CACvB,EACAE,EAAS,IA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S,SACX,CAAC,CACH,CAAC,EAED,GAAG,6DAA8D,SAAY,CAE3E,MAAMO,EAAiC,CACrC,KAAMP,EAAqB,IAC3B,QAAS,EACT,QAAS,QACX,EAGAC,EAAsB,sBAAsBJ,EAAK,IAAI,MAAM,OAAO,CAAC,CAAC,EACpE,MAAMS,EAAS,MAAMF,EAAO,UAAUG,CAAK,EAG3C,OAAOD,CAAM,EAAE,QAAQ,CACrB,KAAMN,EAAqB,MAC3B,MAAO,IAAI,MAAM,OAAO,CAC1B,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["Left", "Right", "NftContextLoader", "ClearSignContextType", "spyGetNftInfosPayload", "spyGetPluginPayload", "mockDataSource", "loader", "transaction", "result", "field"]
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { type NftDataSource } from \"@/nft/data/NftDataSource\";\nimport {\n type NftContextInput,\n NftContextLoader,\n} from \"@/nft/domain/NftContextLoader\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\n\ndescribe(\"NftContextLoader\", () => {\n const spyGetNftInfosPayload = vi.fn();\n const spyGetPluginPayload = vi.fn();\n let mockDataSource: NftDataSource;\n let loader: NftContextLoader;\n\n beforeEach(() => {\n vi.restoreAllMocks();\n mockDataSource = {\n getNftInfosPayload: spyGetNftInfosPayload,\n getSetPluginPayload: spyGetPluginPayload,\n };\n loader = new NftContextLoader(mockDataSource);\n });\n\n describe(\"canHandle function\", () => {\n const validInput: NftContextInput = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n selector: \"0x095ea7b3\",\n chainId: 1,\n };\n\n it(\"should return true for valid input\", () => {\n expect(\n loader.canHandle(validInput, [\n ClearSignContextType.NFT,\n ClearSignContextType.PLUGIN,\n ]),\n ).toBe(true);\n });\n\n it(\"should return false for invalid expected type\", () => {\n expect(loader.canHandle(validInput, [ClearSignContextType.TOKEN])).toBe(\n false,\n );\n expect(loader.canHandle(validInput, [ClearSignContextType.PLUGIN])).toBe(\n false,\n );\n expect(loader.canHandle(validInput, [ClearSignContextType.NFT])).toBe(\n false,\n );\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, to: undefined }, \"missing to\"],\n [{ ...validInput, selector: undefined }, \"missing selector\"],\n [{ ...validInput, chainId: undefined }, \"missing chainId\"],\n [{ ...validInput, to: \"invalid-hex\" }, \"invalid to hex\"],\n [{ ...validInput, to: \"0x\" }, \"empty to hex\"],\n [{ ...validInput, selector: \"invalid-hex\" }, \"invalid selector hex\"],\n [{ ...validInput, selector: \"0x\" }, \"empty selector hex\"],\n [{ ...validInput, selector: \"0x00000000\" }, \"different selector\"],\n [{ ...validInput, chainId: \"1\" }, \"string chainId\"],\n [{ ...validInput, chainId: null }, \"null chainId\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(\n loader.canHandle(input, [\n ClearSignContextType.NFT,\n ClearSignContextType.PLUGIN,\n ]),\n ).toBe(false);\n });\n });\n\n describe(\"load function\", () => {\n it(\"should return an error when datasource get plugin payload return a Left\", async () => {\n const input: NftContextInput = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n selector: \"0x095ea7b3\",\n chainId: 1,\n };\n spyGetPluginPayload.mockResolvedValueOnce(Left(new Error(\"error\")));\n\n const result = await loader.load(input);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n ]);\n });\n\n it(\"should return an error when datasource get nft infos payload return a Left\", async () => {\n const input: NftContextInput = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n selector: \"0x095ea7b3\",\n chainId: 1,\n };\n spyGetPluginPayload.mockResolvedValueOnce(Right(\"payload1\"));\n spyGetNftInfosPayload.mockResolvedValueOnce(Left(new Error(\"error\")));\n\n const result = await loader.load(input);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n ]);\n });\n\n it(\"should return a response\", async () => {\n const input: NftContextInput = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n selector: \"0x095ea7b3\",\n chainId: 1,\n };\n spyGetPluginPayload.mockResolvedValueOnce(Right(\"payload1\"));\n spyGetNftInfosPayload.mockResolvedValueOnce(Right(\"payload2\"));\n\n const result = await loader.load(input);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.PLUGIN,\n payload: \"payload1\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload2\",\n },\n ]);\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAG5B,OAEE,oBAAAC,MACK,gCACP,OAAS,wBAAAC,MAA4B,kCAErC,SAAS,mBAAoB,IAAM,CACjC,MAAMC,EAAwB,GAAG,GAAG,EAC9BC,EAAsB,GAAG,GAAG,EAClC,IAAIC,EACAC,EAEJ,WAAW,IAAM,CACf,GAAG,gBAAgB,EACnBD,EAAiB,CACf,mBAAoBF,EACpB,oBAAqBC,CACvB,EACAE,EAAS,IAAIL,EAAiBI,CAAc,CAC9C,CAAC,EAED,SAAS,qBAAsB,IAAM,CACnC,MAAME,EAA8B,CAClC,GAAI,6CACJ,SAAU,aACV,QAAS,CACX,EAEA,GAAG,qCAAsC,IAAM,CAC7C,OACED,EAAO,UAAUC,EAAY,CAC3BL,EAAqB,IACrBA,EAAqB,MACvB,CAAC,CACH,EAAE,KAAK,EAAI,CACb,CAAC,EAED,GAAG,gDAAiD,IAAM,CACxD,OAAOI,EAAO,UAAUC,EAAY,CAACL,EAAqB,KAAK,CAAC,CAAC,EAAE,KACjE,EACF,EACA,OAAOI,EAAO,UAAUC,EAAY,CAACL,EAAqB,MAAM,CAAC,CAAC,EAAE,KAClE,EACF,EACA,OAAOI,EAAO,UAAUC,EAAY,CAACL,EAAqB,GAAG,CAAC,CAAC,EAAE,KAC/D,EACF,CACF,CAAC,EAED,GAAG,KAAK,CAC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AC3F,MAAMM,EAAyB,CAC7B,GAAI,6CACJ,SAAU,aACV,QAAS,CACX,EACAJ,EAAoB,sBAAsBJ,EAAM,UAAU,CAAC,EAC3DG,EAAsB,sBAAsBJ,EAAK,IAAI,MAAM,OAAO,CAAC,CAAC,EAEpE,MAAMW,EAAS,MAAMJ,EAAO,KAAKE,CAAK,EAEtC,OAAOE,CAAM,EAAE,QAAQ,CACrB,CACE,KAAMR,EAAqB,MAC3B,MAAO,IAAI,MAAM,OAAO,CAC1B,CACF,CAAC,CACH,CAAC,EAED,GAAG,2BAA4B,SAAY,CACzC,MAAMM,EAAyB,CAC7B,GAAI,6CACJ,SAAU,aACV,QAAS,CACX,EACAJ,EAAoB,sBAAsBJ,EAAM,UAAU,CAAC,EAC3DG,EAAsB,sBAAsBH,EAAM,UAAU,CAAC,EAE7D,MAAMU,EAAS,MAAMJ,EAAO,KAAKE,CAAK,EAEtC,OAAOE,CAAM,EAAE,QAAQ,CACrB,CACE,KAAMR,EAAqB,OAC3B,QAAS,UACX,EACA,CACE,KAAMA,EAAqB,IAC3B,QAAS,UACX,CACF,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["Left", "Right", "NftContextLoader", "ClearSignContextType", "spyGetNftInfosPayload", "spyGetPluginPayload", "mockDataSource", "loader", "validInput", "input", "_description", "result"]
7
7
  }