@ledgerhq/context-module 1.4.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (387) hide show
  1. package/lib/cjs/package.json +2 -2
  2. package/lib/cjs/src/ContextModule.js +1 -1
  3. package/lib/cjs/src/ContextModule.js.map +1 -1
  4. package/lib/cjs/src/ContextModuleBuilder.js +1 -1
  5. package/lib/cjs/src/ContextModuleBuilder.js.map +3 -3
  6. package/lib/cjs/src/ContextModuleBuilder.test.js +1 -1
  7. package/lib/cjs/src/ContextModuleBuilder.test.js.map +3 -3
  8. package/lib/cjs/src/DefaultContextModule.js +1 -1
  9. package/lib/cjs/src/DefaultContextModule.js.map +3 -3
  10. package/lib/cjs/src/DefaultContextModule.test.js +1 -1
  11. package/lib/cjs/src/DefaultContextModule.test.js.map +2 -2
  12. package/lib/cjs/src/config/di/configModuleFactory.js +1 -1
  13. package/lib/cjs/src/config/di/configModuleFactory.js.map +3 -3
  14. package/lib/cjs/src/config/model/ContextModuleConfig.js +1 -1
  15. package/lib/cjs/src/config/model/ContextModuleConfig.js.map +1 -1
  16. package/lib/cjs/src/di.js +1 -1
  17. package/lib/cjs/src/di.js.map +3 -3
  18. package/lib/cjs/src/dynamic-network/data/DynamicNetworkDataSource.js +2 -0
  19. package/lib/cjs/src/dynamic-network/data/DynamicNetworkDataSource.js.map +7 -0
  20. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.js +2 -0
  21. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.js.map +7 -0
  22. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js +2 -0
  23. package/lib/cjs/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js.map +7 -0
  24. package/lib/cjs/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.js +2 -0
  25. package/lib/cjs/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.js.map +7 -0
  26. package/lib/cjs/src/dynamic-network/di/dynamicNetworkModuleFactory.js +2 -0
  27. package/lib/cjs/src/dynamic-network/di/dynamicNetworkModuleFactory.js.map +7 -0
  28. package/lib/cjs/src/dynamic-network/di/dynamicNetworkTypes.js +2 -0
  29. package/lib/cjs/src/dynamic-network/di/dynamicNetworkTypes.js.map +7 -0
  30. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.js +2 -0
  31. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +7 -0
  32. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js +2 -0
  33. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +7 -0
  34. package/lib/cjs/src/dynamic-network/model/DynamicNetworkConfiguration.js +2 -0
  35. package/lib/cjs/src/dynamic-network/model/DynamicNetworkConfiguration.js.map +7 -0
  36. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js +1 -1
  37. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js.map +2 -2
  38. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js +1 -1
  39. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +3 -3
  40. package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js +1 -1
  41. package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js.map +3 -3
  42. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js +1 -1
  43. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js.map +3 -3
  44. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
  45. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +3 -3
  46. package/lib/cjs/src/index.js +1 -1
  47. package/lib/cjs/src/index.js.map +2 -2
  48. package/lib/cjs/src/nft/data/HttpNftDataSource.js +1 -1
  49. package/lib/cjs/src/nft/data/HttpNftDataSource.js.map +3 -3
  50. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js +1 -1
  51. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js.map +3 -3
  52. package/lib/cjs/src/nft/di/nftModuleFactory.js +1 -1
  53. package/lib/cjs/src/nft/di/nftModuleFactory.js.map +3 -3
  54. package/lib/cjs/src/nft/domain/NftContextLoader.js +1 -1
  55. package/lib/cjs/src/nft/domain/NftContextLoader.js.map +3 -3
  56. package/lib/cjs/src/nft/domain/NftContextLoader.test.js +1 -1
  57. package/lib/cjs/src/nft/domain/NftContextLoader.test.js.map +2 -2
  58. package/lib/cjs/src/pki/di/pkiModuleFactory.js +1 -1
  59. package/lib/cjs/src/pki/di/pkiModuleFactory.js.map +3 -3
  60. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.js.map +2 -2
  61. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js +1 -1
  62. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +3 -3
  63. package/lib/cjs/src/shared/constant/HttpHeaders.js +1 -1
  64. package/lib/cjs/src/shared/constant/HttpHeaders.js.map +1 -1
  65. package/lib/cjs/src/shared/model/ClearSignContext.js +1 -1
  66. package/lib/cjs/src/shared/model/ClearSignContext.js.map +2 -2
  67. package/lib/cjs/src/shared/model/SolanaTransactionContext.js +2 -0
  68. package/lib/cjs/src/shared/model/SolanaTransactionContext.js.map +7 -0
  69. package/lib/cjs/src/shared/model/TransactionSubset.js +1 -1
  70. package/lib/cjs/src/shared/model/TransactionSubset.js.map +1 -1
  71. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js +2 -0
  72. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +7 -0
  73. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +2 -0
  74. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +7 -0
  75. package/lib/cjs/src/solana/data/SolanaDataSource.js +2 -0
  76. package/lib/cjs/src/solana/data/SolanaDataSource.js.map +7 -0
  77. package/lib/cjs/src/solana/di/SolanaContextModuleFactory.js +2 -0
  78. package/lib/cjs/src/solana/di/SolanaContextModuleFactory.js.map +7 -0
  79. package/lib/cjs/src/solana/di/solanaContextTypes.js +2 -0
  80. package/lib/cjs/src/solana/di/solanaContextTypes.js.map +7 -0
  81. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.js +2 -0
  82. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.js.map +7 -0
  83. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.test.js +2 -0
  84. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.test.js.map +7 -0
  85. package/lib/cjs/src/solana/domain/SolanaContextLoader.js +2 -0
  86. package/lib/cjs/src/solana/domain/SolanaContextLoader.js.map +7 -0
  87. package/lib/cjs/src/solana/domain/solanaContextTypes.js +2 -0
  88. package/lib/cjs/src/solana/domain/solanaContextTypes.js.map +7 -0
  89. package/lib/cjs/src/token/di/tokenModuleFactory.js +1 -1
  90. package/lib/cjs/src/token/di/tokenModuleFactory.js.map +3 -3
  91. package/lib/cjs/src/token/domain/TokenContextLoader.js +1 -1
  92. package/lib/cjs/src/token/domain/TokenContextLoader.js.map +3 -3
  93. package/lib/cjs/src/token/domain/TokenContextLoader.test.js +1 -1
  94. package/lib/cjs/src/token/domain/TokenContextLoader.test.js.map +2 -2
  95. package/lib/cjs/src/transaction/data/HttpProxyDataSource.js +2 -0
  96. package/lib/cjs/src/transaction/data/HttpProxyDataSource.js.map +7 -0
  97. package/lib/cjs/src/transaction/data/HttpProxyDataSource.test.js +2 -0
  98. package/lib/cjs/src/transaction/data/HttpProxyDataSource.test.js.map +7 -0
  99. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js +1 -1
  100. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js.map +2 -2
  101. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js +1 -1
  102. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js.map +3 -3
  103. package/lib/cjs/src/transaction/data/{CalldataDto.js.map → dto/CalldataDto.js.map} +1 -1
  104. package/lib/cjs/src/transaction/data/dto/ProxyDelegateCallDto.js +2 -0
  105. package/lib/cjs/src/transaction/data/dto/ProxyDelegateCallDto.js.map +7 -0
  106. package/lib/cjs/src/transaction/data/dto/ProxyImplementationAddressDto.js +2 -0
  107. package/lib/cjs/src/transaction/data/dto/ProxyImplementationAddressDto.js.map +7 -0
  108. package/lib/cjs/src/transaction/di/transactionModuleFactory.js +1 -1
  109. package/lib/cjs/src/transaction/di/transactionModuleFactory.js.map +3 -3
  110. package/lib/cjs/src/transaction/di/transactionTypes.js +1 -1
  111. package/lib/cjs/src/transaction/di/transactionTypes.js.map +2 -2
  112. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js +1 -1
  113. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js.map +3 -3
  114. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js +1 -1
  115. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js.map +3 -3
  116. package/lib/cjs/src/transaction/model/ProxyDelegateCall.js +2 -0
  117. package/lib/cjs/src/transaction/model/ProxyDelegateCall.js.map +7 -0
  118. package/lib/cjs/src/transaction/model/ProxyImplementationAddress.js +2 -0
  119. package/lib/cjs/src/transaction/model/ProxyImplementationAddress.js.map +7 -0
  120. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
  121. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js.map +2 -2
  122. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  123. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +3 -3
  124. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js +1 -1
  125. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js.map +3 -3
  126. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
  127. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js.map +3 -3
  128. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
  129. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +2 -2
  130. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
  131. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js.map +2 -2
  132. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  133. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
  134. package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js +1 -1
  135. package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js.map +3 -3
  136. package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js +1 -1
  137. package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js.map +3 -3
  138. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js +1 -1
  139. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js.map +3 -3
  140. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
  141. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js.map +2 -2
  142. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.js +1 -1
  143. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.js.map +2 -2
  144. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.test.js +1 -1
  145. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.test.js.map +2 -2
  146. package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js +1 -1
  147. package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js.map +3 -3
  148. package/lib/esm/package.json +2 -2
  149. package/lib/esm/src/ContextModuleBuilder.js +1 -1
  150. package/lib/esm/src/ContextModuleBuilder.js.map +3 -3
  151. package/lib/esm/src/ContextModuleBuilder.test.js +1 -1
  152. package/lib/esm/src/ContextModuleBuilder.test.js.map +3 -3
  153. package/lib/esm/src/DefaultContextModule.js +1 -1
  154. package/lib/esm/src/DefaultContextModule.js.map +3 -3
  155. package/lib/esm/src/DefaultContextModule.test.js +1 -1
  156. package/lib/esm/src/DefaultContextModule.test.js.map +2 -2
  157. package/lib/esm/src/config/di/configModuleFactory.js +1 -1
  158. package/lib/esm/src/config/di/configModuleFactory.js.map +3 -3
  159. package/lib/esm/src/di.js +1 -1
  160. package/lib/esm/src/di.js.map +3 -3
  161. package/lib/esm/src/dynamic-network/data/DynamicNetworkDataSource.js +1 -0
  162. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.js +2 -0
  163. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.js.map +7 -0
  164. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js +2 -0
  165. package/lib/esm/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.js.map +7 -0
  166. package/lib/esm/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.js +1 -0
  167. package/lib/esm/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.js.map +7 -0
  168. package/lib/esm/src/dynamic-network/di/dynamicNetworkModuleFactory.js +2 -0
  169. package/lib/esm/src/dynamic-network/di/dynamicNetworkModuleFactory.js.map +7 -0
  170. package/lib/esm/src/dynamic-network/di/dynamicNetworkTypes.js +2 -0
  171. package/lib/esm/src/dynamic-network/di/dynamicNetworkTypes.js.map +7 -0
  172. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js +2 -0
  173. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +7 -0
  174. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js +2 -0
  175. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +7 -0
  176. package/lib/esm/src/dynamic-network/model/DynamicNetworkConfiguration.js +1 -0
  177. package/lib/esm/src/dynamic-network/model/DynamicNetworkConfiguration.js.map +7 -0
  178. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js +1 -1
  179. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js.map +3 -3
  180. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js +1 -1
  181. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +3 -3
  182. package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js +1 -1
  183. package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js.map +3 -3
  184. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js +1 -1
  185. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js.map +3 -3
  186. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
  187. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +3 -3
  188. package/lib/esm/src/index.js +1 -1
  189. package/lib/esm/src/index.js.map +2 -2
  190. package/lib/esm/src/nft/data/HttpNftDataSource.js +1 -1
  191. package/lib/esm/src/nft/data/HttpNftDataSource.js.map +3 -3
  192. package/lib/esm/src/nft/data/HttpNftDataSource.test.js +1 -1
  193. package/lib/esm/src/nft/data/HttpNftDataSource.test.js.map +3 -3
  194. package/lib/esm/src/nft/di/nftModuleFactory.js +1 -1
  195. package/lib/esm/src/nft/di/nftModuleFactory.js.map +3 -3
  196. package/lib/esm/src/nft/domain/NftContextLoader.js +1 -1
  197. package/lib/esm/src/nft/domain/NftContextLoader.js.map +3 -3
  198. package/lib/esm/src/nft/domain/NftContextLoader.test.js +1 -1
  199. package/lib/esm/src/nft/domain/NftContextLoader.test.js.map +2 -2
  200. package/lib/esm/src/pki/di/pkiModuleFactory.js +1 -1
  201. package/lib/esm/src/pki/di/pkiModuleFactory.js.map +3 -3
  202. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.js.map +2 -2
  203. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js +1 -1
  204. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +3 -3
  205. package/lib/esm/src/shared/constant/HttpHeaders.js +1 -1
  206. package/lib/esm/src/shared/constant/HttpHeaders.js.map +1 -1
  207. package/lib/esm/src/shared/model/ClearSignContext.js +1 -1
  208. package/lib/esm/src/shared/model/ClearSignContext.js.map +2 -2
  209. package/lib/esm/src/shared/model/SolanaTransactionContext.js +1 -0
  210. package/lib/esm/src/shared/model/SolanaTransactionContext.js.map +7 -0
  211. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js +2 -0
  212. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +7 -0
  213. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +2 -0
  214. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +7 -0
  215. package/lib/esm/src/solana/data/SolanaDataSource.js +1 -0
  216. package/lib/esm/src/solana/data/SolanaDataSource.js.map +7 -0
  217. package/lib/esm/src/solana/di/SolanaContextModuleFactory.js +2 -0
  218. package/lib/esm/src/solana/di/SolanaContextModuleFactory.js.map +7 -0
  219. package/lib/esm/src/solana/di/solanaContextTypes.js +2 -0
  220. package/lib/esm/src/solana/di/solanaContextTypes.js.map +7 -0
  221. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.js +2 -0
  222. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.js.map +7 -0
  223. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.test.js +2 -0
  224. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.test.js.map +7 -0
  225. package/lib/esm/src/solana/domain/SolanaContextLoader.js +1 -0
  226. package/lib/esm/src/solana/domain/SolanaContextLoader.js.map +7 -0
  227. package/lib/esm/src/solana/domain/solanaContextTypes.js +1 -0
  228. package/lib/esm/src/solana/domain/solanaContextTypes.js.map +7 -0
  229. package/lib/esm/src/token/di/tokenModuleFactory.js +1 -1
  230. package/lib/esm/src/token/di/tokenModuleFactory.js.map +3 -3
  231. package/lib/esm/src/token/domain/TokenContextLoader.js +1 -1
  232. package/lib/esm/src/token/domain/TokenContextLoader.js.map +3 -3
  233. package/lib/esm/src/token/domain/TokenContextLoader.test.js +1 -1
  234. package/lib/esm/src/token/domain/TokenContextLoader.test.js.map +2 -2
  235. package/lib/esm/src/transaction/data/HttpProxyDataSource.js +2 -0
  236. package/lib/esm/src/transaction/data/HttpProxyDataSource.js.map +7 -0
  237. package/lib/esm/src/transaction/data/HttpProxyDataSource.test.js +2 -0
  238. package/lib/esm/src/transaction/data/HttpProxyDataSource.test.js.map +7 -0
  239. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js +1 -1
  240. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js.map +3 -3
  241. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js +1 -1
  242. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js.map +3 -3
  243. package/lib/esm/src/transaction/data/dto/CalldataDto.js.map +7 -0
  244. package/lib/esm/src/transaction/data/dto/ProxyDelegateCallDto.js +1 -0
  245. package/lib/esm/src/transaction/data/dto/ProxyDelegateCallDto.js.map +7 -0
  246. package/lib/esm/src/transaction/data/dto/ProxyImplementationAddressDto.js +1 -0
  247. package/lib/esm/src/transaction/data/dto/ProxyImplementationAddressDto.js.map +7 -0
  248. package/lib/esm/src/transaction/di/transactionModuleFactory.js +1 -1
  249. package/lib/esm/src/transaction/di/transactionModuleFactory.js.map +3 -3
  250. package/lib/esm/src/transaction/di/transactionTypes.js +1 -1
  251. package/lib/esm/src/transaction/di/transactionTypes.js.map +2 -2
  252. package/lib/esm/src/transaction/domain/TransactionContextLoader.js +1 -1
  253. package/lib/esm/src/transaction/domain/TransactionContextLoader.js.map +3 -3
  254. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js +1 -1
  255. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js.map +3 -3
  256. package/lib/esm/src/transaction/model/ProxyDelegateCall.js +1 -0
  257. package/lib/esm/src/transaction/model/ProxyDelegateCall.js.map +7 -0
  258. package/lib/esm/src/transaction/model/ProxyImplementationAddress.js +1 -0
  259. package/lib/esm/src/transaction/model/ProxyImplementationAddress.js.map +7 -0
  260. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
  261. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js.map +3 -3
  262. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  263. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +3 -3
  264. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js +1 -1
  265. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js.map +3 -3
  266. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
  267. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js.map +3 -3
  268. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js +1 -1
  269. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.test.js.map +2 -2
  270. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
  271. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js.map +3 -3
  272. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  273. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
  274. package/lib/esm/src/typed-data/di/typedDataModuleFactory.js +1 -1
  275. package/lib/esm/src/typed-data/di/typedDataModuleFactory.js.map +3 -3
  276. package/lib/esm/src/uniswap/di/uniswapModuleFactory.js +1 -1
  277. package/lib/esm/src/uniswap/di/uniswapModuleFactory.js.map +3 -3
  278. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js +1 -1
  279. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js.map +3 -3
  280. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
  281. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js.map +2 -2
  282. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.js +1 -1
  283. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.js.map +3 -3
  284. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.test.js +1 -1
  285. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.test.js.map +3 -3
  286. package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js +1 -1
  287. package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js.map +3 -3
  288. package/lib/types/src/ContextModule.d.ts +3 -0
  289. package/lib/types/src/ContextModule.d.ts.map +1 -1
  290. package/lib/types/src/ContextModuleBuilder.d.ts +18 -3
  291. package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -1
  292. package/lib/types/src/DefaultContextModule.d.ts +5 -0
  293. package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
  294. package/lib/types/src/config/di/configModuleFactory.d.ts.map +1 -1
  295. package/lib/types/src/config/model/ContextModuleConfig.d.ts +6 -0
  296. package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -1
  297. package/lib/types/src/di.d.ts.map +1 -1
  298. package/lib/types/src/dynamic-network/data/DynamicNetworkDataSource.d.ts +6 -0
  299. package/lib/types/src/dynamic-network/data/DynamicNetworkDataSource.d.ts.map +1 -0
  300. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.d.ts +13 -0
  301. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.d.ts.map +1 -0
  302. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.d.ts +2 -0
  303. package/lib/types/src/dynamic-network/data/HttpDynamicNetworkDataSource.test.d.ts.map +1 -0
  304. package/lib/types/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.d.ts +14 -0
  305. package/lib/types/src/dynamic-network/data/dto/DynamicNetworkApiResponseDto.d.ts.map +1 -0
  306. package/lib/types/src/dynamic-network/di/dynamicNetworkModuleFactory.d.ts +3 -0
  307. package/lib/types/src/dynamic-network/di/dynamicNetworkModuleFactory.d.ts.map +1 -0
  308. package/lib/types/src/dynamic-network/di/dynamicNetworkTypes.d.ts +5 -0
  309. package/lib/types/src/dynamic-network/di/dynamicNetworkTypes.d.ts.map +1 -0
  310. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts +15 -0
  311. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts.map +1 -0
  312. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.test.d.ts +2 -0
  313. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.test.d.ts.map +1 -0
  314. package/lib/types/src/dynamic-network/model/DynamicNetworkConfiguration.d.ts +16 -0
  315. package/lib/types/src/dynamic-network/model/DynamicNetworkConfiguration.d.ts.map +1 -0
  316. package/lib/types/src/external-plugin/data/HttpExternalPluginDataSource.d.ts.map +1 -1
  317. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.d.ts +1 -1
  318. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.d.ts.map +1 -1
  319. package/lib/types/src/index.d.ts +2 -0
  320. package/lib/types/src/index.d.ts.map +1 -1
  321. package/lib/types/src/nft/data/HttpNftDataSource.d.ts +3 -0
  322. package/lib/types/src/nft/data/HttpNftDataSource.d.ts.map +1 -1
  323. package/lib/types/src/nft/domain/NftContextLoader.d.ts +1 -1
  324. package/lib/types/src/nft/domain/NftContextLoader.d.ts.map +1 -1
  325. package/lib/types/src/pki/domain/DefaultPkiCertificateLoader.d.ts.map +1 -1
  326. package/lib/types/src/shared/constant/HttpHeaders.d.ts +1 -1
  327. package/lib/types/src/shared/constant/HttpHeaders.d.ts.map +1 -1
  328. package/lib/types/src/shared/model/ClearSignContext.d.ts +3 -0
  329. package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -1
  330. package/lib/types/src/shared/model/SolanaTransactionContext.d.ts +11 -0
  331. package/lib/types/src/shared/model/SolanaTransactionContext.d.ts.map +1 -0
  332. package/lib/types/src/shared/model/TransactionSubset.d.ts +3 -3
  333. package/lib/types/src/shared/model/TransactionSubset.d.ts.map +1 -1
  334. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.d.ts +13 -0
  335. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.d.ts.map +1 -0
  336. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.test.d.ts +2 -0
  337. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.test.d.ts.map +1 -0
  338. package/lib/types/src/solana/data/SolanaDataSource.d.ts +12 -0
  339. package/lib/types/src/solana/data/SolanaDataSource.d.ts.map +1 -0
  340. package/lib/types/src/solana/di/SolanaContextModuleFactory.d.ts +3 -0
  341. package/lib/types/src/solana/di/SolanaContextModuleFactory.d.ts.map +1 -0
  342. package/lib/types/src/solana/di/solanaContextTypes.d.ts +5 -0
  343. package/lib/types/src/solana/di/solanaContextTypes.d.ts.map +1 -0
  344. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.d.ts +11 -0
  345. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.d.ts.map +1 -0
  346. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.test.d.ts +2 -0
  347. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.test.d.ts.map +1 -0
  348. package/lib/types/src/solana/domain/SolanaContextLoader.d.ts +5 -0
  349. package/lib/types/src/solana/domain/SolanaContextLoader.d.ts.map +1 -0
  350. package/lib/types/src/solana/domain/solanaContextTypes.d.ts +27 -0
  351. package/lib/types/src/solana/domain/solanaContextTypes.d.ts.map +1 -0
  352. package/lib/types/src/token/domain/TokenContextLoader.d.ts +1 -1
  353. package/lib/types/src/token/domain/TokenContextLoader.d.ts.map +1 -1
  354. package/lib/types/src/transaction/data/HttpProxyDataSource.d.ts +33 -0
  355. package/lib/types/src/transaction/data/HttpProxyDataSource.d.ts.map +1 -0
  356. package/lib/types/src/transaction/data/HttpProxyDataSource.test.d.ts +2 -0
  357. package/lib/types/src/transaction/data/HttpProxyDataSource.test.d.ts.map +1 -0
  358. package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts.map +1 -1
  359. package/lib/types/src/transaction/data/dto/CalldataDto.d.ts.map +1 -0
  360. package/lib/types/src/transaction/data/dto/ProxyDelegateCallDto.d.ts +5 -0
  361. package/lib/types/src/transaction/data/dto/ProxyDelegateCallDto.d.ts.map +1 -0
  362. package/lib/types/src/transaction/data/dto/ProxyImplementationAddressDto.d.ts +6 -0
  363. package/lib/types/src/transaction/data/dto/ProxyImplementationAddressDto.d.ts.map +1 -0
  364. package/lib/types/src/transaction/di/transactionModuleFactory.d.ts.map +1 -1
  365. package/lib/types/src/transaction/di/transactionTypes.d.ts +1 -0
  366. package/lib/types/src/transaction/di/transactionTypes.d.ts.map +1 -1
  367. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts +4 -2
  368. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts.map +1 -1
  369. package/lib/types/src/transaction/model/ProxyDelegateCall.d.ts +5 -0
  370. package/lib/types/src/transaction/model/ProxyDelegateCall.d.ts.map +1 -0
  371. package/lib/types/src/transaction/model/ProxyImplementationAddress.d.ts +4 -0
  372. package/lib/types/src/transaction/model/ProxyImplementationAddress.d.ts.map +1 -0
  373. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts.map +1 -1
  374. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts +1 -1
  375. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts.map +1 -1
  376. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts.map +1 -1
  377. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts.map +1 -1
  378. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts +1 -1
  379. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts.map +1 -1
  380. package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.d.ts.map +1 -1
  381. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  382. package/package.json +6 -6
  383. package/lib/types/src/transaction/data/CalldataDto.d.ts.map +0 -1
  384. /package/lib/cjs/src/transaction/data/{CalldataDto.js → dto/CalldataDto.js} +0 -0
  385. /package/lib/esm/src/{transaction/data/CalldataDto.js.map → dynamic-network/data/DynamicNetworkDataSource.js.map} +0 -0
  386. /package/lib/esm/src/transaction/data/{CalldataDto.js → dto/CalldataDto.js} +0 -0
  387. /package/lib/types/src/transaction/data/{CalldataDto.d.ts → dto/CalldataDto.d.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../../../src/transaction/data/CalldataDto.ts"],
3
+ "sources": ["../../../../../../src/transaction/data/dto/CalldataDto.ts"],
4
4
  "sourcesContent": ["export interface CalldataDto {\n descriptors_calldata: {\n [address: string]: {\n [selector: string]: CalldataDescriptor;\n };\n };\n}\n\nexport type CalldataDescriptor = CalldataDescriptorV1; // For now only V1 descriptors are supported\n\nexport interface CalldataDescriptorV1 {\n type: \"calldata\";\n version: \"v1\";\n transaction_info: CalldataTransactionInfoV1;\n enums: CalldataEnumV1;\n fields: CalldataFieldV1[];\n}\n\nexport type CalldataTransactionDescriptor = {\n data: string;\n signatures: CalldataSignatures;\n};\n\nexport type CalldataSignatures =\n | {\n prod: string;\n test?: string;\n }\n | {\n prod?: string;\n test: string;\n };\n\nexport interface CalldataTransactionInfoV1 {\n descriptor: CalldataTransactionDescriptor;\n}\n\nexport interface CalldataEnumV1 {\n [id: number]: {\n [value: number]: CalldataTransactionDescriptor;\n };\n}\n\nexport interface CalldataFieldV1 {\n descriptor: string;\n param: CalldataDescriptorParam;\n}\n\nexport type CalldataDescriptorParam =\n | CalldataDescriptorParamRawV1\n | CalldataDescriptorParamAmountV1\n | CalldataDescriptorParamTokenAmountV1\n | CalldataDescriptorParamNFTV1\n | CalldataDescriptorParamDatetimeV1\n | CalldataDescriptorParamDurationV1\n | CalldataDescriptorParamUnitV1\n | CalldataDescriptorParamEnumV1\n | CalldataDescriptorParamTrustedNameV1;\n\nexport interface CalldataDescriptorParamRawV1 {\n type: \"RAW\";\n value: CalldataDescriptorValueV1;\n}\n\nexport interface CalldataDescriptorParamAmountV1 {\n type: \"AMOUNT\";\n value: CalldataDescriptorValueV1;\n}\n\nexport interface CalldataDescriptorParamTokenAmountV1 {\n type: \"TOKEN_AMOUNT\";\n value: CalldataDescriptorValueV1;\n token?: CalldataDescriptorValueV1;\n}\n\nexport interface CalldataDescriptorParamNFTV1 {\n type: \"NFT\";\n value: CalldataDescriptorValueV1;\n collection: CalldataDescriptorValueV1;\n}\n\nexport interface CalldataDescriptorParamDatetimeV1 {\n type: \"DATETIME\";\n value: CalldataDescriptorValueV1;\n}\n\nexport interface CalldataDescriptorParamDurationV1 {\n type: \"DURATION\";\n value: CalldataDescriptorValueV1;\n}\n\nexport interface CalldataDescriptorParamUnitV1 {\n type: \"UNIT\";\n value: CalldataDescriptorValueV1;\n}\n\nexport interface CalldataDescriptorParamEnumV1 {\n type: \"ENUM\";\n value: CalldataDescriptorValueV1;\n id: number;\n}\n\nexport interface CalldataDescriptorParamTrustedNameV1 {\n type: \"TRUSTED_NAME\";\n value: CalldataDescriptorValueV1;\n types: string[];\n sources: string[];\n}\n\nexport interface CalldataDescriptorValueBinaryPathV1 {\n type: \"path\";\n binary_path:\n | CalldataDescriptorContainerPathV1\n | CalldataDescriptorPathElementsV1;\n type_family: CalldataDescriptorTypeFamilyV1;\n type_size?: number;\n}\n\nexport interface CalldataDescriptorValueConstantV1 {\n type: \"constant\";\n value: string;\n type_family: CalldataDescriptorTypeFamilyV1;\n type_size?: number;\n}\n\nexport type CalldataDescriptorValueV1 =\n | CalldataDescriptorValueBinaryPathV1\n | CalldataDescriptorValueConstantV1;\n\nexport interface CalldataDescriptorContainerPathV1 {\n type: \"CONTAINER\";\n value: CalldataDescriptorContainerPathTypeV1;\n}\n\nexport interface CalldataDescriptorPathElementsV1 {\n type: \"DATA\";\n elements: CalldataDescriptorPathElementV1[];\n}\n\nexport type CalldataDescriptorPathElementV1 =\n | CalldataDescriptorPathElementTupleV1\n | CalldataDescriptorPathElementArrayV1\n | CalldataDescriptorPathElementRefV1\n | CalldataDescriptorPathElementLeafV1\n | CalldataDescriptorPathElementSliceV1;\n\nexport interface CalldataDescriptorPathElementTupleV1 {\n type: \"TUPLE\";\n offset: number;\n}\n\nexport interface CalldataDescriptorPathElementArrayV1 {\n type: \"ARRAY\";\n start?: number;\n end?: number;\n weight: number;\n}\n\nexport interface CalldataDescriptorPathElementRefV1 {\n type: \"REF\";\n}\n\nexport interface CalldataDescriptorPathElementLeafV1 {\n type: \"LEAF\";\n leaf_type: CalldataDescriptorPathLeafTypeV1;\n}\n\nexport interface CalldataDescriptorPathElementSliceV1 {\n type: \"SLICE\";\n start?: number;\n end?: number;\n}\n\nexport type CalldataDescriptorContainerPathTypeV1 = \"FROM\" | \"TO\" | \"VALUE\";\nexport type CalldataDescriptorPathLeafTypeV1 =\n | \"ARRAY_LEAF\"\n | \"TUPLE_LEAF\"\n | \"STATIC_LEAF\"\n | \"DYNAMIC_LEAF\";\nexport type CalldataDescriptorTypeFamilyV1 =\n | \"UINT\"\n | \"INT\"\n | \"UFIXED\"\n | \"FIXED\"\n | \"ADDRESS\"\n | \"BOOL\"\n | \"BYTES\"\n | \"STRING\";\n"],
5
5
  "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
6
  "names": ["CalldataDto_exports", "__toCommonJS"]
@@ -0,0 +1,2 @@
1
+ "use strict";var g=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var l=(r,e,i,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of a(e))!d.call(r,s)&&s!==i&&g(r,s,{get:()=>e[s],enumerable:!(t=o(e,s))||t.enumerable});return r};var n=r=>l(g({},"__esModule",{value:!0}),r);var p={};module.exports=n(p);
2
+ //# sourceMappingURL=ProxyDelegateCallDto.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/transaction/data/dto/ProxyDelegateCallDto.ts"],
4
+ "sourcesContent": ["export type ProxyDelegateCallDto = {\n addresses: string[];\n signedDescriptor: string;\n};\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["ProxyDelegateCallDto_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var d=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var a=(r,t,n,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of o(t))!p.call(r,s)&&s!==n&&d(r,s,{get:()=>t[s],enumerable:!(e=i(t,s))||e.enumerable});return r};var m=r=>a(d({},"__esModule",{value:!0}),r);var g={};module.exports=m(g);
2
+ //# sourceMappingURL=ProxyImplementationAddressDto.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/transaction/data/dto/ProxyImplementationAddressDto.ts"],
4
+ "sourcesContent": ["export type ProxyImplementationAddressDto = {\n proxyAddress: string;\n implementationAddress: string;\n standard: string;\n};\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["ProxyImplementationAddressDto_exports", "__toCommonJS"]
7
+ }
@@ -1,2 +1,2 @@
1
- "use strict";var e=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var T=(o,t)=>{for(var r in t)e(o,r,{get:t[r],enumerable:!0})},f=(o,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of d(t))!u.call(o,n)&&n!==r&&e(o,n,{get:()=>t[n],enumerable:!(a=p(t,n))||a.enumerable});return o};var x=o=>f(e({},"__esModule",{value:!0}),o);var _={};T(_,{transactionModuleFactory:()=>C});module.exports=x(_);var c=require("inversify"),s=require("../../transaction/data/HttpTransactionDataSource"),i=require("../../transaction/di/transactionTypes"),m=require("../../transaction/domain/TransactionContextLoader");const C=()=>new c.ContainerModule((o,t,r,a)=>{o(i.transactionTypes.TransactionDataSource).to(s.HttpTransactionDataSource),o(i.transactionTypes.TransactionContextLoader).to(m.TransactionContextLoader)});0&&(module.exports={transactionModuleFactory});
1
+ "use strict";var e=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var T=(o,t)=>{for(var a in t)e(o,a,{get:t[a],enumerable:!0})},y=(o,t,a,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of f(t))!x.call(o,r)&&r!==a&&e(o,r,{get:()=>t[r],enumerable:!(c=u(t,r))||c.enumerable});return o};var D=o=>y(e({},"__esModule",{value:!0}),o);var C={};T(C,{transactionModuleFactory:()=>S});module.exports=D(C);var i=require("inversify"),m=require("../../transaction/data/HttpProxyDataSource"),p=require("../../transaction/data/HttpTransactionDataSource"),n=require("../../transaction/di/transactionTypes"),s=require("../../transaction/domain/TransactionContextLoader");const S=()=>new i.ContainerModule(({bind:o})=>{o(n.transactionTypes.TransactionDataSource).to(p.HttpTransactionDataSource),o(n.transactionTypes.TransactionContextLoader).to(s.TransactionContextLoader),o(n.transactionTypes.ProxyDataSource).to(m.HttpProxyDataSource)});0&&(module.exports={transactionModuleFactory});
2
2
  //# sourceMappingURL=transactionModuleFactory.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/transaction/di/transactionModuleFactory.ts"],
