@ledgerhq/context-module 1.4.0 → 1.6.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 (319) 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/external-plugin/data/HttpExternalPluginDataSource.js +1 -1
  19. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.js.map +2 -2
  20. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js +1 -1
  21. package/lib/cjs/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +3 -3
  22. package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js +1 -1
  23. package/lib/cjs/src/external-plugin/di/externalPluginModuleFactory.js.map +3 -3
  24. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js +1 -1
  25. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js.map +3 -3
  26. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
  27. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +3 -3
  28. package/lib/cjs/src/nft/data/HttpNftDataSource.js +1 -1
  29. package/lib/cjs/src/nft/data/HttpNftDataSource.js.map +3 -3
  30. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js +1 -1
  31. package/lib/cjs/src/nft/data/HttpNftDataSource.test.js.map +3 -3
  32. package/lib/cjs/src/nft/di/nftModuleFactory.js +1 -1
  33. package/lib/cjs/src/nft/di/nftModuleFactory.js.map +3 -3
  34. package/lib/cjs/src/nft/domain/NftContextLoader.js +1 -1
  35. package/lib/cjs/src/nft/domain/NftContextLoader.js.map +3 -3
  36. package/lib/cjs/src/nft/domain/NftContextLoader.test.js +1 -1
  37. package/lib/cjs/src/nft/domain/NftContextLoader.test.js.map +2 -2
  38. package/lib/cjs/src/pki/di/pkiModuleFactory.js +1 -1
  39. package/lib/cjs/src/pki/di/pkiModuleFactory.js.map +3 -3
  40. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.js +1 -1
  41. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.js.map +3 -3
  42. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js +1 -1
  43. package/lib/cjs/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +3 -3
  44. package/lib/cjs/src/shared/constant/HttpHeaders.js +1 -1
  45. package/lib/cjs/src/shared/constant/HttpHeaders.js.map +1 -1
  46. package/lib/cjs/src/shared/model/SolanaTransactionContext.js +2 -0
  47. package/lib/cjs/src/shared/model/SolanaTransactionContext.js.map +7 -0
  48. package/lib/cjs/src/shared/model/TransactionSubset.js +1 -1
  49. package/lib/cjs/src/shared/model/TransactionSubset.js.map +1 -1
  50. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js +2 -0
  51. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +7 -0
  52. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +2 -0
  53. package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +7 -0
  54. package/lib/cjs/src/solana/data/SolanaDataSource.js +2 -0
  55. package/lib/cjs/src/solana/data/SolanaDataSource.js.map +7 -0
  56. package/lib/cjs/src/solana/di/SolanaContextModuleFactory.js +2 -0
  57. package/lib/cjs/src/solana/di/SolanaContextModuleFactory.js.map +7 -0
  58. package/lib/cjs/src/solana/di/solanaContextTypes.js +2 -0
  59. package/lib/cjs/src/solana/di/solanaContextTypes.js.map +7 -0
  60. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.js +2 -0
  61. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.js.map +7 -0
  62. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.test.js +2 -0
  63. package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.test.js.map +7 -0
  64. package/lib/cjs/src/solana/domain/SolanaContextLoader.js +2 -0
  65. package/lib/cjs/src/solana/domain/SolanaContextLoader.js.map +7 -0
  66. package/lib/cjs/src/solana/domain/solanaContextTypes.js +2 -0
  67. package/lib/cjs/src/solana/domain/solanaContextTypes.js.map +7 -0
  68. package/lib/cjs/src/token/di/tokenModuleFactory.js +1 -1
  69. package/lib/cjs/src/token/di/tokenModuleFactory.js.map +3 -3
  70. package/lib/cjs/src/token/domain/TokenContextLoader.js +1 -1
  71. package/lib/cjs/src/token/domain/TokenContextLoader.js.map +3 -3
  72. package/lib/cjs/src/token/domain/TokenContextLoader.test.js +1 -1
  73. package/lib/cjs/src/token/domain/TokenContextLoader.test.js.map +2 -2
  74. package/lib/cjs/src/transaction/data/HttpProxyDataSource.js +2 -0
  75. package/lib/cjs/src/transaction/data/HttpProxyDataSource.js.map +7 -0
  76. package/lib/cjs/src/transaction/data/HttpProxyDataSource.test.js +2 -0
  77. package/lib/cjs/src/transaction/data/HttpProxyDataSource.test.js.map +7 -0
  78. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js +1 -1
  79. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js.map +2 -2
  80. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js +1 -1
  81. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.test.js.map +3 -3
  82. package/lib/cjs/src/transaction/data/{CalldataDto.js.map → dto/CalldataDto.js.map} +1 -1
  83. package/lib/cjs/src/transaction/data/dto/ProxyDelegateCallDto.js +2 -0
  84. package/lib/cjs/src/transaction/data/dto/ProxyDelegateCallDto.js.map +7 -0
  85. package/lib/cjs/src/transaction/data/dto/ProxyImplementationAddressDto.js +2 -0
  86. package/lib/cjs/src/transaction/data/dto/ProxyImplementationAddressDto.js.map +7 -0
  87. package/lib/cjs/src/transaction/di/transactionModuleFactory.js +1 -1
  88. package/lib/cjs/src/transaction/di/transactionModuleFactory.js.map +3 -3
  89. package/lib/cjs/src/transaction/di/transactionTypes.js +1 -1
  90. package/lib/cjs/src/transaction/di/transactionTypes.js.map +2 -2
  91. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js +1 -1
  92. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js.map +3 -3
  93. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js +1 -1
  94. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js.map +2 -2
  95. package/lib/cjs/src/transaction/model/ProxyDelegateCall.js +2 -0
  96. package/lib/cjs/src/transaction/model/ProxyDelegateCall.js.map +7 -0
  97. package/lib/cjs/src/transaction/model/ProxyImplementationAddress.js +2 -0
  98. package/lib/cjs/src/transaction/model/ProxyImplementationAddress.js.map +7 -0
  99. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
  100. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.js.map +2 -2
  101. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  102. package/lib/cjs/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +3 -3
  103. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js +1 -1
  104. package/lib/cjs/src/trusted-name/di/trustedNameModuleFactory.js.map +3 -3
  105. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
  106. package/lib/cjs/src/trusted-name/domain/TrustedNameContextLoader.js.map +3 -3
  107. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
  108. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js.map +2 -2
  109. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  110. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
  111. package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js +1 -1
  112. package/lib/cjs/src/typed-data/di/typedDataModuleFactory.js.map +3 -3
  113. package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js +1 -1
  114. package/lib/cjs/src/uniswap/di/uniswapModuleFactory.js.map +3 -3
  115. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js +1 -1
  116. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js.map +3 -3
  117. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
  118. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js.map +2 -2
  119. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.js +1 -1
  120. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.js.map +2 -2
  121. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.test.js +1 -1
  122. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.test.js.map +2 -2
  123. package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js +1 -1
  124. package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js.map +3 -3
  125. package/lib/esm/package.json +2 -2
  126. package/lib/esm/src/ContextModuleBuilder.js +1 -1
  127. package/lib/esm/src/ContextModuleBuilder.js.map +3 -3
  128. package/lib/esm/src/ContextModuleBuilder.test.js +1 -1
  129. package/lib/esm/src/ContextModuleBuilder.test.js.map +3 -3
  130. package/lib/esm/src/DefaultContextModule.js +1 -1
  131. package/lib/esm/src/DefaultContextModule.js.map +3 -3
  132. package/lib/esm/src/DefaultContextModule.test.js +1 -1
  133. package/lib/esm/src/DefaultContextModule.test.js.map +2 -2
  134. package/lib/esm/src/config/di/configModuleFactory.js +1 -1
  135. package/lib/esm/src/config/di/configModuleFactory.js.map +3 -3
  136. package/lib/esm/src/di.js +1 -1
  137. package/lib/esm/src/di.js.map +3 -3
  138. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js +1 -1
  139. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.js.map +3 -3
  140. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js +1 -1
  141. package/lib/esm/src/external-plugin/data/HttpExternalPluginDataSource.test.js.map +3 -3
  142. package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js +1 -1
  143. package/lib/esm/src/external-plugin/di/externalPluginModuleFactory.js.map +3 -3
  144. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js +1 -1
  145. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js.map +3 -3
  146. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
  147. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +3 -3
  148. package/lib/esm/src/nft/data/HttpNftDataSource.js +1 -1
  149. package/lib/esm/src/nft/data/HttpNftDataSource.js.map +3 -3
  150. package/lib/esm/src/nft/data/HttpNftDataSource.test.js +1 -1
  151. package/lib/esm/src/nft/data/HttpNftDataSource.test.js.map +3 -3
  152. package/lib/esm/src/nft/di/nftModuleFactory.js +1 -1
  153. package/lib/esm/src/nft/di/nftModuleFactory.js.map +3 -3
  154. package/lib/esm/src/nft/domain/NftContextLoader.js +1 -1
  155. package/lib/esm/src/nft/domain/NftContextLoader.js.map +3 -3
  156. package/lib/esm/src/nft/domain/NftContextLoader.test.js +1 -1
  157. package/lib/esm/src/nft/domain/NftContextLoader.test.js.map +2 -2
  158. package/lib/esm/src/pki/di/pkiModuleFactory.js +1 -1
  159. package/lib/esm/src/pki/di/pkiModuleFactory.js.map +3 -3
  160. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.js +1 -1
  161. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.js.map +3 -3
  162. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js +1 -1
  163. package/lib/esm/src/pki/domain/DefaultPkiCertificateLoader.test.js.map +3 -3
  164. package/lib/esm/src/shared/constant/HttpHeaders.js +1 -1
  165. package/lib/esm/src/shared/constant/HttpHeaders.js.map +1 -1
  166. package/lib/esm/src/shared/model/SolanaTransactionContext.js +1 -0
  167. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js +2 -0
  168. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +7 -0
  169. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +2 -0
  170. package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +7 -0
  171. package/lib/esm/src/solana/data/SolanaDataSource.js +1 -0
  172. package/lib/esm/src/solana/data/SolanaDataSource.js.map +7 -0
  173. package/lib/esm/src/solana/di/SolanaContextModuleFactory.js +2 -0
  174. package/lib/esm/src/solana/di/SolanaContextModuleFactory.js.map +7 -0
  175. package/lib/esm/src/solana/di/solanaContextTypes.js +2 -0
  176. package/lib/esm/src/solana/di/solanaContextTypes.js.map +7 -0
  177. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.js +2 -0
  178. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.js.map +7 -0
  179. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.test.js +2 -0
  180. package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.test.js.map +7 -0
  181. package/lib/esm/src/solana/domain/SolanaContextLoader.js +1 -0
  182. package/lib/esm/src/solana/domain/SolanaContextLoader.js.map +7 -0
  183. package/lib/esm/src/solana/domain/solanaContextTypes.js +1 -0
  184. package/lib/esm/src/solana/domain/solanaContextTypes.js.map +7 -0
  185. package/lib/esm/src/token/di/tokenModuleFactory.js +1 -1
  186. package/lib/esm/src/token/di/tokenModuleFactory.js.map +3 -3
  187. package/lib/esm/src/token/domain/TokenContextLoader.js +1 -1
  188. package/lib/esm/src/token/domain/TokenContextLoader.js.map +3 -3
  189. package/lib/esm/src/token/domain/TokenContextLoader.test.js +1 -1
  190. package/lib/esm/src/token/domain/TokenContextLoader.test.js.map +2 -2
  191. package/lib/esm/src/transaction/data/HttpProxyDataSource.js +2 -0
  192. package/lib/esm/src/transaction/data/HttpProxyDataSource.js.map +7 -0
  193. package/lib/esm/src/transaction/data/HttpProxyDataSource.test.js +2 -0
  194. package/lib/esm/src/transaction/data/HttpProxyDataSource.test.js.map +7 -0
  195. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js +1 -1
  196. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js.map +3 -3
  197. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js +1 -1
  198. package/lib/esm/src/transaction/data/HttpTransactionDataSource.test.js.map +3 -3
  199. package/lib/esm/src/transaction/data/dto/CalldataDto.js.map +7 -0
  200. package/lib/esm/src/transaction/data/dto/ProxyDelegateCallDto.js +1 -0
  201. package/lib/esm/src/transaction/data/dto/ProxyDelegateCallDto.js.map +7 -0
  202. package/lib/esm/src/transaction/data/dto/ProxyImplementationAddressDto.js +1 -0
  203. package/lib/esm/src/transaction/data/dto/ProxyImplementationAddressDto.js.map +7 -0
  204. package/lib/esm/src/transaction/di/transactionModuleFactory.js +1 -1
  205. package/lib/esm/src/transaction/di/transactionModuleFactory.js.map +3 -3
  206. package/lib/esm/src/transaction/di/transactionTypes.js +1 -1
  207. package/lib/esm/src/transaction/di/transactionTypes.js.map +2 -2
  208. package/lib/esm/src/transaction/domain/TransactionContextLoader.js +1 -1
  209. package/lib/esm/src/transaction/domain/TransactionContextLoader.js.map +3 -3
  210. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js +1 -1
  211. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js.map +2 -2
  212. package/lib/esm/src/transaction/model/ProxyDelegateCall.js +1 -0
  213. package/lib/esm/src/transaction/model/ProxyDelegateCall.js.map +7 -0
  214. package/lib/esm/src/transaction/model/ProxyImplementationAddress.js +1 -0
  215. package/lib/esm/src/transaction/model/ProxyImplementationAddress.js.map +7 -0
  216. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js +1 -1
  217. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.js.map +3 -3
  218. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js +1 -1
  219. package/lib/esm/src/trusted-name/data/HttpTrustedNameDataSource.test.js.map +3 -3
  220. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js +1 -1
  221. package/lib/esm/src/trusted-name/di/trustedNameModuleFactory.js.map +3 -3
  222. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js +1 -1
  223. package/lib/esm/src/trusted-name/domain/TrustedNameContextLoader.js.map +3 -3
  224. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
  225. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js.map +3 -3
  226. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  227. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
  228. package/lib/esm/src/typed-data/di/typedDataModuleFactory.js +1 -1
  229. package/lib/esm/src/typed-data/di/typedDataModuleFactory.js.map +3 -3
  230. package/lib/esm/src/uniswap/di/uniswapModuleFactory.js +1 -1
  231. package/lib/esm/src/uniswap/di/uniswapModuleFactory.js.map +3 -3
  232. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js +1 -1
  233. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js.map +3 -3
  234. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
  235. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js.map +2 -2
  236. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.js +1 -1
  237. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.js.map +3 -3
  238. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.test.js +1 -1
  239. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.test.js.map +3 -3
  240. package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js +1 -1
  241. package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js.map +3 -3
  242. package/lib/types/src/ContextModule.d.ts +3 -0
  243. package/lib/types/src/ContextModule.d.ts.map +1 -1
  244. package/lib/types/src/ContextModuleBuilder.d.ts +18 -3
  245. package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -1
  246. package/lib/types/src/DefaultContextModule.d.ts +5 -0
  247. package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
  248. package/lib/types/src/config/di/configModuleFactory.d.ts.map +1 -1
  249. package/lib/types/src/config/model/ContextModuleConfig.d.ts +6 -0
  250. package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -1
  251. package/lib/types/src/di.d.ts.map +1 -1
  252. package/lib/types/src/external-plugin/data/HttpExternalPluginDataSource.d.ts.map +1 -1
  253. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.d.ts +1 -1
  254. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.d.ts.map +1 -1
  255. package/lib/types/src/nft/data/HttpNftDataSource.d.ts +3 -0
  256. package/lib/types/src/nft/data/HttpNftDataSource.d.ts.map +1 -1
  257. package/lib/types/src/nft/domain/NftContextLoader.d.ts +1 -1
  258. package/lib/types/src/nft/domain/NftContextLoader.d.ts.map +1 -1
  259. package/lib/types/src/pki/domain/DefaultPkiCertificateLoader.d.ts.map +1 -1
  260. package/lib/types/src/shared/constant/HttpHeaders.d.ts +1 -1
  261. package/lib/types/src/shared/constant/HttpHeaders.d.ts.map +1 -1
  262. package/lib/types/src/shared/model/SolanaTransactionContext.d.ts +11 -0
  263. package/lib/types/src/shared/model/SolanaTransactionContext.d.ts.map +1 -0
  264. package/lib/types/src/shared/model/TransactionSubset.d.ts +3 -3
  265. package/lib/types/src/shared/model/TransactionSubset.d.ts.map +1 -1
  266. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.d.ts +13 -0
  267. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.d.ts.map +1 -0
  268. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.test.d.ts +2 -0
  269. package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.test.d.ts.map +1 -0
  270. package/lib/types/src/solana/data/SolanaDataSource.d.ts +12 -0
  271. package/lib/types/src/solana/data/SolanaDataSource.d.ts.map +1 -0
  272. package/lib/types/src/solana/di/SolanaContextModuleFactory.d.ts +3 -0
  273. package/lib/types/src/solana/di/SolanaContextModuleFactory.d.ts.map +1 -0
  274. package/lib/types/src/solana/di/solanaContextTypes.d.ts +5 -0
  275. package/lib/types/src/solana/di/solanaContextTypes.d.ts.map +1 -0
  276. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.d.ts +11 -0
  277. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.d.ts.map +1 -0
  278. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.test.d.ts +2 -0
  279. package/lib/types/src/solana/domain/DefaultSolanaContextLoader.test.d.ts.map +1 -0
  280. package/lib/types/src/solana/domain/SolanaContextLoader.d.ts +5 -0
  281. package/lib/types/src/solana/domain/SolanaContextLoader.d.ts.map +1 -0
  282. package/lib/types/src/solana/domain/solanaContextTypes.d.ts +27 -0
  283. package/lib/types/src/solana/domain/solanaContextTypes.d.ts.map +1 -0
  284. package/lib/types/src/token/domain/TokenContextLoader.d.ts +1 -1
  285. package/lib/types/src/token/domain/TokenContextLoader.d.ts.map +1 -1
  286. package/lib/types/src/transaction/data/HttpProxyDataSource.d.ts +32 -0
  287. package/lib/types/src/transaction/data/HttpProxyDataSource.d.ts.map +1 -0
  288. package/lib/types/src/transaction/data/HttpProxyDataSource.test.d.ts +2 -0
  289. package/lib/types/src/transaction/data/HttpProxyDataSource.test.d.ts.map +1 -0
  290. package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts.map +1 -1
  291. package/lib/types/src/transaction/data/dto/CalldataDto.d.ts.map +1 -0
  292. package/lib/types/src/transaction/data/dto/ProxyDelegateCallDto.d.ts +5 -0
  293. package/lib/types/src/transaction/data/dto/ProxyDelegateCallDto.d.ts.map +1 -0
  294. package/lib/types/src/transaction/data/dto/ProxyImplementationAddressDto.d.ts +6 -0
  295. package/lib/types/src/transaction/data/dto/ProxyImplementationAddressDto.d.ts.map +1 -0
  296. package/lib/types/src/transaction/di/transactionModuleFactory.d.ts.map +1 -1
  297. package/lib/types/src/transaction/di/transactionTypes.d.ts +1 -0
  298. package/lib/types/src/transaction/di/transactionTypes.d.ts.map +1 -1
  299. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts +1 -1
  300. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts.map +1 -1
  301. package/lib/types/src/transaction/model/ProxyDelegateCall.d.ts +5 -0
  302. package/lib/types/src/transaction/model/ProxyDelegateCall.d.ts.map +1 -0
  303. package/lib/types/src/transaction/model/ProxyImplementationAddress.d.ts +4 -0
  304. package/lib/types/src/transaction/model/ProxyImplementationAddress.d.ts.map +1 -0
  305. package/lib/types/src/trusted-name/data/HttpTrustedNameDataSource.d.ts.map +1 -1
  306. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts +1 -1
  307. package/lib/types/src/trusted-name/domain/TrustedNameContextLoader.d.ts.map +1 -1
  308. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts.map +1 -1
  309. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts.map +1 -1
  310. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts +1 -1
  311. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts.map +1 -1
  312. package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.d.ts.map +1 -1
  313. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  314. package/package.json +5 -5
  315. package/lib/types/src/transaction/data/CalldataDto.d.ts.map +0 -1
  316. /package/lib/cjs/src/transaction/data/{CalldataDto.js → dto/CalldataDto.js} +0 -0
  317. /package/lib/esm/src/{transaction/data/CalldataDto.js.map → shared/model/SolanaTransactionContext.js.map} +0 -0
  318. /package/lib/esm/src/transaction/data/{CalldataDto.js → dto/CalldataDto.js} +0 -0
  319. /package/lib/types/src/transaction/data/{CalldataDto.d.ts → dto/CalldataDto.d.ts} +0 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/solana/data/HttpSolanaOwnerInfoDataSource.test.ts"],
