@ledgerhq/context-module 0.0.0-test-recursive-stack-20251002122259 → 0.0.0-test-attest-npmjs-1-20251120163531

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 (299) hide show
  1. package/lib/cjs/package.json +1 -1
  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 +2 -2
  6. package/lib/cjs/src/ContextModuleBuilder.test.js +1 -1
  7. package/lib/cjs/src/ContextModuleBuilder.test.js.map +2 -2
  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 +3 -3
  12. package/lib/cjs/src/config/model/ContextModuleConfig.js +1 -1
  13. package/lib/cjs/src/config/model/ContextModuleConfig.js.map +1 -1
  14. package/lib/cjs/src/di.js +1 -1
  15. package/lib/cjs/src/di.js.map +3 -3
  16. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js +1 -1
  17. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.js.map +3 -3
  18. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
  19. package/lib/cjs/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +3 -3
  20. package/lib/cjs/src/index.js +1 -1
  21. package/lib/cjs/src/index.js.map +2 -2
  22. package/lib/cjs/src/pki/model/KeyUsage.js +1 -1
  23. package/lib/cjs/src/pki/model/KeyUsage.js.map +2 -2
  24. package/lib/cjs/src/safe/data/HttpSafeAccountDataSource.js +2 -0
  25. package/lib/cjs/src/safe/data/HttpSafeAccountDataSource.js.map +7 -0
  26. package/lib/cjs/src/safe/data/HttpSafeAccountDataSource.test.js +2 -0
  27. package/lib/cjs/src/safe/data/HttpSafeAccountDataSource.test.js.map +7 -0
  28. package/lib/cjs/src/safe/data/SafeAccountDataSource.js +2 -0
  29. package/lib/cjs/src/safe/data/SafeAccountDataSource.js.map +7 -0
  30. package/lib/cjs/src/safe/data/dto/SafeAccountDto.js +2 -0
  31. package/lib/cjs/src/safe/data/dto/SafeAccountDto.js.map +7 -0
  32. package/lib/cjs/src/safe/di/safeModuleFactory.js +2 -0
  33. package/lib/cjs/src/safe/di/safeModuleFactory.js.map +7 -0
  34. package/lib/cjs/src/safe/di/safeModuleFactory.test.js +2 -0
  35. package/lib/cjs/src/safe/di/safeModuleFactory.test.js.map +7 -0
  36. package/lib/cjs/src/safe/di/safeTypes.js +2 -0
  37. package/lib/cjs/src/safe/di/safeTypes.js.map +7 -0
  38. package/lib/cjs/src/safe/domain/SafeAddressLoader.js +2 -0
  39. package/lib/cjs/src/safe/domain/SafeAddressLoader.js.map +7 -0
  40. package/lib/cjs/src/safe/domain/SafeAddressLoader.test.js +2 -0
  41. package/lib/cjs/src/safe/domain/SafeAddressLoader.test.js.map +7 -0
  42. package/lib/cjs/src/shared/model/ClearSignContext.js +1 -1
  43. package/lib/cjs/src/shared/model/ClearSignContext.js.map +2 -2
  44. package/lib/cjs/src/shared/utils/KeyUsageMapper.js +1 -1
  45. package/lib/cjs/src/shared/utils/KeyUsageMapper.js.map +2 -2
  46. package/lib/cjs/src/shared/utils/KeyUsageMapper.test.js +1 -1
  47. package/lib/cjs/src/shared/utils/KeyUsageMapper.test.js.map +2 -2
  48. package/lib/cjs/src/token/data/HttpTokenDataSource.js +1 -1
  49. package/lib/cjs/src/token/data/HttpTokenDataSource.js.map +2 -2
  50. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js +1 -1
  51. package/lib/cjs/src/token/data/HttpTokenDataSource.test.js.map +2 -2
  52. package/lib/cjs/src/transaction-check/data/HttpTransactionCheckDataSource.js +2 -0
  53. package/lib/cjs/src/transaction-check/data/HttpTransactionCheckDataSource.js.map +7 -0
  54. package/lib/cjs/src/transaction-check/data/HttpTransactionCheckDataSource.test.js +2 -0
  55. package/lib/cjs/src/transaction-check/data/HttpTransactionCheckDataSource.test.js.map +7 -0
  56. package/lib/cjs/src/transaction-check/data/HttpTypedDataCheckDataSource.js +2 -0
  57. package/lib/cjs/src/transaction-check/data/HttpTypedDataCheckDataSource.js.map +7 -0
  58. package/lib/cjs/src/transaction-check/data/HttpTypedDataCheckDataSource.test.js +2 -0
  59. package/lib/cjs/src/transaction-check/data/HttpTypedDataCheckDataSource.test.js.map +7 -0
  60. package/lib/cjs/src/transaction-check/data/TransactionCheckDataSource.js +2 -0
  61. package/lib/cjs/src/transaction-check/data/TransactionCheckDataSource.js.map +7 -0
  62. package/lib/cjs/src/transaction-check/data/TypedDataCheckDataSource.js +2 -0
  63. package/lib/cjs/src/transaction-check/data/TypedDataCheckDataSource.js.map +7 -0
  64. package/lib/cjs/src/transaction-check/data/dto/TransactionCheckDto.js +2 -0
  65. package/lib/cjs/src/transaction-check/data/dto/TransactionCheckDto.js.map +7 -0
  66. package/lib/cjs/src/transaction-check/data/dto/TypedDataCheckDto.js +2 -0
  67. package/lib/cjs/src/transaction-check/data/dto/TypedDataCheckDto.js.map +7 -0
  68. package/lib/cjs/src/transaction-check/di/transactionCheckModuleFactory.js +2 -0
  69. package/lib/cjs/src/transaction-check/di/transactionCheckModuleFactory.js.map +7 -0
  70. package/lib/cjs/src/transaction-check/di/transactionCheckTypes.js +2 -0
  71. package/lib/cjs/src/transaction-check/di/transactionCheckTypes.js.map +7 -0
  72. package/lib/cjs/src/transaction-check/domain/TransactionCheckContextLoader.js +2 -0
  73. package/lib/cjs/src/transaction-check/domain/TransactionCheckContextLoader.js.map +7 -0
  74. package/lib/cjs/src/transaction-check/domain/TransactionCheckContextLoader.test.js +2 -0
  75. package/lib/cjs/src/transaction-check/domain/TransactionCheckContextLoader.test.js.map +7 -0
  76. package/lib/cjs/src/transaction-check/domain/TypedDataCheckContextLoader.js +2 -0
  77. package/lib/cjs/src/transaction-check/domain/TypedDataCheckContextLoader.js.map +7 -0
  78. package/lib/cjs/src/transaction-check/domain/TypedDataCheckContextLoader.test.js +2 -0
  79. package/lib/cjs/src/transaction-check/domain/TypedDataCheckContextLoader.test.js.map +7 -0
  80. package/lib/cjs/src/uniswap/constants/uniswap.js +1 -1
  81. package/lib/cjs/src/uniswap/constants/uniswap.js.map +3 -3
  82. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js +1 -1
  83. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.js.map +3 -3
  84. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
  85. package/lib/cjs/src/uniswap/domain/UniswapContextLoader.test.js.map +2 -2
  86. package/lib/esm/package.json +1 -1
  87. package/lib/esm/src/ContextModuleBuilder.js +1 -1
  88. package/lib/esm/src/ContextModuleBuilder.js.map +2 -2
  89. package/lib/esm/src/ContextModuleBuilder.test.js +1 -1
  90. package/lib/esm/src/ContextModuleBuilder.test.js.map +2 -2
  91. package/lib/esm/src/DefaultContextModule.js +1 -1
  92. package/lib/esm/src/DefaultContextModule.js.map +3 -3
  93. package/lib/esm/src/DefaultContextModule.test.js +1 -1
  94. package/lib/esm/src/DefaultContextModule.test.js.map +3 -3
  95. package/lib/esm/src/di.js +1 -1
  96. package/lib/esm/src/di.js.map +3 -3
  97. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js +1 -1
  98. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.js.map +3 -3
  99. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js +1 -1
  100. package/lib/esm/src/external-plugin/domain/ExternalPluginContextLoader.test.js.map +3 -3
  101. package/lib/esm/src/index.js +1 -1
  102. package/lib/esm/src/index.js.map +2 -2
  103. package/lib/esm/src/pki/model/KeyUsage.js +1 -1
  104. package/lib/esm/src/pki/model/KeyUsage.js.map +2 -2
  105. package/lib/esm/src/safe/data/HttpSafeAccountDataSource.js +2 -0
  106. package/lib/esm/src/safe/data/HttpSafeAccountDataSource.js.map +7 -0
  107. package/lib/esm/src/safe/data/HttpSafeAccountDataSource.test.js +2 -0
  108. package/lib/esm/src/safe/data/HttpSafeAccountDataSource.test.js.map +7 -0
  109. package/lib/esm/src/safe/data/SafeAccountDataSource.js +1 -0
  110. package/lib/esm/src/safe/data/dto/SafeAccountDto.js +1 -0
  111. package/lib/esm/src/safe/di/safeModuleFactory.js +2 -0
  112. package/lib/esm/src/safe/di/safeModuleFactory.js.map +7 -0
  113. package/lib/esm/src/safe/di/safeModuleFactory.test.js +2 -0
  114. package/lib/esm/src/safe/di/safeModuleFactory.test.js.map +7 -0
  115. package/lib/esm/src/safe/di/safeTypes.js +2 -0
  116. package/lib/esm/src/safe/di/safeTypes.js.map +7 -0
  117. package/lib/esm/src/safe/domain/SafeAddressLoader.js +2 -0
  118. package/lib/esm/src/safe/domain/SafeAddressLoader.js.map +7 -0
  119. package/lib/esm/src/safe/domain/SafeAddressLoader.test.js +2 -0
  120. package/lib/esm/src/safe/domain/SafeAddressLoader.test.js.map +7 -0
  121. package/lib/esm/src/shared/model/ClearSignContext.js +1 -1
  122. package/lib/esm/src/shared/model/ClearSignContext.js.map +2 -2
  123. package/lib/esm/src/shared/utils/KeyUsageMapper.js +1 -1
  124. package/lib/esm/src/shared/utils/KeyUsageMapper.js.map +2 -2
  125. package/lib/esm/src/shared/utils/KeyUsageMapper.test.js +1 -1
  126. package/lib/esm/src/shared/utils/KeyUsageMapper.test.js.map +2 -2
  127. package/lib/esm/src/token/data/HttpTokenDataSource.js +1 -1
  128. package/lib/esm/src/token/data/HttpTokenDataSource.js.map +2 -2
  129. package/lib/esm/src/token/data/HttpTokenDataSource.test.js +1 -1
  130. package/lib/esm/src/token/data/HttpTokenDataSource.test.js.map +2 -2
  131. package/lib/esm/src/transaction-check/data/HttpTransactionCheckDataSource.js +2 -0
  132. package/lib/esm/src/transaction-check/data/HttpTransactionCheckDataSource.js.map +7 -0
  133. package/lib/esm/src/transaction-check/data/HttpTransactionCheckDataSource.test.js +2 -0
  134. package/lib/esm/src/transaction-check/data/HttpTransactionCheckDataSource.test.js.map +7 -0
  135. package/lib/esm/src/transaction-check/data/HttpTypedDataCheckDataSource.js +2 -0
  136. package/lib/esm/src/transaction-check/data/HttpTypedDataCheckDataSource.js.map +7 -0
  137. package/lib/esm/src/transaction-check/data/HttpTypedDataCheckDataSource.test.js +2 -0
  138. package/lib/esm/src/transaction-check/data/HttpTypedDataCheckDataSource.test.js.map +7 -0
  139. package/lib/esm/src/transaction-check/data/TransactionCheckDataSource.js +1 -0
  140. package/lib/esm/src/transaction-check/data/TypedDataCheckDataSource.js +1 -0
  141. package/lib/esm/src/transaction-check/data/dto/TransactionCheckDto.js +1 -0
  142. package/lib/esm/src/transaction-check/data/dto/TransactionCheckDto.js.map +7 -0
  143. package/lib/esm/src/transaction-check/data/dto/TypedDataCheckDto.js +1 -0
  144. package/lib/esm/src/transaction-check/data/dto/TypedDataCheckDto.js.map +7 -0
  145. package/lib/esm/src/transaction-check/di/transactionCheckModuleFactory.js +2 -0
  146. package/lib/esm/src/transaction-check/di/transactionCheckModuleFactory.js.map +7 -0
  147. package/lib/esm/src/transaction-check/di/transactionCheckTypes.js +2 -0
  148. package/lib/esm/src/transaction-check/di/transactionCheckTypes.js.map +7 -0
  149. package/lib/esm/src/transaction-check/domain/TransactionCheckContextLoader.js +2 -0
  150. package/lib/esm/src/transaction-check/domain/TransactionCheckContextLoader.js.map +7 -0
  151. package/lib/esm/src/transaction-check/domain/TransactionCheckContextLoader.test.js +2 -0
  152. package/lib/esm/src/transaction-check/domain/TransactionCheckContextLoader.test.js.map +7 -0
  153. package/lib/esm/src/transaction-check/domain/TypedDataCheckContextLoader.js +2 -0
  154. package/lib/esm/src/transaction-check/domain/TypedDataCheckContextLoader.js.map +7 -0
  155. package/lib/esm/src/transaction-check/domain/TypedDataCheckContextLoader.test.js +2 -0
  156. package/lib/esm/src/transaction-check/domain/TypedDataCheckContextLoader.test.js.map +7 -0
  157. package/lib/esm/src/uniswap/constants/uniswap.js +1 -1
  158. package/lib/esm/src/uniswap/constants/uniswap.js.map +3 -3
  159. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js +1 -1
  160. package/lib/esm/src/uniswap/domain/UniswapContextLoader.js.map +3 -3
  161. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js +1 -1
  162. package/lib/esm/src/uniswap/domain/UniswapContextLoader.test.js.map +3 -3
  163. package/lib/types/src/ContextModule.d.ts +0 -2
  164. package/lib/types/src/ContextModule.d.ts.map +1 -1
  165. package/lib/types/src/ContextModuleBuilder.d.ts +0 -9
  166. package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -1
  167. package/lib/types/src/DefaultContextModule.d.ts +1 -5
  168. package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
  169. package/lib/types/src/config/model/ContextModuleConfig.d.ts +0 -2
  170. package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -1
  171. package/lib/types/src/di.d.ts.map +1 -1
  172. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.d.ts +9 -1
  173. package/lib/types/src/external-plugin/domain/ExternalPluginContextLoader.d.ts.map +1 -1
  174. package/lib/types/src/index.d.ts +0 -5
  175. package/lib/types/src/index.d.ts.map +1 -1
  176. package/lib/types/src/pki/model/KeyUsage.d.ts +2 -1
  177. package/lib/types/src/pki/model/KeyUsage.d.ts.map +1 -1
  178. package/lib/types/src/safe/data/HttpSafeAccountDataSource.d.ts +11 -0
  179. package/lib/types/src/safe/data/HttpSafeAccountDataSource.d.ts.map +1 -0
  180. package/lib/types/src/safe/data/HttpSafeAccountDataSource.test.d.ts +2 -0
  181. package/lib/types/src/safe/data/HttpSafeAccountDataSource.test.d.ts.map +1 -0
  182. package/lib/types/src/safe/data/SafeAccountDataSource.d.ts +20 -0
  183. package/lib/types/src/safe/data/SafeAccountDataSource.d.ts.map +1 -0
  184. package/lib/types/src/safe/data/dto/SafeAccountDto.d.ts +10 -0
  185. package/lib/types/src/safe/data/dto/SafeAccountDto.d.ts.map +1 -0
  186. package/lib/types/src/safe/di/safeModuleFactory.d.ts +3 -0
  187. package/lib/types/src/safe/di/safeModuleFactory.d.ts.map +1 -0
  188. package/lib/types/src/safe/di/safeModuleFactory.test.d.ts +2 -0
  189. package/lib/types/src/safe/di/safeModuleFactory.test.d.ts.map +1 -0
  190. package/lib/types/src/safe/di/safeTypes.d.ts +5 -0
  191. package/lib/types/src/safe/di/safeTypes.d.ts.map +1 -0
  192. package/lib/types/src/safe/domain/SafeAddressLoader.d.ts +19 -0
  193. package/lib/types/src/safe/domain/SafeAddressLoader.d.ts.map +1 -0
  194. package/lib/types/src/safe/domain/SafeAddressLoader.test.d.ts +2 -0
  195. package/lib/types/src/safe/domain/SafeAddressLoader.test.d.ts.map +1 -0
  196. package/lib/types/src/shared/model/ClearSignContext.d.ts +4 -2
  197. package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -1
  198. package/lib/types/src/shared/utils/KeyUsageMapper.d.ts.map +1 -1
  199. package/lib/types/src/token/data/HttpTokenDataSource.d.ts.map +1 -1
  200. package/lib/types/src/transaction-check/data/HttpTransactionCheckDataSource.d.ts +10 -0
  201. package/lib/types/src/transaction-check/data/HttpTransactionCheckDataSource.d.ts.map +1 -0
  202. package/lib/types/src/transaction-check/data/HttpTransactionCheckDataSource.test.d.ts +2 -0
  203. package/lib/types/src/transaction-check/data/HttpTransactionCheckDataSource.test.d.ts.map +1 -0
  204. package/lib/types/src/transaction-check/data/HttpTypedDataCheckDataSource.d.ts +10 -0
  205. package/lib/types/src/transaction-check/data/HttpTypedDataCheckDataSource.d.ts.map +1 -0
  206. package/lib/types/src/transaction-check/data/HttpTypedDataCheckDataSource.test.d.ts +2 -0
  207. package/lib/types/src/transaction-check/data/HttpTypedDataCheckDataSource.test.d.ts.map +1 -0
  208. package/lib/types/src/transaction-check/data/TransactionCheckDataSource.d.ts +14 -0
  209. package/lib/types/src/transaction-check/data/TransactionCheckDataSource.d.ts.map +1 -0
  210. package/lib/types/src/transaction-check/data/TypedDataCheckDataSource.d.ts +28 -0
  211. package/lib/types/src/transaction-check/data/TypedDataCheckDataSource.d.ts.map +1 -0
  212. package/lib/types/src/transaction-check/data/dto/TransactionCheckDto.d.ts +5 -0
  213. package/lib/types/src/transaction-check/data/dto/TransactionCheckDto.d.ts.map +1 -0
  214. package/lib/types/src/transaction-check/data/dto/TypedDataCheckDto.d.ts +5 -0
  215. package/lib/types/src/transaction-check/data/dto/TypedDataCheckDto.d.ts.map +1 -0
  216. package/lib/types/src/transaction-check/di/transactionCheckModuleFactory.d.ts +3 -0
  217. package/lib/types/src/transaction-check/di/transactionCheckModuleFactory.d.ts.map +1 -0
  218. package/lib/types/src/transaction-check/di/transactionCheckTypes.d.ts +7 -0
  219. package/lib/types/src/transaction-check/di/transactionCheckTypes.d.ts.map +1 -0
  220. package/lib/types/src/transaction-check/domain/TransactionCheckContextLoader.d.ts +19 -0
  221. package/lib/types/src/transaction-check/domain/TransactionCheckContextLoader.d.ts.map +1 -0
  222. package/lib/types/src/transaction-check/domain/TransactionCheckContextLoader.test.d.ts +2 -0
  223. package/lib/types/src/transaction-check/domain/TransactionCheckContextLoader.test.d.ts.map +1 -0
  224. package/lib/types/src/transaction-check/domain/TypedDataCheckContextLoader.d.ts +18 -0
  225. package/lib/types/src/transaction-check/domain/TypedDataCheckContextLoader.d.ts.map +1 -0
  226. package/lib/types/src/transaction-check/domain/TypedDataCheckContextLoader.test.d.ts +2 -0
  227. package/lib/types/src/transaction-check/domain/TypedDataCheckContextLoader.test.d.ts.map +1 -0
  228. package/lib/types/src/uniswap/constants/uniswap.d.ts +0 -1
  229. package/lib/types/src/uniswap/constants/uniswap.d.ts.map +1 -1
  230. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts +0 -8
  231. package/lib/types/src/uniswap/domain/UniswapContextLoader.d.ts.map +1 -1
  232. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  233. package/package.json +5 -5
  234. package/lib/cjs/src/uniswap/constants/plugin.js +0 -2
  235. package/lib/cjs/src/uniswap/constants/plugin.js.map +0 -7
  236. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.js +0 -2
  237. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.js.map +0 -7
  238. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.test.js +0 -2
  239. package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.test.js.map +0 -7
  240. package/lib/cjs/src/web3-check/data/Web3CheckDataSource.js +0 -2
  241. package/lib/cjs/src/web3-check/data/Web3CheckDataSource.js.map +0 -7
  242. package/lib/cjs/src/web3-check/data/Web3CheckDto.js +0 -2
  243. package/lib/cjs/src/web3-check/data/Web3CheckDto.js.map +0 -7
  244. package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js +0 -2
  245. package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js.map +0 -7
  246. package/lib/cjs/src/web3-check/di/web3CheckTypes.js +0 -2
  247. package/lib/cjs/src/web3-check/di/web3CheckTypes.js.map +0 -7
  248. package/lib/cjs/src/web3-check/domain/DefaultWeb3CheckLoader.js +0 -2
  249. package/lib/cjs/src/web3-check/domain/DefaultWeb3CheckLoader.js.map +0 -7
  250. package/lib/cjs/src/web3-check/domain/DefaultWeb3CheckLoader.test.js +0 -2
  251. package/lib/cjs/src/web3-check/domain/DefaultWeb3CheckLoader.test.js.map +0 -7
  252. package/lib/cjs/src/web3-check/domain/Web3CheckContextLoader.js +0 -2
  253. package/lib/cjs/src/web3-check/domain/Web3CheckContextLoader.js.map +0 -7
  254. package/lib/cjs/src/web3-check/domain/web3CheckTypes.js +0 -2
  255. package/lib/cjs/src/web3-check/domain/web3CheckTypes.js.map +0 -7
  256. package/lib/esm/src/uniswap/constants/plugin.js +0 -2
  257. package/lib/esm/src/uniswap/constants/plugin.js.map +0 -7
  258. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.js +0 -2
  259. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.js.map +0 -7
  260. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.test.js +0 -2
  261. package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.test.js.map +0 -7
  262. package/lib/esm/src/web3-check/data/Web3CheckDataSource.js +0 -1
  263. package/lib/esm/src/web3-check/data/Web3CheckDto.js +0 -1
  264. package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js +0 -2
  265. package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js.map +0 -7
  266. package/lib/esm/src/web3-check/di/web3CheckTypes.js +0 -2
  267. package/lib/esm/src/web3-check/di/web3CheckTypes.js.map +0 -7
  268. package/lib/esm/src/web3-check/domain/DefaultWeb3CheckLoader.js +0 -2
  269. package/lib/esm/src/web3-check/domain/DefaultWeb3CheckLoader.js.map +0 -7
  270. package/lib/esm/src/web3-check/domain/DefaultWeb3CheckLoader.test.js +0 -2
  271. package/lib/esm/src/web3-check/domain/DefaultWeb3CheckLoader.test.js.map +0 -7
  272. package/lib/esm/src/web3-check/domain/Web3CheckContextLoader.js +0 -1
  273. package/lib/esm/src/web3-check/domain/web3CheckTypes.js +0 -1
  274. package/lib/types/src/uniswap/constants/plugin.d.ts +0 -3
  275. package/lib/types/src/uniswap/constants/plugin.d.ts.map +0 -1
  276. package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.d.ts +0 -14
  277. package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.d.ts.map +0 -1
  278. package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.test.d.ts +0 -2
  279. package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.test.d.ts.map +0 -1
  280. package/lib/types/src/web3-check/data/Web3CheckDataSource.d.ts +0 -6
  281. package/lib/types/src/web3-check/data/Web3CheckDataSource.d.ts.map +0 -1
  282. package/lib/types/src/web3-check/data/Web3CheckDto.d.ts +0 -20
  283. package/lib/types/src/web3-check/data/Web3CheckDto.d.ts.map +0 -1
  284. package/lib/types/src/web3-check/di/web3CheckModuleFactory.d.ts +0 -3
  285. package/lib/types/src/web3-check/di/web3CheckModuleFactory.d.ts.map +0 -1
  286. package/lib/types/src/web3-check/di/web3CheckTypes.d.ts +0 -5
  287. package/lib/types/src/web3-check/di/web3CheckTypes.d.ts.map +0 -1
  288. package/lib/types/src/web3-check/domain/DefaultWeb3CheckLoader.d.ts +0 -10
  289. package/lib/types/src/web3-check/domain/DefaultWeb3CheckLoader.d.ts.map +0 -1
  290. package/lib/types/src/web3-check/domain/DefaultWeb3CheckLoader.test.d.ts +0 -2
  291. package/lib/types/src/web3-check/domain/DefaultWeb3CheckLoader.test.d.ts.map +0 -1
  292. package/lib/types/src/web3-check/domain/Web3CheckContextLoader.d.ts +0 -6
  293. package/lib/types/src/web3-check/domain/Web3CheckContextLoader.d.ts.map +0 -1
  294. package/lib/types/src/web3-check/domain/web3CheckTypes.d.ts +0 -35
  295. package/lib/types/src/web3-check/domain/web3CheckTypes.d.ts.map +0 -1
  296. /package/lib/esm/src/{web3-check/data/Web3CheckDataSource.js.map → safe/data/SafeAccountDataSource.js.map} +0 -0
  297. /package/lib/esm/src/{web3-check/data/Web3CheckDto.js.map → safe/data/dto/SafeAccountDto.js.map} +0 -0
  298. /package/lib/esm/src/{web3-check/domain/Web3CheckContextLoader.js.map → transaction-check/data/TransactionCheckDataSource.js.map} +0 -0
  299. /package/lib/esm/src/{web3-check/domain/web3CheckTypes.js.map → transaction-check/data/TypedDataCheckDataSource.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/DefaultContextModule.test.ts"],
4
- "sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport { type ContextFieldLoader } from \"./shared/domain/ContextFieldLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport { type TypedDataContext } from \"./shared/model/TypedDataContext\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst contextLoaderStubBuilder = (canHandle: boolean): ContextLoader => {\n return {\n load: vi.fn(),\n canHandle: vi\n .fn()\n .mockReturnValue(canHandle) as unknown as ContextLoader[\"canHandle\"],\n };\n};\n\nconst fieldLoaderStubBuilder = (): ContextFieldLoader => {\n return {\n canHandle: vi.fn(),\n loadField: vi.fn(),\n };\n};\n\ndescribe(\"DefaultContextModule\", () => {\n const typedDataLoader: TypedDataContextLoader = { load: vi.fn() };\n const defaultContextModuleConfig: ContextModuleConfig = {\n customLoaders: [],\n defaultLoaders: false,\n defaultFieldLoaders: false,\n customFieldLoaders: [],\n customTypedDataLoader: typedDataLoader,\n cal: {\n url: \"https://cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n web3checks: {\n url: \"https://web3checks/v3\",\n },\n metadataServiceDomain: {\n url: \"https://metadata.com\",\n },\n originToken: \"originToken\",\n };\n\n beforeEach(() => {\n vi.restoreAllMocks();\n });\n\n it(\"should initialize the context module with all the default loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({});\n\n expect(res).toEqual([]);\n });\n\n it(\"should return an empty array when no loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({});\n\n expect(res).toEqual([]);\n });\n\n it(\"should call all fetch method from metadata fetcher\", async () => {\n const loader = contextLoaderStubBuilder(true);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n await contextModule.getContexts({});\n\n expect(loader.canHandle).toHaveBeenCalledTimes(2);\n expect(loader.load).toHaveBeenCalledTimes(2);\n });\n\n it(\"should return an array of context response\", async () => {\n const loader = contextLoaderStubBuilder(true);\n const responses = [\n [{ type: \"provideERC20Info\", payload: \"payload1\" }],\n [\n { type: \"provideERC20Info\", payload: \"payload2\" },\n { type: \"plugin\", payload: \"payload3\" },\n ],\n ] as ClearSignContext[][];\n vi.spyOn(loader, \"load\")\n .mockResolvedValueOnce(responses[0]!)\n .mockResolvedValueOnce(responses[1]!);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n const res = await contextModule.getContexts({});\n\n expect(loader.canHandle).toHaveBeenCalledTimes(2);\n expect(loader.load).toHaveBeenCalledTimes(2);\n expect(res).toEqual(responses.flat());\n });\n\n it(\"should only call loaders that can handle the input\", async () => {\n const loader1 = contextLoaderStubBuilder(true);\n const loader2 = contextLoaderStubBuilder(true);\n\n vi.spyOn(loader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(loader2, \"canHandle\").mockReturnValue(false);\n vi.spyOn(loader1, \"load\").mockResolvedValue([\n { type: ClearSignContextType.TOKEN, payload: \"payload1\" },\n ]);\n vi.spyOn(loader2, \"load\").mockResolvedValue([\n { type: ClearSignContextType.NFT, payload: \"payload2\" },\n ]);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader1, loader2],\n });\n\n const testInput = { to: \"0x123\", selector: \"0xabc\" };\n const res = await contextModule.getContexts(testInput);\n\n expect(loader1.canHandle).toHaveBeenCalledWith(\n testInput,\n Object.values(ClearSignContextType),\n );\n expect(loader2.canHandle).toHaveBeenCalledWith(\n testInput,\n Object.values(ClearSignContextType),\n );\n expect(loader1.load).toHaveBeenCalledWith(testInput);\n expect(loader2.load).not.toHaveBeenCalled(); // Should not be called since canHandle returned false\n expect(res).toEqual([{ type: \"token\", payload: \"payload1\" }]);\n });\n\n it(\"should use expected types if provided\", async () => {\n const loader = contextLoaderStubBuilder(true);\n\n vi.spyOn(loader, \"canHandle\").mockReturnValue(true);\n\n vi.spyOn(loader, \"load\").mockResolvedValue([\n { type: ClearSignContextType.TOKEN, payload: \"payload1\" },\n ]);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader],\n });\n\n const testInput = { to: \"0x123\", selector: \"0xabc\" };\n await contextModule.getContexts(testInput, [ClearSignContextType.TOKEN]);\n\n expect(loader.canHandle).toHaveBeenCalledWith(testInput, [\n ClearSignContextType.TOKEN,\n ]);\n });\n\n it(\"should call the typed data loader\", async () => {\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customTypedDataLoader: typedDataLoader,\n });\n\n await contextModule.getTypedDataFilters({} as TypedDataContext);\n\n expect(typedDataLoader.load).toHaveBeenCalledTimes(1);\n });\n\n it(\"should return a web3 check context\", async () => {\n const loader = { load: vi.fn() }; // Web3CheckLoader doesn't use ContextLoader interface\n vi.spyOn(loader, \"load\").mockResolvedValueOnce(\n Right({ descriptor: \"payload\" }),\n );\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [],\n customWeb3CheckLoader: loader,\n });\n\n const res = await contextModule.getWeb3Checks({\n deviceModelId: DeviceModelId.FLEX,\n from: \"from\",\n rawTx: \"rawTx\",\n chainId: 1,\n });\n\n expect(loader.load).toHaveBeenCalledTimes(1);\n expect(res).toEqual({ type: \"web3Check\", payload: \"payload\" });\n });\n\n it(\"should return null if no web3 check context\", async () => {\n const loader = { load: vi.fn() }; // Web3CheckLoader doesn't use ContextLoader interface\n vi.spyOn(loader, \"load\").mockResolvedValue(Left(new Error(\"error\")));\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [],\n customWeb3CheckLoader: loader,\n });\n\n const res = await contextModule.getWeb3Checks({\n deviceModelId: DeviceModelId.FLEX,\n from: \"from\",\n rawTx: \"rawTx\",\n chainId: 1,\n });\n\n expect(loader.load).toHaveBeenCalledTimes(1);\n expect(res).toBeNull();\n });\n\n it(\"should throw an error if origin token is not provided\", () => {\n expect(\n () =>\n new DefaultContextModule({\n ...defaultContextModuleConfig,\n originToken: undefined,\n }),\n ).toThrow(\"Origin token is required\");\n });\n\n describe(\"getFieldContext\", () => {\n it(\"should return error when no loader can handle the field\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(false);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"unknown\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).not.toHaveBeenCalled();\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${testField} and expected type: ${ClearSignContextType.TOKEN}`,\n ),\n });\n });\n\n it(\"should return context when a loader can handle the field\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n const mockContext: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"test-payload\",\n };\n\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader, \"loadField\").mockResolvedValue(mockContext);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"token\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).toHaveBeenCalledWith(testField);\n expect(result).toEqual(mockContext);\n });\n\n it(\"should return first context when multiple loaders can handle the field\", async () => {\n // GIVEN\n const fieldLoader1 = fieldLoaderStubBuilder();\n const fieldLoader2 = fieldLoaderStubBuilder();\n\n const mockContext1: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"first-payload\",\n };\n const mockContext2: ClearSignContext = {\n type: ClearSignContextType.NFT,\n payload: \"second-payload\",\n };\n\n vi.spyOn(fieldLoader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader2, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader1, \"loadField\").mockResolvedValue(mockContext1);\n vi.spyOn(fieldLoader2, \"loadField\").mockResolvedValue(mockContext2);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader1, fieldLoader2],\n });\n\n const testField = { type: \"multi\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader1.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader2.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader1.loadField).toHaveBeenCalledWith(testField);\n expect(fieldLoader2.loadField).not.toHaveBeenCalled();\n expect(result).toEqual(mockContext1); // Should return first context\n });\n\n it(\"should return second context when first context is an error\", async () => {\n // GIVEN\n const fieldLoader1 = fieldLoaderStubBuilder();\n const fieldLoader2 = fieldLoaderStubBuilder();\n const mockContext1: ClearSignContext = {\n type: ClearSignContextType.ERROR,\n error: new Error(\"first-error\"),\n };\n const mockContext2: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"second-payload\",\n };\n vi.spyOn(fieldLoader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader2, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader1, \"loadField\").mockResolvedValue(mockContext1);\n vi.spyOn(fieldLoader2, \"loadField\").mockResolvedValue(mockContext2);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader1, fieldLoader2],\n });\n\n const testField = { type: \"error\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader1.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader2.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader1.loadField).toHaveBeenCalledWith(testField);\n expect(fieldLoader2.loadField).toHaveBeenCalledWith(testField);\n expect(result).toEqual(mockContext2);\n });\n\n it(\"should handle loader rejection gracefully\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n const loadError = new Error(\"Load field failed\");\n\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader, \"loadField\").mockRejectedValue(loadError);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"error\", address: \"0x123\" };\n\n // WHEN & THEN\n await expect(\n contextModule.getFieldContext(testField, ClearSignContextType.TOKEN),\n ).rejects.toThrow(\"Load field failed\");\n\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).toHaveBeenCalledWith(testField);\n });\n });\n});\n"],
5
- "mappings": "AAAA,OAAS,iBAAAA,MAAqB,kCAC9B,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAK5B,OAEE,wBAAAC,MACK,kCAGP,OAAS,wBAAAC,MAA4B,yBAErC,MAAMC,EAA4BC,IACzB,CACL,KAAM,GAAG,GAAG,EACZ,UAAW,GACR,GAAG,EACH,gBAAgBA,CAAS,CAC9B,GAGIC,EAAyB,KACtB,CACL,UAAW,GAAG,GAAG,EACjB,UAAW,GAAG,GAAG,CACnB,GAGF,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA0C,CAAE,KAAM,GAAG,GAAG,CAAE,EAC1DC,EAAkD,CACtD,cAAe,CAAC,EAChB,eAAgB,GAChB,oB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,CAAC,CACH,CAAC",
6
- "names": ["DeviceModelId", "Left", "Right", "ClearSignContextType", "DefaultContextModule", "contextLoaderStubBuilder", "canHandle", "fieldLoaderStubBuilder", "typedDataLoader", "defaultContextModuleConfig", "res", "loader", "responses", "loader1", "loader2", "contextModule", "testInput", "fieldLoader", "testField", "result", "mockContext", "fieldLoader1", "fieldLoader2", "mockContext1", "mockContext2", "loadError"]
4
+ "sourcesContent": ["import { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport { type ContextFieldLoader } from \"./shared/domain/ContextFieldLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport { type TypedDataContext } from \"./shared/model/TypedDataContext\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst contextLoaderStubBuilder = (canHandle: boolean): ContextLoader => {\n return {\n load: vi.fn(),\n canHandle: vi\n .fn()\n .mockReturnValue(canHandle) as unknown as ContextLoader[\"canHandle\"],\n };\n};\n\nconst fieldLoaderStubBuilder = (): ContextFieldLoader => {\n return {\n canHandle: vi.fn(),\n loadField: vi.fn(),\n };\n};\n\ndescribe(\"DefaultContextModule\", () => {\n const typedDataLoader: TypedDataContextLoader = { load: vi.fn() };\n const defaultContextModuleConfig: ContextModuleConfig = {\n customLoaders: [],\n defaultLoaders: false,\n defaultFieldLoaders: false,\n customFieldLoaders: [],\n customTypedDataLoader: typedDataLoader,\n cal: {\n url: \"https://cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n web3checks: {\n url: \"https://web3checks/v3\",\n },\n metadataServiceDomain: {\n url: \"https://metadata.com\",\n },\n originToken: \"originToken\",\n };\n\n beforeEach(() => {\n vi.restoreAllMocks();\n });\n\n it(\"should initialize the context module with all the default loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({});\n\n expect(res).toEqual([]);\n });\n\n it(\"should return an empty array when no loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({});\n\n expect(res).toEqual([]);\n });\n\n it(\"should call all fetch method from metadata fetcher\", async () => {\n const loader = contextLoaderStubBuilder(true);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n await contextModule.getContexts({});\n\n expect(loader.canHandle).toHaveBeenCalledTimes(2);\n expect(loader.load).toHaveBeenCalledTimes(2);\n });\n\n it(\"should return an array of context response\", async () => {\n const loader = contextLoaderStubBuilder(true);\n const responses = [\n [{ type: \"provideERC20Info\", payload: \"payload1\" }],\n [\n { type: \"provideERC20Info\", payload: \"payload2\" },\n { type: \"plugin\", payload: \"payload3\" },\n ],\n ] as ClearSignContext[][];\n vi.spyOn(loader, \"load\")\n .mockResolvedValueOnce(responses[0]!)\n .mockResolvedValueOnce(responses[1]!);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n const res = await contextModule.getContexts({});\n\n expect(loader.canHandle).toHaveBeenCalledTimes(2);\n expect(loader.load).toHaveBeenCalledTimes(2);\n expect(res).toEqual(responses.flat());\n });\n\n it(\"should only call loaders that can handle the input\", async () => {\n const loader1 = contextLoaderStubBuilder(true);\n const loader2 = contextLoaderStubBuilder(true);\n\n vi.spyOn(loader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(loader2, \"canHandle\").mockReturnValue(false);\n vi.spyOn(loader1, \"load\").mockResolvedValue([\n { type: ClearSignContextType.TOKEN, payload: \"payload1\" },\n ]);\n vi.spyOn(loader2, \"load\").mockResolvedValue([\n { type: ClearSignContextType.NFT, payload: \"payload2\" },\n ]);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader1, loader2],\n });\n\n const testInput = { to: \"0x123\", selector: \"0xabc\" };\n const res = await contextModule.getContexts(testInput);\n\n expect(loader1.canHandle).toHaveBeenCalledWith(\n testInput,\n Object.values(ClearSignContextType),\n );\n expect(loader2.canHandle).toHaveBeenCalledWith(\n testInput,\n Object.values(ClearSignContextType),\n );\n expect(loader1.load).toHaveBeenCalledWith(testInput);\n expect(loader2.load).not.toHaveBeenCalled(); // Should not be called since canHandle returned false\n expect(res).toEqual([{ type: \"token\", payload: \"payload1\" }]);\n });\n\n it(\"should use expected types if provided\", async () => {\n const loader = contextLoaderStubBuilder(true);\n\n vi.spyOn(loader, \"canHandle\").mockReturnValue(true);\n\n vi.spyOn(loader, \"load\").mockResolvedValue([\n { type: ClearSignContextType.TOKEN, payload: \"payload1\" },\n ]);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader],\n });\n\n const testInput = { to: \"0x123\", selector: \"0xabc\" };\n await contextModule.getContexts(testInput, [ClearSignContextType.TOKEN]);\n\n expect(loader.canHandle).toHaveBeenCalledWith(testInput, [\n ClearSignContextType.TOKEN,\n ]);\n });\n\n it(\"should call the typed data loader\", async () => {\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customTypedDataLoader: typedDataLoader,\n });\n\n await contextModule.getTypedDataFilters({} as TypedDataContext);\n\n expect(typedDataLoader.load).toHaveBeenCalledTimes(1);\n });\n\n describe(\"getFieldContext\", () => {\n it(\"should return error when no loader can handle the field\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(false);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"unknown\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).not.toHaveBeenCalled();\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${testField} and expected type: ${ClearSignContextType.TOKEN}`,\n ),\n });\n });\n\n it(\"should return context when a loader can handle the field\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n const mockContext: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"test-payload\",\n };\n\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader, \"loadField\").mockResolvedValue(mockContext);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"token\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).toHaveBeenCalledWith(testField);\n expect(result).toEqual(mockContext);\n });\n\n it(\"should return first context when multiple loaders can handle the field\", async () => {\n // GIVEN\n const fieldLoader1 = fieldLoaderStubBuilder();\n const fieldLoader2 = fieldLoaderStubBuilder();\n\n const mockContext1: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"first-payload\",\n };\n const mockContext2: ClearSignContext = {\n type: ClearSignContextType.NFT,\n payload: \"second-payload\",\n };\n\n vi.spyOn(fieldLoader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader2, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader1, \"loadField\").mockResolvedValue(mockContext1);\n vi.spyOn(fieldLoader2, \"loadField\").mockResolvedValue(mockContext2);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader1, fieldLoader2],\n });\n\n const testField = { type: \"multi\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader1.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader2.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader1.loadField).toHaveBeenCalledWith(testField);\n expect(fieldLoader2.loadField).not.toHaveBeenCalled();\n expect(result).toEqual(mockContext1); // Should return first context\n });\n\n it(\"should return second context when first context is an error\", async () => {\n // GIVEN\n const fieldLoader1 = fieldLoaderStubBuilder();\n const fieldLoader2 = fieldLoaderStubBuilder();\n const mockContext1: ClearSignContext = {\n type: ClearSignContextType.ERROR,\n error: new Error(\"first-error\"),\n };\n const mockContext2: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"second-payload\",\n };\n vi.spyOn(fieldLoader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader2, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader1, \"loadField\").mockResolvedValue(mockContext1);\n vi.spyOn(fieldLoader2, \"loadField\").mockResolvedValue(mockContext2);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader1, fieldLoader2],\n });\n\n const testField = { type: \"error\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader1.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader2.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader1.loadField).toHaveBeenCalledWith(testField);\n expect(fieldLoader2.loadField).toHaveBeenCalledWith(testField);\n expect(result).toEqual(mockContext2);\n });\n\n it(\"should handle loader rejection gracefully\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n const loadError = new Error(\"Load field failed\");\n\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader, \"loadField\").mockRejectedValue(loadError);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"error\", address: \"0x123\" };\n\n // WHEN & THEN\n await expect(\n contextModule.getFieldContext(testField, ClearSignContextType.TOKEN),\n ).rejects.toThrow(\"Load field failed\");\n\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).toHaveBeenCalledWith(testField);\n });\n });\n});\n"],
5
+ "mappings": "AAGA,OAEE,wBAAAA,MACK,kCAGP,OAAS,wBAAAC,MAA4B,yBAErC,MAAMC,EAA4BC,IACzB,CACL,KAAM,GAAG,GAAG,EACZ,UAAW,GACR,GAAG,EACH,gBAAgBA,CAAS,CAC9B,GAGIC,EAAyB,KACtB,CACL,UAAW,GAAG,GAAG,EACjB,UAAW,GAAG,GAAG,CACnB,GAGF,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA0C,CAAE,KAAM,GAAG,GAAG,CAAE,EAC1DC,EAAkD,CACtD,cAAe,CAAC,EAChB,eAAgB,GAChB,oBAAqB,GACrB,mBAAoB,CAAC,EACrB,sBAAuBD,EACvB,IAAK,CACH,IAAK,iBACL,KAAM,OACN,OAAQ,MACV,EACA,WAAY,CACV,IAAK,uBACP,EACA,sBAAuB,CACrB,IAAK,sBACP,EACA,YAAa,aACf,EAEA,WAAW,IAAM,CACf,GAAG,gBAAgB,CACrB,CAAC,EAED,GAAG,oEAAqE,SAAY,CAGlF,MAAME,EAAM,MAFU,IAAIN,EAAqBK,CAA0B,EAEzC,YAAY,CAAC,CAAC,EAE9C,OAAOC,CAAG,EAAE,QAAQ,CAAC,CAAC,CACxB,CAAC,EAED,GAAG,+CAAgD,SAAY,CAG7D,MAAMA,EAAM,MAFU,IAAIN,EAAqBK,CAA0B,EAEzC,YAAY,CAAC,CAAC,EAE9C,OAAOC,CAAG,EAAE,QAAQ,CAAC,CAAC,CACxB,CA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EKJ,EAAY,CAAE,KAAM,QAAS,QAAS,OAAQ,EAG9CC,EAAS,MAAMJ,EAAc,gBACjCG,EACAf,EAAqB,KACvB,EAGA,OAAOkB,EAAa,SAAS,EAAE,qBAC7BH,EACAf,EAAqB,KACvB,EACA,OAAOmB,EAAa,SAAS,EAAE,qBAC7BJ,EACAf,EAAqB,KACvB,EACA,OAAOkB,EAAa,SAAS,EAAE,qBAAqBH,CAAS,EAC7D,OAAOI,EAAa,SAAS,EAAE,qBAAqBJ,CAAS,EAC7D,OAAOC,CAAM,EAAE,QAAQK,CAAY,CACrC,CAAC,EAED,GAAG,4CAA6C,SAAY,CAE1D,MAAMP,EAAcV,EAAuB,EACrCkB,EAAY,IAAI,MAAM,mBAAmB,EAE/C,GAAG,MAAMR,EAAa,WAAW,EAAE,gBAAgB,EAAI,EACvD,GAAG,MAAMA,EAAa,WAAW,EAAE,kBAAkBQ,CAAS,EAE9D,MAAMV,EAAgB,IAAIX,EAAqB,CAC7C,GAAGK,EACH,mBAAoB,CAACQ,CAAW,CAClC,CAAC,EAEKC,EAAY,CAAE,KAAM,QAAS,QAAS,OAAQ,EAGpD,MAAM,OACJH,EAAc,gBAAgBG,EAAWf,EAAqB,KAAK,CACrE,EAAE,QAAQ,QAAQ,mBAAmB,EAErC,OAAOc,EAAY,SAAS,EAAE,qBAC5BC,EACAf,EAAqB,KACvB,EACA,OAAOc,EAAY,SAAS,EAAE,qBAAqBC,CAAS,CAC9D,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["ClearSignContextType", "DefaultContextModule", "contextLoaderStubBuilder", "canHandle", "fieldLoaderStubBuilder", "typedDataLoader", "defaultContextModuleConfig", "res", "loader", "responses", "loader1", "loader2", "contextModule", "testInput", "fieldLoader", "testField", "result", "mockContext", "fieldLoader1", "fieldLoader2", "mockContext1", "mockContext2", "loadError"]
7
7
  }