4
- "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpTransactionDataSource } from \"@/transaction/data/HttpTransactionDataSource\";\nimport { transactionTypes } from \"@/transaction/di/transactionTypes\";\nimport { TransactionContextLoader } from \"@/transaction/domain/TransactionContextLoader\";\n\nexport const transactionModuleFactory = () =>\n new ContainerModule((bind, _unbind, _isBound, _rebind) => {\n bind(transactionTypes.TransactionDataSource).to(HttpTransactionDataSource);\n bind(transactionTypes.TransactionContextLoader).to(\n TransactionContextLoader,\n );\n });\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,qBAEhCC,EAA0C,wDAC1CC,EAAiC,6CACjCC,EAAyC,yDAElC,MAAML,EAA2B,IACtC,IAAI,kBAAgB,CAACM,EAAMC,EAASC,EAAUC,IAAY,CACxDH,EAAK,mBAAiB,qBAAqB,EAAE,GAAG,2BAAyB,EACzEA,EAAK,mBAAiB,wBAAwB,EAAE,GAC9C,0BACF,CACF,CAAC",
6
- "names": ["transactionModuleFactory_exports", "__export", "transactionModuleFactory", "__toCommonJS", "import_inversify", "import_HttpTransactionDataSource", "import_transactionTypes", "import_TransactionContextLoader", "bind", "_unbind", "_isBound", "_rebind"]
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpProxyDataSource } from \"@/transaction/data/HttpProxyDataSource\";\nimport { HttpTransactionDataSource } from \"@/transaction/data/HttpTransactionDataSource\";\nimport { transactionTypes } from \"@/transaction/di/transactionTypes\";\nimport { TransactionContextLoader } from \"@/transaction/domain/TransactionContextLoader\";\n\nexport const transactionModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(transactionTypes.TransactionDataSource).to(HttpTransactionDataSource);\n bind(transactionTypes.TransactionContextLoader).to(\n TransactionContextLoader,\n );\n bind(transactionTypes.ProxyDataSource).to(HttpProxyDataSource);\n });\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,qBAEhCC,EAAoC,kDACpCC,EAA0C,wDAC1CC,EAAiC,6CACjCC,EAAyC,yDAElC,MAAMN,EAA2B,IACtC,IAAI,kBAAgB,CAAC,CAAE,KAAAO,CAAK,IAAM,CAChCA,EAAK,mBAAiB,qBAAqB,EAAE,GAAG,2BAAyB,EACzEA,EAAK,mBAAiB,wBAAwB,EAAE,GAC9C,0BACF,EACAA,EAAK,mBAAiB,eAAe,EAAE,GAAG,qBAAmB,CAC/D,CAAC",
6
+ "names": ["transactionModuleFactory_exports", "__export", "transactionModuleFactory", "__toCommonJS", "import_inversify", "import_HttpProxyDataSource", "import_HttpTransactionDataSource", "import_transactionTypes", "import_TransactionContextLoader", "bind"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var r=Object.defineProperty;var e=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var T=(a,o)=>{for(var n in o)r(a,n,{get:o[n],enumerable:!0})},S=(a,o,n,c)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of s(o))!i.call(a,t)&&t!==n&&r(a,t,{get:()=>o[t],enumerable:!(c=e(o,t))||c.enumerable});return a};var x=a=>S(r({},"__esModule",{value:!0}),a);var b={};T(b,{transactionTypes:()=>y});module.exports=x(b);const y={TransactionDataSource:Symbol.for("TransactionDataSource"),TransactionContextLoader:Symbol.for("TransactionContextLoader")};0&&(module.exports={transactionTypes});
1
+ "use strict";var n=Object.defineProperty;var e=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var y=(a,o)=>{for(var t in o)n(a,t,{get:o[t],enumerable:!0})},i=(a,o,t,c)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of s(o))!S.call(a,r)&&r!==t&&n(a,r,{get:()=>o[r],enumerable:!(c=e(o,r))||c.enumerable});return a};var x=a=>i(n({},"__esModule",{value:!0}),a);var u={};y(u,{transactionTypes:()=>T});module.exports=x(u);const T={TransactionDataSource:Symbol.for("TransactionDataSource"),TransactionContextLoader:Symbol.for("TransactionContextLoader"),ProxyDataSource:Symbol.for("ProxyDataSource")};0&&(module.exports={transactionTypes});
2
2
  //# sourceMappingURL=transactionTypes.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/transaction/di/transactionTypes.ts"],