4
+ "sourcesContent": ["/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n DeviceModelId,\n hexaStringToBuffer,\n} from \"@ledgerhq/device-management-kit\";\nimport axios from \"axios\";\nimport { Left } from \"purify-ts\";\n\nimport type { ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { LEDGER_CLIENT_VERSION_HEADER } from \"@/shared/constant/HttpHeaders\";\nimport { HttpSolanaOwnerInfoDataSource } from \"@/solana/data/HttpSolanaOwnerInfoDataSource\";\nimport type { SolanaTransactionContext } from \"@/solana/domain/solanaContextTypes\";\nimport PACKAGE from \"@root/package.json\";\n\nvi.mock(\"axios\");\n\nfunction stringToHex(str: string): string {\n const encoder = new TextEncoder();\n const bytes = encoder.encode(str); // Uint8Array\n return Array.from(bytes)\n .map((byte) => byte.toString(16).padStart(2, \"0\"))\n .join(\"\");\n}\n\ndescribe(\"HttpSolanaOwnerInfoDataSource\", () => {\n const config = {\n metadataService: { url: \"https://some.doma.in\" },\n originToken: \"mock-origin-token\",\n } as ContextModuleConfig;\n\n const signedDescriptorHex = stringToHex(\"mock-descriptor\");\n const responseData = {\n tokenAccount: \"token-account\",\n owner: \"owner-address\",\n contract: \"contract-address\",\n signedDescriptor: signedDescriptorHex,\n };\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should fetch address metadata via tokenAddress\", async () => {\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: \"some-token\",\n challenge: \"random\",\n createATA: undefined,\n };\n vi.spyOn(axios, \"request\").mockResolvedValueOnce({ data: responseData });\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n const result = await dataSource.getOwnerInfo(context);\n\n expect(result.isRight()).toBe(true);\n expect(result.extract()).toEqual({\n descriptor: hexaStringToBuffer(signedDescriptorHex),\n tokenAccount: \"token-account\",\n owner: \"owner-address\",\n contract: \"contract-address\",\n });\n });\n\n it(\"should compute address when tokenAddress is not provided\", async () => {\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: undefined,\n challenge: \"random\",\n createATA: {\n address: \"some-address\",\n mintAddress: \"some-mint\",\n },\n };\n vi.spyOn(axios, \"request\").mockResolvedValueOnce({ data: responseData });\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n const result = await dataSource.getOwnerInfo(context);\n\n expect(result.isRight()).toBe(true);\n expect((result.extract() as any).tokenAccount).toBe(\"token-account\");\n });\n\n it(\"should return an error if both tokenAddress and createATA are missing or invalid\", async () => {\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: undefined,\n challenge: \"random\",\n createATA: undefined,\n };\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n const result = await dataSource.getOwnerInfo(context);\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: either tokenAddress or valid createATA must be provided\",\n ),\n ),\n );\n });\n\n it(\"should return an error if challenge is missing\", async () => {\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: \"some-token\",\n challenge: undefined,\n createATA: undefined,\n };\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n const result = await dataSource.getOwnerInfo(context);\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: challenge is required\",\n ),\n ),\n );\n });\n\n it(\"should return an error if the descriptor is not valid base64\", async () => {\n vi.spyOn(axios, \"request\").mockResolvedValueOnce({\n data: { ...responseData, signedDescriptor: \"!!!not-valid-base64!!!\" },\n });\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: \"some-token\",\n challenge: \"random\",\n createATA: undefined,\n };\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n const result = await dataSource.getOwnerInfo(context);\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid base64 descriptor received\",\n ),\n ),\n );\n });\n\n it(\"should return an error if the metadata request fails\", async () => {\n vi.spyOn(axios, \"request\").mockRejectedValueOnce(\n new Error(\"Network error\"),\n );\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: \"some-token\",\n challenge: \"random\",\n createATA: undefined,\n };\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n const result = await dataSource.getOwnerInfo(context);\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: Failed to fetch address metadata\",\n ),\n ),\n );\n });\n\n it(\"should return an error if axios request return wrong shape for fetchAddressMetadata\", async () => {\n vi.spyOn(axios, \"request\").mockResolvedValueOnce({\n data: { wrong: \"field\" },\n });\n\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: \"some-token\",\n challenge: \"random\",\n createATA: undefined,\n };\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n const result = await dataSource.getOwnerInfo(context);\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid fetchAddressMetadata response shape\",\n ),\n ),\n );\n });\n\n it(\"should return an error if axios request return wrong shape for computeAddressMetadata\", async () => {\n vi.spyOn(axios, \"request\").mockResolvedValueOnce({\n data: { wrong: \"field\" },\n });\n\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: undefined,\n challenge: \"random\",\n createATA: {\n address: \"some-address\",\n mintAddress: \"some-mint\",\n },\n };\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n const result = await dataSource.getOwnerInfo(context);\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid computeAddressMetadata response shape\",\n ),\n ),\n );\n });\n\n it(\"should throw if originToken is missing\", () => {\n expect(() => {\n new HttpSolanaOwnerInfoDataSource({\n ...config,\n originToken: undefined,\n } as any);\n }).toThrow(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: origin token is required\",\n );\n });\n\n it(\"should call axios with correct headers\", async () => {\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: \"some-token\",\n challenge: \"random\",\n createATA: undefined,\n };\n const spy = vi\n .spyOn(axios, \"request\")\n .mockResolvedValueOnce({ data: responseData });\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n await dataSource.getOwnerInfo(context);\n\n expect(spy).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n \"X-Ledger-Client-Origin\": config.originToken,\n },\n }),\n );\n });\n});\n"],
5
+ "mappings": "AAEA,OACE,iBAAAA,EACA,sBAAAC,MACK,kCACP,OAAOC,MAAW,QAClB,OAAS,QAAAC,MAAY,YAGrB,OAAS,gCAAAC,MAAoC,gCAC7C,OAAS,iCAAAC,MAAqC,8CAE9C,OAAOC,MAAa,qBAEpB,GAAG,KAAK,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"HttpSolanaOwnerInfoDataSource", "PACKAGE", "stringToHex", "str", "bytes", "byte", "config", "signedDescriptorHex", "responseData", "context", "result", "spy"]
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=SolanaDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ import{ContainerModule as a}from"inversify";import{HttpSolanaOwnerInfoDataSource as e}from"../../solana/data/HttpSolanaOwnerInfoDataSource";import{solanaContextTypes as t}from"../../solana/di/solanaContextTypes";import{DefaultSolanaContextLoader as r}from"../../solana/domain/DefaultSolanaContextLoader";const f=()=>new a(({bind:o})=>{o(t.SolanaDataSource).to(e),o(t.SolanaContextLoader).to(r)});export{f as solanaContextModuleFactory};
2
+ //# sourceMappingURL=SolanaContextModuleFactory.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/solana/di/SolanaContextModuleFactory.ts"],
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpSolanaOwnerInfoDataSource } from \"@/solana/data/HttpSolanaOwnerInfoDataSource\";\nimport { solanaContextTypes } from \"@/solana/di/solanaContextTypes\";\nimport { DefaultSolanaContextLoader } from \"@/solana/domain/DefaultSolanaContextLoader\";\n\nexport const solanaContextModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(solanaContextTypes.SolanaDataSource).to(HttpSolanaOwnerInfoDataSource);\n bind(solanaContextTypes.SolanaContextLoader).to(DefaultSolanaContextLoader);\n });\n"],
5
+ "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,iCAAAC,MAAqC,8CAC9C,OAAS,sBAAAC,MAA0B,iCACnC,OAAS,8BAAAC,MAAkC,6CAEpC,MAAMC,EAA6B,IACxC,IAAIJ,EAAgB,CAAC,CAAE,KAAAK,CAAK,IAAM,CAChCA,EAAKH,EAAmB,gBAAgB,EAAE,GAAGD,CAA6B,EAC1EI,EAAKH,EAAmB,mBAAmB,EAAE,GAAGC,CAA0B,CAC5E,CAAC",
6
+ "names": ["ContainerModule", "HttpSolanaOwnerInfoDataSource", "solanaContextTypes", "DefaultSolanaContextLoader", "solanaContextModuleFactory", "bind"]
7
+ }
@@ -0,0 +1,2 @@
1
+ const o={SolanaDataSource:Symbol.for("SolanaDataSource"),SolanaContextLoader:Symbol.for("SolanaContextLoader")};export{o as solanaContextTypes};
2
+ //# sourceMappingURL=solanaContextTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/solana/di/solanaContextTypes.ts"],
4
+ "sourcesContent": ["export const solanaContextTypes = {\n SolanaDataSource: Symbol.for(\"SolanaDataSource\"),\n SolanaContextLoader: Symbol.for(\"SolanaContextLoader\"),\n};\n"],
5
+ "mappings": "AAAO,MAAMA,EAAqB,CAChC,iBAAkB,OAAO,IAAI,kBAAkB,EAC/C,oBAAqB,OAAO,IAAI,qBAAqB,CACvD",
6
+ "names": ["solanaContextTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ var f=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var s=(r,e,t,o)=>{for(var a=o>1?void 0:o?p(e,t):e,i=r.length-1,n;i>=0;i--)(n=r[i])&&(a=(o?n(e,t,a):n(a))||a);return o&&a&&f(e,t,a),a},m=(r,e)=>(t,o)=>e(t,o,r);import{inject as d,injectable as l}from"inversify";import{Left as S}from"purify-ts";import{pkiTypes as u}from"../../pki/di/pkiTypes";import{KeyUsage as y}from"../../pki/model/KeyUsage";import{solanaContextTypes as C}from"../../solana/di/solanaContextTypes";let c=class{constructor(e,t){this._certificateLoader=t;this._dataSource=e}_dataSource;async load(e){const t=await this._certificateLoader.loadCertificate({keyId:"domain_metadata_key",keyUsage:y.TrustedName,targetDevice:e.deviceModelId});return t?(await this._dataSource.getOwnerInfo(e)).map(({descriptor:o,tokenAccount:a,owner:i,contract:n})=>({descriptor:o,tokenAccount:a,owner:i,contract:n,certificate:t})):S(new Error("[ContextModule] - DefaultSolanaContextLoader: CAL certificate is undefined"))}};c=s([l(),m(0,d(C.SolanaDataSource)),m(1,d(u.PkiCertificateLoader))],c);export{c as DefaultSolanaContextLoader};
2
+ //# sourceMappingURL=DefaultSolanaContextLoader.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/solana/domain/DefaultSolanaContextLoader.ts"],
4
+ "sourcesContent": ["import { inject, injectable } from \"inversify\";\nimport { Left } from \"purify-ts\";\n\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { type SolanaDataSource } from \"@/solana/data/SolanaDataSource\";\nimport { solanaContextTypes } from \"@/solana/di/solanaContextTypes\";\n\nimport { SolanaContextLoader } from \"./SolanaContextLoader\";\nimport {\n SolanaTransactionContext,\n SolanaTransactionContextResult,\n} from \"./solanaContextTypes\";\n\n@injectable()\nexport class DefaultSolanaContextLoader implements SolanaContextLoader {\n private _dataSource: SolanaDataSource;\n\n constructor(\n @inject(solanaContextTypes.SolanaDataSource)\n dataSource: SolanaDataSource,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly _certificateLoader: PkiCertificateLoader,\n ) {\n this._dataSource = dataSource;\n }\n\n async load(\n solanaContext: SolanaTransactionContext,\n ): Promise<SolanaTransactionContextResult> {\n // load the CAL certificate\n const certificate = await this._certificateLoader.loadCertificate({\n keyId: \"domain_metadata_key\",\n keyUsage: KeyUsage.TrustedName,\n targetDevice: solanaContext.deviceModelId,\n });\n if (!certificate) {\n return Left(\n new Error(\n \"[ContextModule] - DefaultSolanaContextLoader: CAL certificate is undefined\",\n ),\n );\n }\n\n // fetch the Solana context\n return (await this._dataSource.getOwnerInfo(solanaContext)).map(\n ({ descriptor, tokenAccount, owner, contract }) => ({\n descriptor,\n tokenAccount,\n owner,\n contract,\n certificate,\n }),\n );\n }\n}\n"],
5
+ "mappings": "iOAAA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YACnC,OAAS,QAAAC,MAAY,YAErB,OAAS,YAAAC,MAAgB,oBAEzB,OAAS,YAAAC,MAAgB,uBAEzB,OAAS,sBAAAC,MAA0B,iCAS5B,IAAMC,EAAN,KAAgE,CAGrE,YAEEC,EAEiBC,EACjB,CADiB,wBAAAA,EAEjB,KAAK,YAAcD,CACrB,CATQ,YAWR,MAAM,KACJE,EACyC,CAEzC,MAAMC,EAAc,MAAM,KAAK,mBAAmB,gBAAgB,CAChE,MAAO,sBACP,SAAUC,EAAS,YACnB,aAAcF,EAAc,aAC9B,CAAC,EACD,OAAKC,GASG,MAAM,KAAK,YAAY,aAAaD,CAAa,GAAG,IAC1D,CAAC,CAAE,WAAAG,EAAY,aAAAC,EAAc,MAAAC,EAAO,SAAAC,CAAS,KAAO,CAClD,WAAAH,EACA,aAAAC,EACA,MAAAC,EACA,SAAAC,EACA,YAAAL,CACF,EACF,EAhBSM,EACL,IAAI,MACF,4EACF,CACF,CAaJ,CACF,EAxCaV,EAANW,EAAA,CADNC,EAAW,EAKPC,EAAA,EAAAC,EAAOC,EAAmB,gBAAgB,GAE1CF,EAAA,EAAAC,EAAOE,EAAS,oBAAoB,IAN5BhB",
6
+ "names": ["inject", "injectable", "Left", "pkiTypes", "KeyUsage", "solanaContextTypes", "DefaultSolanaContextLoader", "dataSource", "_certificateLoader", "solanaContext", "certificate", "KeyUsage", "descriptor", "tokenAccount", "owner", "contract", "Left", "__decorateClass", "injectable", "__decorateParam", "inject", "solanaContextTypes", "pkiTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{DeviceModelId as i}from"@ledgerhq/device-management-kit";import{Left as d,Right as l}from"purify-ts";import{KeyUsage as s}from"../../pki/model/KeyUsage";import{DefaultSolanaContextLoader as f}from"../../solana/domain/DefaultSolanaContextLoader";describe("DefaultSolanaContextLoader",()=>{let a,e,r;const o={deviceModelId:i.FLEX,tokenAddress:"token-addr",challenge:"challenge-str"},n={descriptor:"cert-desc",signature:"cert-sig",keyUsageNumber:0,payload:new Uint8Array};beforeEach(()=>{vi.resetAllMocks(),a={getOwnerInfo:vi.fn()},e={loadCertificate:vi.fn()},r=new f(a,e)}),it("should call dataSource.getSolanaContext and certificateLoader.loadCertificate with correct args",async()=>{e.loadCertificate.mockResolvedValue(n),a.getOwnerInfo.mockResolvedValue(l({descriptor:Buffer.from("d"),tokenAccount:"tkn",owner:"own",contract:"ctr"})),await r.load(o),expect(e.loadCertificate).toHaveBeenCalledWith({keyId:"domain_metadata_key",keyUsage:s.TrustedName,targetDevice:o.deviceModelId}),expect(a.getOwnerInfo).toHaveBeenCalledWith(o)}),it("should return Left if certificate loader returns undefined",async()=>{e.loadCertificate.mockResolvedValue(void 0);const t=await r.load(o);expect(t).toEqual(d(new Error("[ContextModule] - DefaultSolanaContextLoader: CAL certificate is undefined")))}),it("should propagate Left from dataSource.getSolanaContext",async()=>{e.loadCertificate.mockResolvedValue(n);const t=new Error("DS failure");a.getOwnerInfo.mockResolvedValue(d(t));const c=await r.load(o);expect(c).toEqual(d(t))}),it("should return Right with merged data and certificate on success",async()=>{e.loadCertificate.mockResolvedValue(n);const t={descriptor:Buffer.from("dd"),tokenAccount:"tokenAcct",owner:"ownerAddr",contract:"contractAddr",certificate:n};a.getOwnerInfo.mockResolvedValue(l(t));const c=await r.load(o);expect(c.isRight()).toBe(!0),expect(c.extract()).toEqual({...t,certificate:n})})});
2
+ //# sourceMappingURL=DefaultSolanaContextLoader.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/solana/domain/DefaultSolanaContextLoader.test.ts"],
4
+ "sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { DefaultSolanaContextLoader } from \"@/solana/domain/DefaultSolanaContextLoader\";\nimport type {\n SolanaTransactionContext,\n SolanaTransactionContextResultSuccess,\n} from \"@/solana/domain/solanaContextTypes\";\n\ndescribe(\"DefaultSolanaContextLoader\", () => {\n let mockDataSource: {\n getOwnerInfo: any;\n };\n let mockCertLoader: {\n loadCertificate: any;\n };\n let loader: DefaultSolanaContextLoader;\n\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: \"token-addr\",\n challenge: \"challenge-str\",\n } as any;\n\n const fakeCert = {\n descriptor: \"cert-desc\",\n signature: \"cert-sig\",\n keyUsageNumber: 0,\n payload: new Uint8Array(),\n };\n\n beforeEach(() => {\n vi.resetAllMocks();\n mockDataSource = {\n getOwnerInfo: vi.fn(),\n };\n mockCertLoader = {\n loadCertificate: vi.fn(),\n };\n\n loader = new DefaultSolanaContextLoader(\n mockDataSource as any,\n mockCertLoader as any,\n );\n });\n\n it(\"should call dataSource.getSolanaContext and certificateLoader.loadCertificate with correct args\", async () => {\n // given\n mockCertLoader.loadCertificate.mockResolvedValue(fakeCert);\n mockDataSource.getOwnerInfo.mockResolvedValue(\n Right({\n descriptor: Buffer.from(\"d\"),\n tokenAccount: \"tkn\",\n owner: \"own\",\n contract: \"ctr\",\n }),\n );\n\n // when\n await loader.load(context);\n\n // then\n expect(mockCertLoader.loadCertificate).toHaveBeenCalledWith({\n keyId: \"domain_metadata_key\",\n keyUsage: KeyUsage.TrustedName,\n targetDevice: context.deviceModelId,\n });\n expect(mockDataSource.getOwnerInfo).toHaveBeenCalledWith(context);\n });\n\n it(\"should return Left if certificate loader returns undefined\", async () => {\n mockCertLoader.loadCertificate.mockResolvedValue(undefined);\n\n const result = await loader.load(context);\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] - DefaultSolanaContextLoader: CAL certificate is undefined\",\n ),\n ),\n );\n });\n\n it(\"should propagate Left from dataSource.getSolanaContext\", async () => {\n mockCertLoader.loadCertificate.mockResolvedValue(fakeCert);\n const dsError = new Error(\"DS failure\");\n mockDataSource.getOwnerInfo.mockResolvedValue(Left(dsError));\n\n const result = await loader.load(context);\n\n expect(result).toEqual(Left(dsError));\n });\n\n it(\"should return Right with merged data and certificate on success\", async () => {\n mockCertLoader.loadCertificate.mockResolvedValue(fakeCert);\n\n const dsPayload: SolanaTransactionContextResultSuccess = {\n descriptor: Buffer.from(\"dd\"),\n tokenAccount: \"tokenAcct\",\n owner: \"ownerAddr\",\n contract: \"contractAddr\",\n certificate: fakeCert,\n };\n mockDataSource.getOwnerInfo.mockResolvedValue(Right(dsPayload));\n\n const result = await loader.load(context);\n\n expect(result.isRight()).toBe(true);\n expect(result.extract()).toEqual({\n ...dsPayload,\n certificate: fakeCert,\n });\n });\n});\n"],
5
+ "mappings": "AACA,OAAS,iBAAAA,MAAqB,kCAC9B,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAE5B,OAAS,YAAAC,MAAgB,uBACzB,OAAS,8BAAAC,MAAkC,6CAM3C,SAAS,6BAA8B,IAAM,CAC3C,IAAIC,EAGAC,EAGAC,EAEJ,MAAMC,EAAoC,CACxC,cAAeR,EAAc,KAC7B,aAAc,aACd,UAAW,eACb,EAEMS,EAAW,CACf,WAAY,YACZ,UAAW,WACX,eAAgB,EAChB,QAAS,IAAI,UACf,EAEA,WAAW,IAAM,CACf,GAAG,cAAc,EACjBJ,EAAiB,CACf,aAAc,GAAG,GAAG,CACtB,EACAC,EAAiB,CACf,gBAAiB,GAAG,GAAG,CACzB,EAEAC,EAAS,IAAIH,EACXC,EACAC,CACF,CACF,CAAC,EAED,GAAG,kGAAmG,SAAY,CAEhHA,EAAe,gBAAgB,kBAAkBG,CAAQ,EACzDJ,EAAe,aAAa,kBAC1BH,EAAM,CACJ,WAAY,OAAO,KAAK,GAAG,EAC3B,aAAc,MACd,MAAO,MACP,SAAU,KACZ,CAAC,CACH,EAGA,MAAMK,EAAO,KAAKC,CAAO,EAGzB,OAAOF,EAAe,eAAe,EAAE,qBAAqB,CAC1D,MAAO,sBACP,SAAUH,EAAS,YACnB,aAAcK,EAAQ,aACxB,CAAC,EACD,OAAOH,EAAe,YAAY,EAAE,qBAAqBG,CAAO,CAClE,CAAC,EAED,GAAG,6DAA8D,SAAY,CAC3EF,EAAe,gBAAgB,kBAAkB,MAAS,EAE1D,MAAMI,EAAS,MAAMH,EAAO,KAAKC,CAAO,EAExC,OAAOE,CAAM,EAAE,QACbT,EACE,IAAI,MACF,4EACF,CACF,CACF,CACF,CAAC,EAED,GAAG,yDAA0D,SAAY,CACvEK,EAAe,gBAAgB,kBAAkBG,CAAQ,EACzD,MAAME,EAAU,IAAI,MAAM,YAAY,EACtCN,EAAe,aAAa,kBAAkBJ,EAAKU,CAAO,CAAC,EAE3D,MAAMD,EAAS,MAAMH,EAAO,KAAKC,CAAO,EAExC,OAAOE,CAAM,EAAE,QAAQT,EAAKU,CAAO,CAAC,CACtC,CAAC,EAED,GAAG,kEAAmE,SAAY,CAChFL,EAAe,gBAAgB,kBAAkBG,CAAQ,EAEzD,MAAMG,EAAmD,CACvD,WAAY,OAAO,KAAK,IAAI,EAC5B,aAAc,YACd,MAAO,YACP,SAAU,eACV,YAAaH,CACf,EACAJ,EAAe,aAAa,kBAAkBH,EAAMU,CAAS,CAAC,EAE9D,MAAMF,EAAS,MAAMH,EAAO,KAAKC,CAAO,EAExC,OAAOE,EAAO,QAAQ,CAAC,EAAE,KAAK,EAAI,EAClC,OAAOA,EAAO,QAAQ,CAAC,EAAE,QAAQ,CAC/B,GAAGE,EACH,YAAaH,CACf,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["DeviceModelId", "Left", "Right", "KeyUsage", "DefaultSolanaContextLoader", "mockDataSource", "mockCertLoader", "loader", "context", "fakeCert", "result", "dsError", "dsPayload"]
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=SolanaContextLoader.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=solanaContextTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,2 +1,2 @@
1
- import{ContainerModule as e}from"inversify";import{HttpTokenDataSource as r}from"../../token/data/HttpTokenDataSource";import{tokenTypes as t}from"../../token/di/tokenTypes";import{TokenContextLoader as n}from"../../token/domain/TokenContextLoader";const T=()=>new e((o,a,m,i)=>{o(t.TokenDataSource).to(r),o(t.TokenContextLoader).to(n)});export{T as tokenModuleFactory};
1
+ import{ContainerModule as e}from"inversify";import{HttpTokenDataSource as r}from"../../token/data/HttpTokenDataSource";import{tokenTypes as t}from"../../token/di/tokenTypes";import{TokenContextLoader as n}from"../../token/domain/TokenContextLoader";const T=()=>new e(({bind:o})=>{o(t.TokenDataSource).to(r),o(t.TokenContextLoader).to(n)});export{T as tokenModuleFactory};
2
2
  //# sourceMappingURL=tokenModuleFactory.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/token/di/tokenModuleFactory.ts"],
4
- "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpTokenDataSource } from \"@/token/data/HttpTokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\nimport { TokenContextLoader } from \"@/token/domain/TokenContextLoader\";\n\nexport const tokenModuleFactory = () =>\n new ContainerModule((bind, _unbind, _isBound, _rebind) => {\n bind(tokenTypes.TokenDataSource).to(HttpTokenDataSource);\n bind(tokenTypes.TokenContextLoader).to(TokenContextLoader);\n });\n"],
5
- "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,uBAAAC,MAA2B,mCACpC,OAAS,cAAAC,MAAkB,wBAC3B,OAAS,sBAAAC,MAA0B,oCAE5B,MAAMC,EAAqB,IAChC,IAAIJ,EAAgB,CAACK,EAAMC,EAASC,EAAUC,IAAY,CACxDH,EAAKH,EAAW,eAAe,EAAE,GAAGD,CAAmB,EACvDI,EAAKH,EAAW,kBAAkB,EAAE,GAAGC,CAAkB,CAC3D,CAAC",
6
- "names": ["ContainerModule", "HttpTokenDataSource", "tokenTypes", "TokenContextLoader", "tokenModuleFactory", "bind", "_unbind", "_isBound", "_rebind"]
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpTokenDataSource } from \"@/token/data/HttpTokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\nimport { TokenContextLoader } from \"@/token/domain/TokenContextLoader\";\n\nexport const tokenModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(tokenTypes.TokenDataSource).to(HttpTokenDataSource);\n bind(tokenTypes.TokenContextLoader).to(TokenContextLoader);\n });\n"],
5
+ "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,uBAAAC,MAA2B,mCACpC,OAAS,cAAAC,MAAkB,wBAC3B,OAAS,sBAAAC,MAA0B,oCAE5B,MAAMC,EAAqB,IAChC,IAAIJ,EAAgB,CAAC,CAAE,KAAAK,CAAK,IAAM,CAChCA,EAAKH,EAAW,eAAe,EAAE,GAAGD,CAAmB,EACvDI,EAAKH,EAAW,kBAAkB,EAAE,GAAGC,CAAkB,CAC3D,CAAC",
6
+ "names": ["ContainerModule", "HttpTokenDataSource", "tokenTypes", "TokenContextLoader", "tokenModuleFactory", "bind"]
7
7
  }