package/lib/esm/src/di.js CHANGED
@@ -1,2 +1,2 @@
1
- import{Container as t}from"inversify";import{calldataModuleFactory as e}from"./calldata/di/calldataModuleFactory";import{configModuleFactory as a}from"./config/di/configModuleFactory";import{dynamicNetworkModuleFactory as m}from"./dynamic-network/di/dynamicNetworkModuleFactory";import{externalPluginModuleFactory as n}from"./external-plugin/di/externalPluginModuleFactory";import{nftModuleFactory as i}from"./nft/di/nftModuleFactory";import{nanoPkiModuleFactory as c}from"./pki/di/pkiModuleFactory";import{proxyModuleFactory as l}from"./proxy/di/proxyModuleFactory";import{solanaContextModuleFactory as p}from"./solana/di/SolanaContextModuleFactory";import{tokenModuleFactory as d}from"./token/di/tokenModuleFactory";import{trustedNameModuleFactory as f}from"./trusted-name/di/trustedNameModuleFactory";import{typedDataModuleFactory as u}from"./typed-data/di/typedDataModuleFactory";import{uniswapModuleFactory as y}from"./uniswap/di/uniswapModuleFactory";import{web3CheckModuleFactory as M}from"./web3-check/di/web3CheckModuleFactory";const j=({config:o})=>{const r=new t;return r.loadSync(a(o),n(),m(),i(),l(o),d(),e(),f(),u(),c(),y(),M(),p()),r};export{j as makeContainer};
1
+ import{Container as t}from"inversify";import{calldataModuleFactory as e}from"./calldata/di/calldataModuleFactory";import{configModuleFactory as a}from"./config/di/configModuleFactory";import{dynamicNetworkModuleFactory as m}from"./dynamic-network/di/dynamicNetworkModuleFactory";import{externalPluginModuleFactory as n}from"./external-plugin/di/externalPluginModuleFactory";import{nftModuleFactory as i}from"./nft/di/nftModuleFactory";import{nanoPkiModuleFactory as c}from"./pki/di/pkiModuleFactory";import{proxyModuleFactory as l}from"./proxy/di/proxyModuleFactory";import{safeModuleFactory as p}from"./safe/di/safeModuleFactory";import{solanaContextModuleFactory as d}from"./solana/di/SolanaContextModuleFactory";import{tokenModuleFactory as f}from"./token/di/tokenModuleFactory";import{transactionCheckModuleFactory as u}from"./transaction-check/di/transactionCheckModuleFactory";import{trustedNameModuleFactory as y}from"./trusted-name/di/trustedNameModuleFactory";import{typedDataModuleFactory as M}from"./typed-data/di/typedDataModuleFactory";import{uniswapModuleFactory as F}from"./uniswap/di/uniswapModuleFactory";const v=({config:o})=>{const r=new t;return r.loadSync(a(o),n(),m(),i(),l(o),p(),f(),e(),y(),M(),c(),F(),u(),d()),r};export{v as makeContainer};
2
2
  //# sourceMappingURL=di.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/di.ts"],