4
- "sourcesContent": ["export const transactionTypes = {\n TransactionDataSource: Symbol.for(\"TransactionDataSource\"),\n TransactionContextLoader: Symbol.for(\"TransactionContextLoader\"),\n};\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAmB,CAC9B,sBAAuB,OAAO,IAAI,uBAAuB,EACzD,yBAA0B,OAAO,IAAI,0BAA0B,CACjE",
4
+ "sourcesContent": ["export const transactionTypes = {\n TransactionDataSource: Symbol.for(\"TransactionDataSource\"),\n TransactionContextLoader: Symbol.for(\"TransactionContextLoader\"),\n ProxyDataSource: Symbol.for(\"ProxyDataSource\"),\n};\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAmB,CAC9B,sBAAuB,OAAO,IAAI,uBAAuB,EACzD,yBAA0B,OAAO,IAAI,0BAA0B,EAC/D,gBAAiB,OAAO,IAAI,iBAAiB,CAC/C",
6
6
  "names": ["transactionTypes_exports", "__export", "transactionTypes", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var n=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var g=(r,t)=>{for(var o in t)n(r,o,{get:t[o],enumerable:!0})},D=(r,t,o,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of C(t))!x.call(r,e)&&e!==o&&n(r,e,{get:()=>t[e],enumerable:!(a=p(t,e))||a.enumerable});return r};var R=r=>D(n({},"__esModule",{value:!0}),r),d=(r,t,o,a)=>{for(var e=a>1?void 0:a?p(t,o):t,s=r.length-1,l;s>=0;s--)(l=r[s])&&(e=(a?l(t,o,e):l(e))||e);return a&&e&&n(t,o,e),e},u=(r,t)=>(o,a)=>t(o,a,r);var y={};g(y,{TransactionContextLoader:()=>i});module.exports=R(y);var S=require("@ledgerhq/device-management-kit"),c=require("inversify"),m=require("../../shared/model/ClearSignContext"),f=require("../../transaction/di/transactionTypes");let i=class{constructor(t){this.transactionDataSource=t}async load(t){if(!t.to||!t.data||t.data==="0x")return[];const o=t.data.slice(0,10);return(0,S.isHexaString)(o)?(await this.transactionDataSource.getTransactionDescriptors({deviceModelId:t.deviceModelId,address:t.to,chainId:t.chainId,selector:o})).caseOf({Left:e=>[{type:m.ClearSignContextType.ERROR,error:e}],Right:e=>e}):[{type:m.ClearSignContextType.ERROR,error:new Error("Invalid selector")}]}};i=d([(0,c.injectable)(),u(0,(0,c.inject)(f.transactionTypes.TransactionDataSource))],i);0&&(module.exports={TransactionContextLoader});
1
+ "use strict";var s=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var T=(i,e)=>{for(var r in e)s(i,r,{get:e[r],enumerable:!0})},E=(i,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of P(e))!R.call(i,t)&&t!==r&&s(i,t,{get:()=>e[t],enumerable:!(a=y(e,t))||a.enumerable});return i};var O=i=>E(s({},"__esModule",{value:!0}),i),g=(i,e,r,a)=>{for(var t=a>1?void 0:a?y(e,r):e,o=i.length-1,n;o>=0;o--)(n=i[o])&&(t=(a?n(e,r,t):n(t))||t);return a&&t&&s(e,r,t),t},C=(i,e)=>(r,a)=>e(r,a,i);var h={};T(h,{TransactionContextLoader:()=>c});module.exports=O(h);var l=require("@ledgerhq/device-management-kit"),d=require("inversify"),S=require("../../pki/di/pkiTypes"),D=require("../../pki/model/KeyId"),x=require("../../pki/model/KeyUsage"),f=require("../../shared/model/ClearSignContext"),k=require("../../transaction/di/transactionTypes");let c=class{constructor(e,r){this.transactionDataSource=e;this.certificateLoader=r}async load(e){if(e.deviceModelId===l.DeviceModelId.NANO_S)return[];const{to:r,data:a,selector:t,chainId:o,deviceModelId:n}=e;if(r===void 0||a==="0x")return[];if(!(0,l.isHexaString)(t))return[{type:f.ClearSignContextType.ERROR,error:new Error("Invalid selector")}];const p=void 0,v=r;let u;p&&(u=await this.certificateLoader.loadCertificate({keyId:D.KeyId.CalCalldataKey,keyUsage:x.KeyUsage.Calldata,targetDevice:e.deviceModelId}));const L=p?[{type:f.ClearSignContextType.PROXY_DELEGATE_CALL,payload:p,certificate:u}]:[],I=(await this.transactionDataSource.getTransactionDescriptors({deviceModelId:n,address:v,chainId:o,selector:t})).caseOf({Left:m=>[{type:f.ClearSignContextType.ERROR,error:m}],Right:m=>m});return[...L,...I]}};c=g([(0,d.injectable)(),C(0,(0,d.inject)(k.transactionTypes.TransactionDataSource)),C(1,(0,d.inject)(S.pkiTypes.PkiCertificateLoader))],c);0&&(module.exports={TransactionContextLoader});
2
2
  //# sourceMappingURL=TransactionContextLoader.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/transaction/domain/TransactionContextLoader.ts"],
4
- "sourcesContent": ["import { isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { TransactionContext } from \"@/shared/model/TransactionContext\";\nimport type { TransactionDataSource } from \"@/transaction/data/TransactionDataSource\";\nimport { transactionTypes } from \"@/transaction/di/transactionTypes\";\n\n@injectable()\nexport class TransactionContextLoader implements ContextLoader {\n constructor(\n @inject(transactionTypes.TransactionDataSource)\n private transactionDataSource: TransactionDataSource,\n ) {}\n\n async load(transaction: TransactionContext): Promise<ClearSignContext[]> {\n if (!transaction.to || !transaction.data || transaction.data === \"0x\") {\n return [];\n }\n\n const selector = transaction.data.slice(0, 10);\n\n if (!isHexaString(selector)) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ];\n }\n\n const result = await this.transactionDataSource.getTransactionDescriptors({\n deviceModelId: transaction.deviceModelId,\n address: transaction.to,\n chainId: transaction.chainId,\n selector,\n });\n\n return result.caseOf({\n Left: (error): ClearSignContext[] => [\n {\n type: ClearSignContextType.ERROR,\n error,\n },\n ],\n Right: (contexts): ClearSignContext[] => contexts,\n });\n }\n}\n"],
5
- "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA6B,2CAC7BC,EAAmC,qBAGnCC,EAGO,2CAGPC,EAAiC,6CAG1B,IAAMC,EAAN,KAAwD,CAC7D,YAEUC,EACR,CADQ,2BAAAA,CACP,CAEH,MAAM,KAAKC,EAA8D,CACvE,GAAI,CAACA,EAAY,IAAM,CAACA,EAAY,MAAQA,EAAY,OAAS,KAC/D,MAAO,CAAC,EAGV,MAAMC,EAAWD,EAAY,KAAK,MAAM,EAAG,EAAE,EAE7C,SAAK,gBAAaC,CAAQ,GASX,MAAM,KAAK,sBAAsB,0BAA0B,CACxE,cAAeD,EAAY,cAC3B,QAASA,EAAY,GACrB,QAASA,EAAY,QACrB,SAAAC,CACF,CAAC,GAEa,OAAO,CACnB,KAAOC,GAA8B,CACnC,CACE,KAAM,uBAAqB,MAC3B,MAAAA,CACF,CACF,EACA,MAAQC,GAAiCA,CAC3C,CAAC,EAvBQ,CACL,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,kBAAkB,CACrC,CACF,CAmBJ,CACF,EAvCaL,EAANM,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,mBAAiB,qBAAqB,IAFrCP",
6
- "names": ["TransactionContextLoader_exports", "__export", "TransactionContextLoader", "__toCommonJS", "import_device_management_kit", "import_inversify", "import_ClearSignContext", "import_transactionTypes", "TransactionContextLoader", "transactionDataSource", "transaction", "selector", "error", "contexts", "__decorateClass", "__decorateParam"]
4
+ "sourcesContent": ["import { DeviceModelId, isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport type { PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { TransactionContext } from \"@/shared/model/TransactionContext\";\n//import type { ProxyDataSource } from \"@/transaction/data/HttpProxyDataSource\";\nimport type { TransactionDataSource } from \"@/transaction/data/TransactionDataSource\";\nimport { transactionTypes } from \"@/transaction/di/transactionTypes\";\n\n@injectable()\nexport class TransactionContextLoader implements ContextLoader {\n constructor(\n @inject(transactionTypes.TransactionDataSource)\n private transactionDataSource: TransactionDataSource,\n /*@inject(transactionTypes.ProxyDataSource)\n private _proxyDataSource: ProxyDataSource,*/\n @inject(pkiTypes.PkiCertificateLoader)\n private certificateLoader: PkiCertificateLoader,\n ) {}\n\n async load(ctx: TransactionContext): Promise<ClearSignContext[]> {\n if (ctx.deviceModelId === DeviceModelId.NANO_S) {\n return [];\n }\n\n //TODO add challenge when proxy is enabled\n const { to, data, selector, chainId, deviceModelId } = ctx;\n if (to === undefined || data === \"0x\") {\n return [];\n }\n\n if (!isHexaString(selector)) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ];\n }\n /*\nDISABLE PROXY FOR NOW, to be enabled later\n\n const proxyDelegateCall = await this.proxyDataSource.getProxyDelegateCall({\n calldata: data,\n proxyAddress: to,\n chainId,\n challenge: challenge || \"\",\n });\n\n // get the resolved address from the list of delegate addresses\n // if the transaction.to is not in the list of delegate addresses,\n // return the first element as the resolved address,\n // and undefined as the proxy delegate call descriptor\n // if the transaction.to is in the list of delegate addresses,\n // return the transaction.to as the resolved address,\n // and the proxy delegate call descriptor\n const [resolvedAddress, proxyDelegateCallDescriptor]: [\n string,\n string | undefined,\n ] = proxyDelegateCall.caseOf({\n Left: () => [to!, undefined],\n Right: (proxyData: ProxyDelegateCall): [string, string | undefined] => {\n return [\n proxyData.delegateAddresses.find((address) => address === to) ||\n proxyData.delegateAddresses[0]!,\n proxyData.signedDescriptor,\n ];\n },\n });\n*/\n // TMP Values to be removed when proxy is enabled\n const proxyDelegateCallDescriptor: string | undefined = undefined;\n const resolvedAddress: string | undefined = to;\n\n let certificate: PkiCertificate | undefined = undefined;\n if (proxyDelegateCallDescriptor) {\n certificate = await this.certificateLoader.loadCertificate({\n keyId: KeyId.CalCalldataKey,\n keyUsage: KeyUsage.Calldata,\n targetDevice: ctx.deviceModelId,\n });\n }\n\n const proxyDelegateCallContext: ClearSignContext[] =\n proxyDelegateCallDescriptor\n ? [\n {\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: proxyDelegateCallDescriptor,\n certificate: certificate,\n },\n ]\n : [];\n\n const transactionContexts = (\n await this.transactionDataSource.getTransactionDescriptors({\n deviceModelId,\n address: resolvedAddress,\n chainId,\n selector,\n })\n ).caseOf({\n Left: (error): ClearSignContext[] => [\n {\n type: ClearSignContextType.ERROR,\n error,\n },\n ],\n Right: (contexts): ClearSignContext[] => contexts,\n });\n\n return [...proxyDelegateCallContext, ...transactionContexts];\n }\n}\n"],
5
+ "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4C,2CAC5CC,EAAmC,qBAEnCC,EAAyB,6BAEzBC,EAAsB,6BACtBC,EAAyB,gCAGzBC,EAGO,2CAIPC,EAAiC,6CAG1B,IAAMC,EAAN,KAAwD,CAC7D,YAEUC,EAIAC,EACR,CALQ,2BAAAD,EAIA,uBAAAC,CACP,CAEH,MAAM,KAAKC,EAAsD,CAC/D,GAAIA,EAAI,gBAAkB,gBAAc,OACtC,MAAO,CAAC,EAIV,KAAM,CAAE,GAAAC,EAAI,KAAAC,EAAM,SAAAC,EAAU,QAAAC,EAAS,cAAAC,CAAc,EAAIL,EACvD,GAAIC,IAAO,QAAaC,IAAS,KAC/B,MAAO,CAAC,EAGV,GAAI,IAAC,gBAAaC,CAAQ,EACxB,MAAO,CACL,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,kBAAkB,CACrC,CACF,EAkCF,MAAMG,EAAkD,OAClDC,EAAsCN,EAE5C,IAAIO,EACAF,IACFE,EAAc,MAAM,KAAK,kBAAkB,gBAAgB,CACzD,MAAO,QAAM,eACb,SAAU,WAAS,SACnB,aAAcR,EAAI,aACpB,CAAC,GAGH,MAAMS,EACJH,EACI,CACE,CACE,KAAM,uBAAqB,oBAC3B,QAASA,EACT,YAAaE,CACf,CACF,EACA,CAAC,EAEDE,GACJ,MAAM,KAAK,sBAAsB,0BAA0B,CACzD,cAAAL,EACA,QAASE,EACT,QAAAH,EACA,SAAAD,CACF,CAAC,GACD,OAAO,CACP,KAAOQ,GAA8B,CACnC,CACE,KAAM,uBAAqB,MAC3B,MAAAA,CACF,CACF,EACA,MAAQC,GAAiCA,CAC3C,CAAC,EAED,MAAO,CAAC,GAAGH,EAA0B,GAAGC,CAAmB,CAC7D,CACF,EAvGab,EAANgB,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,mBAAiB,qBAAqB,GAI7CA,EAAA,eAAO,WAAS,oBAAoB,IAN5BjB",
6
+ "names": ["TransactionContextLoader_exports", "__export", "TransactionContextLoader", "__toCommonJS", "import_device_management_kit", "import_inversify", "import_pkiTypes", "import_KeyId", "import_KeyUsage", "import_ClearSignContext", "import_transactionTypes", "TransactionContextLoader", "transactionDataSource", "certificateLoader", "ctx", "to", "data", "selector", "chainId", "deviceModelId", "proxyDelegateCallDescriptor", "resolvedAddress", "certificate", "proxyDelegateCallContext", "transactionContexts", "error", "contexts", "__decorateClass", "__decorateParam"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var r=require("purify-ts"),o=require("../../shared/model/ClearSignContext"),s=require("../../transaction/domain/TransactionContextLoader");describe("TransactionContextLoader",()=>{const n=vi.fn(),c={getTransactionDescriptors:n},e=new s.TransactionContextLoader(c);beforeEach(()=>{vi.clearAllMocks()}),it("should return an empty array if no destination address is provided",async()=>{const a={},t=await e.load(a);expect(t).toEqual([])}),it("should return an empty array if data is undefined",async()=>{const a={to:"0x0"},t=await e.load(a);expect(t).toEqual([])}),it("should return an empty array if no data provided",async()=>{const a={to:"0x0",data:"0x"},t=await e.load(a);expect(t).toEqual([])}),it("should return an error if selector is invalid",async()=>{const a={to:"0x7",chainId:3,data:"0xzf68b302000000000000000000000000000000000000000000000000000000000002"},t=await e.load(a);expect(t).toEqual([{type:o.ClearSignContextType.ERROR,error:new Error("Invalid selector")}])}),it("should return an error if data source fails",async()=>{n.mockResolvedValue((0,r.Left)(new Error("data source error")));const a={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002"},t=await e.load(a);expect(n).toHaveBeenCalledWith({address:"0x7",chainId:3,selector:"0xaf68b302"}),expect(t).toEqual([{type:o.ClearSignContextType.ERROR,error:new Error("data source error")}])}),it("should return the contexts on success",async()=>{n.mockResolvedValue((0,r.Right)([{type:o.ClearSignContextType.TRANSACTION_INFO,payload:"1234567890"},{type:o.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}]));const a={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002"},t=await e.load(a);expect(t).toEqual([{type:o.ClearSignContextType.TRANSACTION_INFO,payload:"1234567890"},{type:o.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])})});
1
+ "use strict";var o=require("purify-ts"),e=require("../../shared/model/ClearSignContext"),c=require("../../transaction/domain/TransactionContextLoader");describe("TransactionContextLoader",()=>{const s=vi.fn(),n=vi.fn(),d={getTransactionDescriptors:s},i={loadCertificate:vi.fn()},r=new c.TransactionContextLoader(d,i);beforeEach(()=>{vi.resetAllMocks()}),it("should return an empty array if no destination address is provided",async()=>{const a={},t=await r.load(a);expect(t).toEqual([])}),it("should return an empty array if no data provided",async()=>{const a={to:"0x0",data:"0x"},t=await r.load(a);expect(t).toEqual([])}),it("should return an error if selector is invalid",async()=>{const a={to:"0x7",chainId:3,data:"0xzf68b302000000000000000000000000000000000000000000000000000000000002"},t=await r.load(a);expect(t).toEqual([{type:e.ClearSignContextType.ERROR,error:new Error("Invalid selector")}])}),it("should return an error if data source fails",async()=>{n.mockResolvedValue((0,o.Left)(new Error("data source error"))),s.mockResolvedValue((0,o.Left)(new Error("data source error")));const a={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await r.load(a);expect(s).toHaveBeenCalledWith({address:"0x7",chainId:3,selector:"0xaf68b302"}),expect(t).toEqual([{type:e.ClearSignContextType.ERROR,error:new Error("data source error")}])}),it("should return the contexts on success",async()=>{s.mockResolvedValue((0,o.Right)([{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"1234567890"},{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])),n.mockResolvedValue((0,o.Left)(new Error("data source error")));const a={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await r.load(a);expect(t).toEqual([{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"1234567890"},{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])}),it("should return the proxy delegate call context on success",async()=>{s.mockResolvedValue((0,o.Right)([{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"1234567890"},{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])),n.mockResolvedValue((0,o.Right)({delegateAddresses:["0x7"],signedDescriptor:"0x1234567890abcdef"}));const a={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await r.load(a);expect(t).toEqual([{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"1234567890"},{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])}),it("should return the proxy delegate call context if the transaction.to is in the delegate addresses and the transaction.to is not the first element",async()=>{s.mockResolvedValue((0,o.Right)([{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"1234567890"},{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])),n.mockResolvedValue((0,o.Right)({delegateAddresses:["0x7","0x8"],signedDescriptor:"0x1234567890abcdef"}));const a={to:"0x8",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await r.load(a);expect(t).toEqual([{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"1234567890"},{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])}),it("should return the proxy delegate call context if the transaction.to is not in the delegate addresses",async()=>{s.mockResolvedValue((0,o.Right)([{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"1234567890"},{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])),n.mockResolvedValue((0,o.Right)({delegateAddresses:["0x8"],signedDescriptor:"0x1234567890abcdef"}));const a={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await r.load(a);expect(t).toEqual([{type:e.ClearSignContextType.TRANSACTION_INFO,payload:"1234567890"},{type:e.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])})});
2
2
  //# sourceMappingURL=TransactionContextLoader.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/transaction/domain/TransactionContextLoader.test.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport type { TransactionContext } from \"@/shared/model/TransactionContext\";\nimport type { TransactionDataSource } from \"@/transaction/data/TransactionDataSource\";\nimport { TransactionContextLoader } from \"@/transaction/domain/TransactionContextLoader\";\n\ndescribe(\"TransactionContextLoader\", () => {\n const getTransactionDescriptorsMock = vi.fn();\n const mockTransactionDataSource: TransactionDataSource = {\n getTransactionDescriptors: getTransactionDescriptorsMock,\n };\n const loader = new TransactionContextLoader(mockTransactionDataSource);\n\n beforeEach(() => {\n vi.clearAllMocks();\n });\n\n it(\"should return an empty array if no destination address is provided\", async () => {\n // GIVEN\n const transaction = {} as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if data is undefined\", async () => {\n // GIVEN\n const transaction = { to: \"0x0\" } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if no data provided\", async () => {\n // GIVEN\n const transaction = { to: \"0x0\", data: \"0x\" } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an error if selector is invalid\", async () => {\n // GIVEN\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xzf68b302000000000000000000000000000000000000000000000000000000000002\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ]);\n });\n\n it(\"should return an error if data source fails\", async () => {\n // GIVEN\n getTransactionDescriptorsMock.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(getTransactionDescriptorsMock).toHaveBeenCalledWith({\n address: \"0x7\",\n chainId: 3,\n selector: \"0xaf68b302\",\n });\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"data source error\"),\n },\n ]);\n });\n\n it(\"should return the contexts on success\", async () => {\n // GIVEN\n getTransactionDescriptorsMock.mockResolvedValue(\n Right([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]);\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAA4B,qBAE5BC,EAAqC,2CAGrCC,EAAyC,yDAEzC,SAAS,2BAA4B,IAAM,CACzC,MAAMC,EAAgC,GAAG,GAAG,EACtCC,EAAmD,CACvD,0BAA2BD,CAC7B,EACME,EAAS,IAAI,2BAAyBD,CAAyB,EAErE,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,GAAG,qEAAsE,SAAY,CAEnF,MAAME,EAAc,CAAC,EAGfC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,EAED,GAAG,oDAAqD,SAAY,CAElE,MAAMD,EAAc,CAAE,GAAI,KAAM,EAG1BC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,EAED,GAAG,mDAAoD,SAAY,CAEjE,MAAMD,EAAc,CAAE,GAAI,MAAO,KAAM,IAAK,EAGtCC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,EAED,GAAG,gDAAiD,SAAY,CAE9D,MAAMD,EAAc,CAClB,GAAI,MACJ,QAAS,EACT,KAAM,wEACR,EAGMC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CACrB,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,kBAAkB,CACrC,CACF,CAAC,CACH,CAAC,EAED,GAAG,8CAA+C,SAAY,CAE5DJ,EAA8B,qBAC5B,QAAK,IAAI,MAAM,mBAAmB,CAAC,CACrC,EACA,MAAMG,EAAc,CAClB,GAAI,MACJ,QAAS,EACT,KAAM,wEACR,EAGMC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOH,CAA6B,EAAE,qBAAqB,CACzD,QAAS,MACT,QAAS,EACT,SAAU,YACZ,CAAC,EACD,OAAOI,CAAM,EAAE,QAAQ,CACrB,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,mBAAmB,CACtC,CACF,CAAC,CACH,CAAC,EAED,GAAG,wCAAyC,SAAY,CAEtDJ,EAA8B,qBAC5B,SAAM,CACJ,CACE,KAAM,uBAAqB,iBAC3B,QAAS,YACX,EACA,CACE,KAAM,uBAAqB,8BAC3B,QAAS,UACX,CACF,CAAC,CACH,EACA,MAAMG,EAAc,CAClB,GAAI,MACJ,QAAS,EACT,KAAM,wEACR,EAGMC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CACrB,CACE,KAAM,uBAAqB,iBAC3B,QAAS,YACX,EACA,CACE,KAAM,uBAAqB,8BAC3B,QAAS,UACX,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["import_purify_ts", "import_ClearSignContext", "import_TransactionContextLoader", "getTransactionDescriptorsMock", "mockTransactionDataSource", "loader", "transaction", "result"]
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport type { TransactionContext } from \"@/shared/model/TransactionContext\";\nimport type { TransactionDataSource } from \"@/transaction/data/TransactionDataSource\";\nimport { TransactionContextLoader } from \"@/transaction/domain/TransactionContextLoader\";\n\ndescribe(\"TransactionContextLoader\", () => {\n const getTransactionDescriptorsMock = vi.fn();\n const getProxyDelegateCallMock = vi.fn();\n const mockTransactionDataSource: TransactionDataSource = {\n getTransactionDescriptors: getTransactionDescriptorsMock,\n };\n /* const mockProxyDatasource: ProxyDataSource = {\n getProxyDelegateCall: getProxyDelegateCallMock,\n getProxyImplementationAddress: vi.fn(),\n }; */\n const mockCertificateLoader: PkiCertificateLoader = {\n loadCertificate: vi.fn(),\n };\n const loader = new TransactionContextLoader(\n mockTransactionDataSource,\n //mockProxyDatasource,\n mockCertificateLoader,\n );\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should return an empty array if no destination address is provided\", async () => {\n // GIVEN\n const transaction = {} as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if no data provided\", async () => {\n // GIVEN\n const transaction = { to: \"0x0\", data: \"0x\" } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an error if selector is invalid\", async () => {\n // GIVEN\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xzf68b302000000000000000000000000000000000000000000000000000000000002\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ]);\n });\n\n it(\"should return an error if data source fails\", async () => {\n // GIVEN\n getProxyDelegateCallMock.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n getTransactionDescriptorsMock.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(getTransactionDescriptorsMock).toHaveBeenCalledWith({\n address: \"0x7\",\n chainId: 3,\n selector: \"0xaf68b302\",\n });\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"data source error\"),\n },\n ]);\n });\n\n it(\"should return the contexts on success\", async () => {\n // GIVEN\n getTransactionDescriptorsMock.mockResolvedValue(\n Right([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]),\n );\n getProxyDelegateCallMock.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]);\n });\n\n it(\"should return the proxy delegate call context on success\", async () => {\n // GIVEN\n getTransactionDescriptorsMock.mockResolvedValue(\n Right([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]),\n );\n getProxyDelegateCallMock.mockResolvedValue(\n Right({\n delegateAddresses: [\"0x7\"],\n signedDescriptor: \"0x1234567890abcdef\",\n }),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n /* TODO reenable when proxy is enabled\n {\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: \"0x1234567890abcdef\",\n },*/\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]);\n });\n\n it(\"should return the proxy delegate call context if the transaction.to is in the delegate addresses and the transaction.to is not the first element\", async () => {\n // GIVEN\n getTransactionDescriptorsMock.mockResolvedValue(\n Right([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]),\n );\n getProxyDelegateCallMock.mockResolvedValue(\n Right({\n delegateAddresses: [\"0x7\", \"0x8\"],\n signedDescriptor: \"0x1234567890abcdef\",\n }),\n );\n const transaction = {\n to: \"0x8\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n /* TODO reenable when proxy is enabled\n {\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: \"0x1234567890abcdef\",\n },*/\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]);\n });\n\n it(\"should return the proxy delegate call context if the transaction.to is not in the delegate addresses\", async () => {\n // GIVEN\n getTransactionDescriptorsMock.mockResolvedValue(\n Right([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]),\n );\n getProxyDelegateCallMock.mockResolvedValue(\n Right({\n delegateAddresses: [\"0x8\"],\n signedDescriptor: \"0x1234567890abcdef\",\n }),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n /* TODO reenable when proxy is enabled\n {\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: \"0x1234567890abcdef\",\n },*/\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]);\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAA4B,qBAG5BC,EAAqC,2CAGrCC,EAAyC,yDAEzC,SAAS,2BAA4B,IAAM,CACzC,MAAMC,EAAgC,GAAG,GAAG,EACtCC,EAA2B,GAAG,GAAG,EACjCC,EAAmD,CACvD,0BAA2BF,CAC7B,EAKMG,EAA8C,CAClD,gBAAiB,GAAG,GAAG,CACzB,EACMC,EAAS,IAAI,2BACjBF,EAEAC,CACF,EAEA,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,GAAG,qEAAsE,SAAY,CAEnF,MAAME,EAAc,CAAC,EAGfC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,EAED,GAAG,mDAAoD,SAAY,CAEjE,MAAMD,EAAc,CAAE,GAAI,MAAO,KAAM,IAAK,EAGtCC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,EAED,GA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KAAM,yEACN,SAAU,YACZ,EAGMC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CAMrB,CACE,KAAM,uBAAqB,iBAC3B,QAAS,YACX,EACA,CACE,KAAM,uBAAqB,8BAC3B,QAAS,UACX,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_purify_ts", "import_ClearSignContext", "import_TransactionContextLoader", "getTransactionDescriptorsMock", "getProxyDelegateCallMock", "mockTransactionDataSource", "mockCertificateLoader", "loader", "transaction", "result"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ "use strict";var g=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var n=(r,e,d,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of l(e))!a.call(r,s)&&s!==d&&g(r,s,{get:()=>e[s],enumerable:!(t=i(e,s))||t.enumerable});return r};var o=r=>n(g({},"__esModule",{value:!0}),r);var p={};module.exports=o(p);
2
+ //# sourceMappingURL=ProxyDelegateCall.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/transaction/model/ProxyDelegateCall.ts"],
4
+ "sourcesContent": ["export type ProxyDelegateCall = {\n delegateAddresses: string[];\n signedDescriptor: string;\n};\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["ProxyDelegateCall_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var s=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var o=Object.prototype.hasOwnProperty;var p=(t,e,d,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of m(e))!o.call(t,n)&&n!==d&&s(t,n,{get:()=>e[n],enumerable:!(r=i(e,n))||r.enumerable});return t};var a=t=>p(s({},"__esModule",{value:!0}),t);var l={};module.exports=a(l);
2
+ //# sourceMappingURL=ProxyImplementationAddress.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/transaction/model/ProxyImplementationAddress.ts"],
4
+ "sourcesContent": ["export type ProxyImplementationAddress = {\n implementationAddress: string;\n};\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["ProxyImplementationAddress_exports", "__toCommonJS"]
7
+ }
@@ -1,2 +1,2 @@
1
- "use strict";var x=Object.create;var d=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;var w=(o,e)=>{for(var t in e)d(o,t,{get:e[t],enumerable:!0})},E=(o,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of v(e))!G.call(o,r)&&r!==t&&d(o,r,{get:()=>e[r],enumerable:!(a=D(e,r))||a.enumerable});return o};var y=(o,e,t)=>(t=o!=null?x(P(o)):{},E(e||!o||!o.__esModule?d(t,"default",{value:o,enumerable:!0}):t,o)),M=o=>E(d({},"__esModule",{value:!0}),o),N=(o,e,t,a)=>{for(var r=a>1?void 0:a?D(e,t):e,i=o.length-1,n;i>=0;i--)(n=o[i])&&(r=(a?n(e,t,r):n(r))||r);return a&&r&&d(e,t,r),r},$=(o,e)=>(t,a)=>e(t,a,o);var _={};w(_,{HttpTrustedNameDataSource:()=>c});module.exports=M(_);var p=y(require("axios")),u=require("inversify"),s=require("purify-ts"),T=require("../../config/di/configTypes"),g=require("../../shared/constant/HttpHeaders"),l=y(require("../../../package.json"));let c=class{constructor(e){this.config=e}async getDomainNamePayload({chainId:e,domain:t,challenge:a}){try{const n=await p.default.request({method:"GET",url:`https://nft.api.live.ledger.com/v2/names/ethereum/${e}/forward/${t}?types=eoa&sources=ens&challenge=${a}`,headers:{[g.LEDGER_CLIENT_VERSION_HEADER]:`context-module/${l.default.version}`}});return n.data.signedDescriptor?.data?(0,s.Right)(n.data.signedDescriptor.data):(0,s.Left)(new Error("[ContextModule] HttpTrustedNameDataSource: error getting domain payload"))}catch{return(0,s.Left)(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name"))}}async getTrustedNamePayload({chainId:e,address:t,challenge:a,sources:r,types:i}){try{r=r.filter(h=>h==="ens"||h==="crypto_asset_list");const m=(await p.default.request({method:"GET",url:`https://nft.api.live.ledger.com/v2/names/ethereum/${e}/reverse/${t}?types=${i.join(",")}&sources=${r.join(",")}&challenge=${a}`,headers:{[g.LEDGER_CLIENT_VERSION_HEADER]:`context-module/${l.default.version}`}})).data;if(!m?.signedDescriptor?.data)return(0,s.Left)(new Error(`[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address ${t}`));const f=m.signedDescriptor.data;if(!m.signedDescriptor.signatures||typeof m.signedDescriptor.signatures[this.config.cal.mode]!="string")return(0,s.Right)(f);const C=m.signedDescriptor.signatures[this.config.cal.mode];return(0,s.Right)(this.formatTrustedName(f,C))}catch{return(0,s.Left)(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name"))}}formatTrustedName(e,t){t.length%2!==0&&(t="0"+t);const a="15",r=(t.length/2).toString(16);return`${e}${a}${r}${t}`}};c=N([(0,u.injectable)(),$(0,(0,u.inject)(T.configTypes.Config))],c);0&&(module.exports={HttpTrustedNameDataSource});
1
+ "use strict";var x=Object.create;var c=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var P=(o,e)=>{for(var t in e)c(o,t,{get:e[t],enumerable:!0})},D=(o,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of G(e))!v.call(o,r)&&r!==t&&c(o,r,{get:()=>e[r],enumerable:!(a=E(e,r))||a.enumerable});return o};var N=(o,e,t)=>(t=o!=null?x(_(o)):{},D(e||!o||!o.__esModule?c(t,"default",{value:o,enumerable:!0}):t,o)),I=o=>D(c({},"__esModule",{value:!0}),o),T=(o,e,t,a)=>{for(var r=a>1?void 0:a?E(e,t):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(a?s(e,t,r):s(r))||r);return a&&r&&c(e,t,r),r},$=(o,e)=>(t,a)=>e(t,a,o);var w={};P(w,{HttpTrustedNameDataSource:()=>u});module.exports=I(w);var f=N(require("axios")),g=require("inversify"),n=require("purify-ts"),y=require("../../config/di/configTypes"),m=require("../../shared/constant/HttpHeaders"),l=N(require("../../../package.json"));let u=class{constructor(e){this.config=e}async getDomainNamePayload({chainId:e,domain:t,challenge:a}){try{const s=await f.default.request({method:"GET",url:`${this.config.metadataServiceDomain.url}/v2/names/ethereum/${e}/forward/${t}?types=eoa&sources=ens&challenge=${a}`,headers:{[m.LEDGER_CLIENT_VERSION_HEADER]:`context-module/${l.default.version}`,[m.LEDGER_ORIGIN_TOKEN_HEADER]:this.config.originToken}});return s.data.signedDescriptor?.data?(0,n.Right)(s.data.signedDescriptor.data):(0,n.Left)(new Error("[ContextModule] HttpTrustedNameDataSource: error getting domain payload"))}catch{return(0,n.Left)(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name"))}}async getTrustedNamePayload({chainId:e,address:t,challenge:a,sources:r,types:i}){try{r=r.filter(h=>h==="ens"||h==="crypto_asset_list");const d=(await f.default.request({method:"GET",url:`${this.config.metadataServiceDomain.url}/v2/names/ethereum/${e}/reverse/${t}?types=${i.join(",")}&sources=${r.join(",")}&challenge=${a}`,headers:{[m.LEDGER_CLIENT_VERSION_HEADER]:`context-module/${l.default.version}`,[m.LEDGER_ORIGIN_TOKEN_HEADER]:this.config.originToken}})).data;if(!d?.signedDescriptor?.data)return(0,n.Left)(new Error(`[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address ${t}`));const p=d.signedDescriptor.data;if(!d.signedDescriptor.signatures||typeof d.signedDescriptor.signatures[this.config.cal.mode]!="string")return(0,n.Right)(p);const C=d.signedDescriptor.signatures[this.config.cal.mode];return(0,n.Right)(this.formatTrustedName(p,C))}catch{return(0,n.Left)(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name"))}}formatTrustedName(e,t){t.length%2!==0&&(t="0"+t);const a="15",r=(t.length/2).toString(16);return`${e}${a}${r}${t}`}};u=T([(0,g.injectable)(),$(0,(0,g.inject)(y.configTypes.Config))],u);0&&(module.exports={HttpTrustedNameDataSource});
2
2
  //# sourceMappingURL=HttpTrustedNameDataSource.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/trusted-name/data/HttpTrustedNameDataSource.ts"],
4
- "sourcesContent": ["import axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport type { ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { LEDGER_CLIENT_VERSION_HEADER } from \"@/shared/constant/HttpHeaders\";\nimport {\n GetDomainNameInfosParams,\n GetTrustedNameInfosParams,\n TrustedNameDataSource,\n} from \"@/trusted-name/data/TrustedNameDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { TrustedNameDto } from \"./TrustedNameDto\";\n\n@injectable()\nexport class HttpTrustedNameDataSource implements TrustedNameDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n public async getDomainNamePayload({\n chainId,\n domain,\n challenge,\n }: GetDomainNameInfosParams): Promise<Either<Error, string>> {\n try {\n const type = \"eoa\"; // Externally owned account\n const source = \"ens\"; // Ethereum name service\n const response = await axios.request<TrustedNameDto>({\n method: \"GET\",\n url: `https://nft.api.live.ledger.com/v2/names/ethereum/${chainId}/forward/${domain}?types=${type}&sources=${source}&challenge=${challenge}`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n },\n });\n\n return response.data.signedDescriptor?.data\n ? Right(response.data.signedDescriptor.data)\n : Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: error getting domain payload\",\n ),\n );\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name\",\n ),\n );\n }\n }\n\n public async getTrustedNamePayload({\n chainId,\n address,\n challenge,\n sources,\n types,\n }: GetTrustedNameInfosParams): Promise<Either<Error, string>> {\n try {\n // TODO remove that filtering once https://ledgerhq.atlassian.net/browse/BACK-8075 is done\n // For now we have to filter or trusted names won't work with the generic parser, because transaction\n // fields descriptors can contain unsupported sources.\n sources = sources.filter(\n (source) => source === \"ens\" || source === \"crypto_asset_list\",\n );\n const response = await axios.request<TrustedNameDto>({\n method: \"GET\",\n url: `https://nft.api.live.ledger.com/v2/names/ethereum/${chainId}/reverse/${address}?types=${types.join(\",\")}&sources=${sources.join(\",\")}&challenge=${challenge}`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n },\n });\n const trustedName = response.data;\n if (!trustedName?.signedDescriptor?.data) {\n return Left(\n new Error(\n `[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address ${address}`,\n ),\n );\n }\n const payload = trustedName.signedDescriptor.data;\n\n if (\n !trustedName.signedDescriptor.signatures ||\n typeof trustedName.signedDescriptor.signatures[this.config.cal.mode] !==\n \"string\"\n ) {\n // If we have no separated signature but a valid descriptor, it may mean the descriptor was\n // signed on-the-fly for dynamic sources such as ens\n return Right(payload);\n }\n\n const signature =\n trustedName.signedDescriptor.signatures[this.config.cal.mode]!;\n return Right(this.formatTrustedName(payload, signature));\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name\",\n ),\n );\n }\n }\n\n private formatTrustedName(payload: string, signature: string): string {\n // Ensure correct padding\n if (signature.length % 2 !== 0) {\n signature = \"0\" + signature;\n }\n // TLV encoding as according to trusted name documentation\n const signatureTag = \"15\";\n const signatureLength = (signature.length / 2).toString(16);\n return `${payload}${signatureTag}${signatureLength}${signature}`;\n }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,CACF,EAEF,MAAMK,EAAUD,EAAY,iBAAiB,KAE7C,GACE,CAACA,EAAY,iBAAiB,YAC9B,OAAOA,EAAY,iBAAiB,WAAW,KAAK,OAAO,IAAI,IAAI,GACjE,SAIF,SAAO,SAAMC,CAAO,EAGtB,MAAMC,EACJF,EAAY,iBAAiB,WAAW,KAAK,OAAO,IAAI,IAAI,EAC9D,SAAO,SAAM,KAAK,kBAAkBC,EAASC,CAAS,CAAC,CACzD,MAAiB,CACf,SAAO,QACL,IAAI,MACF,yEACF,CACF,CACF,CACF,CAEQ,kBAAkBD,EAAiBC,EAA2B,CAEhEA,EAAU,OAAS,IAAM,IAC3BA,EAAY,IAAMA,GAGpB,MAAMC,EAAe,KACfC,GAAmBF,EAAU,OAAS,GAAG,SAAS,EAAE,EAC1D,MAAO,GAAGD,CAAO,GAAGE,CAAY,GAAGC,CAAe,GAAGF,CAAS,EAChE,CACF,EApGad,EAANiB,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,cAAY,MAAM,IAFjBlB",
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 LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport {\n GetDomainNameInfosParams,\n GetTrustedNameInfosParams,\n TrustedNameDataSource,\n} from \"@/trusted-name/data/TrustedNameDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { TrustedNameDto } from \"./TrustedNameDto\";\n\n@injectable()\nexport class HttpTrustedNameDataSource implements TrustedNameDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n public async getDomainNamePayload({\n chainId,\n domain,\n challenge,\n }: GetDomainNameInfosParams): Promise<Either<Error, string>> {\n try {\n const type = \"eoa\"; // Externally owned account\n const source = \"ens\"; // Ethereum name service\n const response = await axios.request<TrustedNameDto>({\n method: \"GET\",\n url: `${this.config.metadataServiceDomain.url}/v2/names/ethereum/${chainId}/forward/${domain}?types=${type}&sources=${source}&challenge=${challenge}`,\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.signedDescriptor?.data\n ? Right(response.data.signedDescriptor.data)\n : Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: error getting domain payload\",\n ),\n );\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name\",\n ),\n );\n }\n }\n\n public async getTrustedNamePayload({\n chainId,\n address,\n challenge,\n sources,\n types,\n }: GetTrustedNameInfosParams): Promise<Either<Error, string>> {\n try {\n // TODO remove that filtering once https://ledgerhq.atlassian.net/browse/BACK-8075 is done\n // For now we have to filter or trusted names won't work with the generic parser, because transaction\n // fields descriptors can contain unsupported sources.\n sources = sources.filter(\n (source) => source === \"ens\" || source === \"crypto_asset_list\",\n );\n const response = await axios.request<TrustedNameDto>({\n method: \"GET\",\n url: `${this.config.metadataServiceDomain.url}/v2/names/ethereum/${chainId}/reverse/${address}?types=${types.join(\",\")}&sources=${sources.join(\",\")}&challenge=${challenge}`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n });\n const trustedName = response.data;\n if (!trustedName?.signedDescriptor?.data) {\n return Left(\n new Error(\n `[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address ${address}`,\n ),\n );\n }\n const payload = trustedName.signedDescriptor.data;\n\n if (\n !trustedName.signedDescriptor.signatures ||\n typeof trustedName.signedDescriptor.signatures[this.config.cal.mode] !==\n \"string\"\n ) {\n // If we have no separated signature but a valid descriptor, it may mean the descriptor was\n // signed on-the-fly for dynamic sources such as ens\n return Right(payload);\n }\n\n const signature =\n trustedName.signedDescriptor.signatures[this.config.cal.mode]!;\n return Right(this.formatTrustedName(payload, signature));\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name\",\n ),\n );\n }\n }\n\n private formatTrustedName(payload: string, signature: string): string {\n // Ensure correct padding\n if (signature.length % 2 !== 0) {\n signature = \"0\" + signature;\n }\n // TLV encoding as according to trusted name documentation\n const signatureTag = \"15\";\n const signatureLength = (signature.length / 2).toString(16);\n return `${payload}${signatureTag}${signatureLength}${signature}`;\n }\n}\n"],
5
+ "mappings": "qtBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkB,oBAClBC,EAAmC,qBACnCC,EAAoC,qBAEpCC,EAA4B,mCAE5BC,EAGO,yCAMPC,EAAoB,iCAKb,IAAMC,EAAN,KAAiE,CACtE,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CAEH,MAAa,qBAAqB,CAChC,QAAAC,EACA,OAAAC,EACA,UAAAC,CACF,EAA6D,CAC3D,GAAI,CAGF,MAAMC,EAAW,MAAM,EAAAC,QAAM,QAAwB,CACnD,OAAQ,MACR,IAAK,GAAG,KAAK,OAAO,sBAAsB,GAAG,sBAAsBJ,CAAO,YAAYC,CAAM,oCAA8CC,CAAS,GACnJ,QAAS,CACP,CAAC,8BAA4B,EAAG,kBAAkB,EAAAG,QAAQ,OAAO,GACjE,CAAC,4BAA0B,EAAG,KAAK,OAAO,WAC5C,CACF,CAAC,EAED,OAAOF,EAAS,KAAK,kBAAkB,QACnC,SAAMA,EAAS,KAAK,iBAAiB,IAAI,KACzC,QACE,IAAI,MACF,yEACF,CACF,CACN,MAAiB,CACf,SAAO,QACL,IAAI,MACF,wEACF,CACF,CACF,CACF,CAEA,MAAa,sBAAsB,CACjC,QAAAH,EACA,QAAAM,EACA,U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", "__toCommonJS", "import_axios", "import_inversify", "import_purify_ts", "import_configTypes", "import_HttpHeaders", "import_package", "HttpTrustedNameDataSource", "config", "chainId", "domain", "challenge", "response", "axios", "PACKAGE", "address", "sources", "types", "source", "trustedName", "payload", "signature", "signatureTag", "signatureLength", "__decorateClass", "__decorateParam"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var p=Object.create;var c=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty;var v=(a,e,t,d)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of h(e))!g.call(a,r)&&r!==t&&c(a,r,{get:()=>e[r],enumerable:!(d=m(e,r))||d.enumerable});return a};var i=(a,e,t)=>(t=a!=null?p(y(a)):{},v(e||!a||!a.__esModule?c(t,"default",{value:a,enumerable:!0}):t,a));var o=i(require("axios")),s=require("purify-ts"),n=require("../../shared/constant/HttpHeaders"),u=require("../../trusted-name/data/HttpTrustedNameDataSource"),l=i(require("../../../package.json"));vi.mock("axios");describe("HttpTrustedNameDataSource",()=>{let a;beforeAll(()=>{const e={cal:{url:"https://crypto-assets-service.api.ledger.com/v1",mode:"prod",branch:"main"}};a=new u.HttpTrustedNameDataSource(e),vi.clearAllMocks()}),describe("getDomainNamePayload",()=>{it("should call axios with the correct url and ledger client version header",async()=>{const e=`context-module/${l.default.version}`,t=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(o.default,"request").mockImplementation(t),await a.getDomainNamePayload({chainId:137,challenge:"9876",domain:"hello.eth"}),expect(t).toHaveBeenCalledWith(expect.objectContaining({url:"https://nft.api.live.ledger.com/v2/names/ethereum/137/forward/hello.eth?types=eoa&sources=ens&challenge=9876",headers:{[n.LEDGER_CLIENT_VERSION_HEADER]:e}}))}),it("should throw an error when axios throws an error",async()=>{vi.spyOn(o.default,"request").mockRejectedValue(new Error);const e=await a.getDomainNamePayload({chainId:137,challenge:"",domain:"hello.eth"});expect(e).toEqual((0,s.Left)(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name")))}),it("should return an error when no payload is returned",async()=>{const e={data:{test:""}};vi.spyOn(o.default,"request").mockResolvedValue(e);const t=await a.getDomainNamePayload({chainId:137,challenge:"",domain:"hello.eth"});expect(t).toEqual((0,s.Left)(new Error("[ContextModule] HttpTrustedNameDataSource: error getting domain payload")))}),it("should return a payload",async()=>{const e={data:{signedDescriptor:{data:"payload"}}};vi.spyOn(o.default,"request").mockResolvedValue(e);const t=await a.getDomainNamePayload({chainId:137,challenge:"challenge",domain:"hello.eth"});expect(t).toEqual((0,s.Right)("payload"))})}),describe("getTrustedNamePayload",()=>{it("should call axios with the correct url and ledger client version header",async()=>{const e=`context-module/${l.default.version}`,t=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(o.default,"request").mockImplementation(t),await a.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"5678",sources:["ens","crypto_asset_list"],types:["eoa"]}),expect(t).toHaveBeenCalledWith(expect.objectContaining({url:"https://nft.api.live.ledger.com/v2/names/ethereum/137/reverse/0x1234?types=eoa&sources=ens,crypto_asset_list&challenge=5678",headers:{[n.LEDGER_CLIENT_VERSION_HEADER]:e}}))}),it("should throw an error when axios throws an error",async()=>{vi.spyOn(o.default,"request").mockRejectedValue(new Error);const e=await a.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(e).toEqual((0,s.Left)(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name")))}),it("should return an error when no payload is returned",async()=>{const e={data:{test:""}};vi.spyOn(o.default,"request").mockResolvedValue(e);const t=await a.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(t).toEqual((0,s.Left)(new Error("[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address 0x1234")))}),it("should return a payload",async()=>{const e={data:{signedDescriptor:{data:"payload"}}};vi.spyOn(o.default,"request").mockResolvedValue(e);const t=await a.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(t).toEqual((0,s.Right)("payload"))}),it("should return a payload with a signature",async()=>{const e={data:{signedDescriptor:{data:"payload",signatures:{prod:"12345"}}}};vi.spyOn(o.default,"request").mockResolvedValue(e);const t=await a.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(t).toEqual((0,s.Right)("payload153012345"))})})});
1
+ "use strict";var m=Object.create;var c=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var x=(a,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!v.call(a,n)&&n!==t&&c(a,n,{get:()=>e[n],enumerable:!(i=h(e,n))||i.enumerable});return a};var u=(a,e,t)=>(t=a!=null?m(g(a)):{},x(e||!a||!a.__esModule?c(t,"default",{value:a,enumerable:!0}):t,a));var o=u(require("axios")),r=require("purify-ts"),s=require("../../shared/constant/HttpHeaders"),p=require("../../trusted-name/data/HttpTrustedNameDataSource"),d=u(require("../../../package.json"));vi.mock("axios");const l={cal:{url:"https://crypto-assets-service.api.ledger.com/v1",mode:"prod",branch:"main"},metadataServiceDomain:{url:"https://nft.api.live.ledger.com"},originToken:"originToken"};describe("HttpTrustedNameDataSource",()=>{let a;beforeAll(()=>{a=new p.HttpTrustedNameDataSource(l),vi.clearAllMocks()}),describe("getDomainNamePayload",()=>{it("should call axios with the correct url and ledger client version header",async()=>{const e=`context-module/${d.default.version}`,t=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(o.default,"request").mockImplementation(t),await a.getDomainNamePayload({chainId:137,challenge:"9876",domain:"hello.eth"}),expect(t).toHaveBeenCalledWith(expect.objectContaining({url:"https://nft.api.live.ledger.com/v2/names/ethereum/137/forward/hello.eth?types=eoa&sources=ens&challenge=9876",headers:{[s.LEDGER_CLIENT_VERSION_HEADER]:e,[s.LEDGER_ORIGIN_TOKEN_HEADER]:l.originToken}}))}),it("should throw an error when axios throws an error",async()=>{vi.spyOn(o.default,"request").mockRejectedValue(new Error);const e=await a.getDomainNamePayload({chainId:137,challenge:"",domain:"hello.eth"});expect(e).toEqual((0,r.Left)(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name")))}),it("should return an error when no payload is returned",async()=>{const e={data:{test:""}};vi.spyOn(o.default,"request").mockResolvedValue(e);const t=await a.getDomainNamePayload({chainId:137,challenge:"",domain:"hello.eth"});expect(t).toEqual((0,r.Left)(new Error("[ContextModule] HttpTrustedNameDataSource: error getting domain payload")))}),it("should return a payload",async()=>{const e={data:{signedDescriptor:{data:"payload"}}};vi.spyOn(o.default,"request").mockResolvedValue(e);const t=await a.getDomainNamePayload({chainId:137,challenge:"challenge",domain:"hello.eth"});expect(t).toEqual((0,r.Right)("payload"))})}),describe("getTrustedNamePayload",()=>{it("should call axios with the correct url and ledger client version header",async()=>{const e=`context-module/${d.default.version}`,t=vi.fn(()=>Promise.resolve({data:[]}));vi.spyOn(o.default,"request").mockImplementation(t),await a.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"5678",sources:["ens","crypto_asset_list"],types:["eoa"]}),expect(t).toHaveBeenCalledWith(expect.objectContaining({url:"https://nft.api.live.ledger.com/v2/names/ethereum/137/reverse/0x1234?types=eoa&sources=ens,crypto_asset_list&challenge=5678",headers:{[s.LEDGER_CLIENT_VERSION_HEADER]:e,[s.LEDGER_ORIGIN_TOKEN_HEADER]:l.originToken}}))}),it("should throw an error when axios throws an error",async()=>{vi.spyOn(o.default,"request").mockRejectedValue(new Error);const e=await a.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(e).toEqual((0,r.Left)(new Error("[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name")))}),it("should return an error when no payload is returned",async()=>{const e={data:{test:""}};vi.spyOn(o.default,"request").mockResolvedValue(e);const t=await a.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(t).toEqual((0,r.Left)(new Error("[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address 0x1234")))}),it("should return a payload",async()=>{const e={data:{signedDescriptor:{data:"payload"}}};vi.spyOn(o.default,"request").mockResolvedValue(e);const t=await a.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(t).toEqual((0,r.Right)("payload"))}),it("should return a payload with a signature",async()=>{const e={data:{signedDescriptor:{data:"payload",signatures:{prod:"12345"}}}};vi.spyOn(o.default,"request").mockResolvedValue(e);const t=await a.getTrustedNamePayload({chainId:137,address:"0x1234",challenge:"",sources:["ens"],types:["eoa"]});expect(t).toEqual((0,r.Right)("payload153012345"))})})});
2
2
  //# sourceMappingURL=HttpTrustedNameDataSource.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/trusted-name/data/HttpTrustedNameDataSource.test.ts"],
4
- "sourcesContent": ["import axios from \"axios\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { LEDGER_CLIENT_VERSION_HEADER } from \"@/shared/constant/HttpHeaders\";\nimport { HttpTrustedNameDataSource } from \"@/trusted-name/data/HttpTrustedNameDataSource\";\nimport { type TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\nvi.mock(\"axios\");\n\ndescribe(\"HttpTrustedNameDataSource\", () => {\n let datasource: TrustedNameDataSource;\n\n beforeAll(() => {\n const config = {\n cal: {\n url: \"https://crypto-assets-service.api.ledger.com/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n } as ContextModuleConfig;\n datasource = new HttpTrustedNameDataSource(config);\n vi.clearAllMocks();\n });\n\n describe(\"getDomainNamePayload\", () => {\n it(\"should call axios with the correct url and 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.getDomainNamePayload({\n chainId: 137,\n challenge: \"9876\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n url: `https://nft.api.live.ledger.com/v2/names/ethereum/137/forward/hello.eth?types=eoa&sources=ens&challenge=9876`,\n headers: { [LEDGER_CLIENT_VERSION_HEADER]: version },\n }),\n );\n });\n\n it(\"should throw an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error());\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name\",\n ),\n ),\n );\n });\n\n it(\"should return an error when no payload is returned\", async () => {\n // GIVEN\n const response = { data: { test: \"\" } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: error getting domain payload\",\n ),\n ),\n );\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const response = { data: { signedDescriptor: { data: \"payload\" } } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"challenge\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(Right(\"payload\"));\n });\n });\n\n describe(\"getTrustedNamePayload\", () => {\n it(\"should call axios with the correct url and 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.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"5678\",\n sources: [\"ens\", \"crypto_asset_list\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n url: `https://nft.api.live.ledger.com/v2/names/ethereum/137/reverse/0x1234?types=eoa&sources=ens,crypto_asset_list&challenge=5678`,\n headers: { [LEDGER_CLIENT_VERSION_HEADER]: version },\n }),\n );\n });\n\n it(\"should throw an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error());\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name\",\n ),\n ),\n );\n });\n\n it(\"should return an error when no payload is returned\", async () => {\n // GIVEN\n const response = { data: { test: \"\" } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address 0x1234\",\n ),\n ),\n );\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const response = {\n data: {\n signedDescriptor: { data: \"payload\" },\n },\n };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(Right(\"payload\"));\n });\n\n it(\"should return a payload with a signature\", async () => {\n // GIVEN\n const response = {\n data: {\n signedDescriptor: { data: \"payload\", signatures: { prod: \"12345\" } },\n },\n };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(Right(\"payload153012345\"));\n });\n });\n});\n"],
5
- "mappings": "wdAAA,IAAAA,EAAkB,oBAClBC,EAA4B,qBAG5BC,EAA6C,yCAC7CC,EAA0C,yDAE1CC,EAAoB,iCAEpB,GAAG,KAAK,OAAO,EAEf,SAAS,4BAA6B,IAAM,CAC1C,IAAIC,EAEJ,UAAU,IAAM,CACd,MAAMC,EAAS,CACb,IAAK,CACH,IAAK,kDACL,KAAM,OACN,OAAQ,MACV,CACF,EACAD,EAAa,IAAI,4BAA0BC,CAAM,EACjD,GAAG,cAAc,CACnB,CAAC,EAED,SAAS,uBAAwB,IAAM,CACrC,GAAG,0EAA2E,SAAY,CAExF,MAAMC,EAAU,kBAAkB,EAAAC,QAAQ,OAAO,GAC3CC,EAAa,GAAG,GAAG,IAAM,QAAQ,QAAQ,CAAE,KAAM,CAAC,CAAE,CAAC,CAAC,EAC5D,GAAG,MAAM,EAAAC,QAAO,SAAS,EAAE,mBAAmBD,CAAU,EAGxD,MAAMJ,EAAW,qBAAqB,CACpC,QAAS,IACT,UAAW,OACX,OAAQ,WACV,CAAC,EAGD,OAAOI,CAAU,EAAE,qBACjB,OAAO,iBAAiB,CACtB,IAAK,+GACL,QAAS,CAAE,CAAC,8BAA4B,EAAGF,CAAQ,CACrD,CAAC,CACH,CACF,CAAC,EAED,GAAG,mDAAoD,SAAY,CAEjE,GAAG,MAAM,EAAAG,QAAO,SAAS,EAAE,kBAAkB,IAAI,KAAO,EAGxD,MAAMC,EAAS,MAAMN,EAAW,qBAAqB,CACnD,QAAS,IACT,UAAW,GACX,OAAQ,WACV,CAAC,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GACX,QAAS,CAAC,KAAK,EACf,MAAO,CAAC,KAAK,CACf,CAAC,EAGD,OAAOM,CAAM,EAAE,WAAQ,SAAM,kBAAkB,CAAC,CAClD,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["import_axios", "import_purify_ts", "import_HttpHeaders", "import_HttpTrustedNameDataSource", "import_package", "datasource", "config", "version", "PACKAGE", "requestSpy", "axios", "result", "response"]
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { Left, Right } from \"purify-ts\";\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 { HttpTrustedNameDataSource } from \"@/trusted-name/data/HttpTrustedNameDataSource\";\nimport { type TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\nvi.mock(\"axios\");\n\nconst config = {\n cal: {\n url: \"https://crypto-assets-service.api.ledger.com/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n metadataServiceDomain: {\n url: \"https://nft.api.live.ledger.com\",\n },\n originToken: \"originToken\",\n} as ContextModuleConfig;\ndescribe(\"HttpTrustedNameDataSource\", () => {\n let datasource: TrustedNameDataSource;\n\n beforeAll(() => {\n datasource = new HttpTrustedNameDataSource(config);\n vi.clearAllMocks();\n });\n\n describe(\"getDomainNamePayload\", () => {\n it(\"should call axios with the correct url and 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.getDomainNamePayload({\n chainId: 137,\n challenge: \"9876\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n url: `https://nft.api.live.ledger.com/v2/names/ethereum/137/forward/hello.eth?types=eoa&sources=ens&challenge=9876`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: version,\n [LEDGER_ORIGIN_TOKEN_HEADER]: config.originToken,\n },\n }),\n );\n });\n\n it(\"should throw an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error());\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch domain name\",\n ),\n ),\n );\n });\n\n it(\"should return an error when no payload is returned\", async () => {\n // GIVEN\n const response = { data: { test: \"\" } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: error getting domain payload\",\n ),\n ),\n );\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const response = { data: { signedDescriptor: { data: \"payload\" } } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getDomainNamePayload({\n chainId: 137,\n challenge: \"challenge\",\n domain: \"hello.eth\",\n });\n\n // THEN\n expect(result).toEqual(Right(\"payload\"));\n });\n });\n\n describe(\"getTrustedNamePayload\", () => {\n it(\"should call axios with the correct url and 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.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"5678\",\n sources: [\"ens\", \"crypto_asset_list\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n url: `https://nft.api.live.ledger.com/v2/names/ethereum/137/reverse/0x1234?types=eoa&sources=ens,crypto_asset_list&challenge=5678`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: version,\n [LEDGER_ORIGIN_TOKEN_HEADER]: config.originToken,\n },\n }),\n );\n });\n\n it(\"should throw an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error());\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: Failed to fetch trusted name\",\n ),\n ),\n );\n });\n\n it(\"should return an error when no payload is returned\", async () => {\n // GIVEN\n const response = { data: { test: \"\" } };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTrustedNameDataSource: no trusted name metadata for address 0x1234\",\n ),\n ),\n );\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const response = {\n data: {\n signedDescriptor: { data: \"payload\" },\n },\n };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(Right(\"payload\"));\n });\n\n it(\"should return a payload with a signature\", async () => {\n // GIVEN\n const response = {\n data: {\n signedDescriptor: { data: \"payload\", signatures: { prod: \"12345\" } },\n },\n };\n vi.spyOn(axios, \"request\").mockResolvedValue(response);\n\n // WHEN\n const result = await datasource.getTrustedNamePayload({\n chainId: 137,\n address: \"0x1234\",\n challenge: \"\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n });\n\n // THEN\n expect(result).toEqual(Right(\"payload153012345\"));\n });\n });\n});\n"],
5
+ "mappings": "wdAAA,IAAAA,EAAkB,oBAClBC,EAA4B,qBAG5BC,EAGO,yCACPC,EAA0C,yDAE1CC,EAAoB,iCAEpB,GAAG,KAAK,OAAO,EAEf,MAAMC,EAAS,CACb,IAAK,CACH,IAAK,kDACL,KAAM,OACN,OAAQ,MACV,EACA,sBAAuB,CACrB,IAAK,iCACP,EACA,YAAa,aACf,EACA,SAAS,4BAA6B,IAAM,CAC1C,IAAIC,EAEJ,UAAU,IAAM,CACdA,EAAa,IAAI,4BAA0BD,CAAM,EACjD,GAAG,cAAc,CACnB,CAAC,EAED,SAAS,uBAAwB,IAAM,CACrC,GAAG,0EAA2E,SAAY,CAExF,MAAME,EAAU,kBAAkB,EAAAC,QAAQ,OAAO,GAC3CC,EAAa,GAAG,GAAG,IAAM,QAAQ,QAAQ,CAAE,KAAM,CAAC,CAAE,CAAC,CAAC,EAC5D,GAAG,MAAM,EAAAC,QAAO,SAAS,EAAE,mBAAmBD,CAAU,EAGxD,MAAMH,EAAW,qBAAqB,CACpC,QAAS,IACT,UAAW,OACX,OAAQ,WACV,CAAC,EAGD,OAAOG,CAAU,EAAE,qBACjB,OAAO,iBAAiB,CACtB,IAAK,+GACL,QAAS,CACP,CAAC,8BAA4B,EAAGF,EAChC,CAAC,4BAA0B,EAAGF,EAAO,WACvC,CACF,CAAC,CACH,CACF,CAAC,EAED,GAAG,mDAAoD,SAAY,CAEjE,GAAG,MAAM,EAAAK,QAAO,SAAS,EAAE,kBAAkB,IAAI,KAAO,EAGxD,MAAMC,EAAS,MAAML,EAAW,qBAAqB,CACnD,QAAS,IACT,UAAW,GACX,OAAQ,WACV,CAAC,EAGD,OAAOK,CAAM,EAAE,WACb,QACE,IAAI,MACF,wEACF,CACF,CACF,CACF,CAAC,EAED,GAAG,qDAAsD,SAAY,CAEnE,MAAMC,EAAW,CAAE,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,CAAC,CAClD,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_axios", "import_purify_ts", "import_HttpHeaders", "import_HttpTrustedNameDataSource", "import_package", "config", "datasource", "version", "PACKAGE", "requestSpy", "axios", "result", "response"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var m=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var T=(t,e)=>{for(var o in e)m(t,o,{get:e[o],enumerable:!0})},c=(t,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of p(e))!N.call(t,r)&&r!==o&&m(t,r,{get:()=>e[r],enumerable:!(a=i(e,r))||a.enumerable});return t};var f=t=>c(m({},"__esModule",{value:!0}),t);var C={};T(C,{trustedNameModuleFactory:()=>x});module.exports=f(C);var u=require("inversify"),n=require("../../trusted-name/data/HttpTrustedNameDataSource"),d=require("../../trusted-name/di/trustedNameTypes"),s=require("../../trusted-name/domain/TrustedNameContextLoader");const x=()=>new u.ContainerModule((t,e,o,a)=>{t(d.trustedNameTypes.TrustedNameDataSource).to(n.HttpTrustedNameDataSource),t(d.trustedNameTypes.TrustedNameContextLoader).to(s.TrustedNameContextLoader)});0&&(module.exports={trustedNameModuleFactory});
1
+ "use strict";var a=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var c=(t,e)=>{for(var r in e)a(t,r,{get:e[r],enumerable:!0})},f=(t,e,r,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of n(e))!T.call(t,o)&&o!==r&&a(t,o,{get:()=>e[o],enumerable:!(u=N(e,o))||u.enumerable});return t};var i=t=>f(a({},"__esModule",{value:!0}),t);var C={};c(C,{trustedNameModuleFactory:()=>x});module.exports=i(C);var d=require("inversify"),s=require("../../trusted-name/data/HttpTrustedNameDataSource"),m=require("../../trusted-name/di/trustedNameTypes"),p=require("../../trusted-name/domain/TrustedNameContextLoader");const x=()=>new d.ContainerModule(({bind:t})=>{t(m.trustedNameTypes.TrustedNameDataSource).to(s.HttpTrustedNameDataSource),t(m.trustedNameTypes.TrustedNameContextLoader).to(p.TrustedNameContextLoader)});0&&(module.exports={trustedNameModuleFactory});
2
2
  //# sourceMappingURL=trustedNameModuleFactory.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/trusted-name/di/trustedNameModuleFactory.ts"],
4
- "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpTrustedNameDataSource } from \"@/trusted-name/data/HttpTrustedNameDataSource\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\nimport { TrustedNameContextLoader } from \"@/trusted-name/domain/TrustedNameContextLoader\";\n\nexport const trustedNameModuleFactory = () =>\n new ContainerModule((bind, _unbind, _isBound, _rebind) => {\n bind(trustedNameTypes.TrustedNameDataSource).to(HttpTrustedNameDataSource);\n bind(trustedNameTypes.TrustedNameContextLoader).to(\n TrustedNameContextLoader,\n );\n });\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,qBAEhCC,EAA0C,yDAC1CC,EAAiC,8CACjCC,EAAyC,0DAElC,MAAML,EAA2B,IACtC,IAAI,kBAAgB,CAACM,EAAMC,EAASC,EAAUC,IAAY,CACxDH,EAAK,mBAAiB,qBAAqB,EAAE,GAAG,2BAAyB,EACzEA,EAAK,mBAAiB,wBAAwB,EAAE,GAC9C,0BACF,CACF,CAAC",
6
- "names": ["trustedNameModuleFactory_exports", "__export", "trustedNameModuleFactory", "__toCommonJS", "import_inversify", "import_HttpTrustedNameDataSource", "import_trustedNameTypes", "import_TrustedNameContextLoader", "bind", "_unbind", "_isBound", "_rebind"]
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpTrustedNameDataSource } from \"@/trusted-name/data/HttpTrustedNameDataSource\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\nimport { TrustedNameContextLoader } from \"@/trusted-name/domain/TrustedNameContextLoader\";\n\nexport const trustedNameModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(trustedNameTypes.TrustedNameDataSource).to(HttpTrustedNameDataSource);\n bind(trustedNameTypes.TrustedNameContextLoader).to(\n TrustedNameContextLoader,\n );\n });\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,qBAEhCC,EAA0C,yDAC1CC,EAAiC,8CACjCC,EAAyC,0DAElC,MAAML,EAA2B,IACtC,IAAI,kBAAgB,CAAC,CAAE,KAAAM,CAAK,IAAM,CAChCA,EAAK,mBAAiB,qBAAqB,EAAE,GAAG,2BAAyB,EACzEA,EAAK,mBAAiB,wBAAwB,EAAE,GAC9C,0BACF,CACF,CAAC",
6
+ "names": ["trustedNameModuleFactory_exports", "__export", "trustedNameModuleFactory", "__toCommonJS", "import_inversify", "import_HttpTrustedNameDataSource", "import_trustedNameTypes", "import_TrustedNameContextLoader", "bind"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var c=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var S=(n,t)=>{for(var r in t)c(n,r,{get:t[r],enumerable:!0})},h=(n,t,r,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of g(t))!C.call(n,a)&&a!==r&&c(n,a,{get:()=>t[a],enumerable:!(e=m(t,a))||e.enumerable});return n};var T=n=>h(c({},"__esModule",{value:!0}),n),p=(n,t,r,e)=>{for(var a=e>1?void 0:e?m(t,r):t,l=n.length-1,o;l>=0;l--)(o=n[l])&&(a=(e?o(t,r,a):o(a))||a);return e&&a&&c(t,r,a),a},u=(n,t)=>(r,e)=>t(r,e,n);var R={};S(R,{TrustedNameContextLoader:()=>s});module.exports=T(R);var d=require("inversify"),i=require("../../shared/model/ClearSignContext"),y=require("../../trusted-name/di/trustedNameTypes");let s=class{_dataSource;constructor(t){this._dataSource=t}async load(t){const{chainId:r,domain:e,challenge:a}=t;return!e||!a?[]:this.isDomainValid(e)?[(await this._dataSource.getDomainNamePayload({chainId:r,domain:e,challenge:a})).caseOf({Left:o=>({type:i.ClearSignContextType.ERROR,error:o}),Right:o=>({type:i.ClearSignContextType.TRUSTED_NAME,payload:o})})]:[{type:i.ClearSignContextType.ERROR,error:new Error("[ContextModule] TrustedNameLoader: invalid domain")}]}async loadField(t){return t.type!==i.ClearSignContextType.TRUSTED_NAME?null:(await this._dataSource.getTrustedNamePayload({chainId:t.chainId,address:t.address,challenge:t.challenge,types:t.types,sources:t.sources})).caseOf({Left:e=>({type:i.ClearSignContextType.ERROR,error:e}),Right:e=>({type:i.ClearSignContextType.TRUSTED_NAME,payload:e})})}isDomainValid(t){const r=t.length>0&&Number(t.length)<30,e=new RegExp("^[a-zA-Z0-9\\-\\_\\.]+$").test(t);return r&&e}};s=p([(0,d.injectable)(),u(0,(0,d.inject)(y.trustedNameTypes.TrustedNameDataSource))],s);0&&(module.exports={TrustedNameContextLoader});
1
+ "use strict";var c=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var S=(n,t)=>{for(var r in t)c(n,r,{get:t[r],enumerable:!0})},h=(n,t,r,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of C(t))!g.call(n,a)&&a!==r&&c(n,a,{get:()=>t[a],enumerable:!(e=p(t,a))||e.enumerable});return n};var T=n=>h(c({},"__esModule",{value:!0}),n),u=(n,t,r,e)=>{for(var a=e>1?void 0:e?p(t,r):t,l=n.length-1,o;l>=0;l--)(o=n[l])&&(a=(e?o(t,r,a):o(a))||a);return e&&a&&c(t,r,a),a},m=(n,t)=>(r,e)=>t(r,e,n);var R={};S(R,{TrustedNameContextLoader:()=>s});module.exports=T(R);var d=require("inversify"),i=require("../../shared/model/ClearSignContext"),y=require("../../trusted-name/di/trustedNameTypes");let s=class{_dataSource;constructor(t){this._dataSource=t}async load(t){const{chainId:r,domain:e,challenge:a}=t;return!e||!a?[]:this.isDomainValid(e)?[(await this._dataSource.getDomainNamePayload({chainId:r,domain:e,challenge:a})).caseOf({Left:o=>({type:i.ClearSignContextType.ERROR,error:o}),Right:o=>({type:i.ClearSignContextType.TRUSTED_NAME,payload:o})})]:[{type:i.ClearSignContextType.ERROR,error:new Error("[ContextModule] TrustedNameLoader: invalid domain")}]}async loadField(t){return t.type!==i.ClearSignContextType.TRUSTED_NAME?null:(await this._dataSource.getTrustedNamePayload({chainId:t.chainId,address:t.address,challenge:t.challenge,types:t.types,sources:t.sources})).caseOf({Left:e=>({type:i.ClearSignContextType.ERROR,error:e}),Right:e=>({type:i.ClearSignContextType.TRUSTED_NAME,payload:e})})}isDomainValid(t){const r=t.length>0&&Number(t.length)<30,e=new RegExp("^[a-zA-Z0-9\\-\\_\\.]+$").test(t);return r&&e}};s=u([(0,d.injectable)(),m(0,(0,d.inject)(y.trustedNameTypes.TrustedNameDataSource))],s);0&&(module.exports={TrustedNameContextLoader});
2
2
  //# sourceMappingURL=TrustedNameContextLoader.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/trusted-name/domain/TrustedNameContextLoader.ts"],
4
- "sourcesContent": ["import { inject, injectable } from \"inversify\";\n\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport {\n TransactionContext,\n TransactionFieldContext,\n} from \"@/shared/model/TransactionContext\";\nimport type { TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\n@injectable()\nexport class TrustedNameContextLoader implements ContextLoader {\n private _dataSource: TrustedNameDataSource;\n\n constructor(\n @inject(trustedNameTypes.TrustedNameDataSource)\n dataSource: TrustedNameDataSource,\n ) {\n this._dataSource = dataSource;\n }\n\n async load(\n transactionContext: TransactionContext,\n ): Promise<ClearSignContext[]> {\n const { chainId, domain, challenge } = transactionContext;\n\n if (!domain || !challenge) {\n return [];\n }\n\n if (!this.isDomainValid(domain)) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ];\n }\n\n const payload = await this._dataSource.getDomainNamePayload({\n chainId: chainId,\n domain: domain,\n challenge: challenge,\n });\n\n return [\n payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error: error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: value,\n }),\n }),\n ];\n }\n\n async loadField(\n field: TransactionFieldContext,\n ): Promise<ClearSignContext | null> {\n if (field.type !== ClearSignContextType.TRUSTED_NAME) {\n return null;\n }\n const payload = await this._dataSource.getTrustedNamePayload({\n chainId: field.chainId,\n address: field.address,\n challenge: field.challenge,\n types: field.types,\n sources: field.sources,\n });\n return payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: value,\n }),\n });\n }\n\n private isDomainValid(domain: string) {\n const lengthIsValid = domain.length > 0 && Number(domain.length) < 30;\n const containsOnlyValidChars = new RegExp(\"^[a-zA-Z0-9\\\\-\\\\_\\\\.]+$\").test(\n domain,\n );\n\n return lengthIsValid && containsOnlyValidChars;\n }\n}\n"],
5
- "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAmC,qBAGnCC,EAGO,2CAMPC,EAAiC,8CAG1B,IAAMC,EAAN,KAAwD,CACrD,YAER,YAEEC,EACA,CACA,KAAK,YAAcA,CACrB,CAEA,MAAM,KACJC,EAC6B,CAC7B,KAAM,CAAE,QAAAC,EAAS,OAAAC,EAAQ,UAAAC,CAAU,EAAIH,EAEvC,MAAI,CAACE,GAAU,CAACC,EACP,CAAC,EAGL,KAAK,cAAcD,CAAM,EAevB,EANS,MAAM,KAAK,YAAY,qBAAqB,CAC1D,QAASD,EACT,OAAQC,EACR,UAAWC,CACb,CAAC,GAGS,OAAO,CACb,KAAOC,IAA6B,CAClC,KAAM,uBAAqB,MAC3B,MAAOA,CACT,GACA,MAAQC,IAA6B,CACnC,KAAM,uBAAqB,aAC3B,QAASA,CACX,EACF,CAAC,CACH,EAzBS,CACL,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,mDAAmD,CACtE,CACF,CAqBJ,CAEA,MAAM,UACJC,EACkC,CAClC,OAAIA,EAAM,OAAS,uBAAqB,aAC/B,MAEO,MAAM,KAAK,YAAY,sBAAsB,CAC3D,QAASA,EAAM,QACf,QAASA,EAAM,QACf,UAAWA,EAAM,UACjB,MAAOA,EAAM,MACb,QAASA,EAAM,OACjB,CAAC,GACc,OAAO,CACpB,KAAOF,IAA6B,CAClC,KAAM,uBAAqB,MAC3B,MAAAA,CACF,GACA,MAAQC,IAA6B,CACnC,KAAM,uBAAqB,aAC3B,QAASA,CACX,EACF,CAAC,CACH,CAEQ,cAAcH,EAAgB,CACpC,MAAMK,EAAgBL,EAAO,OAAS,GAAK,OAAOA,EAAO,MAAM,EAAI,GAC7DM,EAAyB,IAAI,OAAO,yBAAyB,EAAE,KACnEN,CACF,EAEA,OAAOK,GAAiBC,CAC1B,CACF,EAjFaV,EAANW,EAAA,IADN,cAAW,EAKPC,EAAA,eAAO,mBAAiB,qBAAqB,IAJrCZ",
6
- "names": ["TrustedNameContextLoader_exports", "__export", "TrustedNameContextLoader", "__toCommonJS", "import_inversify", "import_ClearSignContext", "import_trustedNameTypes", "TrustedNameContextLoader", "dataSource", "transactionContext", "chainId", "domain", "challenge", "error", "value", "field", "lengthIsValid", "containsOnlyValidChars", "__decorateClass", "__decorateParam"]
4
+ "sourcesContent": ["import { inject, injectable } from \"inversify\";\n\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport {\n TransactionContext,\n TransactionFieldContext,\n} from \"@/shared/model/TransactionContext\";\nimport type { TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\n@injectable()\nexport class TrustedNameContextLoader implements ContextLoader {\n private _dataSource: TrustedNameDataSource;\n\n constructor(\n @inject(trustedNameTypes.TrustedNameDataSource)\n dataSource: TrustedNameDataSource,\n ) {\n this._dataSource = dataSource;\n }\n\n async load(ctx: TransactionContext): Promise<ClearSignContext[]> {\n const { chainId, domain, challenge } = ctx;\n\n if (!domain || !challenge) {\n return [];\n }\n\n if (!this.isDomainValid(domain)) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ];\n }\n\n const payload = await this._dataSource.getDomainNamePayload({\n chainId,\n domain,\n challenge,\n });\n\n return [\n payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error: error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: value,\n }),\n }),\n ];\n }\n\n async loadField(\n field: TransactionFieldContext,\n ): Promise<ClearSignContext | null> {\n if (field.type !== ClearSignContextType.TRUSTED_NAME) {\n return null;\n }\n const payload = await this._dataSource.getTrustedNamePayload({\n chainId: field.chainId,\n address: field.address,\n challenge: field.challenge,\n types: field.types,\n sources: field.sources,\n });\n return payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: value,\n }),\n });\n }\n\n private isDomainValid(domain: string) {\n const lengthIsValid = domain.length > 0 && Number(domain.length) < 30;\n const containsOnlyValidChars = new RegExp(\"^[a-zA-Z0-9\\\\-\\\\_\\\\.]+$\").test(\n domain,\n );\n\n return lengthIsValid && containsOnlyValidChars;\n }\n}\n"],
5
+ "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAmC,qBAGnCC,EAGO,2CAMPC,EAAiC,8CAG1B,IAAMC,EAAN,KAAwD,CACrD,YAER,YAEEC,EACA,CACA,KAAK,YAAcA,CACrB,CAEA,MAAM,KAAKC,EAAsD,CAC/D,KAAM,CAAE,QAAAC,EAAS,OAAAC,EAAQ,UAAAC,CAAU,EAAIH,EAEvC,MAAI,CAACE,GAAU,CAACC,EACP,CAAC,EAGL,KAAK,cAAcD,CAAM,EAevB,EANS,MAAM,KAAK,YAAY,qBAAqB,CAC1D,QAAAD,EACA,OAAAC,EACA,UAAAC,CACF,CAAC,GAGS,OAAO,CACb,KAAOC,IAA6B,CAClC,KAAM,uBAAqB,MAC3B,MAAOA,CACT,GACA,MAAQC,IAA6B,CACnC,KAAM,uBAAqB,aAC3B,QAASA,CACX,EACF,CAAC,CACH,EAzBS,CACL,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,mDAAmD,CACtE,CACF,CAqBJ,CAEA,MAAM,UACJC,EACkC,CAClC,OAAIA,EAAM,OAAS,uBAAqB,aAC/B,MAEO,MAAM,KAAK,YAAY,sBAAsB,CAC3D,QAASA,EAAM,QACf,QAASA,EAAM,QACf,UAAWA,EAAM,UACjB,MAAOA,EAAM,MACb,QAASA,EAAM,OACjB,CAAC,GACc,OAAO,CACpB,KAAOF,IAA6B,CAClC,KAAM,uBAAqB,MAC3B,MAAAA,CACF,GACA,MAAQC,IAA6B,CACnC,KAAM,uBAAqB,aAC3B,QAASA,CACX,EACF,CAAC,CACH,CAEQ,cAAcH,EAAgB,CACpC,MAAMK,EAAgBL,EAAO,OAAS,GAAK,OAAOA,EAAO,MAAM,EAAI,GAC7DM,EAAyB,IAAI,OAAO,yBAAyB,EAAE,KACnEN,CACF,EAEA,OAAOK,GAAiBC,CAC1B,CACF,EA/EaV,EAANW,EAAA,IADN,cAAW,EAKPC,EAAA,eAAO,mBAAiB,qBAAqB,IAJrCZ",
6
+ "names": ["TrustedNameContextLoader_exports", "__export", "TrustedNameContextLoader", "__toCommonJS", "import_inversify", "import_ClearSignContext", "import_trustedNameTypes", "TrustedNameContextLoader", "dataSource", "ctx", "chainId", "domain", "challenge", "error", "value", "field", "lengthIsValid", "containsOnlyValidChars", "__decorateClass", "__decorateParam"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var l=require("purify-ts"),t=require("../../shared/model/ClearSignContext"),n=require("../../trusted-name/domain/TrustedNameContextLoader");describe("TrustedNameContextLoader",()=>{const o={getDomainNamePayload:vi.fn(),getTrustedNamePayload:vi.fn()};beforeEach(()=>{vi.restoreAllMocks(),vi.spyOn(o,"getDomainNamePayload").mockResolvedValue((0,l.Right)("payload"))}),describe("load function",async()=>{it("should return an empty array when no domain or registry",async()=>{const e={},r=new n.TrustedNameContextLoader(o),a=()=>r.load(e);await expect(a()).resolves.toEqual([])}),it("should return an error when domain > max length",async()=>{const e={domain:"maxlength-maxlength-maxlength-maxlength-maxlength-maxlength",challenge:"challenge"},a=await new n.TrustedNameContextLoader(o).load(e);expect(a).toEqual([{type:t.ClearSignContextType.ERROR,error:new Error("[ContextModule] TrustedNameLoader: invalid domain")}])}),it("should return an error when domain is not valid",async()=>{const e={domain:"hello\u{1F44B}",challenge:"challenge"},a=await new n.TrustedNameContextLoader(o).load(e);expect(a).toEqual([{type:t.ClearSignContextType.ERROR,error:new Error("[ContextModule] TrustedNameLoader: invalid domain")}])}),it("should return a payload",async()=>{const e={domain:"hello.eth",challenge:"challenge"},a=await new n.TrustedNameContextLoader(o).load(e);expect(a).toEqual([{type:t.ClearSignContextType.TRUSTED_NAME,payload:"payload"}])}),it("should return an error when unable to fetch the datasource",async()=>{const e={domain:"hello.eth",challenge:"challenge"};vi.spyOn(o,"getDomainNamePayload").mockResolvedValue((0,l.Left)(new Error("error")));const a=await new n.TrustedNameContextLoader(o).load(e);expect(a).toEqual([{type:t.ClearSignContextType.ERROR,error:new Error("error")}])}),it("should return an empty array when no challenge",async()=>{const e={domain:"hello.eth",challenge:void 0},a=await new n.TrustedNameContextLoader(o).load(e);expect(a).toEqual([])})}),describe("loadField function",()=>{it("should return an error when field type if not supported",async()=>{const e={type:t.ClearSignContextType.TOKEN,chainId:7,address:"0x1234"},a=await new n.TrustedNameContextLoader(o).loadField(e);expect(a).toEqual(null)}),it("should return a payload",async()=>{const e={type:t.ClearSignContextType.TRUSTED_NAME,chainId:7,address:"0x1234",challenge:"17",sources:["ens"],types:["eoa"]};vi.spyOn(o,"getTrustedNamePayload").mockResolvedValue((0,l.Right)("payload"));const a=await new n.TrustedNameContextLoader(o).loadField(e);expect(a).toEqual({type:t.ClearSignContextType.TRUSTED_NAME,payload:"payload"})}),it("should return an error when unable to fetch the datasource",async()=>{const e={type:t.ClearSignContextType.TRUSTED_NAME,chainId:7,address:"0x1234",challenge:"17",sources:["ens"],types:["eoa"]};vi.spyOn(o,"getTrustedNamePayload").mockResolvedValue((0,l.Left)(new Error("error")));const a=await new n.TrustedNameContextLoader(o).loadField(e);expect(a).toEqual({type:t.ClearSignContextType.ERROR,error:new Error("error")})})})});
1
+ "use strict";var l=require("purify-ts"),t=require("../../shared/model/ClearSignContext"),n=require("../../trusted-name/domain/TrustedNameContextLoader");describe("TrustedNameContextLoader",()=>{const o={getDomainNamePayload:vi.fn(),getTrustedNamePayload:vi.fn()};beforeEach(()=>{vi.restoreAllMocks(),vi.spyOn(o,"getDomainNamePayload").mockResolvedValue((0,l.Right)("payload"))}),describe("load function",()=>{it("should return an empty array when no domain or registry",async()=>{const e={},r=new n.TrustedNameContextLoader(o),a=()=>r.load(e);await expect(a()).resolves.toEqual([])}),it("should return an error when domain > max length",async()=>{const e={domain:"maxlength-maxlength-maxlength-maxlength-maxlength-maxlength",challenge:"challenge"},a=await new n.TrustedNameContextLoader(o).load(e);expect(a).toEqual([{type:t.ClearSignContextType.ERROR,error:new Error("[ContextModule] TrustedNameLoader: invalid domain")}])}),it("should return an error when domain is not valid",async()=>{const e={domain:"hello\u{1F44B}",challenge:"challenge"},a=await new n.TrustedNameContextLoader(o).load(e);expect(a).toEqual([{type:t.ClearSignContextType.ERROR,error:new Error("[ContextModule] TrustedNameLoader: invalid domain")}])}),it("should return a payload",async()=>{const e={domain:"hello.eth",challenge:"challenge"},a=await new n.TrustedNameContextLoader(o).load(e);expect(a).toEqual([{type:t.ClearSignContextType.TRUSTED_NAME,payload:"payload"}])}),it("should return an error when unable to fetch the datasource",async()=>{const e={domain:"hello.eth",challenge:"challenge"};vi.spyOn(o,"getDomainNamePayload").mockResolvedValue((0,l.Left)(new Error("error")));const a=await new n.TrustedNameContextLoader(o).load(e);expect(a).toEqual([{type:t.ClearSignContextType.ERROR,error:new Error("error")}])}),it("should return an empty array when no challenge",async()=>{const e={domain:"hello.eth",challenge:void 0},a=await new n.TrustedNameContextLoader(o).load(e);expect(a).toEqual([])})}),describe("loadField function",()=>{it("should return an error when field type if not supported",async()=>{const e={type:t.ClearSignContextType.TOKEN,chainId:7,address:"0x1234"},a=await new n.TrustedNameContextLoader(o).loadField(e);expect(a).toEqual(null)}),it("should return a payload",async()=>{const e={type:t.ClearSignContextType.TRUSTED_NAME,chainId:7,address:"0x1234",challenge:"17",sources:["ens"],types:["eoa"]};vi.spyOn(o,"getTrustedNamePayload").mockResolvedValue((0,l.Right)("payload"));const a=await new n.TrustedNameContextLoader(o).loadField(e);expect(a).toEqual({type:t.ClearSignContextType.TRUSTED_NAME,payload:"payload"})}),it("should return an error when unable to fetch the datasource",async()=>{const e={type:t.ClearSignContextType.TRUSTED_NAME,chainId:7,address:"0x1234",challenge:"17",sources:["ens"],types:["eoa"]};vi.spyOn(o,"getTrustedNamePayload").mockResolvedValue((0,l.Left)(new Error("error")));const a=await new n.TrustedNameContextLoader(o).loadField(e);expect(a).toEqual({type:t.ClearSignContextType.ERROR,error:new Error("error")})})})});
2
2
  //# sourceMappingURL=TrustedNameContextLoader.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/trusted-name/domain/TrustedNameContextLoader.test.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"@/shared/model/TransactionContext\";\nimport { type TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport { TrustedNameContextLoader } from \"@/trusted-name/domain/TrustedNameContextLoader\";\n\ndescribe(\"TrustedNameContextLoader\", () => {\n const mockTrustedNameDataSource: TrustedNameDataSource = {\n getDomainNamePayload: vi.fn(),\n getTrustedNamePayload: vi.fn(),\n };\n\n beforeEach(() => {\n vi.restoreAllMocks();\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getDomainNamePayload\",\n ).mockResolvedValue(Right(\"payload\"));\n });\n\n describe(\"load function\", async () => {\n it(\"should return an empty array when no domain or registry\", async () => {\n const transaction = {} as TransactionContext;\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const promise = () => loader.load(transaction);\n\n await expect(promise()).resolves.toEqual([]);\n });\n\n it(\"should return an error when domain > max length\", async () => {\n const transaction = {\n domain: \"maxlength-maxlength-maxlength-maxlength-maxlength-maxlength\",\n challenge: \"challenge\",\n } as TransactionContext;\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ]);\n });\n\n it(\"should return an error when domain is not valid\", async () => {\n const transaction = {\n domain: \"hello\uD83D\uDC4B\",\n challenge: \"challenge\",\n } as TransactionContext;\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ]);\n });\n\n it(\"should return a payload\", async () => {\n const transaction = {\n domain: \"hello.eth\",\n challenge: \"challenge\",\n } as TransactionContext;\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.TRUSTED_NAME,\n payload: \"payload\",\n },\n ]);\n });\n\n it(\"should return an error when unable to fetch the datasource\", async () => {\n // GIVEN\n const transaction = {\n domain: \"hello.eth\",\n challenge: \"challenge\",\n } as TransactionContext;\n\n // WHEN\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getDomainNamePayload\",\n ).mockResolvedValue(Left(new Error(\"error\")));\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n { type: ClearSignContextType.ERROR, error: new Error(\"error\") },\n ]);\n });\n\n it(\"should return an empty array when no challenge\", async () => {\n // GIVEN\n const transaction = {\n domain: \"hello.eth\",\n challenge: undefined,\n } as TransactionContext;\n\n // WHEN\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n });\n\n describe(\"loadField function\", () => {\n it(\"should return an error when field type if not supported\", async () => {\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TOKEN,\n chainId: 7,\n address: \"0x1234\",\n };\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.loadField(field);\n\n expect(result).toEqual(null);\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TRUSTED_NAME,\n chainId: 7,\n address: \"0x1234\",\n challenge: \"17\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n };\n\n // WHEN\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(\"payload\"));\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: \"payload\",\n });\n });\n\n it(\"should return an error when unable to fetch the datasource\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TRUSTED_NAME,\n chainId: 7,\n address: \"0x1234\",\n challenge: \"17\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n };\n\n // WHEN\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Left(new Error(\"error\")));\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n });\n });\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAA4B,qBAE5BC,EAAqC,2CAMrCC,EAAyC,0DAEzC,SAAS,2BAA4B,IAAM,CACzC,MAAMC,EAAmD,CACvD,qBAAsB,GAAG,GAAG,EAC5B,sBAAuB,GAAG,GAAG,CAC/B,EAEA,WAAW,IAAM,CACf,GAAG,gBAAgB,EACnB,GAAG,MACDA,EACA,sBACF,EAAE,qBAAkB,SAAM,SAAS,CAAC,CACtC,CAAC,EAED,SAAS,gBAAiB,SAAY,CACpC,GAAG,0DAA2D,SAAY,CACxE,MAAMC,EAAc,CAAC,EACfC,EAAS,IAAI,2BAAyBF,CAAyB,EAC/DG,EAAU,IAAMD,EAAO,KAAKD,CAAW,EAE7C,MAAM,OAAOE,EAAQ,CAAC,EAAE,SAAS,QAAQ,CAAC,CAAC,CAC7C,CAAC,EAED,GAAG,kDAAmD,SAAY,CAChE,MAAMF,EAAc,CAClB,OAAQ,8DACR,U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,SAAS,qBAAsB,IAAM,CACnC,GAAG,0DAA2D,SAAY,CACxE,MAAMC,EAAiC,CACrC,KAAM,uBAAqB,MAC3B,QAAS,EACT,QAAS,QACX,EAGMD,EAAS,MADA,IAAI,2BAAyBJ,CAAyB,EACzC,UAAUK,CAAK,EAE3C,OAAOD,CAAM,EAAE,QAAQ,IAAI,CAC7B,CAAC,EAED,GAAG,0BAA2B,SAAY,CAExC,MAAMC,EAAiC,CACrC,KAAM,uBAAqB,aAC3B,QAAS,EACT,QAAS,SACT,UAAW,KACX,QAAS,CAAC,KAAK,EACf,MAAO,CAAC,KAAK,CACf,EAGA,GAAG,MACDL,EACA,uBACF,EAAE,qBAAkB,SAAM,SAAS,CAAC,EAEpC,MAAMI,EAAS,MADA,IAAI,2BAAyBJ,CAAyB,EACzC,UAAUK,CAAK,EAG3C,OAAOD,CAAM,EAAE,QAAQ,CACrB,KAAM,uBAAqB,aAC3B,QAAS,SACX,CAAC,CACH,CAAC,EAED,GAAG,6DAA8D,SAAY,CAE3E,MAAMC,EAAiC,CACrC,KAAM,uBAAqB,aAC3B,QAAS,EACT,QAAS,SACT,UAAW,KACX,QAAS,CAAC,KAAK,EACf,MAAO,CAAC,KAAK,CACf,EAGA,GAAG,MACDL,EACA,uBACF,EAAE,qBAAkB,QAAK,IAAI,MAAM,OAAO,CAAC,CAAC,EAE5C,MAAMI,EAAS,MADA,IAAI,2BAAyBJ,CAAyB,EACzC,UAAUK,CAAK,EAG3C,OAAOD,CAAM,EAAE,QAAQ,CACrB,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,OAAO,CAC1B,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"@/shared/model/TransactionContext\";\nimport { type TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport { TrustedNameContextLoader } from \"@/trusted-name/domain/TrustedNameContextLoader\";\n\ndescribe(\"TrustedNameContextLoader\", () => {\n const mockTrustedNameDataSource: TrustedNameDataSource = {\n getDomainNamePayload: vi.fn(),\n getTrustedNamePayload: vi.fn(),\n };\n\n beforeEach(() => {\n vi.restoreAllMocks();\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getDomainNamePayload\",\n ).mockResolvedValue(Right(\"payload\"));\n });\n\n describe(\"load function\", () => {\n it(\"should return an empty array when no domain or registry\", async () => {\n const transaction = {} as TransactionContext;\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const promise = () => loader.load(transaction);\n\n await expect(promise()).resolves.toEqual([]);\n });\n\n it(\"should return an error when domain > max length\", async () => {\n const transaction = {\n domain: \"maxlength-maxlength-maxlength-maxlength-maxlength-maxlength\",\n challenge: \"challenge\",\n } as TransactionContext;\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ]);\n });\n\n it(\"should return an error when domain is not valid\", async () => {\n const transaction = {\n domain: \"hello\uD83D\uDC4B\",\n challenge: \"challenge\",\n } as TransactionContext;\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"[ContextModule] TrustedNameLoader: invalid domain\"),\n },\n ]);\n });\n\n it(\"should return a payload\", async () => {\n const transaction = {\n domain: \"hello.eth\",\n challenge: \"challenge\",\n } as TransactionContext;\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n expect(result).toEqual([\n {\n type: ClearSignContextType.TRUSTED_NAME,\n payload: \"payload\",\n },\n ]);\n });\n\n it(\"should return an error when unable to fetch the datasource\", async () => {\n // GIVEN\n const transaction = {\n domain: \"hello.eth\",\n challenge: \"challenge\",\n } as TransactionContext;\n\n // WHEN\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getDomainNamePayload\",\n ).mockResolvedValue(Left(new Error(\"error\")));\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n { type: ClearSignContextType.ERROR, error: new Error(\"error\") },\n ]);\n });\n\n it(\"should return an empty array when no challenge\", async () => {\n // GIVEN\n const transaction = {\n domain: \"hello.eth\",\n challenge: undefined,\n } as TransactionContext;\n\n // WHEN\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n });\n\n describe(\"loadField function\", () => {\n it(\"should return an error when field type if not supported\", async () => {\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TOKEN,\n chainId: 7,\n address: \"0x1234\",\n };\n\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.loadField(field);\n\n expect(result).toEqual(null);\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TRUSTED_NAME,\n chainId: 7,\n address: \"0x1234\",\n challenge: \"17\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n };\n\n // WHEN\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(\"payload\"));\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: \"payload\",\n });\n });\n\n it(\"should return an error when unable to fetch the datasource\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TRUSTED_NAME,\n chainId: 7,\n address: \"0x1234\",\n challenge: \"17\",\n sources: [\"ens\"],\n types: [\"eoa\"],\n };\n\n // WHEN\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Left(new Error(\"error\")));\n const loader = new TrustedNameContextLoader(mockTrustedNameDataSource);\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n });\n });\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAA4B,qBAE5BC,EAAqC,2CAMrCC,EAAyC,0DAEzC,SAAS,2BAA4B,IAAM,CACzC,MAAMC,EAAmD,CACvD,qBAAsB,GAAG,GAAG,EAC5B,sBAAuB,GAAG,GAAG,CAC/B,EAEA,WAAW,IAAM,CACf,GAAG,gBAAgB,EACnB,GAAG,MACDA,EACA,sBACF,EAAE,qBAAkB,SAAM,SAAS,CAAC,CACtC,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,GAAG,0DAA2D,SAAY,CACxE,MAAMC,EAAc,CAAC,EACfC,EAAS,IAAI,2BAAyBF,CAAyB,EAC/DG,EAAU,IAAMD,EAAO,KAAKD,CAAW,EAE7C,MAAM,OAAOE,EAAQ,CAAC,EAAE,SAAS,QAAQ,CAAC,CAAC,CAC7C,CAAC,EAED,GAAG,kDAAmD,SAAY,CAChE,MAAMF,EAAc,CAClB,OAAQ,8DACR,UAAW,WACb,EAGMG,EAAS,MADA,IAAI,2BAAyBJ,CAAyB,EACzC,KAAKC,CAAW,EAE5C,OAAOG,CAAM,EAAE,QAAQ,CACrB,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,mDAAmD,CACtE,CACF,CAAC,CACH,CAAC,EAED,GAAG,kDAAmD,SAAY,CAChE,MAAMH,EAAc,CAClB,OAAQ,iBACR,UAAW,WACb,EAGMG,EAAS,MADA,IAAI,2BAAyBJ,CAAyB,EACzC,KAAKC,CAAW,EAE5C,OAAOG,CAAM,EAAE,QAAQ,CACrB,CACE,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,mDAAmD,CACtE,CACF,CAAC,CACH,CAAC,EAED,GAAG,0B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AAS,MADA,IAAI,2BAAyBJ,CAAyB,EACzC,UAAUK,CAAK,EAG3C,OAAOD,CAAM,EAAE,QAAQ,CACrB,KAAM,uBAAqB,aAC3B,QAAS,SACX,CAAC,CACH,CAAC,EAED,GAAG,6DAA8D,SAAY,CAE3E,MAAMC,EAAiC,CACrC,KAAM,uBAAqB,aAC3B,QAAS,EACT,QAAS,SACT,UAAW,KACX,QAAS,CAAC,KAAK,EACf,MAAO,CAAC,KAAK,CACf,EAGA,GAAG,MACDL,EACA,uBACF,EAAE,qBAAkB,QAAK,IAAI,MAAM,OAAO,CAAC,CAAC,EAE5C,MAAMI,EAAS,MADA,IAAI,2BAAyBJ,CAAyB,EACzC,UAAUK,CAAK,EAG3C,OAAOD,CAAM,EAAE,QAAQ,CACrB,KAAM,uBAAqB,MAC3B,MAAO,IAAI,MAAM,OAAO,CAC1B,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
6
  "names": ["import_purify_ts", "import_ClearSignContext", "import_TrustedNameContextLoader", "mockTrustedNameDataSource", "transaction", "loader", "promise", "result", "field"]
7
7
  }