@@ -1,2 +1,2 @@
1
- var u=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var c=(n,e,t,a)=>{for(var r=a>1?void 0:a?S(e,t):e,s=n.length-1,l;s>=0;s--)(l=n[s])&&(r=(a?l(e,t,r):l(r))||r);return a&&r&&u(e,t,r),r},p=(n,e)=>(t,a)=>e(t,a,n);import{isHexaString as x}from"@ledgerhq/device-management-kit";import{inject as m,injectable as y}from"inversify";import{ClearSignContextType as o}from"../../shared/model/ClearSignContext";import{tokenTypes as f}from"../../token/di/tokenTypes";var d=(t=>(t.Approve="0x095ea7b3",t.Transfer="0xa9059cbb",t))(d||{});const g=Object.values(d);let i=class{_dataSource;constructor(e){this._dataSource=e}async load(e){if(!e.to||!e.data||e.data==="0x")return[];const t=e.data.slice(0,10);return x(t)?this.isSelectorSupported(t)?[(await this._dataSource.getTokenInfosPayload({address:e.to,chainId:e.chainId})).caseOf({Left:r=>({type:o.ERROR,error:r}),Right:r=>({type:o.TOKEN,payload:r})})]:[]:[{type:o.ERROR,error:new Error("Invalid selector")}]}async loadField(e){return e.type!==o.TOKEN?null:(await this._dataSource.getTokenInfosPayload({address:e.address,chainId:e.chainId})).caseOf({Left:a=>({type:o.ERROR,error:a}),Right:a=>({type:o.TOKEN,payload:a})})}isSelectorSupported(e){return Object.values(g).includes(e)}};i=c([y(),p(0,m(f.TokenDataSource))],i);export{d as ERC20_SUPPORTED_SELECTORS,i as TokenContextLoader};
1
+ var u=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var l=(i,t,a,e)=>{for(var r=e>1?void 0:e?S(t,a):t,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=(e?o(t,a,r):o(r))||r);return e&&r&&u(t,a,r),r},p=(i,t)=>(a,e)=>t(a,e,i);import{isHexaString as m}from"@ledgerhq/device-management-kit";import{inject as x,injectable as y}from"inversify";import{ClearSignContextType as n}from"../../shared/model/ClearSignContext";import{tokenTypes as f}from"../../token/di/tokenTypes";var d=(a=>(a.Approve="0x095ea7b3",a.Transfer="0xa9059cbb",a))(d||{});const g=Object.values(d);let c=class{_dataSource;constructor(t){this._dataSource=t}async load(t){const{to:a,selector:e,chainId:r}=t;return a?m(e)?this.isSelectorSupported(e)?[(await this._dataSource.getTokenInfosPayload({address:a,chainId:r})).caseOf({Left:o=>({type:n.ERROR,error:o}),Right:o=>({type:n.TOKEN,payload:o})})]:[]:[{type:n.ERROR,error:new Error("Invalid selector")}]:[]}async loadField(t){return t.type!==n.TOKEN?null:(await this._dataSource.getTokenInfosPayload({address:t.address,chainId:t.chainId})).caseOf({Left:e=>({type:n.ERROR,error:e}),Right:e=>({type:n.TOKEN,payload:e})})}isSelectorSupported(t){return Object.values(g).includes(t)}};c=l([y(),p(0,x(f.TokenDataSource))],c);export{d as ERC20_SUPPORTED_SELECTORS,c as TokenContextLoader};
2
2
  //# sourceMappingURL=TokenContextLoader.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/token/domain/TokenContextLoader.ts"],