4
- "sourcesContent": ["import { Container } from \"inversify\";\n\nimport { calldataModuleFactory } from \"@/calldata/di/calldataModuleFactory\";\nimport { configModuleFactory } from \"@/config/di/configModuleFactory\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { dynamicNetworkModuleFactory } from \"@/dynamic-network/di/dynamicNetworkModuleFactory\";\nimport { externalPluginModuleFactory } from \"@/external-plugin/di/externalPluginModuleFactory\";\nimport { nftModuleFactory } from \"@/nft/di/nftModuleFactory\";\nimport { nanoPkiModuleFactory } from \"@/pki/di/pkiModuleFactory\";\nimport { proxyModuleFactory } from \"@/proxy/di/proxyModuleFactory\";\nimport { solanaContextModuleFactory } from \"@/solana/di/SolanaContextModuleFactory\";\nimport { tokenModuleFactory } from \"@/token/di/tokenModuleFactory\";\nimport { trustedNameModuleFactory } from \"@/trusted-name/di/trustedNameModuleFactory\";\nimport { typedDataModuleFactory } from \"@/typed-data/di/typedDataModuleFactory\";\nimport { uniswapModuleFactory } from \"@/uniswap/di/uniswapModuleFactory\";\nimport { web3CheckModuleFactory } from \"@/web3-check/di/web3CheckModuleFactory\";\n\ntype MakeContainerArgs = {\n config: ContextModuleConfig;\n};\n\nexport const makeContainer = ({ config }: MakeContainerArgs) => {\n const container = new Container();\n\n container.loadSync(\n configModuleFactory(config),\n externalPluginModuleFactory(),\n dynamicNetworkModuleFactory(),\n nftModuleFactory(),\n proxyModuleFactory(config),\n tokenModuleFactory(),\n calldataModuleFactory(),\n trustedNameModuleFactory(),\n typedDataModuleFactory(),\n nanoPkiModuleFactory(),\n uniswapModuleFactory(),\n web3CheckModuleFactory(),\n solanaContextModuleFactory(),\n );\n\n return container;\n};\n"],
5
- "mappings": "AAAA,OAAS,aAAAA,MAAiB,YAE1B,OAAS,yBAAAC,MAA6B,sCACtC,OAAS,uBAAAC,MAA2B,kCAEpC,OAAS,+BAAAC,MAAmC,mDAC5C,OAAS,+BAAAC,MAAmC,mDAC5C,OAAS,oBAAAC,MAAwB,4BACjC,OAAS,wBAAAC,MAA4B,4BACrC,OAAS,sBAAAC,MAA0B,gCACnC,OAAS,8BAAAC,MAAkC,yCAC3C,OAAS,sBAAAC,MAA0B,gCACnC,OAAS,4BAAAC,MAAgC,6CACzC,OAAS,0BAAAC,MAA8B,yCACvC,OAAS,wBAAAC,MAA4B,oCACrC,OAAS,0BAAAC,MAA8B,yCAMhC,MAAMC,EAAgB,CAAC,CAAE,OAAAC,CAAO,IAAyB,CAC9D,MAAMC,EAAY,IAAIhB,EAEtB,OAAAgB,EAAU,SACRd,EAAoBa,CAAM,EAC1BX,EAA4B,EAC5BD,EAA4B,EAC5BE,EAAiB,EACjBE,EAAmBQ,CAAM,EACzBN,EAAmB,EACnBR,EAAsB,EACtBS,EAAyB,EACzBC,EAAuB,EACvBL,EAAqB,EACrBM,EAAqB,EACrBC,EAAuB,EACvBL,EAA2B,CAC7B,EAEOQ,CACT",
6
- "names": ["Container", "calldataModuleFactory", "configModuleFactory", "dynamicNetworkModuleFactory", "externalPluginModuleFactory", "nftModuleFactory", "nanoPkiModuleFactory", "proxyModuleFactory", "solanaContextModuleFactory", "tokenModuleFactory", "trustedNameModuleFactory", "typedDataModuleFactory", "uniswapModuleFactory", "web3CheckModuleFactory", "makeContainer", "config", "container"]
4
+ "sourcesContent": ["import { Container } from \"inversify\";\n\nimport { calldataModuleFactory } from \"@/calldata/di/calldataModuleFactory\";\nimport { configModuleFactory } from \"@/config/di/configModuleFactory\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { dynamicNetworkModuleFactory } from \"@/dynamic-network/di/dynamicNetworkModuleFactory\";\nimport { externalPluginModuleFactory } from \"@/external-plugin/di/externalPluginModuleFactory\";\nimport { nftModuleFactory } from \"@/nft/di/nftModuleFactory\";\nimport { nanoPkiModuleFactory } from \"@/pki/di/pkiModuleFactory\";\nimport { proxyModuleFactory } from \"@/proxy/di/proxyModuleFactory\";\nimport { safeModuleFactory } from \"@/safe/di/safeModuleFactory\";\nimport { solanaContextModuleFactory } from \"@/solana/di/SolanaContextModuleFactory\";\nimport { tokenModuleFactory } from \"@/token/di/tokenModuleFactory\";\nimport { transactionCheckModuleFactory } from \"@/transaction-check/di/transactionCheckModuleFactory\";\nimport { trustedNameModuleFactory } from \"@/trusted-name/di/trustedNameModuleFactory\";\nimport { typedDataModuleFactory } from \"@/typed-data/di/typedDataModuleFactory\";\nimport { uniswapModuleFactory } from \"@/uniswap/di/uniswapModuleFactory\";\n\ntype MakeContainerArgs = {\n config: ContextModuleConfig;\n};\n\nexport const makeContainer = ({ config }: MakeContainerArgs) => {\n const container = new Container();\n\n container.loadSync(\n configModuleFactory(config),\n externalPluginModuleFactory(),\n dynamicNetworkModuleFactory(),\n nftModuleFactory(),\n proxyModuleFactory(config),\n safeModuleFactory(),\n tokenModuleFactory(),\n calldataModuleFactory(),\n trustedNameModuleFactory(),\n typedDataModuleFactory(),\n nanoPkiModuleFactory(),\n uniswapModuleFactory(),\n transactionCheckModuleFactory(),\n solanaContextModuleFactory(),\n );\n\n return container;\n};\n"],
5
+ "mappings": "AAAA,OAAS,aAAAA,MAAiB,YAE1B,OAAS,yBAAAC,MAA6B,sCACtC,OAAS,uBAAAC,MAA2B,kCAEpC,OAAS,+BAAAC,MAAmC,mDAC5C,OAAS,+BAAAC,MAAmC,mDAC5C,OAAS,oBAAAC,MAAwB,4BACjC,OAAS,wBAAAC,MAA4B,4BACrC,OAAS,sBAAAC,MAA0B,gCACnC,OAAS,qBAAAC,MAAyB,8BAClC,OAAS,8BAAAC,MAAkC,yCAC3C,OAAS,sBAAAC,MAA0B,gCACnC,OAAS,iCAAAC,MAAqC,uDAC9C,OAAS,4BAAAC,MAAgC,6CACzC,OAAS,0BAAAC,MAA8B,yCACvC,OAAS,wBAAAC,MAA4B,oCAM9B,MAAMC,EAAgB,CAAC,CAAE,OAAAC,CAAO,IAAyB,CAC9D,MAAMC,EAAY,IAAIjB,EAEtB,OAAAiB,EAAU,SACRf,EAAoBc,CAAM,EAC1BZ,EAA4B,EAC5BD,EAA4B,EAC5BE,EAAiB,EACjBE,EAAmBS,CAAM,EACzBR,EAAkB,EAClBE,EAAmB,EACnBT,EAAsB,EACtBW,EAAyB,EACzBC,EAAuB,EACvBP,EAAqB,EACrBQ,EAAqB,EACrBH,EAA8B,EAC9BF,EAA2B,CAC7B,EAEOQ,CACT",
6
+ "names": ["Container", "calldataModuleFactory", "configModuleFactory", "dynamicNetworkModuleFactory", "externalPluginModuleFactory", "nftModuleFactory", "nanoPkiModuleFactory", "proxyModuleFactory", "safeModuleFactory", "solanaContextModuleFactory", "tokenModuleFactory", "transactionCheckModuleFactory", "trustedNameModuleFactory", "typedDataModuleFactory", "uniswapModuleFactory", "makeContainer", "config", "container"]
7
7
  }
@@ -1,2 +1,2 @@
1
- var E=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var m=(i,e,a,t)=>{for(var r=t>1?void 0:t?P(e,a):e,n=i.length-1,l;n>=0;n--)(l=i[n])&&(r=(t?l(e,a,r):l(r))||r);return t&&r&&E(e,a,r),r},S=(i,e)=>(a,t)=>e(a,t,i);import{isHexaString as d}from"@ledgerhq/device-management-kit";import{Interface as I}from"ethers";import{inject as D,injectable as R}from"inversify";import{EitherAsync as f,Left as T,Right as k}from"purify-ts";import{externalPluginTypes as _}from"../../external-plugin/di/externalPluginTypes";import{ClearSignContextType as o}from"../../shared/model/ClearSignContext";import{tokenTypes as b}from"../../token/di/tokenTypes";const L=[o.EXTERNAL_PLUGIN,o.TOKEN];let g=class{_externalPluginDataSource;_tokenDataSource;constructor(e,a){this._externalPluginDataSource=e,this._tokenDataSource=a}canHandle(e,a){return typeof e=="object"&&e!==null&&"to"in e&&"data"in e&&"selector"in e&&"chainId"in e&&typeof e.chainId=="number"&&d(e.to)&&e.to!=="0x"&&d(e.data)&&e.data!=="0x"&&d(e.selector)&&e.selector!=="0x"&&L.every(t=>a.includes(t))}async load(e){const{to:a,data:t,selector:r,chainId:n}=e,l=await this._externalPluginDataSource.getDappInfos({address:a,chainId:n,selector:r});return f(async({liftEither:c})=>{const s=await c(l);if(!s)return[];const C={type:o.EXTERNAL_PLUGIN,payload:s.selectorDetails.serializedData.concat(s.selectorDetails.signature)},x=this.getDecodedCallData(s.abi,s.selectorDetails.method,t);if(x.isLeft())return[{type:o.ERROR,error:x.extract()},C];const h=x.extract(),y=s.selectorDetails.erc20OfInterest.map(async u=>this.getTokenPayload(e,u,h));return[...(await Promise.all(y)).map(u=>u.caseOf({Left:p=>({type:o.ERROR,error:p}),Right:p=>({type:o.TOKEN,payload:p})})),C]}).caseOf({Left:c=>[{type:o.ERROR,error:c}],Right:c=>c})}getTokenPayload(e,a,t){const r=this.getAddressFromPath(a,t);return f(({fromPromise:n})=>n(this._tokenDataSource.getTokenInfosPayload({address:r,chainId:e.chainId})))}getDecodedCallData(e,a,t){try{const r=new I(e);return k(r.decodeFunctionData(a,t))}catch{return T(new Error("[ContextModule] ExternalPluginContextLoader: Unable to parse abi"))}}getAddressFromPath(e,a){let t=a;for(const r of e.split("."))r==="-1"?t=t[t.length-1]:t=t[r];if(!d(t))throw new Error("[ContextModule] ExternalPluginContextLoader: Unable to get address");return t}};g=m([R(),S(0,D(_.ExternalPluginDataSource)),S(1,D(b.TokenDataSource))],g);export{g as ExternalPluginContextLoader};
1
+ var D=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var y=(i,e,r,t)=>{for(var a=t>1?void 0:t?I(e,r):e,o=i.length-1,l;o>=0;o--)(l=i[o])&&(a=(t?l(e,r,a):l(a))||a);return t&&a&&D(e,r,a),a},u=(i,e)=>(r,t)=>e(r,t,i);import{isHexaString as x}from"@ledgerhq/device-management-kit";import{Interface as T}from"ethers";import{inject as h,injectable as L}from"inversify";import{EitherAsync as S,Left as R,Right as k}from"purify-ts";import{externalPluginTypes as w}from"../../external-plugin/di/externalPluginTypes";import{ClearSignContextType as n}from"../../shared/model/ClearSignContext";import{tokenTypes as _}from"../../token/di/tokenTypes";import{uniswapTypes as b}from"../../uniswap/di/uniswapTypes";const H=[n.EXTERNAL_PLUGIN,n.TOKEN];let g=class{constructor(e,r,t){this._externalPluginDataSource=e;this._tokenDataSource=r;this._uniswapLoader=t;this._customPluginLoaders={Uniswap:this._uniswapLoader}}_customPluginLoaders;canHandle(e,r){return typeof e=="object"&&e!==null&&"to"in e&&"data"in e&&"selector"in e&&"chainId"in e&&typeof e.chainId=="number"&&x(e.to)&&e.to!=="0x"&&x(e.data)&&e.data!=="0x"&&x(e.selector)&&e.selector!=="0x"&&H.every(t=>r.includes(t))}async load(e){const{to:r,data:t,selector:a,chainId:o}=e,l=await this._externalPluginDataSource.getDappInfos({address:r,chainId:o,selector:a});return S(async({liftEither:c})=>{const s=await c(l);if(!s)return[];const p={type:n.EXTERNAL_PLUGIN,payload:s.selectorDetails.serializedData.concat(s.selectorDetails.signature)},m=this._customPluginLoaders[s.selectorDetails.plugin];if(m!==void 0&&m.canHandle(e,[n.TOKEN])){const d=await m.load(e);return[p,...d]}const C=this.getDecodedCallData(s.abi,s.selectorDetails.method,t);if(C.isLeft())return[{type:n.ERROR,error:C.extract()},p];const P=C.extract(),E=s.selectorDetails.erc20OfInterest.map(async d=>this.getTokenPayload(e,d,P));return[...(await Promise.all(E)).map(d=>d.caseOf({Left:f=>({type:n.ERROR,error:f}),Right:f=>({type:n.TOKEN,payload:f})})),p]}).caseOf({Left:c=>[{type:n.ERROR,error:c}],Right:c=>c})}getTokenPayload(e,r,t){const a=this.getAddressFromPath(r,t);return S(({fromPromise:o})=>o(this._tokenDataSource.getTokenInfosPayload({address:a,chainId:e.chainId})))}getDecodedCallData(e,r,t){try{const a=new T(e);return k(a.decodeFunctionData(r,t))}catch{return R(new Error("[ContextModule] ExternalPluginContextLoader: Unable to parse abi"))}}getAddressFromPath(e,r){let t=r;for(const a of e.split("."))a==="-1"?t=t[t.length-1]:t=t[a];if(!x(t))throw new Error("[ContextModule] ExternalPluginContextLoader: Unable to get address");return t}};g=y([L(),u(0,h(w.ExternalPluginDataSource)),u(1,h(_.TokenDataSource)),u(2,h(b.UniswapContextLoader))],g);export{g as ExternalPluginContextLoader};
2
2
  //# sourceMappingURL=ExternalPluginContextLoader.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/external-plugin/domain/ExternalPluginContextLoader.ts"],