4
- "sourcesContent": ["import { HexaString, isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport {\n TransactionContext,\n TransactionFieldContext,\n} from \"@/shared/model/TransactionContext\";\nimport type { TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\n\nexport enum ERC20_SUPPORTED_SELECTORS {\n Approve = \"0x095ea7b3\",\n Transfer = \"0xa9059cbb\",\n}\n\nconst SUPPORTED_SELECTORS: HexaString[] = Object.values(\n ERC20_SUPPORTED_SELECTORS,\n);\n\n@injectable()\nexport class TokenContextLoader implements ContextLoader {\n private _dataSource: TokenDataSource;\n\n constructor(@inject(tokenTypes.TokenDataSource) dataSource: TokenDataSource) {\n this._dataSource = dataSource;\n }\n\n async load(transaction: TransactionContext): Promise<ClearSignContext[]> {\n if (!transaction.to || !transaction.data || transaction.data === \"0x\") {\n return [];\n }\n\n const selector = transaction.data.slice(0, 10);\n\n if (!isHexaString(selector)) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ];\n }\n\n if (!this.isSelectorSupported(selector)) {\n return [];\n }\n\n const payload = await this._dataSource.getTokenInfosPayload({\n address: transaction.to,\n chainId: transaction.chainId,\n });\n\n return [\n payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TOKEN,\n payload: value,\n }),\n }),\n ];\n }\n\n async loadField(\n field: TransactionFieldContext,\n ): Promise<ClearSignContext | null> {\n if (field.type !== ClearSignContextType.TOKEN) {\n return null;\n }\n const payload = await this._dataSource.getTokenInfosPayload({\n address: field.address,\n chainId: field.chainId,\n });\n return payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TOKEN,\n payload: value,\n }),\n });\n }\n\n private isSelectorSupported(selector: HexaString) {\n return Object.values(SUPPORTED_SELECTORS).includes(selector);\n }\n}\n"],
5
- "mappings": "iOAAA,OAAqB,gBAAAA,MAAoB,kCACzC,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YAGnC,OAEE,wBAAAC,MACK,kCAMP,OAAS,cAAAC,MAAkB,wBAEpB,IAAKC,OACVA,EAAA,QAAU,aACVA,EAAA,SAAW,aAFDA,OAAA,IAKZ,MAAMC,EAAoC,OAAO,OAC/CD,CACF,EAGO,IAAME,EAAN,KAAkD,CAC/C,YAER,YAAgDC,EAA6B,CAC3E,KAAK,YAAcA,CACrB,CAEA,MAAM,KAAKC,EAA8D,CACvE,GAAI,CAACA,EAAY,IAAM,CAACA,EAAY,MAAQA,EAAY,OAAS,KAC/D,MAAO,CAAC,EAGV,MAAMC,EAAWD,EAAY,KAAK,MAAM,EAAG,EAAE,EAE7C,OAAKE,EAAaD,CAAQ,EASrB,KAAK,oBAAoBA,CAAQ,EAS/B,EALS,MAAM,KAAK,YAAY,qBAAqB,CAC1D,QAASD,EAAY,GACrB,QAASA,EAAY,OACvB,CAAC,GAGS,OAAO,CACb,KAAOG,IAA6B,CAClC,KAAMC,EAAqB,MAC3B,MAAAD,CACF,GACA,MAAQE,IAA6B,CACnC,KAAMD,EAAqB,MAC3B,QAASC,CACX,EACF,CAAC,CACH,EAnBS,CAAC,EATD,CACL,CACE,KAAMD,EAAqB,MAC3B,MAAO,IAAI,MAAM,kBAAkB,CACrC,CACF,CAwBJ,CAEA,MAAM,UACJE,EACkC,CAClC,OAAIA,EAAM,OAASF,EAAqB,MAC/B,MAEO,MAAM,KAAK,YAAY,qBAAqB,CAC1D,QAASE,EAAM,QACf,QAASA,EAAM,OACjB,CAAC,GACc,OAAO,CACpB,KAAOH,IAA6B,CAClC,KAAMC,EAAqB,MAC3B,MAAAD,CACF,GACA,MAAQE,IAA6B,CACnC,KAAMD,EAAqB,MAC3B,QAASC,CACX,EACF,CAAC,CACH,CAEQ,oBAAoBJ,EAAsB,CAChD,OAAO,OAAO,OAAOJ,CAAmB,EAAE,SAASI,CAAQ,CAC7D,CACF,EAvEaH,EAANS,EAAA,CADNC,EAAW,EAIGC,EAAA,EAAAC,EAAOC,EAAW,eAAe,IAHnCb",
6
- "names": ["isHexaString", "inject", "injectable", "ClearSignContextType", "tokenTypes", "ERC20_SUPPORTED_SELECTORS", "SUPPORTED_SELECTORS", "TokenContextLoader", "dataSource", "transaction", "selector", "isHexaString", "error", "ClearSignContextType", "value", "field", "__decorateClass", "injectable", "__decorateParam", "inject", "tokenTypes"]
4
+ "sourcesContent": ["import { HexaString, isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport {\n TransactionContext,\n TransactionFieldContext,\n} from \"@/shared/model/TransactionContext\";\nimport type { TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\n\nexport enum ERC20_SUPPORTED_SELECTORS {\n Approve = \"0x095ea7b3\",\n Transfer = \"0xa9059cbb\",\n}\n\nconst SUPPORTED_SELECTORS: HexaString[] = Object.values(\n ERC20_SUPPORTED_SELECTORS,\n);\n\n@injectable()\nexport class TokenContextLoader implements ContextLoader {\n private _dataSource: TokenDataSource;\n\n constructor(@inject(tokenTypes.TokenDataSource) dataSource: TokenDataSource) {\n this._dataSource = dataSource;\n }\n\n async load(ctx: TransactionContext): Promise<ClearSignContext[]> {\n const { to, selector, chainId } = ctx;\n if (!to) {\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\n if (!this.isSelectorSupported(selector)) {\n return [];\n }\n\n const payload = await this._dataSource.getTokenInfosPayload({\n address: to,\n chainId,\n });\n\n return [\n payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TOKEN,\n payload: value,\n }),\n }),\n ];\n }\n\n async loadField(\n field: TransactionFieldContext,\n ): Promise<ClearSignContext | null> {\n if (field.type !== ClearSignContextType.TOKEN) {\n return null;\n }\n const payload = await this._dataSource.getTokenInfosPayload({\n address: field.address,\n chainId: field.chainId,\n });\n return payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TOKEN,\n payload: value,\n }),\n });\n }\n\n private isSelectorSupported(selector: HexaString) {\n return Object.values(SUPPORTED_SELECTORS).includes(selector);\n }\n}\n"],
5
+ "mappings": "iOAAA,OAAqB,gBAAAA,MAAoB,kCACzC,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YAGnC,OAEE,wBAAAC,MACK,kCAMP,OAAS,cAAAC,MAAkB,wBAEpB,IAAKC,OACVA,EAAA,QAAU,aACVA,EAAA,SAAW,aAFDA,OAAA,IAKZ,MAAMC,EAAoC,OAAO,OAC/CD,CACF,EAGO,IAAME,EAAN,KAAkD,CAC/C,YAER,YAAgDC,EAA6B,CAC3E,KAAK,YAAcA,CACrB,CAEA,MAAM,KAAKC,EAAsD,CAC/D,KAAM,CAAE,GAAAC,EAAI,SAAAC,EAAU,QAAAC,CAAQ,EAAIH,EAClC,OAAKC,EAIAG,EAAaF,CAAQ,EASrB,KAAK,oBAAoBA,CAAQ,EAS/B,EALS,MAAM,KAAK,YAAY,qBAAqB,CAC1D,QAASD,EACT,QAAAE,CACF,CAAC,GAGS,OAAO,CACb,KAAOE,IAA6B,CAClC,KAAMC,EAAqB,MAC3B,MAAAD,CACF,GACA,MAAQE,IAA6B,CACnC,KAAMD,EAAqB,MAC3B,QAASC,CACX,EACF,CAAC,CACH,EAnBS,CAAC,EATD,CACL,CACE,KAAMD,EAAqB,MAC3B,MAAO,IAAI,MAAM,kBAAkB,CACrC,CACF,EATO,CAAC,CAiCZ,CAEA,MAAM,UACJE,EACkC,CAClC,OAAIA,EAAM,OAASF,EAAqB,MAC/B,MAEO,MAAM,KAAK,YAAY,qBAAqB,CAC1D,QAASE,EAAM,QACf,QAASA,EAAM,OACjB,CAAC,GACc,OAAO,CACpB,KAAOH,IAA6B,CAClC,KAAMC,EAAqB,MAC3B,MAAAD,CACF,GACA,MAAQE,IAA6B,CACnC,KAAMD,EAAqB,MAC3B,QAASC,CACX,EACF,CAAC,CACH,CAEQ,oBAAoBL,EAAsB,CAChD,OAAO,OAAO,OAAOL,CAAmB,EAAE,SAASK,CAAQ,CAC7D,CACF,EAtEaJ,EAANW,EAAA,CADNC,EAAW,EAIGC,EAAA,EAAAC,EAAOC,EAAW,eAAe,IAHnCf",
6
+ "names": ["isHexaString", "inject", "injectable", "ClearSignContextType", "tokenTypes", "ERC20_SUPPORTED_SELECTORS", "SUPPORTED_SELECTORS", "TokenContextLoader", "dataSource", "ctx", "to", "selector", "chainId", "isHexaString", "error", "ClearSignContextType", "value", "field", "__decorateClass", "injectable", "__decorateParam", "inject", "tokenTypes"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{Left as r,Right as s}from"purify-ts";import{ClearSignContextType as o}from"../../shared/model/ClearSignContext";import{TokenContextLoader as c}from"../../token/domain/TokenContextLoader";describe("TokenContextLoader",()=>{const n={getTokenInfosPayload:vi.fn()},e=new c(n);beforeEach(()=>{vi.restoreAllMocks(),vi.spyOn(n,"getTokenInfosPayload").mockImplementation(({address:t})=>Promise.resolve(s(`payload-${t}`)))}),describe("load function",()=>{it("should return an empty array if transaction dest is undefined",async()=>{const t={to:void 0,data:"0x01"},a=await e.load(t);expect(a).toEqual([])}),it("should return an empty array if transaction data is undefined",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:void 0},a=await e.load(t);expect(a).toEqual([])}),it("should return an empty array if transaction data is empty",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x"},a=await e.load(t);expect(a).toEqual([])}),it("should return an empty array if the selector is not supported",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x095ea7b20000000000000"},a=await e.load(t);expect(a).toEqual([])}),it("should return an error when transaction data is not a valid hex string",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"notahexstring"},a=await e.load(t);expect(a).toEqual([{type:o.ERROR,error:new Error("Invalid selector")}])}),it("should return an error when datasource returns an error",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x095ea7b30000000000",chainId:1};vi.spyOn(n,"getTokenInfosPayload").mockResolvedValue(r(new Error("error")));const a=await e.load(t);expect(a).toEqual([{type:o.ERROR,error:new Error("error")}])}),it("should return a correct response",async()=>{const t={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",data:"0x095ea7b30000000000",chainId:1},a=await e.load(t);expect(a).toEqual([{type:o.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"}])})}),describe("loadField function",()=>{it("should return an error when field type if not supported",async()=>{const t={type:o.NFT,chainId:7,address:"0x1234"},a=await e.loadField(t);expect(a).toEqual(null)}),it("should return a payload",async()=>{const t={type:o.TOKEN,chainId:7,address:"0x1234"};vi.spyOn(n,"getTokenInfosPayload").mockResolvedValue(s("payload"));const a=await e.loadField(t);expect(a).toEqual({type:o.TOKEN,payload:"payload"})}),it("should return an error when unable to fetch the datasource",async()=>{const t={type:o.TOKEN,chainId:7,address:"0x1234"};vi.spyOn(n,"getTokenInfosPayload").mockResolvedValue(r(new Error("error")));const a=await e.loadField(t);expect(a).toEqual({type:o.ERROR,error:new Error("error")})})})});
1
+ import{Left as r,Right as s}from"purify-ts";import{ClearSignContextType as t}from"../../shared/model/ClearSignContext";import{TokenContextLoader as d}from"../../token/domain/TokenContextLoader";describe("TokenContextLoader",()=>{const n={getTokenInfosPayload:vi.fn()},a=new d(n);beforeEach(()=>{vi.restoreAllMocks(),vi.spyOn(n,"getTokenInfosPayload").mockImplementation(({address:e})=>Promise.resolve(s(`payload-${e}`)))}),describe("load function",()=>{it("should return an empty array if transaction dest is undefined",async()=>{const e={to:void 0},o=await a.load(e);expect(o).toEqual([])}),it("should return an error when datasource returns an error",async()=>{const e={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",chainId:1,selector:"0x095ea7b3"};vi.spyOn(n,"getTokenInfosPayload").mockResolvedValue(r(new Error("error")));const o=await a.load(e);expect(o).toEqual([{type:t.ERROR,error:new Error("error")}])}),it("should return a correct response",async()=>{const e={to:"0xdAC17F958D2ee523a2206206994597C13D831ec7",chainId:1,selector:"0x095ea7b3"},o=await a.load(e);expect(o).toEqual([{type:t.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"}])})}),describe("loadField function",()=>{it("should return an error when field type if not supported",async()=>{const e={type:t.NFT,chainId:7,address:"0x1234"},o=await a.loadField(e);expect(o).toEqual(null)}),it("should return a payload",async()=>{const e={type:t.TOKEN,chainId:7,address:"0x1234"};vi.spyOn(n,"getTokenInfosPayload").mockResolvedValue(s("payload"));const o=await a.loadField(e);expect(o).toEqual({type:t.TOKEN,payload:"payload"})}),it("should return an error when unable to fetch the datasource",async()=>{const e={type:t.TOKEN,chainId:7,address:"0x1234"};vi.spyOn(n,"getTokenInfosPayload").mockResolvedValue(r(new Error("error")));const o=await a.loadField(e);expect(o).toEqual({type:t.ERROR,error:new Error("error")})})})});
2
2
  //# sourceMappingURL=TokenContextLoader.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/token/domain/TokenContextLoader.test.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport {\n type TransactionContext,\n type TransactionFieldContext,\n} from \"@/shared/model/TransactionContext\";\nimport { type TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { TokenContextLoader } from \"@/token/domain/TokenContextLoader\";\n\ndescribe(\"TokenContextLoader\", () => {\n const mockTokenDataSource: TokenDataSource = {\n getTokenInfosPayload: vi.fn(),\n };\n const loader = new TokenContextLoader(mockTokenDataSource);\n\n beforeEach(() => {\n vi.restoreAllMocks();\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockImplementation(\n ({ address }) => Promise.resolve(Right(`payload-${address}`)),\n );\n });\n\n describe(\"load function\", () => {\n it(\"should return an empty array if transaction dest is undefined\", async () => {\n // GIVEN\n const transaction = { to: undefined, data: \"0x01\" } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if transaction data is undefined\", async () => {\n // GIVEN\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: undefined,\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if transaction data is empty\", async () => {\n // GIVEN\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if the selector is not supported\", async () => {\n // GIVEN\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x095ea7b20000000000000\",\n } as unknown as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an error when transaction data is not a valid hex string\", async () => {\n // GIVEN\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"notahexstring\",\n } as unknown as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ]);\n });\n\n it(\"should return an error when datasource returns an error\", async () => {\n // GIVEN\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x095ea7b30000000000\",\n chainId: 1,\n } as TransactionContext;\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(new Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n { type: ClearSignContextType.ERROR, error: new Error(\"error\") },\n ]);\n });\n\n it(\"should return a correct response\", async () => {\n // GIVEN\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n data: \"0x095ea7b30000000000\",\n chainId: 1,\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n ]);\n });\n });\n\n describe(\"loadField function\", () => {\n it(\"should return an error when field type if not supported\", async () => {\n const field: TransactionFieldContext = {\n type: ClearSignContextType.NFT,\n chainId: 7,\n address: \"0x1234\",\n };\n\n const result = await loader.loadField(field);\n\n expect(result).toEqual(null);\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TOKEN,\n chainId: 7,\n address: \"0x1234\",\n };\n\n // WHEN\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Right(\"payload\"),\n );\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.TOKEN,\n payload: \"payload\",\n });\n });\n\n it(\"should return an error when unable to fetch the datasource\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TOKEN,\n chainId: 7,\n address: \"0x1234\",\n };\n\n // WHEN\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(new Error(\"error\")),\n );\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n });\n });\n });\n});\n"],
5
- "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAE5B,OAAS,wBAAAC,MAA4B,kCAMrC,OAAS,sBAAAC,MAA0B,oCAEnC,SAAS,qBAAsB,IAAM,CACnC,MAAMC,EAAuC,CAC3C,qBAAsB,GAAG,GAAG,CAC9B,EACMC,EAAS,IAAIF,EAAmBC,CAAmB,EAEzD,WAAW,IAAM,CACf,GAAG,gBAAgB,EACnB,GAAG,MAAMA,EAAqB,sBAAsB,EAAE,mBACpD,CAAC,CAAE,QAAAE,CAAQ,IAAM,QAAQ,QAAQL,EAAM,WAAWK,CAAO,EAAE,CAAC,CAC9D,CACF,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,GAAG,gEAAiE,SAAY,CAE9E,MAAMC,EAAc,CAAE,GAAI,OAAW,KAAM,MAAO,EAG5CC,EAAS,MAAMH,EAAO,KAAKE,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,EAED,GAAG,gEAAiE,SAAY,CAE9E,MAAMD,EAAc,CAClB,GAAI,6CACJ,KAAM,MACR,EAGMC,E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ACH,CAAC,CACH,CAAC,EAED,SAAS,qBAAsB,IAAM,CACnC,GAAG,0DAA2D,SAAY,CACxE,MAAMO,EAAiC,CACrC,KAAMP,EAAqB,IAC3B,QAAS,EACT,QAAS,QACX,EAEMM,EAAS,MAAMH,EAAO,UAAUI,CAAK,EAE3C,OAAOD,CAAM,EAAE,QAAQ,IAAI,CAC7B,CAAC,EAED,GAAG,0BAA2B,SAAY,CAExC,MAAMC,EAAiC,CACrC,KAAMP,EAAqB,MAC3B,QAAS,EACT,QAAS,QACX,EAGA,GAAG,MAAME,EAAqB,sBAAsB,EAAE,kBACpDH,EAAM,SAAS,CACjB,EACA,MAAMO,EAAS,MAAMH,EAAO,UAAUI,CAAK,EAG3C,OAAOD,CAAM,EAAE,QAAQ,CACrB,KAAMN,EAAqB,MAC3B,QAAS,SACX,CAAC,CACH,CAAC,EAED,GAAG,6DAA8D,SAAY,CAE3E,MAAMO,EAAiC,CACrC,KAAMP,EAAqB,MAC3B,QAAS,EACT,QAAS,QACX,EAGA,GAAG,MAAME,EAAqB,sBAAsB,EAAE,kBACpDJ,EAAK,IAAI,MAAM,OAAO,CAAC,CACzB,EACA,MAAMQ,EAAS,MAAMH,EAAO,UAAUI,CAAK,EAG3C,OAAOD,CAAM,EAAE,QAAQ,CACrB,KAAMN,EAAqB,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 TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { TokenContextLoader } from \"@/token/domain/TokenContextLoader\";\n\ndescribe(\"TokenContextLoader\", () => {\n const mockTokenDataSource: TokenDataSource = {\n getTokenInfosPayload: vi.fn(),\n };\n const loader = new TokenContextLoader(mockTokenDataSource);\n\n beforeEach(() => {\n vi.restoreAllMocks();\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockImplementation(\n ({ address }) => Promise.resolve(Right(`payload-${address}`)),\n );\n });\n\n describe(\"load function\", () => {\n it(\"should return an empty array if transaction dest is undefined\", async () => {\n // GIVEN\n const transaction = { to: undefined } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an error when datasource returns an error\", async () => {\n // GIVEN\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n chainId: 1,\n selector: \"0x095ea7b3\",\n } as TransactionContext;\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(new Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n { type: ClearSignContextType.ERROR, error: new Error(\"error\") },\n ]);\n });\n\n it(\"should return a correct response\", async () => {\n // GIVEN\n const transaction = {\n to: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n chainId: 1,\n selector: \"0x095ea7b3\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n ]);\n });\n });\n\n describe(\"loadField function\", () => {\n it(\"should return an error when field type if not supported\", async () => {\n const field: TransactionFieldContext = {\n type: ClearSignContextType.NFT,\n chainId: 7,\n address: \"0x1234\",\n };\n\n const result = await loader.loadField(field);\n\n expect(result).toEqual(null);\n });\n\n it(\"should return a payload\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TOKEN,\n chainId: 7,\n address: \"0x1234\",\n };\n\n // WHEN\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Right(\"payload\"),\n );\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.TOKEN,\n payload: \"payload\",\n });\n });\n\n it(\"should return an error when unable to fetch the datasource\", async () => {\n // GIVEN\n const field: TransactionFieldContext = {\n type: ClearSignContextType.TOKEN,\n chainId: 7,\n address: \"0x1234\",\n };\n\n // WHEN\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(new Error(\"error\")),\n );\n const result = await loader.loadField(field);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n });\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAE5B,OAAS,wBAAAC,MAA4B,kCAMrC,OAAS,sBAAAC,MAA0B,oCAEnC,SAAS,qBAAsB,IAAM,CACnC,MAAMC,EAAuC,CAC3C,qBAAsB,GAAG,GAAG,CAC9B,EACMC,EAAS,IAAIF,EAAmBC,CAAmB,EAEzD,WAAW,IAAM,CACf,GAAG,gBAAgB,EACnB,GAAG,MAAMA,EAAqB,sBAAsB,EAAE,mBACpD,CAAC,CAAE,QAAAE,CAAQ,IAAM,QAAQ,QAAQL,EAAM,WAAWK,CAAO,EAAE,CAAC,CAC9D,CACF,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,GAAG,gEAAiE,SAAY,CAE9E,MAAMC,EAAc,CAAE,GAAI,MAAU,EAG9BC,EAAS,MAAMH,EAAO,KAAKE,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,EAED,GAAG,0DAA2D,SAAY,CAExE,MAAMD,EAAc,CAClB,GAAI,6CACJ,QAAS,EACT,SAAU,YACZ,EACA,GAAG,MAAMH,EAAqB,sBAAsB,EAAE,kBACpDJ,EAAK,IAAI,MAAM,OAAO,CAAC,CACzB,EAGA,MAAMQ,EAAS,MAAMH,EAAO,KAAKE,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CACrB,CAAE,KAAMN,EAAqB,MAAO,MAAO,IAAI,MAAM,OAAO,CAAE,CAChE,CAAC,CACH,CAAC,EAED,GAAG,mCAAoC,SAAY,CAEjD,MAAMK,EAAc,CAClB,GAAI,6CACJ,QAAS,EACT,SAAU,YACZ,EAGMC,EAAS,MAAMH,EAAO,KAAKE,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CACrB,CACE,KAAMN,EAAqB,MAC3B,QAAS,oDACX,CACF,CAAC,CACH,CAAC,CACH,CAAC,EAED,SAAS,qBAAsB,IAAM,CACnC,GAAG,0DAA2D,SAAY,CACxE,MAAMO,EAAiC,CACrC,KAAMP,EAAqB,IAC3B,QAAS,EACT,QAAS,QACX,EAEMM,EAAS,MAAMH,EAAO,UAAUI,CAAK,EAE3C,OAAOD,CAAM,EAAE,QAAQ,IAAI,CAC7B,CAAC,EAED,GAAG,0BAA2B,SAAY,CAExC,MAAMC,EAAiC,CACrC,KAAMP,EAAqB,MAC3B,QAAS,EACT,QAAS,QACX,EAGA,GAAG,MAAME,EAAqB,sBAAsB,EAAE,kBACpDH,EAAM,SAAS,CACjB,EACA,MAAMO,EAAS,MAAMH,EAAO,UAAUI,CAAK,EAG3C,OAAOD,CAAM,EAAE,QAAQ,CACrB,KAAMN,EAAqB,MAC3B,QAAS,SACX,CAAC,CACH,CAAC,EAED,GAAG,6DAA8D,SAAY,CAE3E,MAAMO,EAAiC,CACrC,KAAMP,EAAqB,MAC3B,QAAS,EACT,QAAS,QACX,EAGA,GAAG,MAAME,EAAqB,sBAAsB,EAAE,kBACpDJ,EAAK,IAAI,MAAM,OAAO,CAAC,CACzB,EACA,MAAMQ,EAAS,MAAMH,EAAO,UAAUI,CAAK,EAG3C,OAAOD,CAAM,EAAE,QAAQ,CACrB,KAAMN,EAAqB,MAC3B,MAAO,IAAI,MAAM,OAAO,CAC1B,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
6
  "names": ["Left", "Right", "ClearSignContextType", "TokenContextLoader", "mockTokenDataSource", "loader", "address", "transaction", "result", "field"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ var P=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var l=(a,e,o,r)=>{for(var t=r>1?void 0:r?f(e,o):e,i=a.length-1,d;i>=0;i--)(d=a[i])&&(t=(r?d(e,o,t):d(t))||t);return r&&t&&P(e,o,t),t},m=(a,e)=>(o,r)=>e(o,r,a);import p from"axios";import{inject as D,injectable as u}from"inversify";import{Left as n,Right as y}from"purify-ts";import{configTypes as C}from"../../config/di/configTypes";import{LEDGER_CLIENT_VERSION_HEADER as x,LEDGER_ORIGIN_TOKEN_HEADER as g}from"../../shared/constant/HttpHeaders";import c from"../../../package.json";let s=class{constructor(e){this.config=e}async getProxyDelegateCall({proxyAddress:e,calldata:o,chainId:r}){let t;try{t=(await p.request({method:"POST",url:`${this.config.metadataService.url}/ethereum/${r}/contract/proxy/delegate`,headers:{[x]:`context-module/${c.version}`,[g]:this.config.originToken},data:{proxy:e,data:o}})).data}catch{return n(new Error("[ContextModule] HttpProxyDataSource: Failed to fetch delegate proxy"))}return t?this.isProxyDelegateCallDto(t)?y(t):n(new Error(`[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${e} on chain ${r}`)):n(new Error(`[ContextModule] HttpProxyDataSource: No data received for proxy ${e} on chain ${r}`))}async getProxyImplementationAddress({proxyAddress:e,chainId:o}){let r;try{r=(await p.request({method:"GET",url:`${this.config.metadataService.url}/ethereum/${o}/contract/proxy/${e}`,headers:{[x]:`context-module/${c.version}`,[g]:this.config.originToken}})).data}catch{return n(new Error("[ContextModule] HttpProxyDataSource: Failed to fetch implementation address"))}return r?this.isProxyImplementationAddressDto(r)?y({implementationAddress:r.implementationAddress}):n(new Error(`[ContextModule] HttpProxyDataSource: Invalid proxy implementation address response format for proxy ${e} on chain ${o}`)):n(new Error(`[ContextModule] HttpProxyDataSource: No data received for proxy ${e} on chain ${o}`))}isProxyDelegateCallDto(e){return typeof e=="object"&&e!==null&&"delegateAddresses"in e&&"signedDescriptor"in e&&Array.isArray(e.delegateAddresses)&&e.delegateAddresses.every(o=>typeof o=="string")&&typeof e.signedDescriptor=="string"}isProxyImplementationAddressDto(e){return typeof e=="object"&&e!==null&&"proxyAddress"in e&&"implementationAddress"in e&&"standard"in e&&typeof e.proxyAddress=="string"&&typeof e.implementationAddress=="string"&&typeof e.standard=="string"&&e.standard.length>0}};s=l([u(),m(0,D(C.Config))],s);export{s as HttpProxyDataSource};
2
+ //# sourceMappingURL=HttpProxyDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/transaction/data/HttpProxyDataSource.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 {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport { type ProxyDelegateCall } from \"@/transaction/model/ProxyDelegateCall\";\nimport { type ProxyImplementationAddress } from \"@/transaction/model/ProxyImplementationAddress\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { type ProxyDelegateCallDto } from \"./dto/ProxyDelegateCallDto\";\nimport { type ProxyImplementationAddressDto } from \"./dto/ProxyImplementationAddressDto\";\n\nexport type GetProxyDelegateCallParam = {\n proxyAddress: string;\n calldata: string;\n chainId: number;\n};\n\nexport type GetProxyImplementationAddressParam = {\n proxyAddress: string;\n chainId: number;\n};\n\nexport interface ProxyDataSource {\n getProxyDelegateCall(\n params: GetProxyDelegateCallParam,\n ): Promise<Either<Error, ProxyDelegateCall>>;\n getProxyImplementationAddress(\n params: GetProxyImplementationAddressParam,\n ): Promise<Either<Error, ProxyImplementationAddress>>;\n}\n\n@injectable()\nexport class HttpProxyDataSource implements ProxyDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n public async getProxyDelegateCall({\n proxyAddress,\n calldata,\n chainId,\n }: GetProxyDelegateCallParam): Promise<Either<Error, ProxyDelegateCall>> {\n let dto: ProxyDelegateCallDto | undefined;\n try {\n const response = await axios.request<ProxyDelegateCallDto>({\n method: \"POST\",\n url: `${this.config.metadataService.url}/ethereum/${chainId}/contract/proxy/delegate`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n data: {\n proxy: proxyAddress,\n data: calldata,\n },\n });\n dto = response.data;\n } catch (_error) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: Failed to fetch delegate proxy`,\n ),\n );\n }\n\n if (!dto) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: No data received for proxy ${proxyAddress} on chain ${chainId}`,\n ),\n );\n }\n\n if (!this.isProxyDelegateCallDto(dto)) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy ${proxyAddress} on chain ${chainId}`,\n ),\n );\n }\n\n return Right(dto as ProxyDelegateCall);\n }\n\n public async getProxyImplementationAddress({\n proxyAddress,\n chainId,\n }: GetProxyImplementationAddressParam): Promise<\n Either<Error, ProxyImplementationAddress>\n > {\n let dto: ProxyImplementationAddressDto | undefined;\n try {\n const response = await axios.request<ProxyImplementationAddressDto>({\n method: \"GET\",\n url: `${this.config.metadataService.url}/ethereum/${chainId}/contract/proxy/${proxyAddress}`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n });\n dto = response.data;\n } catch (_error) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: Failed to fetch implementation address`,\n ),\n );\n }\n\n if (!dto) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: No data received for proxy ${proxyAddress} on chain ${chainId}`,\n ),\n );\n }\n\n if (!this.isProxyImplementationAddressDto(dto)) {\n return Left(\n new Error(\n `[ContextModule] HttpProxyDataSource: Invalid proxy implementation address response format for proxy ${proxyAddress} on chain ${chainId}`,\n ),\n );\n }\n\n return Right({ implementationAddress: dto.implementationAddress });\n }\n\n /**\n * Type guard to validate ProxyDelegateCallDto\n */\n private isProxyDelegateCallDto(\n value: unknown,\n ): value is ProxyDelegateCallDto {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"delegateAddresses\" in value &&\n \"signedDescriptor\" in value &&\n Array.isArray(value.delegateAddresses) &&\n value.delegateAddresses.every((address) => typeof address === \"string\") &&\n typeof value.signedDescriptor === \"string\"\n );\n }\n\n /**\n * Type guard to validate ProxyImplementationAddressDto\n */\n private isProxyImplementationAddressDto(\n value: unknown,\n ): value is ProxyImplementationAddressDto {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"proxyAddress\" in value &&\n \"implementationAddress\" in value &&\n \"standard\" in value &&\n typeof value.proxyAddress === \"string\" &&\n typeof value.implementationAddress === \"string\" &&\n typeof value.standard === \"string\" &&\n value.standard.length > 0\n );\n }\n}\n"],
5
+ "mappings": "iOAAA,OAAOA,MAAW,QAClB,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAE5B,OACE,gCAAAC,EACA,8BAAAC,MACK,gCAGP,OAAOC,MAAa,qBA0Bb,IAAMC,EAAN,KAAqD,CAC1D,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CAEH,MAAa,qBAAqB,CAChC,aAAAC,EACA,SAAAC,EACA,QAAAC,CACF,EAAyE,CACvE,IAAIC,EACJ,GAAI,CAaFA,GAZiB,MAAMC,EAAM,QAA8B,CACzD,OAAQ,OACR,IAAK,GAAG,KAAK,OAAO,gBAAgB,GAAG,aAAaF,CAAO,2BAC3D,QAAS,CACP,CAACG,CAA4B,EAA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,GAAU,UACjBA,IAAU,MACV,iBAAkBA,GAClB,0BAA2BA,GAC3B,aAAcA,GACd,OAAOA,EAAM,cAAiB,UAC9B,OAAOA,EAAM,uBAA0B,UACvC,OAAOA,EAAM,UAAa,UAC1BA,EAAM,SAAS,OAAS,CAE5B,CACF,EAnIaZ,EAANc,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,IAFjBlB",
6
+ "names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "LEDGER_CLIENT_VERSION_HEADER", "LEDGER_ORIGIN_TOKEN_HEADER", "PACKAGE", "HttpProxyDataSource", "config", "proxyAddress", "calldata", "chainId", "dto", "axios", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "LEDGER_ORIGIN_TOKEN_HEADER", "Left", "Right", "value", "address", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import a from"axios";import{Left as n,Right as l}from"purify-ts";import{LEDGER_CLIENT_VERSION_HEADER as p,LEDGER_ORIGIN_TOKEN_HEADER as m}from"../../shared/constant/HttpHeaders";import x from"../../../package.json";import{HttpProxyDataSource as y}from"./HttpProxyDataSource";vi.mock("axios");describe("HttpProxyDataSource",()=>{const c={web3checks:{url:"web3checksUrl"},originToken:"originToken"};let t;const s={proxyAddress:"0x72CBdEaAdddD14Ec95b92995933CeC69566650f0",calldata:"0x6a76120200000000000000000000000072cbdeaadddd14ec95b92995933cec69566650f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000440d582f13000000000000000000000000cfa7eae32032bf431aed95532142a9c2b35715d40000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041000000000000000000000000a0766b65a4f7b1da79a1af79ac695456efa2864400000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000",chainId:1},r={proxyAddress:"0xee6a57ec80ea46401049e92587e52f5ec1c24785",chainId:1},d={delegateAddresses:["0xd9db270c1b5e3bd161e8c8503c55ceabee709552"],signedDescriptor:"0x1234567890abcdef"},u={implementationAddress:"0x91ae842a5ffd8d12023116943e72a606179294f3"},i={implementationAddress:"0x91ae842a5ffd8d12023116943e72a606179294f3",proxyAddress:"0xee6a57ec80ea46401049e92587e52f5ec1c24785",standard:"proxy"};beforeEach(()=>{vi.clearAllMocks(),t=new y({metadataService:{url:"https://nft.api.live.ledger.com/v2"},originToken:"originToken"})}),describe("getDelegateProxy",()=>{it("should call axios with the ledger client version header",async()=>{const e=`context-module/${x.version}`,o=vi.fn(()=>Promise.resolve({data:d}));vi.spyOn(a,"request").mockImplementation(o),await t.getProxyDelegateCall(s),expect(o).toHaveBeenCalledWith(expect.objectContaining({headers:{[p]:e,[m]:c.originToken}}))}),it("should return the delegate proxy response on success",async()=>{vi.spyOn(a,"request").mockResolvedValue({data:d});const e=await t.getProxyDelegateCall(s);expect(e).toEqual(l(d))}),it("should return an error when axios throws an error",async()=>{vi.spyOn(a,"request").mockRejectedValue(new Error("fail"));const e=await t.getProxyDelegateCall(s);expect(e).toEqual(n(new Error("[ContextModule] HttpProxyDataSource: Failed to fetch delegate proxy")))}),it("should return an error if response shape is invalid",async()=>{vi.spyOn(a,"request").mockResolvedValue({data:{foo:"bar"}});const e=await t.getProxyDelegateCall(s);expect(e).toEqual(n(new Error("[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy 0x72CBdEaAdddD14Ec95b92995933CeC69566650f0 on chain 1")))}),it("should use the provided chainId in the URL",async()=>{const e=vi.fn(()=>Promise.resolve({data:d}));vi.spyOn(a,"request").mockImplementation(e);const o={proxyAddress:"0x72CBdEaAdddD14Ec95b92995933CeC69566650f0",calldata:"0x6a76120200000000000000000000000072cbdeaadddd14ec95b92995933cec69566650f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000440d582f13000000000000000000000000cfa7eae32032bf431aed95532142a9c2b35715d40000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041000000000000000000000000a0766b65a4f7b1da79a1af79ac695456efa2864400000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000",chainId:137};await t.getProxyDelegateCall(o),expect(e).toHaveBeenCalledWith(expect.objectContaining({method:"POST",url:"https://nft.api.live.ledger.com/v2/ethereum/137/contract/proxy/delegate"}))}),it("should return an error if no dto is returned from the api",async()=>{vi.spyOn(a,"request").mockResolvedValue({data:void 0});const e=await t.getProxyDelegateCall(s);expect(e).toEqual(n(new Error("[ContextModule] HttpProxyDataSource: No data received for proxy 0x72CBdEaAdddD14Ec95b92995933CeC69566650f0 on chain 1")))})}),describe("getImplementAddress",()=>{it("should call axios with the ledger client version header",async()=>{const e=`context-module/${x.version}`,o=vi.fn(()=>Promise.resolve({data:i}));vi.spyOn(a,"request").mockImplementation(o),await t.getProxyImplementationAddress(r),expect(o).toHaveBeenCalledWith(expect.objectContaining({headers:{[p]:e,[m]:c.originToken}}))}),it("should make a GET request to the correct URL",async()=>{const e=vi.fn(()=>Promise.resolve({data:i}));vi.spyOn(a,"request").mockImplementation(e),await t.getProxyImplementationAddress(r),expect(e).toHaveBeenCalledWith(expect.objectContaining({method:"GET",url:"https://nft.api.live.ledger.com/v2/ethereum/1/contract/proxy/0xee6a57ec80ea46401049e92587e52f5ec1c24785"}))}),it("should use the provided chainId in the URL",async()=>{const e=vi.fn(()=>Promise.resolve({data:i}));vi.spyOn(a,"request").mockImplementation(e);const o={proxyAddress:"0xee6a57ec80ea46401049e92587e52f5ec1c24785",chainId:137};await t.getProxyImplementationAddress(o),expect(e).toHaveBeenCalledWith(expect.objectContaining({method:"GET",url:"https://nft.api.live.ledger.com/v2/ethereum/137/contract/proxy/0xee6a57ec80ea46401049e92587e52f5ec1c24785"}))}),it("should return the implementation address response on success",async()=>{vi.spyOn(a,"request").mockResolvedValue({data:i});const e=await t.getProxyImplementationAddress(r);expect(e).toEqual(l(u))}),it("should return an error when axios throws an error",async()=>{vi.spyOn(a,"request").mockRejectedValue(new Error("network error"));const e=await t.getProxyImplementationAddress(r);expect(e).toEqual(n(new Error("[ContextModule] HttpProxyDataSource: Failed to fetch implementation address")))}),it("should return an error if response shape is invalid",async()=>{vi.spyOn(a,"request").mockResolvedValue({data:{invalid:"data"}});const e=await t.getProxyImplementationAddress(r);expect(e).toEqual(n(new Error("[ContextModule] HttpProxyDataSource: Invalid proxy implementation address response format for proxy 0xee6a57ec80ea46401049e92587e52f5ec1c24785 on chain 1")))}),it("should return an error if no dto is returned from the api",async()=>{vi.spyOn(a,"request").mockResolvedValue({data:void 0});const e=await t.getProxyImplementationAddress(r);expect(e).toEqual(n(new Error("[ContextModule] HttpProxyDataSource: No data received for proxy 0xee6a57ec80ea46401049e92587e52f5ec1c24785 on chain 1")))})})});
2
+ //# sourceMappingURL=HttpProxyDataSource.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/transaction/data/HttpProxyDataSource.test.ts"],
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 type { ProxyDelegateCall } from \"@/transaction/model/ProxyDelegateCall\";\nimport type { ProxyImplementationAddress } from \"@/transaction/model/ProxyImplementationAddress\";\nimport PACKAGE from \"@root/package.json\";\n\nimport { type ProxyImplementationAddressDto } from \"./dto/ProxyImplementationAddressDto\";\nimport type {\n GetProxyDelegateCallParam,\n GetProxyImplementationAddressParam,\n ProxyDataSource,\n} from \"./HttpProxyDataSource\";\nimport { HttpProxyDataSource } from \"./HttpProxyDataSource\";\n\nvi.mock(\"axios\");\n\ndescribe(\"HttpProxyDataSource\", () => {\n const config = {\n web3checks: {\n url: \"web3checksUrl\",\n },\n originToken: \"originToken\",\n } as ContextModuleConfig;\n\n let datasource: ProxyDataSource;\n const defaultParams: GetProxyDelegateCallParam = {\n proxyAddress: \"0x72CBdEaAdddD14Ec95b92995933CeC69566650f0\",\n calldata:\n \"0x6a76120200000000000000000000000072cbdeaadddd14ec95b92995933cec69566650f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000440d582f13000000000000000000000000cfa7eae32032bf431aed95532142a9c2b35715d40000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041000000000000000000000000a0766b65a4f7b1da79a1af79ac695456efa2864400000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000\",\n chainId: 1,\n };\n const defaultImplementAddressParams: GetProxyImplementationAddressParam = {\n proxyAddress: \"0xee6a57ec80ea46401049e92587e52f5ec1c24785\",\n chainId: 1,\n };\n const delegateProxyResponse: ProxyDelegateCall = {\n delegateAddresses: [\"0xd9db270c1b5e3bd161e8c8503c55ceabee709552\"],\n signedDescriptor: \"0x1234567890abcdef\",\n };\n const implementationAddressResponse: ProxyImplementationAddress = {\n implementationAddress: \"0x91ae842a5ffd8d12023116943e72a606179294f3\",\n };\n const implementationAddressDto: ProxyImplementationAddressDto = {\n implementationAddress: \"0x91ae842a5ffd8d12023116943e72a606179294f3\",\n proxyAddress: \"0xee6a57ec80ea46401049e92587e52f5ec1c24785\",\n standard: \"proxy\",\n };\n\n beforeEach(() => {\n vi.clearAllMocks();\n datasource = new HttpProxyDataSource({\n metadataService: {\n url: \"https://nft.api.live.ledger.com/v2\",\n },\n originToken: \"originToken\",\n } as ContextModuleConfig);\n });\n\n describe(\"getDelegateProxy\", () => {\n it(\"should call axios with the ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() =>\n Promise.resolve({ data: delegateProxyResponse }),\n );\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getProxyDelegateCall(defaultParams);\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: version,\n [LEDGER_ORIGIN_TOKEN_HEADER]: config.originToken,\n },\n }),\n );\n });\n\n it(\"should return the delegate proxy response on success\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: delegateProxyResponse,\n });\n\n // WHEN\n const result = await datasource.getProxyDelegateCall(defaultParams);\n\n // THEN\n expect(result).toEqual(Right(delegateProxyResponse));\n });\n\n it(\"should return an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"fail\"));\n\n // WHEN\n const result = await datasource.getProxyDelegateCall(defaultParams);\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: Failed to fetch delegate proxy\",\n ),\n ),\n );\n });\n\n it(\"should return an error if response shape is invalid\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: { foo: \"bar\" } });\n\n // WHEN\n const result = await datasource.getProxyDelegateCall(defaultParams);\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: Invalid proxy delegate call response format for proxy 0x72CBdEaAdddD14Ec95b92995933CeC69566650f0 on chain 1\",\n ),\n ),\n );\n });\n\n it(\"should use the provided chainId in the URL\", async () => {\n // GIVEN\n const requestSpy = vi.fn(() =>\n Promise.resolve({ data: delegateProxyResponse }),\n );\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n const paramsWithDifferentChainId: GetProxyDelegateCallParam = {\n proxyAddress: \"0x72CBdEaAdddD14Ec95b92995933CeC69566650f0\",\n calldata:\n \"0x6a76120200000000000000000000000072cbdeaadddd14ec95b92995933cec69566650f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000440d582f13000000000000000000000000cfa7eae32032bf431aed95532142a9c2b35715d40000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041000000000000000000000000a0766b65a4f7b1da79a1af79ac695456efa2864400000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000\",\n chainId: 137, // Polygon\n };\n\n // WHEN\n await datasource.getProxyDelegateCall(paramsWithDifferentChainId);\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n method: \"POST\",\n url: \"https://nft.api.live.ledger.com/v2/ethereum/137/contract/proxy/delegate\",\n }),\n );\n });\n\n it(\"should return an error if no dto is returned from the api\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: undefined,\n });\n\n // WHEN\n const result = await datasource.getProxyDelegateCall(defaultParams);\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: No data received for proxy 0x72CBdEaAdddD14Ec95b92995933CeC69566650f0 on chain 1\",\n ),\n ),\n );\n });\n });\n\n describe(\"getImplementAddress\", () => {\n it(\"should call axios with the ledger client version header\", async () => {\n // GIVEN\n const version = `context-module/${PACKAGE.version}`;\n const requestSpy = vi.fn(() =>\n Promise.resolve({ data: implementationAddressDto }),\n );\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: version,\n [LEDGER_ORIGIN_TOKEN_HEADER]: config.originToken,\n },\n }),\n );\n });\n\n it(\"should make a GET request to the correct URL\", async () => {\n // GIVEN\n const requestSpy = vi.fn(() =>\n Promise.resolve({ data: implementationAddressDto }),\n );\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n // WHEN\n await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n method: \"GET\",\n url: \"https://nft.api.live.ledger.com/v2/ethereum/1/contract/proxy/0xee6a57ec80ea46401049e92587e52f5ec1c24785\",\n }),\n );\n });\n\n it(\"should use the provided chainId in the URL\", async () => {\n // GIVEN\n const requestSpy = vi.fn(() =>\n Promise.resolve({ data: implementationAddressDto }),\n );\n vi.spyOn(axios, \"request\").mockImplementation(requestSpy);\n\n const paramsWithDifferentChainId: GetProxyImplementationAddressParam = {\n proxyAddress: \"0xee6a57ec80ea46401049e92587e52f5ec1c24785\",\n chainId: 137, // Polygon\n };\n\n // WHEN\n await datasource.getProxyImplementationAddress(\n paramsWithDifferentChainId,\n );\n\n // THEN\n expect(requestSpy).toHaveBeenCalledWith(\n expect.objectContaining({\n method: \"GET\",\n url: \"https://nft.api.live.ledger.com/v2/ethereum/137/contract/proxy/0xee6a57ec80ea46401049e92587e52f5ec1c24785\",\n }),\n );\n });\n\n it(\"should return the implementation address response on success\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: implementationAddressDto,\n });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(result).toEqual(Right(implementationAddressResponse));\n });\n\n it(\"should return an error when axios throws an error\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"network error\"));\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: Failed to fetch implementation address\",\n ),\n ),\n );\n });\n\n it(\"should return an error if response shape is invalid\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: { invalid: \"data\" },\n });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: Invalid proxy implementation address response format for proxy 0xee6a57ec80ea46401049e92587e52f5ec1c24785 on chain 1\",\n ),\n ),\n );\n });\n\n it(\"should return an error if no dto is returned from the api\", async () => {\n // GIVEN\n vi.spyOn(axios, \"request\").mockResolvedValue({\n data: undefined,\n });\n\n // WHEN\n const result = await datasource.getProxyImplementationAddress(\n defaultImplementAddressParams,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpProxyDataSource: No data received for proxy 0xee6a57ec80ea46401049e92587e52f5ec1c24785 on chain 1\",\n ),\n ),\n );\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OA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AAMgB,EAAS,MAAMR,EAAW,8BAC9BE,CACF,EAGA,OAAOM,CAAM,EAAE,QACbf,EACE,IAAI,MACF,6EACF,CACF,CACF,CACF,CAAC,EAED,GAAG,sDAAuD,SAAY,CAEpE,GAAG,MAAMD,EAAO,SAAS,EAAE,kBAAkB,CAC3C,KAAM,CAAE,QAAS,MAAO,CAC1B,CAAC,EAGD,MAAMgB,EAAS,MAAMR,EAAW,8BAC9BE,CACF,EAGA,OAAOM,CAAM,EAAE,QACbf,EACE,IAAI,MACF,2JACF,CACF,CACF,CACF,CAAC,EAED,GAAG,4DAA6D,SAAY,CAE1E,GAAG,MAAMD,EAAO,SAAS,EAAE,kBAAkB,CAC3C,KAAM,MACR,CAAC,EAGD,MAAMgB,EAAS,MAAMR,EAAW,8BAC9BE,CACF,EAGA,OAAOM,CAAM,EAAE,QACbf,EACE,IAAI,MACF,uHACF,CACF,CACF,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["axios", "Left", "Right", "LEDGER_CLIENT_VERSION_HEADER", "LEDGER_ORIGIN_TOKEN_HEADER", "PACKAGE", "HttpProxyDataSource", "config", "datasource", "defaultParams", "defaultImplementAddressParams", "delegateProxyResponse", "implementationAddressResponse", "implementationAddressDto", "version", "requestSpy", "result", "paramsWithDifferentChainId"]
7
+ }
@@ -1,2 +1,2 @@
1
- var P=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var d=(l,e,t,r)=>{for(var o=r>1?void 0:r?S(e,t):e,n=l.length-1,i;n>=0;n--)(i=l[n])&&(o=(r?i(e,t,o):i(o))||o);return r&&o&&P(e,t,o),o},f=(l,e)=>(t,r)=>e(t,r,l);import M from"axios";import{inject as m,injectable as I}from"inversify";import{Left as c,Right as R}from"purify-ts";import{configTypes as x}from"../../config/di/configTypes";import{pkiTypes as O}from"../../pki/di/pkiTypes";import{KeyId as F}from"../../pki/model/KeyId";import{KeyUsage as L}from"../../pki/model/KeyUsage";import{LEDGER_CLIENT_VERSION_HEADER as U}from"../../shared/constant/HttpHeaders";import{ClearSignContextType as a}from"../../shared/model/ClearSignContext";import{INFO_SIGNATURE_TAG as h}from"../../shared/model/SignatureTags";import{HexStringUtils as T}from"../../shared/utils/HexStringUtils";import k from"../../../package.json";let y=class{constructor(e,t){this.config=e;this._certificateLoader=t}async getTransactionDescriptors({chainId:e,address:t,selector:r,deviceModelId:o}){let n;try{n=(await M.request({method:"GET",url:`${this.config.cal.url}/dapps`,params:{output:"descriptors_calldata",chain_id:e,contracts:t,ref:`branch:${this.config.cal.branch}`},headers:{[U]:`context-module/${k.version}`}})).data}catch(i){return c(new Error(`[ContextModule] HttpTransactionDataSource: Failed to fetch transaction informations: ${i}`))}if(!Array.isArray(n))return c(new Error("[ContextModule] HttpTransactionDataSource: Response is not an array"));if(n.length===0)return c(new Error(`[ContextModule] HttpTransactionDataSource: No data for contract ${t} and selector ${r}`));for(const i of n){t=t.toLowerCase(),r=`0x${r.slice(2).toLowerCase()}`;const s=i.descriptors_calldata?.[t]?.[r];if(!s||!this.isCalldataDescriptorV1(s,this.config.cal.mode))continue;const E=s.transaction_info.descriptor.data,g=s.transaction_info.descriptor.signatures[this.config.cal.mode],D={targetDevice:o,keyUsage:L.Calldata,keyId:F.CalCalldataKey},u=await this._certificateLoader.loadCertificate(D),V={type:a.TRANSACTION_INFO,payload:T.appendSignatureToPayload(E,g,h),certificate:u},C=[];for(const[p,_]of Object.entries(s.enums))for(const[N,{data:b,signatures:v}]of Object.entries(_))C.push({type:a.ENUM,id:Number(p),value:Number(N),payload:T.appendSignatureToPayload(b,v[this.config.cal.mode],h),certificate:u});const A=s.fields.map(p=>({type:a.TRANSACTION_FIELD_DESCRIPTION,payload:p.descriptor,reference:this.getReference(p.param)}));return R([V,...C,...A])}return c(new Error(`[ContextModule] HttpTransactionDataSource: Invalid response for contract ${t} and selector ${r}`))}getReference(e){if(e.type==="TOKEN_AMOUNT"&&e.token!==void 0&&e.token.type==="path")return{type:a.TOKEN,valuePath:this.toGenericPath(e.token.binary_path)};if(e.type==="TOKEN_AMOUNT"&&e.token!==void 0&&e.token.type==="constant")return{type:a.TOKEN,value:e.token.value};if(e.type==="NFT"&&e.collection.type==="path")return{type:a.NFT,valuePath:this.toGenericPath(e.collection.binary_path)};if(e.type==="NFT"&&e.collection.type==="constant")return{type:a.NFT,value:e.collection.value};if(e.type==="TRUSTED_NAME"&&e.value.type==="path")return{type:a.TRUSTED_NAME,valuePath:this.toGenericPath(e.value.binary_path),types:e.types,sources:e.sources};if(e.type==="ENUM"&&e.value.type==="path")return{type:a.ENUM,valuePath:this.toGenericPath(e.value.binary_path),id:e.id}}toGenericPath(e){return e.type==="CONTAINER"?e.value:e.elements.map(t=>{if(t.type==="ARRAY"){const{weight:r,...o}=t;return{itemSize:r,...o}}else if(t.type==="LEAF"){const{leaf_type:r,...o}=t;return{leafType:r,...o}}return t})}isCalldataDescriptorV1(e,t){return typeof e=="object"&&e.type==="calldata"&&e.version==="v1"&&this.isTransactionInfoV1(e.transaction_info,t)&&this.isEnumV1(e.enums,t)&&Array.isArray(e.fields)&&e.fields.every(r=>this.isFieldV1(r))}isTransactionInfoV1(e,t){return typeof e=="object"&&typeof e.descriptor=="object"&&typeof e.descriptor.data=="string"&&typeof e.descriptor.signatures=="object"&&typeof e.descriptor.signatures[t]=="string"}isEnumV1(e,t){return typeof e=="object"&&Object.entries(e).every(([r,o])=>typeof r=="string"&&typeof o=="object"&&Object.entries(o).every(([n,i])=>typeof n=="string"&&typeof i=="object"&&typeof i.data=="string"&&i.signatures!==void 0&&this.isCalldataSignatures(i.signatures,t)))}isCalldataSignatures(e,t){return typeof e=="object"&&typeof e[t]=="string"}isFieldV1(e){return typeof e=="object"&&typeof e.descriptor=="string"&&typeof e.param=="object"&&typeof e.param.value=="object"&&this.isDescriptorValueV1(e.param.value)&&(e.param.type==="RAW"||e.param.type==="AMOUNT"||e.param.type==="DATETIME"||e.param.type==="DURATION"||e.param.type==="UNIT"||e.param.type==="ENUM"||e.param.type==="NFT"&&this.isDescriptorValueV1(e.param.collection)||e.param.type==="TOKEN_AMOUNT"&&(e.param.token===void 0||this.isDescriptorValueV1(e.param.token))||e.param.type==="TRUSTED_NAME"&&Array.isArray(e.param.types)&&Array.isArray(e.param.sources)&&e.param.types.every(t=>typeof t=="string")&&e.param.sources.every(t=>typeof t=="string"))}isDescriptorValueV1(e){return typeof e=="object"&&typeof e.type_family=="string"&&["UINT","INT","UFIXED","FIXED","ADDRESS","BOOL","BYTES","STRING"].includes(e.type_family)&&(typeof e.type_size>"u"||typeof e.type_size=="number")&&(e.type==="path"&&this.isCalldataDescriptorValueBinaryPathV1(e)||e.type==="constant"&&this.isCalldataDescriptorValueConstantV1(e))}isCalldataDescriptorValueConstantV1(e){return typeof e=="object"&&e.type==="constant"&&typeof e.value=="string"}isCalldataDescriptorValueBinaryPathV1(e){return typeof e=="object"&&(e.type==="path"&&e.binary_path.type==="CONTAINER"&&["FROM","TO","VALUE"].includes(e.binary_path.value)||e.binary_path.type==="DATA"&&Array.isArray(e.binary_path.elements)&&e.binary_path.elements.every(t=>this.isPathElementV1(t)))}isPathElementV1(e){return typeof e=="object"&&(e.type==="REF"||e.type==="TUPLE"&&typeof e.offset=="number"||e.type==="ARRAY"&&typeof e.weight=="number"&&(typeof e.start>"u"||typeof e.start=="number")&&(typeof e.end>"u"||typeof e.end=="number")||e.type==="LEAF"&&typeof e.leaf_type=="string"&&["ARRAY_LEAF","TUPLE_LEAF","STATIC_LEAF","DYNAMIC_LEAF"].includes(e.leaf_type)||e.type==="SLICE"&&(typeof e.start>"u"||typeof e.start=="number")&&(typeof e.end>"u"||typeof e.end=="number"))}};y=d([I(),f(0,m(x.Config)),f(1,m(O.PkiCertificateLoader))],y);export{y as HttpTransactionDataSource};
1
+ var P=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var d=(l,e,t,r)=>{for(var o=r>1?void 0:r?S(e,t):e,n=l.length-1,i;n>=0;n--)(i=l[n])&&(o=(r?i(e,t,o):i(o))||o);return r&&o&&P(e,t,o),o},f=(l,e)=>(t,r)=>e(t,r,l);import I from"axios";import{inject as m,injectable as M}from"inversify";import{Left as c,Right as R}from"purify-ts";import{configTypes as O}from"../../config/di/configTypes";import{pkiTypes as x}from"../../pki/di/pkiTypes";import{KeyId as F}from"../../pki/model/KeyId";import{KeyUsage as L}from"../../pki/model/KeyUsage";import{LEDGER_CLIENT_VERSION_HEADER as k,LEDGER_ORIGIN_TOKEN_HEADER as U}from"../../shared/constant/HttpHeaders";import{ClearSignContextType as a}from"../../shared/model/ClearSignContext";import{INFO_SIGNATURE_TAG as h}from"../../shared/model/SignatureTags";import{HexStringUtils as E}from"../../shared/utils/HexStringUtils";import j from"../../../package.json";let y=class{constructor(e,t){this.config=e;this._certificateLoader=t}async getTransactionDescriptors({chainId:e,address:t,selector:r,deviceModelId:o}){let n;try{n=(await I.request({method:"GET",url:`${this.config.cal.url}/dapps`,params:{output:"descriptors_calldata",chain_id:e,contracts:t,ref:`branch:${this.config.cal.branch}`},headers:{[k]:`context-module/${j.version}`,[U]:this.config.originToken}})).data}catch(i){return c(new Error(`[ContextModule] HttpTransactionDataSource: Failed to fetch transaction informations: ${i}`))}if(!Array.isArray(n))return c(new Error("[ContextModule] HttpTransactionDataSource: Response is not an array"));if(n.length===0)return c(new Error(`[ContextModule] HttpTransactionDataSource: No data for contract ${t} and selector ${r}`));for(const i of n){t=t.toLowerCase(),r=`0x${r.slice(2).toLowerCase()}`;const s=i.descriptors_calldata?.[t]?.[r];if(!s||!this.isCalldataDescriptorV1(s,this.config.cal.mode))continue;const T=s.transaction_info.descriptor.data,g=s.transaction_info.descriptor.signatures[this.config.cal.mode],D={targetDevice:o,keyUsage:L.Calldata,keyId:F.CalCalldataKey},u=await this._certificateLoader.loadCertificate(D),V={type:a.TRANSACTION_INFO,payload:E.appendSignatureToPayload(T,g,h),certificate:u},C=[];for(const[p,_]of Object.entries(s.enums))for(const[N,{data:b,signatures:v}]of Object.entries(_))C.push({type:a.ENUM,id:Number(p),value:Number(N),payload:E.appendSignatureToPayload(b,v[this.config.cal.mode],h),certificate:u});const A=s.fields.map(p=>({type:a.TRANSACTION_FIELD_DESCRIPTION,payload:p.descriptor,reference:this.getReference(p.param)}));return R([V,...C,...A])}return c(new Error(`[ContextModule] HttpTransactionDataSource: Invalid response for contract ${t} and selector ${r}`))}getReference(e){if(e.type==="TOKEN_AMOUNT"&&e.token!==void 0&&e.token.type==="path")return{type:a.TOKEN,valuePath:this.toGenericPath(e.token.binary_path)};if(e.type==="TOKEN_AMOUNT"&&e.token!==void 0&&e.token.type==="constant")return{type:a.TOKEN,value:e.token.value};if(e.type==="NFT"&&e.collection.type==="path")return{type:a.NFT,valuePath:this.toGenericPath(e.collection.binary_path)};if(e.type==="NFT"&&e.collection.type==="constant")return{type:a.NFT,value:e.collection.value};if(e.type==="TRUSTED_NAME"&&e.value.type==="path")return{type:a.TRUSTED_NAME,valuePath:this.toGenericPath(e.value.binary_path),types:e.types,sources:e.sources};if(e.type==="ENUM"&&e.value.type==="path")return{type:a.ENUM,valuePath:this.toGenericPath(e.value.binary_path),id:e.id}}toGenericPath(e){return e.type==="CONTAINER"?e.value:e.elements.map(t=>{if(t.type==="ARRAY"){const{weight:r,...o}=t;return{itemSize:r,...o}}else if(t.type==="LEAF"){const{leaf_type:r,...o}=t;return{leafType:r,...o}}return t})}isCalldataDescriptorV1(e,t){return typeof e=="object"&&e.type==="calldata"&&e.version==="v1"&&this.isTransactionInfoV1(e.transaction_info,t)&&this.isEnumV1(e.enums,t)&&Array.isArray(e.fields)&&e.fields.every(r=>this.isFieldV1(r))}isTransactionInfoV1(e,t){return typeof e=="object"&&typeof e.descriptor=="object"&&typeof e.descriptor.data=="string"&&typeof e.descriptor.signatures=="object"&&typeof e.descriptor.signatures[t]=="string"}isEnumV1(e,t){return typeof e=="object"&&Object.entries(e).every(([r,o])=>typeof r=="string"&&typeof o=="object"&&Object.entries(o).every(([n,i])=>typeof n=="string"&&typeof i=="object"&&typeof i.data=="string"&&i.signatures!==void 0&&this.isCalldataSignatures(i.signatures,t)))}isCalldataSignatures(e,t){return typeof e=="object"&&typeof e[t]=="string"}isFieldV1(e){return typeof e=="object"&&typeof e.descriptor=="string"&&typeof e.param=="object"&&typeof e.param.value=="object"&&this.isDescriptorValueV1(e.param.value)&&(e.param.type==="RAW"||e.param.type==="AMOUNT"||e.param.type==="DATETIME"||e.param.type==="DURATION"||e.param.type==="UNIT"||e.param.type==="ENUM"||e.param.type==="NFT"&&this.isDescriptorValueV1(e.param.collection)||e.param.type==="TOKEN_AMOUNT"&&(e.param.token===void 0||this.isDescriptorValueV1(e.param.token))||e.param.type==="TRUSTED_NAME"&&Array.isArray(e.param.types)&&Array.isArray(e.param.sources)&&e.param.types.every(t=>typeof t=="string")&&e.param.sources.every(t=>typeof t=="string"))}isDescriptorValueV1(e){return typeof e=="object"&&typeof e.type_family=="string"&&["UINT","INT","UFIXED","FIXED","ADDRESS","BOOL","BYTES","STRING"].includes(e.type_family)&&(typeof e.type_size>"u"||typeof e.type_size=="number")&&(e.type==="path"&&this.isCalldataDescriptorValueBinaryPathV1(e)||e.type==="constant"&&this.isCalldataDescriptorValueConstantV1(e))}isCalldataDescriptorValueConstantV1(e){return typeof e=="object"&&e.type==="constant"&&typeof e.value=="string"}isCalldataDescriptorValueBinaryPathV1(e){return typeof e=="object"&&(e.type==="path"&&e.binary_path.type==="CONTAINER"&&["FROM","TO","VALUE"].includes(e.binary_path.value)||e.binary_path.type==="DATA"&&Array.isArray(e.binary_path.elements)&&e.binary_path.elements.every(t=>this.isPathElementV1(t)))}isPathElementV1(e){return typeof e=="object"&&(e.type==="REF"||e.type==="TUPLE"&&typeof e.offset=="number"||e.type==="ARRAY"&&typeof e.weight=="number"&&(typeof e.start>"u"||typeof e.start=="number")&&(typeof e.end>"u"||typeof e.end=="number")||e.type==="LEAF"&&typeof e.leaf_type=="string"&&["ARRAY_LEAF","TUPLE_LEAF","STATIC_LEAF","DYNAMIC_LEAF"].includes(e.leaf_type)||e.type==="SLICE"&&(typeof e.start>"u"||typeof e.start=="number")&&(typeof e.end>"u"||typeof e.end=="number"))}};y=d([M(),f(0,m(O.Config)),f(1,m(x.PkiCertificateLoader))],y);export{y as HttpTransactionDataSource};
2
2
  //# sourceMappingURL=HttpTransactionDataSource.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/transaction/data/HttpTransactionDataSource.ts"],
4
- "sourcesContent": ["import axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport {\n type ContextModuleCalMode,\n type ContextModuleConfig,\n} from \"@/config/model/ContextModuleConfig\";\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 { PkiCertificateInfo } from \"@/pki/model/PkiCertificateInfo\";\nimport { LEDGER_CLIENT_VERSION_HEADER } from \"@/shared/constant/HttpHeaders\";\nimport {\n ClearSignContextReference,\n ClearSignContextSuccess,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { GenericPath } from \"@/shared/model/GenericPath\";\nimport { INFO_SIGNATURE_TAG } from \"@/shared/model/SignatureTags\";\nimport { HexStringUtils } from \"@/shared/utils/HexStringUtils\";\nimport PACKAGE from \"@root/package.json\";\n\nimport {\n CalldataDescriptor,\n CalldataDescriptorContainerPathV1,\n CalldataDescriptorParam,\n CalldataDescriptorPathElementsV1,\n CalldataDescriptorPathElementV1,\n CalldataDescriptorV1,\n CalldataDescriptorValueBinaryPathV1,\n CalldataDescriptorValueConstantV1,\n CalldataDescriptorValueV1,\n CalldataDto,\n CalldataEnumV1,\n CalldataFieldV1,\n CalldataSignatures,\n CalldataTransactionDescriptor,\n CalldataTransactionInfoV1,\n} from \"./CalldataDto\";\nimport {\n GetTransactionDescriptorsParams,\n TransactionDataSource,\n} from \"./TransactionDataSource\";\n\n@injectable()\nexport class HttpTransactionDataSource implements TransactionDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly _certificateLoader: PkiCertificateLoader,\n ) {}\n\n public async getTransactionDescriptors({\n chainId,\n address,\n selector,\n deviceModelId,\n }: GetTransactionDescriptorsParams): Promise<\n Either<Error, ClearSignContextSuccess[]>\n > {\n let dto: CalldataDto[] | undefined;\n try {\n const response = await axios.request<CalldataDto[]>({\n method: \"GET\",\n url: `${this.config.cal.url}/dapps`,\n params: {\n output: \"descriptors_calldata\",\n chain_id: chainId,\n contracts: address,\n ref: `branch:${this.config.cal.branch}`,\n },\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n },\n });\n dto = response.data;\n } catch (error) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Failed to fetch transaction informations: ${error}`,\n ),\n );\n }\n\n if (!Array.isArray(dto)) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Response is not an array`,\n ),\n );\n }\n\n if (dto.length === 0) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: No data for contract ${address} and selector ${selector}`,\n ),\n );\n }\n\n for (const calldata of dto) {\n // Normalize the address and selector\n address = address.toLowerCase();\n selector = `0x${selector.slice(2).toLowerCase()}`;\n const calldataDescriptor =\n calldata.descriptors_calldata?.[address]?.[selector];\n\n if (\n !calldataDescriptor ||\n !this.isCalldataDescriptorV1(calldataDescriptor, this.config.cal.mode)\n ) {\n continue;\n }\n\n const infoData = calldataDescriptor.transaction_info.descriptor.data;\n const infoSignature =\n calldataDescriptor.transaction_info.descriptor.signatures[\n this.config.cal.mode\n ];\n\n const certificateInfos: PkiCertificateInfo = {\n targetDevice: deviceModelId,\n keyUsage: KeyUsage.Calldata,\n keyId: KeyId.CalCalldataKey,\n };\n const certificate: PkiCertificate | undefined =\n await this._certificateLoader.loadCertificate(certificateInfos);\n\n const info: ClearSignContextSuccess = {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: HexStringUtils.appendSignatureToPayload(\n infoData,\n infoSignature,\n INFO_SIGNATURE_TAG,\n ),\n certificate,\n };\n\n const enums: ClearSignContextSuccess[] = [];\n for (const [id, values] of Object.entries(calldataDescriptor.enums)) {\n for (const [\n value,\n { data, signatures },\n ] of Object.entries<CalldataTransactionDescriptor>(values)) {\n enums.push({\n type: ClearSignContextType.ENUM,\n id: Number(id),\n value: Number(value),\n payload: HexStringUtils.appendSignatureToPayload(\n data,\n signatures[this.config.cal.mode]!,\n INFO_SIGNATURE_TAG,\n ),\n certificate,\n });\n }\n }\n\n const fields: ClearSignContextSuccess[] = calldataDescriptor.fields.map(\n (field) => ({\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: field.descriptor,\n reference: this.getReference(field.param),\n }),\n );\n return Right([info, ...enums, ...fields]);\n }\n\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Invalid response for contract ${address} and selector ${selector}`,\n ),\n );\n }\n\n private getReference(\n param: CalldataDescriptorParam,\n ): ClearSignContextReference | undefined {\n if (\n param.type === \"TOKEN_AMOUNT\" &&\n param.token !== undefined &&\n param.token.type === \"path\"\n ) {\n return {\n type: ClearSignContextType.TOKEN,\n valuePath: this.toGenericPath(param.token.binary_path),\n };\n } else if (\n param.type === \"TOKEN_AMOUNT\" &&\n param.token !== undefined &&\n param.token.type === \"constant\"\n ) {\n return {\n type: ClearSignContextType.TOKEN,\n value: param.token.value,\n };\n } else if (param.type === \"NFT\" && param.collection.type === \"path\") {\n return {\n type: ClearSignContextType.NFT,\n valuePath: this.toGenericPath(param.collection.binary_path),\n };\n } else if (param.type === \"NFT\" && param.collection.type === \"constant\") {\n return {\n type: ClearSignContextType.NFT,\n value: param.collection.value,\n };\n } else if (param.type === \"TRUSTED_NAME\" && param.value.type === \"path\") {\n return {\n type: ClearSignContextType.TRUSTED_NAME,\n valuePath: this.toGenericPath(param.value.binary_path),\n types: param.types,\n sources: param.sources,\n };\n } else if (param.type === \"ENUM\" && param.value.type === \"path\") {\n return {\n type: ClearSignContextType.ENUM,\n valuePath: this.toGenericPath(param.value.binary_path),\n id: param.id,\n };\n }\n return undefined;\n }\n\n private toGenericPath(\n path: CalldataDescriptorContainerPathV1 | CalldataDescriptorPathElementsV1,\n ): GenericPath {\n if (path.type === \"CONTAINER\") {\n return path.value;\n }\n return path.elements.map((element) => {\n if (element.type === \"ARRAY\") {\n const { weight: itemSize, ...rest } = element;\n return {\n itemSize,\n ...rest,\n };\n } else if (element.type === \"LEAF\") {\n const { leaf_type: leafType, ...rest } = element;\n return {\n leafType,\n ...rest,\n };\n }\n return element;\n });\n }\n\n private isCalldataDescriptorV1(\n data: CalldataDescriptor,\n mode: ContextModuleCalMode,\n ): data is CalldataDescriptorV1 & {\n transaction_info: {\n descriptor: {\n signatures: { [_key in ContextModuleCalMode]: string };\n };\n };\n } {\n return (\n typeof data === \"object\" &&\n data.type === \"calldata\" &&\n data.version === \"v1\" &&\n this.isTransactionInfoV1(data.transaction_info, mode) &&\n this.isEnumV1(data.enums, mode) &&\n Array.isArray(data.fields) &&\n data.fields.every((f) => this.isFieldV1(f))\n );\n }\n\n private isTransactionInfoV1(\n data: CalldataTransactionInfoV1,\n mode: ContextModuleCalMode,\n ): data is CalldataTransactionInfoV1 & {\n descriptor: {\n signatures: { [_key in ContextModuleCalMode]: string };\n };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.descriptor === \"object\" &&\n typeof data.descriptor.data === \"string\" &&\n typeof data.descriptor.signatures === \"object\" &&\n typeof data.descriptor.signatures[mode] === \"string\"\n );\n }\n\n private isEnumV1(\n calldata: CalldataEnumV1,\n mode: ContextModuleCalMode,\n ): calldata is CalldataEnumV1 {\n return (\n typeof calldata === \"object\" &&\n Object.entries(calldata).every(\n ([id, values]) =>\n typeof id === \"string\" &&\n typeof values === \"object\" &&\n Object.entries<CalldataTransactionDescriptor>(values).every(\n ([value, obj]) =>\n typeof value === \"string\" &&\n typeof obj === \"object\" &&\n typeof obj.data === \"string\" &&\n obj.signatures !== undefined &&\n this.isCalldataSignatures(obj.signatures, mode),\n ),\n )\n );\n }\n\n private isCalldataSignatures(\n data: CalldataSignatures,\n mode: ContextModuleCalMode,\n ): data is CalldataSignatures & { [_key in ContextModuleCalMode]: string } {\n return typeof data === \"object\" && typeof data[mode] === \"string\";\n }\n\n private isFieldV1(data: CalldataFieldV1): boolean {\n return (\n typeof data === \"object\" &&\n typeof data.descriptor === \"string\" &&\n typeof data.param === \"object\" &&\n typeof data.param.value === \"object\" &&\n this.isDescriptorValueV1(data.param.value) &&\n (data.param.type === \"RAW\" ||\n data.param.type === \"AMOUNT\" ||\n data.param.type === \"DATETIME\" ||\n data.param.type === \"DURATION\" ||\n data.param.type === \"UNIT\" ||\n data.param.type === \"ENUM\" ||\n (data.param.type === \"NFT\" &&\n this.isDescriptorValueV1(data.param.collection)) ||\n (data.param.type === \"TOKEN_AMOUNT\" &&\n (data.param.token === undefined ||\n this.isDescriptorValueV1(data.param.token))) ||\n (data.param.type === \"TRUSTED_NAME\" &&\n Array.isArray(data.param.types) &&\n Array.isArray(data.param.sources) &&\n data.param.types.every((t) => typeof t === \"string\") &&\n data.param.sources.every((t) => typeof t === \"string\")))\n );\n }\n\n private isDescriptorValueV1(data: CalldataDescriptorValueV1): boolean {\n return (\n typeof data === \"object\" &&\n typeof data.type_family === \"string\" &&\n [\n \"UINT\",\n \"INT\",\n \"UFIXED\",\n \"FIXED\",\n \"ADDRESS\",\n \"BOOL\",\n \"BYTES\",\n \"STRING\",\n ].includes(data.type_family) &&\n (typeof data.type_size === \"undefined\" ||\n typeof data.type_size === \"number\") &&\n ((data.type === \"path\" &&\n this.isCalldataDescriptorValueBinaryPathV1(data)) ||\n (data.type === \"constant\" &&\n this.isCalldataDescriptorValueConstantV1(data)))\n );\n }\n\n private isCalldataDescriptorValueConstantV1(\n data: CalldataDescriptorValueConstantV1,\n ): boolean {\n return (\n typeof data === \"object\" &&\n data.type === \"constant\" &&\n typeof data.value === \"string\"\n );\n }\n\n private isCalldataDescriptorValueBinaryPathV1(\n data: CalldataDescriptorValueBinaryPathV1,\n ): boolean {\n return (\n typeof data === \"object\" &&\n ((data.type === \"path\" &&\n data.binary_path.type === \"CONTAINER\" &&\n [\"FROM\", \"TO\", \"VALUE\"].includes(data.binary_path.value)) ||\n (data.binary_path.type === \"DATA\" &&\n Array.isArray(data.binary_path.elements) &&\n data.binary_path.elements.every((e) => this.isPathElementV1(e))))\n );\n }\n\n private isPathElementV1(data: CalldataDescriptorPathElementV1): boolean {\n return (\n typeof data === \"object\" &&\n (data.type === \"REF\" ||\n (data.type === \"TUPLE\" && typeof data.offset === \"number\") ||\n (data.type === \"ARRAY\" &&\n typeof data.weight === \"number\" &&\n (typeof data.start === \"undefined\" ||\n typeof data.start === \"number\") &&\n (typeof data.end === \"undefined\" || typeof data.end === \"number\")) ||\n (data.type === \"LEAF\" &&\n typeof data.leaf_type === \"string\" &&\n [\"ARRAY_LEAF\", \"TUPLE_LEAF\", \"STATIC_LEAF\", \"DYNAMIC_LEAF\"].includes(\n data.leaf_type,\n )) ||\n (data.type === \"SLICE\" &&\n (typeof data.start === \"undefined\" ||\n typeof data.start === \"number\") &&\n (typeof data.end === \"undefined\" || typeof data.end === \"number\")))\n );\n }\n}\n"],
5
- "mappings": "iOAAA,OAAOA,MAAW,QAClB,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAK5B,OAAS,YAAAC,MAAgB,oBAEzB,OAAS,SAAAC,MAAa,oBACtB,OAAS,YAAAC,MAAgB,uBAGzB,OAAS,gCAAAC,MAAoC,gCAC7C,OAGE,wBAAAC,MACK,kCAEP,OAAS,sBAAA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S,oBAAoB,IAH5BjD",
6
- "names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "pkiTypes", "KeyId", "KeyUsage", "LEDGER_CLIENT_VERSION_HEADER", "ClearSignContextType", "INFO_SIGNATURE_TAG", "HexStringUtils", "PACKAGE", "HttpTransactionDataSource", "config", "_certificateLoader", "chainId", "address", "selector", "deviceModelId", "dto", "axios", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "error", "Left", "calldata", "calldataDescriptor", "infoData", "infoSignature", "certificateInfos", "KeyUsage", "KeyId", "certificate", "info", "ClearSignContextType", "HexStringUtils", "INFO_SIGNATURE_TAG", "enums", "id", "values", "value", "data", "signatures", "fields", "field", "Right", "param", "path", "element", "itemSize", "rest", "leafType", "mode", "f", "obj", "e", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes", "pkiTypes"]
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport {\n type ContextModuleCalMode,\n type ContextModuleConfig,\n} from \"@/config/model/ContextModuleConfig\";\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 { PkiCertificateInfo } from \"@/pki/model/PkiCertificateInfo\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport {\n ClearSignContextReference,\n ClearSignContextSuccess,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { GenericPath } from \"@/shared/model/GenericPath\";\nimport { INFO_SIGNATURE_TAG } from \"@/shared/model/SignatureTags\";\nimport { HexStringUtils } from \"@/shared/utils/HexStringUtils\";\nimport PACKAGE from \"@root/package.json\";\n\nimport {\n CalldataDescriptor,\n CalldataDescriptorContainerPathV1,\n CalldataDescriptorParam,\n CalldataDescriptorPathElementsV1,\n CalldataDescriptorPathElementV1,\n CalldataDescriptorV1,\n CalldataDescriptorValueBinaryPathV1,\n CalldataDescriptorValueConstantV1,\n CalldataDescriptorValueV1,\n CalldataDto,\n CalldataEnumV1,\n CalldataFieldV1,\n CalldataSignatures,\n CalldataTransactionDescriptor,\n CalldataTransactionInfoV1,\n} from \"./dto/CalldataDto\";\nimport {\n GetTransactionDescriptorsParams,\n TransactionDataSource,\n} from \"./TransactionDataSource\";\n\n@injectable()\nexport class HttpTransactionDataSource implements TransactionDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly _certificateLoader: PkiCertificateLoader,\n ) {}\n\n public async getTransactionDescriptors({\n chainId,\n address,\n selector,\n deviceModelId,\n }: GetTransactionDescriptorsParams): Promise<\n Either<Error, ClearSignContextSuccess[]>\n > {\n let dto: CalldataDto[] | undefined;\n try {\n const response = await axios.request<CalldataDto[]>({\n method: \"GET\",\n url: `${this.config.cal.url}/dapps`,\n params: {\n output: \"descriptors_calldata\",\n chain_id: chainId,\n contracts: address,\n ref: `branch:${this.config.cal.branch}`,\n },\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n });\n dto = response.data;\n } catch (error) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Failed to fetch transaction informations: ${error}`,\n ),\n );\n }\n\n if (!Array.isArray(dto)) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Response is not an array`,\n ),\n );\n }\n\n if (dto.length === 0) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: No data for contract ${address} and selector ${selector}`,\n ),\n );\n }\n\n for (const calldata of dto) {\n // Normalize the address and selector\n address = address.toLowerCase();\n selector = `0x${selector.slice(2).toLowerCase()}`;\n const calldataDescriptor =\n calldata.descriptors_calldata?.[address]?.[selector];\n\n if (\n !calldataDescriptor ||\n !this.isCalldataDescriptorV1(calldataDescriptor, this.config.cal.mode)\n ) {\n continue;\n }\n\n const infoData = calldataDescriptor.transaction_info.descriptor.data;\n const infoSignature =\n calldataDescriptor.transaction_info.descriptor.signatures[\n this.config.cal.mode\n ];\n\n const certificateInfos: PkiCertificateInfo = {\n targetDevice: deviceModelId,\n keyUsage: KeyUsage.Calldata,\n keyId: KeyId.CalCalldataKey,\n };\n const certificate: PkiCertificate | undefined =\n await this._certificateLoader.loadCertificate(certificateInfos);\n\n const info: ClearSignContextSuccess = {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: HexStringUtils.appendSignatureToPayload(\n infoData,\n infoSignature,\n INFO_SIGNATURE_TAG,\n ),\n certificate,\n };\n\n const enums: ClearSignContextSuccess[] = [];\n for (const [id, values] of Object.entries(calldataDescriptor.enums)) {\n for (const [\n value,\n { data, signatures },\n ] of Object.entries<CalldataTransactionDescriptor>(values)) {\n enums.push({\n type: ClearSignContextType.ENUM,\n id: Number(id),\n value: Number(value),\n payload: HexStringUtils.appendSignatureToPayload(\n data,\n signatures[this.config.cal.mode]!,\n INFO_SIGNATURE_TAG,\n ),\n certificate,\n });\n }\n }\n\n const fields: ClearSignContextSuccess[] = calldataDescriptor.fields.map(\n (field) => ({\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: field.descriptor,\n reference: this.getReference(field.param),\n }),\n );\n return Right([info, ...enums, ...fields]);\n }\n\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Invalid response for contract ${address} and selector ${selector}`,\n ),\n );\n }\n\n private getReference(\n param: CalldataDescriptorParam,\n ): ClearSignContextReference | undefined {\n if (\n param.type === \"TOKEN_AMOUNT\" &&\n param.token !== undefined &&\n param.token.type === \"path\"\n ) {\n return {\n type: ClearSignContextType.TOKEN,\n valuePath: this.toGenericPath(param.token.binary_path),\n };\n } else if (\n param.type === \"TOKEN_AMOUNT\" &&\n param.token !== undefined &&\n param.token.type === \"constant\"\n ) {\n return {\n type: ClearSignContextType.TOKEN,\n value: param.token.value,\n };\n } else if (param.type === \"NFT\" && param.collection.type === \"path\") {\n return {\n type: ClearSignContextType.NFT,\n valuePath: this.toGenericPath(param.collection.binary_path),\n };\n } else if (param.type === \"NFT\" && param.collection.type === \"constant\") {\n return {\n type: ClearSignContextType.NFT,\n value: param.collection.value,\n };\n } else if (param.type === \"TRUSTED_NAME\" && param.value.type === \"path\") {\n return {\n type: ClearSignContextType.TRUSTED_NAME,\n valuePath: this.toGenericPath(param.value.binary_path),\n types: param.types,\n sources: param.sources,\n };\n } else if (param.type === \"ENUM\" && param.value.type === \"path\") {\n return {\n type: ClearSignContextType.ENUM,\n valuePath: this.toGenericPath(param.value.binary_path),\n id: param.id,\n };\n }\n return undefined;\n }\n\n private toGenericPath(\n path: CalldataDescriptorContainerPathV1 | CalldataDescriptorPathElementsV1,\n ): GenericPath {\n if (path.type === \"CONTAINER\") {\n return path.value;\n }\n return path.elements.map((element) => {\n if (element.type === \"ARRAY\") {\n const { weight: itemSize, ...rest } = element;\n return {\n itemSize,\n ...rest,\n };\n } else if (element.type === \"LEAF\") {\n const { leaf_type: leafType, ...rest } = element;\n return {\n leafType,\n ...rest,\n };\n }\n return element;\n });\n }\n\n private isCalldataDescriptorV1(\n data: CalldataDescriptor,\n mode: ContextModuleCalMode,\n ): data is CalldataDescriptorV1 & {\n transaction_info: {\n descriptor: {\n signatures: { [_key in ContextModuleCalMode]: string };\n };\n };\n } {\n return (\n typeof data === \"object\" &&\n data.type === \"calldata\" &&\n data.version === \"v1\" &&\n this.isTransactionInfoV1(data.transaction_info, mode) &&\n this.isEnumV1(data.enums, mode) &&\n Array.isArray(data.fields) &&\n data.fields.every((f) => this.isFieldV1(f))\n );\n }\n\n private isTransactionInfoV1(\n data: CalldataTransactionInfoV1,\n mode: ContextModuleCalMode,\n ): data is CalldataTransactionInfoV1 & {\n descriptor: {\n signatures: { [_key in ContextModuleCalMode]: string };\n };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.descriptor === \"object\" &&\n typeof data.descriptor.data === \"string\" &&\n typeof data.descriptor.signatures === \"object\" &&\n typeof data.descriptor.signatures[mode] === \"string\"\n );\n }\n\n private isEnumV1(\n calldata: CalldataEnumV1,\n mode: ContextModuleCalMode,\n ): calldata is CalldataEnumV1 {\n return (\n typeof calldata === \"object\" &&\n Object.entries(calldata).every(\n ([id, values]) =>\n typeof id === \"string\" &&\n typeof values === \"object\" &&\n Object.entries<CalldataTransactionDescriptor>(values).every(\n ([value, obj]) =>\n typeof value === \"string\" &&\n typeof obj === \"object\" &&\n typeof obj.data === \"string\" &&\n obj.signatures !== undefined &&\n this.isCalldataSignatures(obj.signatures, mode),\n ),\n )\n );\n }\n\n private isCalldataSignatures(\n data: CalldataSignatures,\n mode: ContextModuleCalMode,\n ): data is CalldataSignatures & { [_key in ContextModuleCalMode]: string } {\n return typeof data === \"object\" && typeof data[mode] === \"string\";\n }\n\n private isFieldV1(data: CalldataFieldV1): boolean {\n return (\n typeof data === \"object\" &&\n typeof data.descriptor === \"string\" &&\n typeof data.param === \"object\" &&\n typeof data.param.value === \"object\" &&\n this.isDescriptorValueV1(data.param.value) &&\n (data.param.type === \"RAW\" ||\n data.param.type === \"AMOUNT\" ||\n data.param.type === \"DATETIME\" ||\n data.param.type === \"DURATION\" ||\n data.param.type === \"UNIT\" ||\n data.param.type === \"ENUM\" ||\n (data.param.type === \"NFT\" &&\n this.isDescriptorValueV1(data.param.collection)) ||\n (data.param.type === \"TOKEN_AMOUNT\" &&\n (data.param.token === undefined ||\n this.isDescriptorValueV1(data.param.token))) ||\n (data.param.type === \"TRUSTED_NAME\" &&\n Array.isArray(data.param.types) &&\n Array.isArray(data.param.sources) &&\n data.param.types.every((t) => typeof t === \"string\") &&\n data.param.sources.every((t) => typeof t === \"string\")))\n );\n }\n\n private isDescriptorValueV1(data: CalldataDescriptorValueV1): boolean {\n return (\n typeof data === \"object\" &&\n typeof data.type_family === \"string\" &&\n [\n \"UINT\",\n \"INT\",\n \"UFIXED\",\n \"FIXED\",\n \"ADDRESS\",\n \"BOOL\",\n \"BYTES\",\n \"STRING\",\n ].includes(data.type_family) &&\n (typeof data.type_size === \"undefined\" ||\n typeof data.type_size === \"number\") &&\n ((data.type === \"path\" &&\n this.isCalldataDescriptorValueBinaryPathV1(data)) ||\n (data.type === \"constant\" &&\n this.isCalldataDescriptorValueConstantV1(data)))\n );\n }\n\n private isCalldataDescriptorValueConstantV1(\n data: CalldataDescriptorValueConstantV1,\n ): boolean {\n return (\n typeof data === \"object\" &&\n data.type === \"constant\" &&\n typeof data.value === \"string\"\n );\n }\n\n private isCalldataDescriptorValueBinaryPathV1(\n data: CalldataDescriptorValueBinaryPathV1,\n ): boolean {\n return (\n typeof data === \"object\" &&\n ((data.type === \"path\" &&\n data.binary_path.type === \"CONTAINER\" &&\n [\"FROM\", \"TO\", \"VALUE\"].includes(data.binary_path.value)) ||\n (data.binary_path.type === \"DATA\" &&\n Array.isArray(data.binary_path.elements) &&\n data.binary_path.elements.every((e) => this.isPathElementV1(e))))\n );\n }\n\n private isPathElementV1(data: CalldataDescriptorPathElementV1): boolean {\n return (\n typeof data === \"object\" &&\n (data.type === \"REF\" ||\n (data.type === \"TUPLE\" && typeof data.offset === \"number\") ||\n (data.type === \"ARRAY\" &&\n typeof data.weight === \"number\" &&\n (typeof data.start === \"undefined\" ||\n typeof data.start === \"number\") &&\n (typeof data.end === \"undefined\" || typeof data.end === \"number\")) ||\n (data.type === \"LEAF\" &&\n typeof data.leaf_type === \"string\" &&\n [\"ARRAY_LEAF\", \"TUPLE_LEAF\", \"STATIC_LEAF\", \"DYNAMIC_LEAF\"].includes(\n data.leaf_type,\n )) ||\n (data.type === \"SLICE\" &&\n (typeof data.start === \"undefined\" ||\n typeof data.start === \"number\") &&\n (typeof data.end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A,EAAK,IAAQ,KAAe,OAAOA,EAAK,KAAQ,WACzDA,EAAK,OAAS,QACb,OAAOA,EAAK,WAAc,UAC1B,CAAC,aAAc,aAAc,cAAe,cAAc,EAAE,SAC1DA,EAAK,SACP,GACDA,EAAK,OAAS,UACZ,OAAOA,EAAK,MAAU,KACrB,OAAOA,EAAK,OAAU,YACvB,OAAOA,EAAK,IAAQ,KAAe,OAAOA,EAAK,KAAQ,UAEhE,CACF,EA5Wa9B,EAAN6C,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,GACzBF,EAAA,EAAAC,EAAOE,EAAS,oBAAoB,IAH5BlD",
6
+ "names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "pkiTypes", "KeyId", "KeyUsage", "LEDGER_CLIENT_VERSION_HEADER", "LEDGER_ORIGIN_TOKEN_HEADER", "ClearSignContextType", "INFO_SIGNATURE_TAG", "HexStringUtils", "PACKAGE", "HttpTransactionDataSource", "config", "_certificateLoader", "chainId", "address", "selector", "deviceModelId", "dto", "axios", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "LEDGER_ORIGIN_TOKEN_HEADER", "error", "Left", "calldata", "calldataDescriptor", "infoData", "infoSignature", "certificateInfos", "KeyUsage", "KeyId", "certificate", "info", "ClearSignContextType", "HexStringUtils", "INFO_SIGNATURE_TAG", "enums", "id", "values", "value", "data", "signatures", "fields", "field", "Right", "param", "path", "element", "itemSize", "rest", "leafType", "mode", "f", "obj", "e", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes", "pkiTypes"]
7
7
  }