4
- "sourcesContent": ["import { HexaString, isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { ethers, Interface } from \"ethers\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, EitherAsync, Left, Right } from \"purify-ts\";\n\nimport type { ExternalPluginDataSource } from \"@/external-plugin/data/ExternalPluginDataSource\";\nimport { externalPluginTypes } from \"@/external-plugin/di/externalPluginTypes\";\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport type { TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\n\nexport type ExternalPluginContextInput = {\n to: HexaString;\n data: HexaString;\n selector: HexaString;\n chainId: number;\n};\n\nconst SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.EXTERNAL_PLUGIN,\n ClearSignContextType.TOKEN,\n];\n\n@injectable()\nexport class ExternalPluginContextLoader\n implements ContextLoader<ExternalPluginContextInput>\n{\n private _externalPluginDataSource: ExternalPluginDataSource;\n private _tokenDataSource: TokenDataSource;\n\n constructor(\n @inject(externalPluginTypes.ExternalPluginDataSource)\n externalPluginDataSource: ExternalPluginDataSource,\n @inject(tokenTypes.TokenDataSource) tokenDataSource: TokenDataSource,\n ) {\n this._externalPluginDataSource = externalPluginDataSource;\n this._tokenDataSource = tokenDataSource;\n }\n\n canHandle(\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ): input is ExternalPluginContextInput {\n return (\n typeof input === \"object\" &&\n input !== null &&\n \"to\" in input &&\n \"data\" in input &&\n \"selector\" in input &&\n \"chainId\" in input &&\n typeof input.chainId === \"number\" &&\n isHexaString(input.to) &&\n input.to !== \"0x\" &&\n isHexaString(input.data) &&\n input.data !== \"0x\" && // non empty data\n isHexaString(input.selector) &&\n input.selector !== \"0x\" &&\n SUPPORTED_TYPES.every((type) => expectedTypes.includes(type))\n );\n }\n\n async load(input: ExternalPluginContextInput): Promise<ClearSignContext[]> {\n const { to, data, selector, chainId } = input;\n\n const eitherDappInfos = await this._externalPluginDataSource.getDappInfos({\n address: to,\n chainId,\n selector,\n });\n\n return EitherAsync<Error, ClearSignContext[]>(async ({ liftEither }) => {\n const dappInfos = await liftEither(eitherDappInfos);\n\n // if the dappInfos is null, return an empty array\n // this means that the selector is not a known selector\n if (!dappInfos) {\n return [];\n }\n\n const externalPluginContext: ClearSignContext = {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: dappInfos.selectorDetails.serializedData.concat(\n dappInfos.selectorDetails.signature,\n ),\n };\n\n const decodedCallData = this.getDecodedCallData(\n dappInfos.abi,\n dappInfos.selectorDetails.method,\n data,\n );\n\n // if the call data cannot be decoded, return the error\n // but also the externalPluginContext because it is still valid\n if (decodedCallData.isLeft()) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: decodedCallData.extract(),\n },\n externalPluginContext,\n ];\n }\n\n // decodedCallData is a Right so we can extract it safely\n const extractedDecodedCallData =\n decodedCallData.extract() as ethers.Result;\n\n // get the token payload for each erc20OfInterest\n // and return the payload or the error\n const promises = dappInfos.selectorDetails.erc20OfInterest.map(\n async (erc20Path) =>\n this.getTokenPayload(input, erc20Path, extractedDecodedCallData),\n );\n\n const tokensPayload = await Promise.all(promises);\n\n // map the payload or the error to a ClearSignContext\n const contexts: ClearSignContext[] = tokensPayload.map((eitherToken) =>\n eitherToken.caseOf<ClearSignContext>({\n Left: (error) => ({ type: ClearSignContextType.ERROR, error }),\n Right: (payload) => ({ type: ClearSignContextType.TOKEN, payload }),\n }),\n );\n\n return [...contexts, externalPluginContext];\n }).caseOf<ClearSignContext[]>({\n // parse all errors into ClearSignContext\n Left: (error) => [{ type: ClearSignContextType.ERROR, error }],\n Right: (contexts) => contexts,\n });\n }\n\n private getTokenPayload(\n input: ExternalPluginContextInput,\n erc20Path: string,\n decodedCallData: ethers.Result,\n ) {\n const address = this.getAddressFromPath(erc20Path, decodedCallData);\n\n return EitherAsync<Error, string>(({ fromPromise }) =>\n fromPromise(\n this._tokenDataSource.getTokenInfosPayload({\n address,\n chainId: input.chainId,\n }),\n ),\n );\n }\n\n private getDecodedCallData(\n abi: object[],\n method: string,\n data: string,\n ): Either<Error, ethers.Result> {\n try {\n const contractInterface = new Interface(abi);\n return Right(contractInterface.decodeFunctionData(method, data));\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to parse abi\",\n ),\n );\n }\n }\n\n private getAddressFromPath(\n path: string,\n decodedCallData: ethers.Result,\n ): HexaString {\n // ethers.Result is a record string, any\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let value: any = decodedCallData;\n for (const key of path.split(\".\")) {\n // In Solidity, a struct cannot begin with a number\n // Additionally, when we use -1, it signifies the last element of the array.\n if (key === \"-1\") {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n value = value[value.length - 1];\n } else {\n // This access can throw a RangeError error in case of an invalid key\n // but is correctly caught by the liftEither above\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n value = value[key];\n }\n }\n\n if (!isHexaString(value)) {\n throw new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to get address\",\n );\n }\n\n return value;\n }\n}\n"],
5
- "mappings": "iOAAA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AMC,CAAG,EAIrB,GAAI,CAAC7B,EAAa4B,CAAK,EACrB,MAAM,IAAI,MACR,oEACF,EAGF,OAAOA,CACT,CACF,EA5KajC,EAANmC,EAAA,CADNC,EAAW,EAQPC,EAAA,EAAAC,EAAOC,EAAoB,wBAAwB,GAEnDF,EAAA,EAAAC,EAAOE,EAAW,eAAe,IATzBxC",
6
- "names": ["isHexaString", "Interface", "inject", "injectable", "EitherAsync", "Left", "Right", "externalPluginTypes", "ClearSignContextType", "tokenTypes", "SUPPORTED_TYPES", "ClearSignContextType", "ExternalPluginContextLoader", "externalPluginDataSource", "tokenDataSource", "input", "expectedTypes", "isHexaString", "type", "to", "data", "selector", "chainId", "eitherDappInfos", "EitherAsync", "liftEither", "dappInfos", "externalPluginContext", "decodedCallData", "extractedDecodedCallData", "promises", "erc20Path", "eitherToken", "error", "payload", "contexts", "address", "fromPromise", "abi", "method", "contractInterface", "Interface", "Right", "Left", "path", "value", "key", "__decorateClass", "injectable", "__decorateParam", "inject", "externalPluginTypes", "tokenTypes"]
4
+ "sourcesContent": ["import { HexaString, isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { ethers, Interface } from \"ethers\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, EitherAsync, Left, Right } from \"purify-ts\";\n\nimport type { ExternalPluginDataSource } from \"@/external-plugin/data/ExternalPluginDataSource\";\nimport { externalPluginTypes } from \"@/external-plugin/di/externalPluginTypes\";\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport type { TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { tokenTypes } from \"@/token/di/tokenTypes\";\nimport { uniswapTypes } from \"@/uniswap/di/uniswapTypes\";\nimport type { UniswapContextLoader } from \"@/uniswap/domain/UniswapContextLoader\";\n\nexport type ExternalPluginContextInput = {\n to: HexaString;\n data: HexaString;\n selector: HexaString;\n chainId: number;\n};\n\nexport type ExternalPluginTokensInput = {\n data: HexaString;\n selector: HexaString;\n chainId: number;\n};\n\nconst SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.EXTERNAL_PLUGIN,\n ClearSignContextType.TOKEN,\n];\n\n@injectable()\nexport class ExternalPluginContextLoader\n implements ContextLoader<ExternalPluginContextInput>\n{\n private _customPluginLoaders: Record<\n string,\n ContextLoader<ExternalPluginTokensInput>\n >;\n\n constructor(\n @inject(externalPluginTypes.ExternalPluginDataSource)\n private _externalPluginDataSource: ExternalPluginDataSource,\n @inject(tokenTypes.TokenDataSource)\n private _tokenDataSource: TokenDataSource,\n @inject(uniswapTypes.UniswapContextLoader)\n private _uniswapLoader: UniswapContextLoader,\n ) {\n this._customPluginLoaders = {\n Uniswap: this._uniswapLoader,\n };\n }\n\n canHandle(\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ): input is ExternalPluginContextInput {\n return (\n typeof input === \"object\" &&\n input !== null &&\n \"to\" in input &&\n \"data\" in input &&\n \"selector\" in input &&\n \"chainId\" in input &&\n typeof input.chainId === \"number\" &&\n isHexaString(input.to) &&\n input.to !== \"0x\" &&\n isHexaString(input.data) &&\n input.data !== \"0x\" && // non empty data\n isHexaString(input.selector) &&\n input.selector !== \"0x\" &&\n SUPPORTED_TYPES.every((type) => expectedTypes.includes(type))\n );\n }\n\n async load(input: ExternalPluginContextInput): Promise<ClearSignContext[]> {\n const { to, data, selector, chainId } = input;\n\n const eitherDappInfos = await this._externalPluginDataSource.getDappInfos({\n address: to,\n chainId,\n selector,\n });\n\n return EitherAsync<Error, ClearSignContext[]>(async ({ liftEither }) => {\n const dappInfos = await liftEither(eitherDappInfos);\n\n // if the dappInfos is null, return an empty array\n // this means that the selector is not a known selector\n if (!dappInfos) {\n return [];\n }\n\n const externalPluginContext: ClearSignContext = {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: dappInfos.selectorDetails.serializedData.concat(\n dappInfos.selectorDetails.signature,\n ),\n };\n\n const customLoader =\n this._customPluginLoaders[dappInfos.selectorDetails.plugin];\n if (\n customLoader !== undefined &&\n customLoader.canHandle(input, [ClearSignContextType.TOKEN])\n ) {\n const tokens = await customLoader.load(input);\n return [externalPluginContext, ...tokens];\n }\n\n const decodedCallData = this.getDecodedCallData(\n dappInfos.abi,\n dappInfos.selectorDetails.method,\n data,\n );\n\n // if the call data cannot be decoded, return the error\n // but also the externalPluginContext because it is still valid\n if (decodedCallData.isLeft()) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: decodedCallData.extract(),\n },\n externalPluginContext,\n ];\n }\n\n // decodedCallData is a Right so we can extract it safely\n const extractedDecodedCallData =\n decodedCallData.extract() as ethers.Result;\n\n // get the token payload for each erc20OfInterest\n // and return the payload or the error\n const promises = dappInfos.selectorDetails.erc20OfInterest.map(\n async (erc20Path) =>\n this.getTokenPayload(input, erc20Path, extractedDecodedCallData),\n );\n\n const tokensPayload = await Promise.all(promises);\n\n // map the payload or the error to a ClearSignContext\n const contexts: ClearSignContext[] = tokensPayload.map((eitherToken) =>\n eitherToken.caseOf<ClearSignContext>({\n Left: (error) => ({ type: ClearSignContextType.ERROR, error }),\n Right: (payload) => ({ type: ClearSignContextType.TOKEN, payload }),\n }),\n );\n\n return [...contexts, externalPluginContext];\n }).caseOf<ClearSignContext[]>({\n // parse all errors into ClearSignContext\n Left: (error) => [{ type: ClearSignContextType.ERROR, error }],\n Right: (contexts) => contexts,\n });\n }\n\n private getTokenPayload(\n input: ExternalPluginContextInput,\n erc20Path: string,\n decodedCallData: ethers.Result,\n ) {\n const address = this.getAddressFromPath(erc20Path, decodedCallData);\n\n return EitherAsync<Error, string>(({ fromPromise }) =>\n fromPromise(\n this._tokenDataSource.getTokenInfosPayload({\n address,\n chainId: input.chainId,\n }),\n ),\n );\n }\n\n private getDecodedCallData(\n abi: object[],\n method: string,\n data: string,\n ): Either<Error, ethers.Result> {\n try {\n const contractInterface = new Interface(abi);\n return Right(contractInterface.decodeFunctionData(method, data));\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to parse abi\",\n ),\n );\n }\n }\n\n private getAddressFromPath(\n path: string,\n decodedCallData: ethers.Result,\n ): HexaString {\n // ethers.Result is a record string, any\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let value: any = decodedCallData;\n for (const key of path.split(\".\")) {\n // In Solidity, a struct cannot begin with a number\n // Additionally, when we use -1, it signifies the last element of the array.\n if (key === \"-1\") {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n value = value[value.length - 1];\n } else {\n // This access can throw a RangeError error in case of an invalid key\n // but is correctly caught by the liftEither above\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n value = value[key];\n }\n }\n\n if (!isHexaString(value)) {\n throw new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to get address\",\n );\n }\n\n return value;\n }\n}\n"],
5
+ "mappings": "iOAAA,OAAqB,gBAAAA,MAAoB,kCACzC,OAAiB,aAAAC,MAAiB,SAClC,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,eAAAC,EAAa,QAAAC,EAAM,SAAAC,MAAa,YAGjD,OAAS,uBAAAC,MAA2B,2CAEpC,OAEE,wBAAAC,MACK,kCAEP,OAAS,cAAAC,MAAkB,wBAC3B,OAAS,gBAAAC,MAAoB,4BAgB7B,MAAMC,EAA0C,CAC9CC,EAAqB,gBACrBA,EAAqB,KACvB,EAGO,IAAMC,EAAN,KAEP,CAME,YAEUC,EAEAC,EAEAC,EACR,CALQ,+BAAAF,EAEA,sBAAAC,EAEA,oBAAAC,EAER,KAAK,qBAAuB,CAC1B,QAAS,KAAK,cAChB,CACF,CAhBQ,qBAkBR,UACEC,EACAC,EACqC,CACrC,OACE,OAAOD,GAAU,UACjBA,IAAU,MACV,OAAQA,GACR,SAAUA,GACV,aAAcA,GACd,YAAaA,GACb,OAAOA,EAAM,SAAY,UACzBE,EAAaF,EA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PluginTypes", "ClearSignContextType", "tokenTypes", "uniswapTypes", "SUPPORTED_TYPES", "ClearSignContextType", "ExternalPluginContextLoader", "_externalPluginDataSource", "_tokenDataSource", "_uniswapLoader", "input", "expectedTypes", "isHexaString", "type", "to", "data", "selector", "chainId", "eitherDappInfos", "EitherAsync", "liftEither", "dappInfos", "externalPluginContext", "customLoader", "tokens", "decodedCallData", "extractedDecodedCallData", "promises", "erc20Path", "eitherToken", "error", "payload", "contexts", "address", "fromPromise", "abi", "method", "contractInterface", "Interface", "Right", "Left", "path", "value", "key", "__decorateClass", "injectable", "__decorateParam", "inject", "externalPluginTypes", "tokenTypes", "uniswapTypes"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{Interface as u}from"ethers";import{Left as i,Right as c}from"purify-ts";import r from"@/external-plugin/__tests__/abi.json";import{ExternalPluginContextLoader as E}from"../../external-plugin/domain/ExternalPluginContextLoader";import{ClearSignContextType as a}from"../../shared/model/ClearSignContext";const d=({abi:p,selectorDetails:s})=>({abi:p,selectorDetails:{erc20OfInterest:[],method:"",plugin:"",serializedData:"123456",signature:"7890",...s}}),l=(p,s,n)=>{const t=new u(JSON.stringify(p)).encodeFunctionData(s,n);return{to:"0x0",data:t,selector:t.slice(0,10),chainId:1}};describe("ExternalPluginContextLoader",()=>{const p={getTokenInfosPayload:vi.fn()},s={getDappInfos:vi.fn()},n=new E(s,p);beforeEach(()=>{vi.clearAllMocks(),vi.spyOn(p,"getTokenInfosPayload").mockImplementation(({address:e})=>Promise.resolve(c(`payload-${e}`)))}),describe("canHandle function",()=>{const e={to:"0x1234567890123456789012345678901234567890",data:"0x095ea7b30000000000000000000000001234567890123456789012345678901234567890",selector:"0x095ea7b3",chainId:1};it("should return true for valid input",()=>{expect(n.canHandle(e,[a.EXTERNAL_PLUGIN,a.TOKEN])).toBe(!0)}),it("should return false for invalid expected type",()=>{expect(n.canHandle(e,[a.NFT])).toBe(!1),expect(n.canHandle(e,[a.TOKEN])).toBe(!1),expect(n.canHandle(e,[a.EXTERNAL_PLUGIN])).toBe(!1)}),it.each([[null,"null input"],[void 0,"undefined input"],[{},"empty object"],["string","string input"],[123,"number input"]])("should return false for %s",(t,o)=>{expect(n.canHandle(t,[a.EXTERNAL_PLUGIN,a.TOKEN])).toBe(!1)}),it.each([[{...e,to:void 0},"missing to"],[{...e,data:void 0},"missing data"],[{...e,selector:void 0},"missing selector"],[{...e,chainId:void 0},"missing chainId"]])("should return false for %s",(t,o)=>{expect(n.canHandle(t,[a.EXTERNAL_PLUGIN,a.TOKEN])).toBe(!1)}),it.each([[{...e,to:"invalid-hex"},"invalid to hex"],[{...e,to:"0x"},"empty to hex"],[{...e,data:"invalid-hex"},"invalid data hex"],[{...e,data:"0x"},"empty data (0x)"],[{...e,selector:"invalid-hex"},"invalid selector hex"],[{...e,selector:"0x"},"empty selector hex"]])("should return false for %s",(t,o)=>{expect(n.canHandle(t,[a.EXTERNAL_PLUGIN,a.TOKEN])).toBe(!1)}),it.each([[{...e,chainId:"1"},"string chainId"],[{...e,chainId:null},"null chainId"],[{...e,chainId:void 0},"undefined chainId"]])("should return false for %s",(t,o)=>{expect(n.canHandle(t,[a.EXTERNAL_PLUGIN,a.TOKEN])).toBe(!1)})}),describe("load function",()=>{it("should return an empty array if no dapp info is provided",async()=>{const e=l(r,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(c(void 0));const t=await n.load(e);expect(t).toEqual([])}),it("should return e plugin if no erc20OfInterest is provided",async()=>{const e=d({abi:r,selectorDetails:{erc20OfInterest:[],method:"singleParam"}}),t=l(r,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(c(e));const o=await n.load(t);expect(o).toEqual([{type:a.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return a list of context responses when one erc20OfInterest is provided for a single parameter",async()=>{const e=d({abi:r,selectorDetails:{erc20OfInterest:["fromToken"],method:"singleParam"}}),t=l(r,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(c(e));const o=await n.load(t);expect(o).toEqual(expect.arrayContaining([{type:a.EXTERNAL_PLUGIN,payload:"1234567890"},{type:a.TOKEN,payload:"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"}]))}),it("should return a context response with only set external plugin when one erc20OfInterest is provided for a single parameter but no payload is feched",async()=>{const e=d({abi:r,selectorDetails:{erc20OfInterest:["fromToken"],method:"singleParam"}}),t=l(r,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(c(e)),vi.spyOn(p,"getTokenInfosPayload").mockResolvedValue(i(Error("error")));const o=await n.load(t);expect(o).toEqual([{type:a.ERROR,error:new Error("error")},{type:a.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return a list of context responses when two erc20OfInterest are provided for two parameters",async()=>{const e=d({abi:r,selectorDetails:{erc20OfInterest:["fromToken","toToken"],method:"multipleParams"}}),t=l(r,"multipleParams",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(c(e));const o=await n.load(t);expect(o).toEqual(expect.arrayContaining([{type:a.EXTERNAL_PLUGIN,payload:"1234567890"},{type:a.TOKEN,payload:"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{type:a.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"}]))}),it("should return a list of context responses when one erc20OfInterest is an array",async()=>{const e=d({abi:r,selectorDetails:{erc20OfInterest:["fromToken.0","fromToken.1","fromToken.2","fromToken.-1"],method:"arrayParam"}}),t=l(r,"arrayParam",[["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7","0xB8c77482e45F1F44dE1745F52C74426C631bDD52"]]);vi.spyOn(s,"getDappInfos").mockResolvedValue(c(e));const o=await n.load(t);expect(o).toEqual([{type:a.TOKEN,payload:"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{type:a.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"},{type:a.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"},{type:a.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"},{type:a.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return an error when a token datasource returns an error",async()=>{const e=d({abi:r,selectorDetails:{erc20OfInterest:["fromToken"],method:"singleParam"}}),t=l(r,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(c(e)),vi.spyOn(p,"getTokenInfosPayload").mockResolvedValue(i(new Error("error")));const o=await n.load(t);expect(o).toEqual([{type:a.ERROR,error:new Error("error")},{type:a.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return an error when the abi is not conform",async()=>{const e=d({abi:[{fakeabi:"notworking"}],selectorDetails:{erc20OfInterest:["fromToken"],method:"singleParam"}}),t=l(r,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(c(e));const o=await n.load(t);expect(o).toEqual([{type:a.ERROR,error:new Error("[ContextModule] ExternalPluginContextLoader: Unable to parse abi")},{type:a.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should throw an error when the erc20OfInterest doest not exist in the transaction",async()=>{const e=d({abi:r,selectorDetails:{erc20OfInterest:["notFound"],method:"singleParam"}}),t=l(r,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(c(e));const o=await n.load(t);expect(o).toEqual([{type:a.ERROR,error:new Error("[ContextModule] ExternalPluginContextLoader: Unable to get address")}])}),it("should throw an error when an out-of-bounds element is present in erc20OfInterest",async()=>{const e=d({abi:r,selectorDetails:{erc20OfInterest:["fromToken.3"],method:"arrayParam"}}),t=l(r,"arrayParam",[["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7","0xB8c77482e45F1F44dE1745F52C74426C631bDD52"]]);vi.spyOn(s,"getDappInfos").mockResolvedValue(c(e));const o=await n.load(t);expect(o).toEqual([{type:a.ERROR,error:new RangeError("out of result range")}])}),it("should return a list of context responses when one erc20OfInterest is a complex struct",async()=>{const e=d({abi:r,selectorDetails:{erc20OfInterest:["complexStruct.address1","complexStruct.param1.param2.0.param3.addresses.0","complexStruct.param1.param2.0.param3.addresses.1","complexStruct.param1.param2.0.param3.addresses.-1","complexStruct.param1.param2.1.param3.addresses.0","complexStruct.param1.param2.-1.param3.addresses.0"],method:"complexStructParam"}}),t=l(r,"complexStructParam",[{address1:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",param1:{param2:[{param3:{addresses:["0xdAC17F958D2ee523a2206206994597C13D831ec7","0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE"]}},{param3:{addresses:["0xB8c77482e45F1F44dE1745F52C74426C631bDD52"]}}]}}]);vi.spyOn(s,"getDappInfos").mockResolvedValue(c(e));const o=await n.load(t);expect(o).toEqual([{type:a.TOKEN,payload:"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{type:a.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"},{type:a.TOKEN,payload:"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE"},{type:a.TOKEN,payload:"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE"},{type:a.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"},{type:a.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"},{type:a.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return an error when datasource return a Left",async()=>{const e=l(r,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(i(new Error("error")));const t=await n.load(e);expect(t).toEqual([{type:a.ERROR,error:new Error("error")}])})})});
1
+ import{Interface as E}from"ethers";import{Left as u,Right as l}from"purify-ts";import n from"@/external-plugin/__tests__/abi.json";import{ExternalPluginContextLoader as m}from"../../external-plugin/domain/ExternalPluginContextLoader";import{ClearSignContextType as a}from"../../shared/model/ClearSignContext";const p=({abi:i,selectorDetails:s})=>({abi:i,selectorDetails:{erc20OfInterest:[],method:"",plugin:"",serializedData:"123456",signature:"7890",...s}}),c=(i,s,d)=>{const e=new E(JSON.stringify(i)).encodeFunctionData(s,d);return{to:"0x0",data:e,selector:e.slice(0,10),chainId:1}};describe("ExternalPluginContextLoader",()=>{const i={getTokenInfosPayload:vi.fn()},s={getDappInfos:vi.fn()},d={canHandle:vi.fn(),load:vi.fn()},r=new m(s,i,d);beforeEach(()=>{vi.clearAllMocks(),vi.spyOn(i,"getTokenInfosPayload").mockImplementation(({address:e})=>Promise.resolve(l(`payload-${e}`)))}),describe("canHandle function",()=>{const e={to:"0x1234567890123456789012345678901234567890",data:"0x095ea7b30000000000000000000000001234567890123456789012345678901234567890",selector:"0x095ea7b3",chainId:1};it("should return true for valid input",()=>{expect(r.canHandle(e,[a.EXTERNAL_PLUGIN,a.TOKEN])).toBe(!0)}),it("should return false for invalid expected type",()=>{expect(r.canHandle(e,[a.NFT])).toBe(!1),expect(r.canHandle(e,[a.TOKEN])).toBe(!1),expect(r.canHandle(e,[a.EXTERNAL_PLUGIN])).toBe(!1)}),it.each([[null,"null input"],[void 0,"undefined input"],[{},"empty object"],["string","string input"],[123,"number input"]])("should return false for %s",(t,o)=>{expect(r.canHandle(t,[a.EXTERNAL_PLUGIN,a.TOKEN])).toBe(!1)}),it.each([[{...e,to:void 0},"missing to"],[{...e,data:void 0},"missing data"],[{...e,selector:void 0},"missing selector"],[{...e,chainId:void 0},"missing chainId"]])("should return false for %s",(t,o)=>{expect(r.canHandle(t,[a.EXTERNAL_PLUGIN,a.TOKEN])).toBe(!1)}),it.each([[{...e,to:"invalid-hex"},"invalid to hex"],[{...e,to:"0x"},"empty to hex"],[{...e,data:"invalid-hex"},"invalid data hex"],[{...e,data:"0x"},"empty data (0x)"],[{...e,selector:"invalid-hex"},"invalid selector hex"],[{...e,selector:"0x"},"empty selector hex"]])("should return false for %s",(t,o)=>{expect(r.canHandle(t,[a.EXTERNAL_PLUGIN,a.TOKEN])).toBe(!1)}),it.each([[{...e,chainId:"1"},"string chainId"],[{...e,chainId:null},"null chainId"],[{...e,chainId:void 0},"undefined chainId"]])("should return false for %s",(t,o)=>{expect(r.canHandle(t,[a.EXTERNAL_PLUGIN,a.TOKEN])).toBe(!1)})}),describe("load function",()=>{it("should return an empty array if no dapp info is provided",async()=>{const e=c(n,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(l(void 0));const t=await r.load(e);expect(t).toEqual([])}),it("should return e plugin if no erc20OfInterest is provided",async()=>{const e=p({abi:n,selectorDetails:{erc20OfInterest:[],method:"singleParam",plugin:"TestPlugin"}}),t=c(n,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(l(e));const o=await r.load(t);expect(d.canHandle).not.toHaveBeenCalled(),expect(o).toEqual([{type:a.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return a list of context responses when one erc20OfInterest is provided for a single parameter",async()=>{const e=p({abi:n,selectorDetails:{erc20OfInterest:["fromToken"],method:"singleParam",plugin:"TestPlugin"}}),t=c(n,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(l(e));const o=await r.load(t);expect(d.canHandle).not.toHaveBeenCalled(),expect(o).toEqual(expect.arrayContaining([{type:a.EXTERNAL_PLUGIN,payload:"1234567890"},{type:a.TOKEN,payload:"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"}]))}),it("should return a context response with only set external plugin when one erc20OfInterest is provided for a single parameter but no payload is feched",async()=>{const e=p({abi:n,selectorDetails:{erc20OfInterest:["fromToken"],method:"singleParam"}}),t=c(n,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(l(e)),vi.spyOn(i,"getTokenInfosPayload").mockResolvedValue(u(Error("error")));const o=await r.load(t);expect(d.canHandle).not.toHaveBeenCalled(),expect(o).toEqual([{type:a.ERROR,error:new Error("error")},{type:a.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return a list of context responses when two erc20OfInterest are provided for two parameters",async()=>{const e=p({abi:n,selectorDetails:{erc20OfInterest:["fromToken","toToken"],method:"multipleParams"}}),t=c(n,"multipleParams",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(l(e));const o=await r.load(t);expect(o).toEqual(expect.arrayContaining([{type:a.EXTERNAL_PLUGIN,payload:"1234567890"},{type:a.TOKEN,payload:"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{type:a.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"}]))}),it("should return a list of context responses when one erc20OfInterest is an array",async()=>{const e=p({abi:n,selectorDetails:{erc20OfInterest:["fromToken.0","fromToken.1","fromToken.2","fromToken.-1"],method:"arrayParam"}}),t=c(n,"arrayParam",[["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7","0xB8c77482e45F1F44dE1745F52C74426C631bDD52"]]);vi.spyOn(s,"getDappInfos").mockResolvedValue(l(e));const o=await r.load(t);expect(o).toEqual([{type:a.TOKEN,payload:"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{type:a.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"},{type:a.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"},{type:a.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"},{type:a.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return an error when a token datasource returns an error",async()=>{const e=p({abi:n,selectorDetails:{erc20OfInterest:["fromToken"],method:"singleParam"}}),t=c(n,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(l(e)),vi.spyOn(i,"getTokenInfosPayload").mockResolvedValue(u(new Error("error")));const o=await r.load(t);expect(o).toEqual([{type:a.ERROR,error:new Error("error")},{type:a.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return an error when the abi is not conform",async()=>{const e=p({abi:[{fakeabi:"notworking"}],selectorDetails:{erc20OfInterest:["fromToken"],method:"singleParam"}}),t=c(n,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(l(e));const o=await r.load(t);expect(o).toEqual([{type:a.ERROR,error:new Error("[ContextModule] ExternalPluginContextLoader: Unable to parse abi")},{type:a.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should throw an error when the erc20OfInterest doest not exist in the transaction",async()=>{const e=p({abi:n,selectorDetails:{erc20OfInterest:["notFound"],method:"singleParam"}}),t=c(n,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(l(e));const o=await r.load(t);expect(o).toEqual([{type:a.ERROR,error:new Error("[ContextModule] ExternalPluginContextLoader: Unable to get address")}])}),it("should throw an error when an out-of-bounds element is present in erc20OfInterest",async()=>{const e=p({abi:n,selectorDetails:{erc20OfInterest:["fromToken.3"],method:"arrayParam"}}),t=c(n,"arrayParam",[["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7","0xB8c77482e45F1F44dE1745F52C74426C631bDD52"]]);vi.spyOn(s,"getDappInfos").mockResolvedValue(l(e));const o=await r.load(t);expect(o).toEqual([{type:a.ERROR,error:new RangeError("out of result range")}])}),it("should return a list of context responses when one erc20OfInterest is a complex struct",async()=>{const e=p({abi:n,selectorDetails:{erc20OfInterest:["complexStruct.address1","complexStruct.param1.param2.0.param3.addresses.0","complexStruct.param1.param2.0.param3.addresses.1","complexStruct.param1.param2.0.param3.addresses.-1","complexStruct.param1.param2.1.param3.addresses.0","complexStruct.param1.param2.-1.param3.addresses.0"],method:"complexStructParam"}}),t=c(n,"complexStructParam",[{address1:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",param1:{param2:[{param3:{addresses:["0xdAC17F958D2ee523a2206206994597C13D831ec7","0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE"]}},{param3:{addresses:["0xB8c77482e45F1F44dE1745F52C74426C631bDD52"]}}]}}]);vi.spyOn(s,"getDappInfos").mockResolvedValue(l(e));const o=await r.load(t);expect(o).toEqual([{type:a.TOKEN,payload:"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{type:a.TOKEN,payload:"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7"},{type:a.TOKEN,payload:"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE"},{type:a.TOKEN,payload:"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE"},{type:a.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"},{type:a.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"},{type:a.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return a plugin with Uniswap not being able to load token",async()=>{const e=p({abi:n,selectorDetails:{erc20OfInterest:[],method:"singleParam",plugin:"Uniswap"}}),t=c(n,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(l(e)),vi.spyOn(d,"canHandle").mockReturnValueOnce(!1);const o=await r.load(t);expect(d.canHandle).toHaveBeenCalled(),expect(d.load).not.toHaveBeenCalled(),expect(o).toEqual([{type:a.EXTERNAL_PLUGIN,payload:"1234567890"}])}),it("should return a plugin with Uniswap extracted tokens",async()=>{const e=p({abi:n,selectorDetails:{erc20OfInterest:[],method:"singleParam",plugin:"Uniswap"}}),t=c(n,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(l(e)),vi.spyOn(d,"canHandle").mockReturnValueOnce(!0),vi.spyOn(d,"load").mockResolvedValue([{type:a.TOKEN,payload:"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE"},{type:a.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"}]);const o=await r.load(t);expect(d.canHandle).toHaveBeenCalled(),expect(d.load).toHaveBeenCalled(),expect(o).toEqual([{type:a.EXTERNAL_PLUGIN,payload:"1234567890"},{type:a.TOKEN,payload:"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE"},{type:a.TOKEN,payload:"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52"}])}),it("should return an error when datasource return a Left",async()=>{const e=c(n,"singleParam",["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"]);vi.spyOn(s,"getDappInfos").mockResolvedValue(u(new Error("error")));const t=await r.load(e);expect(t).toEqual([{type:a.ERROR,error:new Error("error")}])})})});
2
2
  //# sourceMappingURL=ExternalPluginContextLoader.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/external-plugin/domain/ExternalPluginContextLoader.test.ts"],
4
- "sourcesContent": ["import { Interface } from \"ethers\";\nimport { Left, Right } from \"purify-ts\";\n\nimport ABI from \"@/external-plugin/__tests__/abi.json\";\nimport { type ExternalPluginDataSource } from \"@/external-plugin/data/ExternalPluginDataSource\";\nimport {\n type ExternalPluginContextInput,\n ExternalPluginContextLoader,\n} from \"@/external-plugin/domain/ExternalPluginContextLoader\";\nimport { type DappInfos } from \"@/external-plugin/model/DappInfos\";\nimport { type SelectorDetails } from \"@/external-plugin/model/SelectorDetails\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport { type TokenDataSource } from \"@/token/data/TokenDataSource\";\n\nconst dappInfosBuilder = ({\n abi,\n selectorDetails,\n}: {\n abi?: object[];\n selectorDetails?: Partial<SelectorDetails>;\n}) => {\n return {\n abi: abi,\n selectorDetails: {\n erc20OfInterest: [],\n method: \"\",\n plugin: \"\",\n serializedData: \"123456\",\n signature: \"7890\",\n ...selectorDetails,\n },\n } as DappInfos;\n};\n\nconst inputBuilder = (\n abi: object,\n functionName: string,\n params: unknown[],\n): ExternalPluginContextInput => {\n const contract = new Interface(JSON.stringify(abi));\n const data = contract.encodeFunctionData(functionName, params);\n return {\n to: \"0x0\",\n data: data as `0x${string}`,\n selector: data.slice(0, 10) as `0x${string}`,\n chainId: 1,\n };\n};\n\ndescribe(\"ExternalPluginContextLoader\", () => {\n const mockTokenDataSource: TokenDataSource = {\n getTokenInfosPayload: vi.fn(),\n };\n const mockExternalPluginDataSource: ExternalPluginDataSource = {\n getDappInfos: vi.fn(),\n };\n const loader = new ExternalPluginContextLoader(\n mockExternalPluginDataSource,\n mockTokenDataSource,\n );\n\n beforeEach(() => {\n vi.clearAllMocks();\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockImplementation(\n ({ address }) => Promise.resolve(Right(`payload-${address}`)),\n );\n });\n\n describe(\"canHandle function\", () => {\n const validInput: ExternalPluginContextInput = {\n to: \"0x1234567890123456789012345678901234567890\",\n data: \"0x095ea7b30000000000000000000000001234567890123456789012345678901234567890\",\n selector: \"0x095ea7b3\",\n chainId: 1,\n };\n\n it(\"should return true for valid input\", () => {\n expect(\n loader.canHandle(validInput, [\n ClearSignContextType.EXTERNAL_PLUGIN,\n ClearSignContextType.TOKEN,\n ]),\n ).toBe(true);\n });\n\n it(\"should return false for invalid expected type\", () => {\n expect(loader.canHandle(validInput, [ClearSignContextType.NFT])).toBe(\n false,\n );\n expect(loader.canHandle(validInput, [ClearSignContextType.TOKEN])).toBe(\n false,\n );\n expect(\n loader.canHandle(validInput, [ClearSignContextType.EXTERNAL_PLUGIN]),\n ).toBe(false);\n });\n\n it.each([\n [null, \"null input\"],\n [undefined, \"undefined input\"],\n [{}, \"empty object\"],\n [\"string\", \"string input\"],\n [123, \"number input\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(\n loader.canHandle(input, [\n ClearSignContextType.EXTERNAL_PLUGIN,\n ClearSignContextType.TOKEN,\n ]),\n ).toBe(false);\n });\n\n it.each([\n [{ ...validInput, to: undefined }, \"missing to\"],\n [{ ...validInput, data: undefined }, \"missing data\"],\n [{ ...validInput, selector: undefined }, \"missing selector\"],\n [{ ...validInput, chainId: undefined }, \"missing chainId\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(\n loader.canHandle(input, [\n ClearSignContextType.EXTERNAL_PLUGIN,\n ClearSignContextType.TOKEN,\n ]),\n ).toBe(false);\n });\n\n it.each([\n [{ ...validInput, to: \"invalid-hex\" }, \"invalid to hex\"],\n [{ ...validInput, to: \"0x\" }, \"empty to hex\"],\n [{ ...validInput, data: \"invalid-hex\" }, \"invalid data hex\"],\n [{ ...validInput, data: \"0x\" }, \"empty data (0x)\"],\n [{ ...validInput, selector: \"invalid-hex\" }, \"invalid selector hex\"],\n [{ ...validInput, selector: \"0x\" }, \"empty selector hex\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(\n loader.canHandle(input, [\n ClearSignContextType.EXTERNAL_PLUGIN,\n ClearSignContextType.TOKEN,\n ]),\n ).toBe(false);\n });\n\n it.each([\n [{ ...validInput, chainId: \"1\" }, \"string chainId\"],\n [{ ...validInput, chainId: null }, \"null chainId\"],\n [{ ...validInput, chainId: undefined }, \"undefined chainId\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(\n loader.canHandle(input, [\n ClearSignContextType.EXTERNAL_PLUGIN,\n ClearSignContextType.TOKEN,\n ]),\n ).toBe(false);\n });\n });\n\n describe(\"load function\", () => {\n it(\"should return an empty array if no dapp info is provided\", async () => {\n // GIVEN\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(undefined),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return e plugin if no erc20OfInterest is provided\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [],\n method: \"singleParam\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return a list of context responses when one erc20OfInterest is provided for a single parameter\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual(\n expect.arrayContaining([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n ]),\n );\n });\n\n it(\"should return a context response with only set external plugin when one erc20OfInterest is provided for a single parameter but no payload is feched\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return a list of context responses when two erc20OfInterest are provided for two parameters\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\", \"toToken\"],\n method: \"multipleParams\",\n },\n });\n const input = inputBuilder(ABI, \"multipleParams\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual(\n expect.arrayContaining([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n ]),\n );\n });\n\n it(\"should return a list of context responses when one erc20OfInterest is an array\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\n \"fromToken.0\",\n \"fromToken.1\",\n \"fromToken.2\",\n \"fromToken.-1\",\n ],\n method: \"arrayParam\",\n },\n });\n const input = inputBuilder(ABI, \"arrayParam\", [\n [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n \"0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n ],\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n // fromToken.2\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n // fromToken.-1\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return an error when a token datasource returns an error\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(new Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return an error when the abi is not conform\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: [{ fakeabi: \"notworking\" }],\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to parse abi\",\n ),\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should throw an error when the erc20OfInterest doest not exist in the transaction\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"notFound\"],\n method: \"singleParam\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to get address\",\n ),\n },\n ]);\n });\n\n it(\"should throw an error when an out-of-bounds element is present in erc20OfInterest\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken.3\"],\n method: \"arrayParam\",\n },\n });\n const input = inputBuilder(ABI, \"arrayParam\", [\n [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n \"0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n ],\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new RangeError(\"out of result range\"),\n },\n ]);\n });\n\n it(\"should return a list of context responses when one erc20OfInterest is a complex struct\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\n \"complexStruct.address1\",\n \"complexStruct.param1.param2.0.param3.addresses.0\",\n \"complexStruct.param1.param2.0.param3.addresses.1\",\n \"complexStruct.param1.param2.0.param3.addresses.-1\",\n \"complexStruct.param1.param2.1.param3.addresses.0\",\n \"complexStruct.param1.param2.-1.param3.addresses.0\",\n ],\n method: \"complexStructParam\",\n },\n });\n const input = inputBuilder(ABI, \"complexStructParam\", [\n {\n address1: \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n param1: {\n param2: [\n {\n param3: {\n addresses: [\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n \"0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n ],\n },\n },\n {\n param3: {\n addresses: [\"0xB8c77482e45F1F44dE1745F52C74426C631bDD52\"],\n },\n },\n ],\n },\n },\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return an error when datasource return a Left\", async () => {\n // GIVEN\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Left(new Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n ]);\n });\n });\n});\n"],
5
- "mappings": "AAAA,OAAS,aAAAA,MAAiB,SAC1B,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAE5B,OAAOC,MAAS,uCAEhB,OAEE,+BAAAC,MACK,uDAGP,OAAS,wBAAAC,MAA4B,kCAGrC,MAAMC,EAAmB,CAAC,CACxB,IAAAC,EACA,gBAAAC,CACF,KAIS,CACL,IAA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1B,CACF,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["Interface", "Left", "Right", "ABI", "ExternalPluginContextLoader", "ClearSignContextType", "dappInfosBuilder", "abi", "selectorDetails", "inputBuilder", "functionName", "params", "data", "mockTokenDataSource", "mockExternalPluginDataSource", "loader", "address", "validInput", "input", "_description", "result", "dappInfos"]
4
+ "sourcesContent": ["import { Interface } from \"ethers\";\nimport { Left, Right } from \"purify-ts\";\n\nimport ABI from \"@/external-plugin/__tests__/abi.json\";\nimport { type ExternalPluginDataSource } from \"@/external-plugin/data/ExternalPluginDataSource\";\nimport {\n type ExternalPluginContextInput,\n ExternalPluginContextLoader,\n} from \"@/external-plugin/domain/ExternalPluginContextLoader\";\nimport { type DappInfos } from \"@/external-plugin/model/DappInfos\";\nimport { type SelectorDetails } from \"@/external-plugin/model/SelectorDetails\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport { type TokenDataSource } from \"@/token/data/TokenDataSource\";\nimport { type UniswapContextLoader } from \"@/uniswap/domain/UniswapContextLoader\";\n\nconst dappInfosBuilder = ({\n abi,\n selectorDetails,\n}: {\n abi?: object[];\n selectorDetails?: Partial<SelectorDetails>;\n}) => {\n return {\n abi: abi,\n selectorDetails: {\n erc20OfInterest: [],\n method: \"\",\n plugin: \"\",\n serializedData: \"123456\",\n signature: \"7890\",\n ...selectorDetails,\n },\n } as DappInfos;\n};\n\nconst inputBuilder = (\n abi: object,\n functionName: string,\n params: unknown[],\n): ExternalPluginContextInput => {\n const contract = new Interface(JSON.stringify(abi));\n const data = contract.encodeFunctionData(functionName, params);\n return {\n to: \"0x0\",\n data: data as `0x${string}`,\n selector: data.slice(0, 10) as `0x${string}`,\n chainId: 1,\n };\n};\n\ndescribe(\"ExternalPluginContextLoader\", () => {\n const mockTokenDataSource: TokenDataSource = {\n getTokenInfosPayload: vi.fn(),\n };\n const mockExternalPluginDataSource: ExternalPluginDataSource = {\n getDappInfos: vi.fn(),\n };\n const mockUniswapLoader: UniswapContextLoader = {\n canHandle: vi.fn(),\n load: vi.fn(),\n } as unknown as UniswapContextLoader;\n const loader = new ExternalPluginContextLoader(\n mockExternalPluginDataSource,\n mockTokenDataSource,\n mockUniswapLoader,\n );\n\n beforeEach(() => {\n vi.clearAllMocks();\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockImplementation(\n ({ address }) => Promise.resolve(Right(`payload-${address}`)),\n );\n });\n\n describe(\"canHandle function\", () => {\n const validInput: ExternalPluginContextInput = {\n to: \"0x1234567890123456789012345678901234567890\",\n data: \"0x095ea7b30000000000000000000000001234567890123456789012345678901234567890\",\n selector: \"0x095ea7b3\",\n chainId: 1,\n };\n\n it(\"should return true for valid input\", () => {\n expect(\n loader.canHandle(validInput, [\n ClearSignContextType.EXTERNAL_PLUGIN,\n ClearSignContextType.TOKEN,\n ]),\n ).toBe(true);\n });\n\n it(\"should return false for invalid expected type\", () => {\n expect(loader.canHandle(validInput, [ClearSignContextType.NFT])).toBe(\n false,\n );\n expect(loader.canHandle(validInput, [ClearSignContextType.TOKEN])).toBe(\n false,\n );\n expect(\n loader.canHandle(validInput, [ClearSignContextType.EXTERNAL_PLUGIN]),\n ).toBe(false);\n });\n\n it.each([\n [null, \"null input\"],\n [undefined, \"undefined input\"],\n [{}, \"empty object\"],\n [\"string\", \"string input\"],\n [123, \"number input\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(\n loader.canHandle(input, [\n ClearSignContextType.EXTERNAL_PLUGIN,\n ClearSignContextType.TOKEN,\n ]),\n ).toBe(false);\n });\n\n it.each([\n [{ ...validInput, to: undefined }, \"missing to\"],\n [{ ...validInput, data: undefined }, \"missing data\"],\n [{ ...validInput, selector: undefined }, \"missing selector\"],\n [{ ...validInput, chainId: undefined }, \"missing chainId\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(\n loader.canHandle(input, [\n ClearSignContextType.EXTERNAL_PLUGIN,\n ClearSignContextType.TOKEN,\n ]),\n ).toBe(false);\n });\n\n it.each([\n [{ ...validInput, to: \"invalid-hex\" }, \"invalid to hex\"],\n [{ ...validInput, to: \"0x\" }, \"empty to hex\"],\n [{ ...validInput, data: \"invalid-hex\" }, \"invalid data hex\"],\n [{ ...validInput, data: \"0x\" }, \"empty data (0x)\"],\n [{ ...validInput, selector: \"invalid-hex\" }, \"invalid selector hex\"],\n [{ ...validInput, selector: \"0x\" }, \"empty selector hex\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(\n loader.canHandle(input, [\n ClearSignContextType.EXTERNAL_PLUGIN,\n ClearSignContextType.TOKEN,\n ]),\n ).toBe(false);\n });\n\n it.each([\n [{ ...validInput, chainId: \"1\" }, \"string chainId\"],\n [{ ...validInput, chainId: null }, \"null chainId\"],\n [{ ...validInput, chainId: undefined }, \"undefined chainId\"],\n ])(\"should return false for %s\", (input, _description) => {\n expect(\n loader.canHandle(input, [\n ClearSignContextType.EXTERNAL_PLUGIN,\n ClearSignContextType.TOKEN,\n ]),\n ).toBe(false);\n });\n });\n\n describe(\"load function\", () => {\n it(\"should return an empty array if no dapp info is provided\", async () => {\n // GIVEN\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(undefined),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return e plugin if no erc20OfInterest is provided\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [],\n method: \"singleParam\",\n plugin: \"TestPlugin\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(mockUniswapLoader.canHandle).not.toHaveBeenCalled();\n expect(result).toEqual([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return a list of context responses when one erc20OfInterest is provided for a single parameter\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n plugin: \"TestPlugin\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(mockUniswapLoader.canHandle).not.toHaveBeenCalled();\n expect(result).toEqual(\n expect.arrayContaining([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n ]),\n );\n });\n\n it(\"should return a context response with only set external plugin when one erc20OfInterest is provided for a single parameter but no payload is feched\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(mockUniswapLoader.canHandle).not.toHaveBeenCalled();\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return a list of context responses when two erc20OfInterest are provided for two parameters\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\", \"toToken\"],\n method: \"multipleParams\",\n },\n });\n const input = inputBuilder(ABI, \"multipleParams\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual(\n expect.arrayContaining([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n ]),\n );\n });\n\n it(\"should return a list of context responses when one erc20OfInterest is an array\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\n \"fromToken.0\",\n \"fromToken.1\",\n \"fromToken.2\",\n \"fromToken.-1\",\n ],\n method: \"arrayParam\",\n },\n });\n const input = inputBuilder(ABI, \"arrayParam\", [\n [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n \"0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n ],\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n // fromToken.2\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n // fromToken.-1\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return an error when a token datasource returns an error\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n vi.spyOn(mockTokenDataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(new Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return an error when the abi is not conform\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: [{ fakeabi: \"notworking\" }],\n selectorDetails: {\n erc20OfInterest: [\"fromToken\"],\n method: \"singleParam\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to parse abi\",\n ),\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should throw an error when the erc20OfInterest doest not exist in the transaction\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"notFound\"],\n method: \"singleParam\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] ExternalPluginContextLoader: Unable to get address\",\n ),\n },\n ]);\n });\n\n it(\"should throw an error when an out-of-bounds element is present in erc20OfInterest\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\"fromToken.3\"],\n method: \"arrayParam\",\n },\n });\n const input = inputBuilder(ABI, \"arrayParam\", [\n [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n \"0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n ],\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new RangeError(\"out of result range\"),\n },\n ]);\n });\n\n it(\"should return a list of context responses when one erc20OfInterest is a complex struct\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [\n \"complexStruct.address1\",\n \"complexStruct.param1.param2.0.param3.addresses.0\",\n \"complexStruct.param1.param2.0.param3.addresses.1\",\n \"complexStruct.param1.param2.0.param3.addresses.-1\",\n \"complexStruct.param1.param2.1.param3.addresses.0\",\n \"complexStruct.param1.param2.-1.param3.addresses.0\",\n ],\n method: \"complexStructParam\",\n },\n });\n const input = inputBuilder(ABI, \"complexStructParam\", [\n {\n address1: \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n param1: {\n param2: [\n {\n param3: {\n addresses: [\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n \"0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n ],\n },\n },\n {\n param3: {\n addresses: [\"0xB8c77482e45F1F44dE1745F52C74426C631bDD52\"],\n },\n },\n ],\n },\n },\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return a plugin with Uniswap not being able to load token\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [],\n method: \"singleParam\",\n plugin: \"Uniswap\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n vi.spyOn(mockUniswapLoader, \"canHandle\").mockReturnValueOnce(false);\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(mockUniswapLoader.canHandle).toHaveBeenCalled();\n expect(mockUniswapLoader.load).not.toHaveBeenCalled();\n expect(result).toEqual([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n ]);\n });\n\n it(\"should return a plugin with Uniswap extracted tokens\", async () => {\n // GIVEN\n const dappInfos = dappInfosBuilder({\n abi: ABI,\n selectorDetails: {\n erc20OfInterest: [],\n method: \"singleParam\",\n plugin: \"Uniswap\",\n },\n });\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Right(dappInfos),\n );\n vi.spyOn(mockUniswapLoader, \"canHandle\").mockReturnValueOnce(true);\n vi.spyOn(mockUniswapLoader, \"load\").mockResolvedValue([\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n ]);\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(mockUniswapLoader.canHandle).toHaveBeenCalled();\n expect(mockUniswapLoader.load).toHaveBeenCalled();\n expect(result).toEqual([\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-0xB8c77482e45F1F44dE1745F52C74426C631bDD52\",\n },\n ]);\n });\n\n it(\"should return an error when datasource return a Left\", async () => {\n // GIVEN\n const input = inputBuilder(ABI, \"singleParam\", [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n ]);\n vi.spyOn(mockExternalPluginDataSource, \"getDappInfos\").mockResolvedValue(\n Left(new Error(\"error\")),\n );\n\n // WHEN\n const result = await loader.load(input);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n ]);\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,aAAAA,MAAiB,SAC1B,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAE5B,OAAOC,MAAS,uCAEhB,OAEE,+BAAAC,MACK,uDAGP,OAAS,wBAAAC,MAA4B,kCAIrC,MAAMC,EAAmB,CAAC,CACxB,IAAAC,EACA,gBAAAC,CACF,KAIS,CACL,IAAKD,EACL,gBAAiB,CACf,gBAAiB,CAAC,EAClB,OAAQ,GACR,OAAQ,GACR,eAAgB,SAChB,UAAW,OACX,GAAGC,CACL,CACF,GAGIC,EAAe,CACnBF,EACAG,EACAC,IAC+B,CAE/B,MAAMC,EADW,IAAIZ,EAAU,KAAK,UAAUO,CAAG,CAAC,EAC5B,mBAAmBG,EAAcC,CAAM,EAC7D,MAAO,CACL,GAAI,MACJ,KAAMC,EACN,SAAUA,EAAK,MAAM,EAAG,EAAE,EAC1B,QAAS,CACX,CACF,EAEA,SAAS,8BAA+B,IAAM,CAC5C,MAAMC,EAAuC,CAC3C,qBAAsB,GAAG,GAAG,CAC9B,EACMC,EAAyD,CAC7D,aAAc,GAAG,GAAG,CACtB,EACMC,EAA0C,CAC9C,UAAW,GAAG,GAAG,EACjB,KAAM,GAAG,GAAG,CACd,EACMC,EA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wD,SAAY,CAErE,MAAMiB,EAAYhB,EAAiB,CACjC,IAAKH,EACL,gBAAiB,CACf,gBAAiB,CAAC,EAClB,OAAQ,cACR,OAAQ,SACV,CACF,CAAC,EACKgB,EAAQV,EAAaN,EAAK,cAAe,CAC7C,4CACF,CAAC,EACD,GAAG,MAAMW,EAA8B,cAAc,EAAE,kBACrDZ,EAAMoB,CAAS,CACjB,EACA,GAAG,MAAMP,EAAmB,WAAW,EAAE,oBAAoB,EAAI,EACjE,GAAG,MAAMA,EAAmB,MAAM,EAAE,kBAAkB,CACpD,CACE,KAAMV,EAAqB,MAC3B,QAAS,oDACX,EACA,CACE,KAAMA,EAAqB,MAC3B,QAAS,oDACX,CACF,CAAC,EAGD,MAAMgB,EAAS,MAAML,EAAO,KAAKG,CAAK,EAGtC,OAAOJ,EAAkB,SAAS,EAAE,iBAAiB,EACrD,OAAOA,EAAkB,IAAI,EAAE,iBAAiB,EAChD,OAAOM,CAAM,EAAE,QAAQ,CACrB,CACE,KAAMhB,EAAqB,gBAC3B,QAAS,YACX,EACA,CACE,KAAMA,EAAqB,MAC3B,QAAS,oDACX,EACA,CACE,KAAMA,EAAqB,MAC3B,QAAS,oDACX,CACF,CAAC,CACH,CAAC,EAED,GAAG,uDAAwD,SAAY,CAErE,MAAMc,EAAQV,EAAaN,EAAK,cAAe,CAC7C,4CACF,CAAC,EACD,GAAG,MAAMW,EAA8B,cAAc,EAAE,kBACrDb,EAAK,IAAI,MAAM,OAAO,CAAC,CACzB,EAGA,MAAMoB,EAAS,MAAML,EAAO,KAAKG,CAAK,EAGtC,OAAOE,CAAM,EAAE,QAAQ,CACrB,CACE,KAAMhB,EAAqB,MAC3B,MAAO,IAAI,MAAM,OAAO,CAC1B,CACF,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["Interface", "Left", "Right", "ABI", "ExternalPluginContextLoader", "ClearSignContextType", "dappInfosBuilder", "abi", "selectorDetails", "inputBuilder", "functionName", "params", "data", "mockTokenDataSource", "mockExternalPluginDataSource", "mockUniswapLoader", "loader", "address", "validInput", "input", "_description", "result", "dappInfos"]
7
7
  }
@@ -1,2 +1,2 @@
1
- export*from"./calldata/data/CalldataDescriptorDataSource";export*from"./calldata/data/HttpCalldataDescriptorDataSource";export*from"./calldata/domain/CalldataContextLoader";export*from"./config/model/ContextModuleConfig";export*from"./ContextModule";export*from"./ContextModuleBuilder";export*from"./DefaultContextModule";export*from"./dynamic-network/data/DynamicNetworkDataSource";export*from"./dynamic-network/data/HttpDynamicNetworkDataSource";export*from"./dynamic-network/domain/DynamicNetworkContextLoader";export*from"./dynamic-network/model/DynamicNetworkConfiguration";export*from"./external-plugin/data/ExternalPluginDataSource";export*from"./external-plugin/data/HttpExternalPluginDataSource";export*from"./external-plugin/domain/ExternalPluginContextLoader";export*from"./nft/data/HttpNftDataSource";export*from"./nft/data/NftDataSource";export*from"./nft/domain/NftContextFieldLoader";export*from"./nft/domain/NftContextLoader";export*from"./pki/data/HttpPkiCertificateDataSource";export*from"./pki/data/PkiCertificateDataSource";export*from"./pki/domain/DefaultPkiCertificateLoader";export*from"./pki/domain/PkiCertificateLoader";export*from"./pki/model/KeyId";export*from"./pki/model/KeyUsage";export*from"./pki/model/PkiCertificate";export*from"./pki/model/PkiCertificateInfo";export*from"./proxy/data/HttpProxyDataSource";export*from"./proxy/data/HttpSafeProxyDataSource";export*from"./proxy/data/ProxyDataSource";export*from"./proxy/domain/ProxyContextFieldLoader";export*from"./shared/domain/ContextFieldLoader";export*from"./shared/domain/ContextLoader";export*from"./shared/model/ClearSignContext";export*from"./shared/model/GenericPath";export*from"./shared/model/TransactionSubset";export*from"./shared/model/TypedDataClearSignContext";export*from"./shared/model/TypedDataContext";export*from"./solana/data/HttpSolanaOwnerInfoDataSource";export*from"./solana/data/SolanaDataSource";export*from"./solana/domain/DefaultSolanaContextLoader";export*from"./solana/domain/SolanaContextLoader";export*from"./token/data/HttpTokenDataSource";export*from"./token/data/TokenDataSource";export*from"./token/domain/TokenContextFieldLoader";export*from"./token/domain/TokenContextLoader";export*from"./trusted-name/data/HttpTrustedNameDataSource";export*from"./trusted-name/data/TrustedNameDataSource";export*from"./trusted-name/domain/TrustedNameContextFieldLoader";export*from"./trusted-name/domain/TrustedNameContextLoader";export*from"./typed-data/data/HttpTypedDataDataSource";export*from"./typed-data/data/TypedDataDataSource";export*from"./typed-data/domain/DefaultTypedDataContextLoader";export*from"./typed-data/domain/TypedDataContextLoader";export*from"./uniswap/data/AbiDecoderDataSource";export*from"./uniswap/data/CommandDecoderDataSource";export*from"./uniswap/data/DefaultCommandDecoderDataSource";export*from"./uniswap/data/EthersAbiDecoderDataSource";export*from"./uniswap/domain/UniswapContextLoader";export*from"./web3-check/data/HttpWeb3CheckDataSource";export*from"./web3-check/data/Web3CheckDataSource";export*from"./web3-check/domain/DefaultWeb3CheckLoader";export*from"./web3-check/domain/Web3CheckContextLoader";export*from"./web3-check/domain/web3CheckTypes";
1
+ export*from"./calldata/data/CalldataDescriptorDataSource";export*from"./calldata/data/HttpCalldataDescriptorDataSource";export*from"./calldata/domain/CalldataContextLoader";export*from"./config/model/ContextModuleConfig";export*from"./ContextModule";export*from"./ContextModuleBuilder";export*from"./DefaultContextModule";export*from"./dynamic-network/data/DynamicNetworkDataSource";export*from"./dynamic-network/data/HttpDynamicNetworkDataSource";export*from"./dynamic-network/domain/DynamicNetworkContextLoader";export*from"./dynamic-network/model/DynamicNetworkConfiguration";export*from"./external-plugin/data/ExternalPluginDataSource";export*from"./external-plugin/data/HttpExternalPluginDataSource";export*from"./external-plugin/domain/ExternalPluginContextLoader";export*from"./nft/data/HttpNftDataSource";export*from"./nft/data/NftDataSource";export*from"./nft/domain/NftContextFieldLoader";export*from"./nft/domain/NftContextLoader";export*from"./pki/data/HttpPkiCertificateDataSource";export*from"./pki/data/PkiCertificateDataSource";export*from"./pki/domain/DefaultPkiCertificateLoader";export*from"./pki/domain/PkiCertificateLoader";export*from"./pki/model/KeyId";export*from"./pki/model/KeyUsage";export*from"./pki/model/PkiCertificate";export*from"./pki/model/PkiCertificateInfo";export*from"./proxy/data/HttpProxyDataSource";export*from"./proxy/data/HttpSafeProxyDataSource";export*from"./proxy/data/ProxyDataSource";export*from"./proxy/domain/ProxyContextFieldLoader";export*from"./shared/domain/ContextFieldLoader";export*from"./shared/domain/ContextLoader";export*from"./shared/model/ClearSignContext";export*from"./shared/model/GenericPath";export*from"./shared/model/TransactionSubset";export*from"./shared/model/TypedDataClearSignContext";export*from"./shared/model/TypedDataContext";export*from"./solana/data/HttpSolanaOwnerInfoDataSource";export*from"./solana/data/SolanaDataSource";export*from"./solana/domain/DefaultSolanaContextLoader";export*from"./solana/domain/SolanaContextLoader";export*from"./token/data/HttpTokenDataSource";export*from"./token/data/TokenDataSource";export*from"./token/domain/TokenContextFieldLoader";export*from"./token/domain/TokenContextLoader";export*from"./trusted-name/data/HttpTrustedNameDataSource";export*from"./trusted-name/data/TrustedNameDataSource";export*from"./trusted-name/domain/TrustedNameContextFieldLoader";export*from"./trusted-name/domain/TrustedNameContextLoader";export*from"./typed-data/data/HttpTypedDataDataSource";export*from"./typed-data/data/TypedDataDataSource";export*from"./typed-data/domain/DefaultTypedDataContextLoader";export*from"./typed-data/domain/TypedDataContextLoader";export*from"./uniswap/data/AbiDecoderDataSource";export*from"./uniswap/data/CommandDecoderDataSource";export*from"./uniswap/data/DefaultCommandDecoderDataSource";export*from"./uniswap/data/EthersAbiDecoderDataSource";export*from"./uniswap/domain/UniswapContextLoader";
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/index.ts"],
4
- "sourcesContent": ["export * from \"./calldata/data/CalldataDescriptorDataSource\";\nexport * from \"./calldata/data/HttpCalldataDescriptorDataSource\";\nexport * from \"./calldata/domain/CalldataContextLoader\";\nexport * from \"./config/model/ContextModuleConfig\";\nexport * from \"./ContextModule\";\nexport * from \"./ContextModuleBuilder\";\nexport * from \"./DefaultContextModule\";\nexport * from \"./dynamic-network/data/DynamicNetworkDataSource\";\nexport * from \"./dynamic-network/data/HttpDynamicNetworkDataSource\";\nexport * from \"./dynamic-network/domain/DynamicNetworkContextLoader\";\nexport * from \"./dynamic-network/model/DynamicNetworkConfiguration\";\nexport * from \"./external-plugin/data/ExternalPluginDataSource\";\nexport * from \"./external-plugin/data/HttpExternalPluginDataSource\";\nexport * from \"./external-plugin/domain/ExternalPluginContextLoader\";\nexport * from \"./nft/data/HttpNftDataSource\";\nexport * from \"./nft/data/NftDataSource\";\nexport * from \"./nft/domain/NftContextFieldLoader\";\nexport * from \"./nft/domain/NftContextLoader\";\nexport * from \"./pki/data/HttpPkiCertificateDataSource\";\nexport * from \"./pki/data/PkiCertificateDataSource\";\nexport * from \"./pki/domain/DefaultPkiCertificateLoader\";\nexport * from \"./pki/domain/PkiCertificateLoader\";\nexport * from \"./pki/model/KeyId\";\nexport * from \"./pki/model/KeyUsage\";\nexport * from \"./pki/model/PkiCertificate\";\nexport * from \"./pki/model/PkiCertificateInfo\";\nexport * from \"./proxy/data/HttpProxyDataSource\";\nexport * from \"./proxy/data/HttpSafeProxyDataSource\";\nexport * from \"./proxy/data/ProxyDataSource\";\nexport * from \"./proxy/domain/ProxyContextFieldLoader\";\nexport * from \"./shared/domain/ContextFieldLoader\";\nexport * from \"./shared/domain/ContextLoader\";\nexport * from \"./shared/model/ClearSignContext\";\nexport * from \"./shared/model/GenericPath\";\nexport * from \"./shared/model/TransactionSubset\";\nexport * from \"./shared/model/TypedDataClearSignContext\";\nexport * from \"./shared/model/TypedDataContext\";\nexport * from \"./solana/data/HttpSolanaOwnerInfoDataSource\";\nexport * from \"./solana/data/SolanaDataSource\";\nexport * from \"./solana/domain/DefaultSolanaContextLoader\";\nexport * from \"./solana/domain/SolanaContextLoader\";\nexport * from \"./token/data/HttpTokenDataSource\";\nexport * from \"./token/data/TokenDataSource\";\nexport * from \"./token/domain/TokenContextFieldLoader\";\nexport * from \"./token/domain/TokenContextLoader\";\nexport * from \"./trusted-name/data/HttpTrustedNameDataSource\";\nexport * from \"./trusted-name/data/TrustedNameDataSource\";\nexport * from \"./trusted-name/domain/TrustedNameContextFieldLoader\";\nexport * from \"./trusted-name/domain/TrustedNameContextLoader\";\nexport * from \"./typed-data/data/HttpTypedDataDataSource\";\nexport * from \"./typed-data/data/TypedDataDataSource\";\nexport * from \"./typed-data/domain/DefaultTypedDataContextLoader\";\nexport * from \"./typed-data/domain/TypedDataContextLoader\";\nexport * from \"./uniswap/data/AbiDecoderDataSource\";\nexport * from \"./uniswap/data/CommandDecoderDataSource\";\nexport * from \"./uniswap/data/DefaultCommandDecoderDataSource\";\nexport * from \"./uniswap/data/EthersAbiDecoderDataSource\";\nexport * from \"./uniswap/domain/UniswapContextLoader\";\nexport * from \"./web3-check/data/HttpWeb3CheckDataSource\";\nexport * from \"./web3-check/data/Web3CheckDataSource\";\nexport * from \"./web3-check/domain/DefaultWeb3CheckLoader\";\nexport * from \"./web3-check/domain/Web3CheckContextLoader\";\nexport * from \"./web3-check/domain/web3CheckTypes\";\n"],
5
- "mappings": "AAAA,WAAc,+CACd,WAAc,mDACd,WAAc,0CACd,WAAc,qCACd,WAAc,kBACd,WAAc,yBACd,WAAc,yBACd,WAAc,kDACd,WAAc,sDACd,WAAc,uDACd,WAAc,sDACd,WAAc,kDACd,WAAc,sDACd,WAAc,uDACd,WAAc,+BACd,WAAc,2BACd,WAAc,qCACd,WAAc,gCACd,WAAc,0CACd,WAAc,sCACd,WAAc,2CACd,WAAc,oCACd,WAAc,oBACd,WAAc,uBACd,WAAc,6BACd,WAAc,iCACd,WAAc,mCACd,WAAc,uCACd,WAAc,+BACd,WAAc,yCACd,WAAc,qCACd,WAAc,gCACd,WAAc,kCACd,WAAc,6BACd,WAAc,mCACd,WAAc,2CACd,WAAc,kCACd,WAAc,8CACd,WAAc,iCACd,WAAc,6CACd,WAAc,sCACd,WAAc,mCACd,WAAc,+BACd,WAAc,yCACd,WAAc,oCACd,WAAc,gDACd,WAAc,4CACd,WAAc,sDACd,WAAc,iDACd,WAAc,4CACd,WAAc,wCACd,WAAc,oDACd,WAAc,6CACd,WAAc,sCACd,WAAc,0CACd,WAAc,iDACd,WAAc,4CACd,WAAc,wCACd,WAAc,4CACd,WAAc,wCACd,WAAc,6CACd,WAAc,6CACd,WAAc",
4
+ "sourcesContent": ["export * from \"./calldata/data/CalldataDescriptorDataSource\";\nexport * from \"./calldata/data/HttpCalldataDescriptorDataSource\";\nexport * from \"./calldata/domain/CalldataContextLoader\";\nexport * from \"./config/model/ContextModuleConfig\";\nexport * from \"./ContextModule\";\nexport * from \"./ContextModuleBuilder\";\nexport * from \"./DefaultContextModule\";\nexport * from \"./dynamic-network/data/DynamicNetworkDataSource\";\nexport * from \"./dynamic-network/data/HttpDynamicNetworkDataSource\";\nexport * from \"./dynamic-network/domain/DynamicNetworkContextLoader\";\nexport * from \"./dynamic-network/model/DynamicNetworkConfiguration\";\nexport * from \"./external-plugin/data/ExternalPluginDataSource\";\nexport * from \"./external-plugin/data/HttpExternalPluginDataSource\";\nexport * from \"./external-plugin/domain/ExternalPluginContextLoader\";\nexport * from \"./nft/data/HttpNftDataSource\";\nexport * from \"./nft/data/NftDataSource\";\nexport * from \"./nft/domain/NftContextFieldLoader\";\nexport * from \"./nft/domain/NftContextLoader\";\nexport * from \"./pki/data/HttpPkiCertificateDataSource\";\nexport * from \"./pki/data/PkiCertificateDataSource\";\nexport * from \"./pki/domain/DefaultPkiCertificateLoader\";\nexport * from \"./pki/domain/PkiCertificateLoader\";\nexport * from \"./pki/model/KeyId\";\nexport * from \"./pki/model/KeyUsage\";\nexport * from \"./pki/model/PkiCertificate\";\nexport * from \"./pki/model/PkiCertificateInfo\";\nexport * from \"./proxy/data/HttpProxyDataSource\";\nexport * from \"./proxy/data/HttpSafeProxyDataSource\";\nexport * from \"./proxy/data/ProxyDataSource\";\nexport * from \"./proxy/domain/ProxyContextFieldLoader\";\nexport * from \"./shared/domain/ContextFieldLoader\";\nexport * from \"./shared/domain/ContextLoader\";\nexport * from \"./shared/model/ClearSignContext\";\nexport * from \"./shared/model/GenericPath\";\nexport * from \"./shared/model/TransactionSubset\";\nexport * from \"./shared/model/TypedDataClearSignContext\";\nexport * from \"./shared/model/TypedDataContext\";\nexport * from \"./solana/data/HttpSolanaOwnerInfoDataSource\";\nexport * from \"./solana/data/SolanaDataSource\";\nexport * from \"./solana/domain/DefaultSolanaContextLoader\";\nexport * from \"./solana/domain/SolanaContextLoader\";\nexport * from \"./token/data/HttpTokenDataSource\";\nexport * from \"./token/data/TokenDataSource\";\nexport * from \"./token/domain/TokenContextFieldLoader\";\nexport * from \"./token/domain/TokenContextLoader\";\nexport * from \"./trusted-name/data/HttpTrustedNameDataSource\";\nexport * from \"./trusted-name/data/TrustedNameDataSource\";\nexport * from \"./trusted-name/domain/TrustedNameContextFieldLoader\";\nexport * from \"./trusted-name/domain/TrustedNameContextLoader\";\nexport * from \"./typed-data/data/HttpTypedDataDataSource\";\nexport * from \"./typed-data/data/TypedDataDataSource\";\nexport * from \"./typed-data/domain/DefaultTypedDataContextLoader\";\nexport * from \"./typed-data/domain/TypedDataContextLoader\";\nexport * from \"./uniswap/data/AbiDecoderDataSource\";\nexport * from \"./uniswap/data/CommandDecoderDataSource\";\nexport * from \"./uniswap/data/DefaultCommandDecoderDataSource\";\nexport * from \"./uniswap/data/EthersAbiDecoderDataSource\";\nexport * from \"./uniswap/domain/UniswapContextLoader\";\n"],
5
+ "mappings": "AAAA,WAAc,+CACd,WAAc,mDACd,WAAc,0CACd,WAAc,qCACd,WAAc,kBACd,WAAc,yBACd,WAAc,yBACd,WAAc,kDACd,WAAc,sDACd,WAAc,uDACd,WAAc,sDACd,WAAc,kDACd,WAAc,sDACd,WAAc,uDACd,WAAc,+BACd,WAAc,2BACd,WAAc,qCACd,WAAc,gCACd,WAAc,0CACd,WAAc,sCACd,WAAc,2CACd,WAAc,oCACd,WAAc,oBACd,WAAc,uBACd,WAAc,6BACd,WAAc,iCACd,WAAc,mCACd,WAAc,uCACd,WAAc,+BACd,WAAc,yCACd,WAAc,qCACd,WAAc,gCACd,WAAc,kCACd,WAAc,6BACd,WAAc,mCACd,WAAc,2CACd,WAAc,kCACd,WAAc,8CACd,WAAc,iCACd,WAAc,6CACd,WAAc,sCACd,WAAc,mCACd,WAAc,+BACd,WAAc,yCACd,WAAc,oCACd,WAAc,gDACd,WAAc,4CACd,WAAc,sDACd,WAAc,iDACd,WAAc,4CACd,WAAc,wCACd,WAAc,oDACd,WAAc,6CACd,WAAc,sCACd,WAAc,0CACd,WAAc,iDACd,WAAc,4CACd,WAAc",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- var r=(t=>(t.GenuineCheck="genuine_check",t.ExchangePayload="exchange_payload",t.NftMeta="nft_meta",t.TrustedName="trusted_name",t.BackupProvider="backup_provider",t.ProtectOrchestrator="protect_orchestrator",t.PluginMeta="plugin_meta",t.CoinMeta="coin_meta",t.SeedIdAuth="seed_id_auth",t.TxSimulationSigner="tx_simu_signer",t.Calldata="calldata",t.Network="network",t))(r||{});export{r as KeyUsage};
1
+ var r=(t=>(t.GenuineCheck="genuine_check",t.ExchangePayload="exchange_payload",t.NftMeta="nft_meta",t.TrustedName="trusted_name",t.BackupProvider="backup_provider",t.ProtectOrchestrator="protect_orchestrator",t.PluginMeta="plugin_meta",t.CoinMeta="coin_meta",t.SeedIdAuth="seed_id_auth",t.TxSimulationSigner="tx_simu_signer",t.Calldata="calldata",t.Network="network",t.LESMultisig="les_multisig",t))(r||{});export{r as KeyUsage};
2
2
  //# sourceMappingURL=KeyUsage.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/pki/model/KeyUsage.ts"],
4
- "sourcesContent": ["export enum KeyUsage {\n GenuineCheck = \"genuine_check\",\n ExchangePayload = \"exchange_payload\",\n NftMeta = \"nft_meta\",\n TrustedName = \"trusted_name\",\n BackupProvider = \"backup_provider\",\n ProtectOrchestrator = \"protect_orchestrator\",\n PluginMeta = \"plugin_meta\",\n CoinMeta = \"coin_meta\",\n SeedIdAuth = \"seed_id_auth\",\n TxSimulationSigner = \"tx_simu_signer\",\n Calldata = \"calldata\",\n Network = \"network\",\n}\n"],
5
- "mappings": "AAAO,IAAKA,OACVA,EAAA,aAAe,gBACfA,EAAA,gBAAkB,mBAClBA,EAAA,QAAU,WACVA,EAAA,YAAc,eACdA,EAAA,eAAiB,kBACjBA,EAAA,oBAAsB,uBACtBA,EAAA,WAAa,cACbA,EAAA,SAAW,YACXA,EAAA,WAAa,eACbA,EAAA,mBAAqB,iBACrBA,EAAA,SAAW,WACXA,EAAA,QAAU,UAZAA,OAAA",
4
+ "sourcesContent": ["export enum KeyUsage {\n GenuineCheck = \"genuine_check\",\n ExchangePayload = \"exchange_payload\",\n NftMeta = \"nft_meta\",\n TrustedName = \"trusted_name\",\n BackupProvider = \"backup_provider\",\n ProtectOrchestrator = \"protect_orchestrator\",\n PluginMeta = \"plugin_meta\",\n CoinMeta = \"coin_meta\",\n SeedIdAuth = \"seed_id_auth\",\n TxSimulationSigner = \"tx_simu_signer\",\n Calldata = \"calldata\",\n Network = \"network\",\n LESMultisig = \"les_multisig\",\n}\n"],
5
+ "mappings": "AAAO,IAAKA,OACVA,EAAA,aAAe,gBACfA,EAAA,gBAAkB,mBAClBA,EAAA,QAAU,WACVA,EAAA,YAAc,eACdA,EAAA,eAAiB,kBACjBA,EAAA,oBAAsB,uBACtBA,EAAA,WAAa,cACbA,EAAA,SAAW,YACXA,EAAA,WAAa,eACbA,EAAA,mBAAqB,iBACrBA,EAAA,SAAW,WACXA,EAAA,QAAU,UACVA,EAAA,YAAc,eAbJA,OAAA",
6
6
  "names": ["KeyUsage"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ var D=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var p=(s,e,o,r)=>{for(var t=r>1?void 0:r?d(e,o):e,c=s.length-1,n;c>=0;c--)(n=s[c])&&(t=(r?n(e,o,t):n(t))||t);return r&&t&&D(e,o,t),t},f=(s,e)=>(o,r)=>e(o,r,s);import u from"axios";import{inject as g}from"inversify";import{Left as a,Right as m}from"purify-ts";import{configTypes as y}from"../../config/di/configTypes";import{LEDGER_CLIENT_VERSION_HEADER as S,LEDGER_ORIGIN_TOKEN_HEADER as E}from"../../shared/constant/HttpHeaders";import k from"../../../package.json";let i=class{constructor(e){this.config=e}async getDescriptors({safeContractAddress:e,chainId:o,challenge:r}){try{const t=await u.request({method:"GET",url:`${this.config.metadataServiceDomain.url}/v2/ethereum/${o}/safe/account/${e}`,params:{challenge:r},headers:{[S]:`context-module/${k.version}`,[E]:this.config.originToken}});return t.data?this.isSafeAccountDto(t.data)?m({account:{signedDescriptor:t.data.accountDescriptor.signedDescriptor,keyId:t.data.accountDescriptor.keyId,keyUsage:t.data.accountDescriptor.keyUsage},signers:{signedDescriptor:t.data.signersDescriptor.signedDescriptor,keyId:t.data.signersDescriptor.keyId,keyUsage:t.data.signersDescriptor.keyUsage}}):a(new Error("[ContextModule] HttpSafeAccountDataSource: invalid safe account response format")):a(new Error("[ContextModule] HttpSafeAccountDataSource: unexpected empty response"))}catch{return a(new Error("[ContextModule] HttpSafeAccountDataSource: Failed to fetch safe account descriptors"))}}isSafeAccountDto(e){return typeof e=="object"&&e!==null&&"accountDescriptor"in e&&"signersDescriptor"in e&&typeof e.accountDescriptor=="object"&&typeof e.signersDescriptor=="object"&&this.isSafeDescriptorDto(e.accountDescriptor)&&this.isSafeDescriptorDto(e.signersDescriptor)}isSafeDescriptorDto(e){return typeof e=="object"&&e!==null&&"signedDescriptor"in e&&"keyId"in e&&"keyUsage"in e&&typeof e.signedDescriptor=="string"&&typeof e.keyId=="string"&&typeof e.keyUsage=="string"}};i=p([f(0,g(y.Config))],i);export{i as HttpSafeAccountDataSource};
2
+ //# sourceMappingURL=HttpSafeAccountDataSource.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/safe/data/HttpSafeAccountDataSource.ts"],
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { inject } from \"inversify\";\nimport { type 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 PACKAGE from \"@root/package.json\";\n\nimport { SafeAccountDto, SafeDescriptorDto } from \"./dto/SafeAccountDto\";\nimport {\n type GetSafeAccountParams,\n type GetSafeAccountResponse,\n type SafeAccountDataSource,\n} from \"./SafeAccountDataSource\";\n\nexport class HttpSafeAccountDataSource implements SafeAccountDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n async getDescriptors({\n safeContractAddress,\n chainId,\n challenge,\n }: GetSafeAccountParams): Promise<Either<Error, GetSafeAccountResponse>> {\n try {\n const response = await axios.request<SafeAccountDto>({\n method: \"GET\",\n url: `${this.config.metadataServiceDomain.url}/v2/ethereum/${chainId}/safe/account/${safeContractAddress}`,\n params: {\n challenge,\n },\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n });\n\n if (!response.data) {\n return Left(\n new Error(\n \"[ContextModule] HttpSafeAccountDataSource: unexpected empty response\",\n ),\n );\n }\n\n if (!this.isSafeAccountDto(response.data)) {\n return Left(\n new Error(\n \"[ContextModule] HttpSafeAccountDataSource: invalid safe account response format\",\n ),\n );\n }\n\n return Right({\n account: {\n signedDescriptor: response.data.accountDescriptor.signedDescriptor,\n keyId: response.data.accountDescriptor.keyId,\n keyUsage: response.data.accountDescriptor.keyUsage,\n },\n signers: {\n signedDescriptor: response.data.signersDescriptor.signedDescriptor,\n keyId: response.data.signersDescriptor.keyId,\n keyUsage: response.data.signersDescriptor.keyUsage,\n },\n });\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpSafeAccountDataSource: Failed to fetch safe account descriptors\",\n ),\n );\n }\n }\n\n private isSafeAccountDto(value: unknown): value is SafeAccountDto {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"accountDescriptor\" in value &&\n \"signersDescriptor\" in value &&\n typeof value.accountDescriptor === \"object\" &&\n typeof value.signersDescriptor === \"object\" &&\n this.isSafeDescriptorDto(value.accountDescriptor) &&\n this.isSafeDescriptorDto(value.signersDescriptor)\n );\n }\n\n private isSafeDescriptorDto(value: unknown): value is SafeDescriptorDto {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"signedDescriptor\" in value &&\n \"keyId\" in value &&\n \"keyUsage\" in value &&\n typeof value.signedDescriptor === \"string\" &&\n typeof value.keyId === \"string\" &&\n typeof value.keyUsage === \"string\"\n );\n }\n}\n"],
5
+ "mappings": "iOAAA,OAAOA,MAAW,QAClB,OAAS,UAAAC,MAAc,YACvB,OAAsB,QAAAC,EAAM,SAAAC,MAAa,YAEzC,OAAS,eAAAC,MAAmB,0BAE5B,OACE,gCAAAC,EACA,8BAAAC,MACK,gCACP,OAAOC,MAAa,qBASb,IAAMC,EAAN,KAAiE,CACtE,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CAEH,MAAM,eAAe,CACnB,oBAAAC,EACA,QAAAC,EACA,UAAAC,CACF,EAAyE,CACvE,GAAI,CACF,MAAMC,EAAW,MAAMC,EAAM,QAAwB,CACnD,OAAQ,MACR,IAAK,GAAG,KAAK,OAAO,sBAAsB,GAAG,gBAAgBH,CAAO,iBAAiBD,CAAmB,GACxG,OAAQ,CACN,UAAAE,CACF,EACA,QAAS,CACP,CAACG,CAA4B,EAAG,kBAAkBC,EAAQ,OAAO,GACjE,CAACC,CAA0B,EAAG,KAAK,OAAO,WAC5C,CACF,CAAC,EAED,OAAKJ,EAAS,KAQT,KAAK,iBAAiBA,EAAS,IAAI,EAQjCK,EAAM,CACX,QAAS,CACP,iBAAkBL,EAAS,KAAK,kBAAkB,iBAClD,MAAOA,EAAS,KAAK,kBAAkB,MACvC,SAAUA,EAAS,KAAK,kBAAkB,QAC5C,EACA,QAAS,CACP,iBAAkBA,EAAS,KAAK,kBAAkB,iBAClD,MAAOA,EAAS,KAAK,kBAAkB,MACvC,SAAUA,EAAS,KAAK,kBAAkB,QAC5C,CACF,CAAC,EAlBQM,EACL,IAAI,MACF,iFACF,CACF,EAZOA,EACL,IAAI,MACF,sEACF,CACF,CAuBJ,MAAiB,CACf,OAAOA,EACL,IAAI,MACF,qFACF,CACF,CACF,CACF,CAEQ,iBAAiBC,EAAyC,CAChE,OACE,OAAOA,GAAU,UACjBA,IAAU,MACV,sBAAuBA,GACvB,sBAAuBA,GACvB,OAAOA,EAAM,mBAAsB,UACnC,OAAOA,EAAM,mBAAsB,UACnC,KAAK,oBAAoBA,EAAM,iBAAiB,GAChD,KAAK,oBAAoBA,EAAM,iBAAiB,CAEpD,CAEQ,oBAAoBA,EAA4C,CACtE,OACE,OAAOA,GAAU,UACjBA,IAAU,MACV,qBAAsBA,GACtB,UAAWA,GACX,aAAcA,GACd,OAAOA,EAAM,kBAAqB,UAClC,OAAOA,EAAM,OAAU,UACvB,OAAOA,EAAM,UAAa,QAE9B,CACF,EArFaZ,EAANa,EAAA,CAEFC,EAAA,EAAAC,EAAOC,EAAY,MAAM,IAFjBhB",
6
+ "names": ["axios", "inject", "Left", "Right", "configTypes", "LEDGER_CLIENT_VERSION_HEADER", "LEDGER_ORIGIN_TOKEN_HEADER", "PACKAGE", "HttpSafeAccountDataSource", "config", "safeContractAddress", "chainId", "challenge", "response", "axios", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "LEDGER_ORIGIN_TOKEN_HEADER", "Right", "Left", "value", "__decorateClass", "__decorateParam", "inject", "configTypes"]
7
+ }