@ledgerhq/context-module 0.0.0-multisig-20250905101831 → 0.0.0-multisig-20250918154034

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 (282) 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 +3 -3
  6. package/lib/cjs/src/ContextModuleBuilder.test.js +1 -1
  7. package/lib/cjs/src/ContextModuleBuilder.test.js.map +3 -3
  8. package/lib/cjs/src/DefaultContextModule.js +1 -1
  9. package/lib/cjs/src/DefaultContextModule.js.map +3 -3
  10. package/lib/cjs/src/DefaultContextModule.test.js +1 -1
  11. package/lib/cjs/src/DefaultContextModule.test.js.map +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/dynamic-network/domain/DynamicNetworkContextLoader.js +1 -1
  17. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +3 -3
  18. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js +1 -1
  19. package/lib/cjs/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +2 -2
  20. package/lib/cjs/src/index.js +1 -1
  21. package/lib/cjs/src/index.js.map +2 -2
  22. package/lib/cjs/src/nft/domain/NftContextFieldLoader.js +1 -1
  23. package/lib/cjs/src/nft/domain/NftContextFieldLoader.js.map +2 -2
  24. package/lib/cjs/src/nft/domain/NftContextFieldLoader.test.js +2 -0
  25. package/lib/cjs/src/nft/domain/NftContextFieldLoader.test.js.map +7 -0
  26. package/lib/cjs/src/proxy/data/HttpProxyDataSource.js +2 -0
  27. package/lib/cjs/src/proxy/data/HttpProxyDataSource.js.map +7 -0
  28. package/lib/cjs/src/proxy/data/HttpProxyDataSource.test.js +2 -0
  29. package/lib/cjs/src/proxy/data/HttpProxyDataSource.test.js.map +7 -0
  30. package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.js +2 -0
  31. package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.js.map +7 -0
  32. package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.test.js +2 -0
  33. package/lib/cjs/src/proxy/data/HttpSafeProxyDataSource.test.js.map +7 -0
  34. package/lib/cjs/src/proxy/data/ProxyDataSource.js +2 -0
  35. package/lib/cjs/src/proxy/data/ProxyDataSource.js.map +7 -0
  36. package/lib/cjs/src/{transaction → proxy}/data/dto/ProxyDelegateCallDto.js.map +1 -1
  37. package/lib/cjs/src/{transaction → proxy}/data/dto/ProxyImplementationAddressDto.js.map +1 -1
  38. package/lib/cjs/src/proxy/data/dto/SafeProxyImplementationAddressDto.js +2 -0
  39. package/lib/cjs/src/proxy/data/dto/SafeProxyImplementationAddressDto.js.map +7 -0
  40. package/lib/cjs/src/proxy/di/proxyModuleFactory.js +2 -0
  41. package/lib/cjs/src/proxy/di/proxyModuleFactory.js.map +7 -0
  42. package/lib/cjs/src/proxy/di/proxyModuleFactory.test.js +2 -0
  43. package/lib/cjs/src/proxy/di/proxyModuleFactory.test.js.map +7 -0
  44. package/lib/cjs/src/proxy/di/proxyTypes.js +2 -0
  45. package/lib/cjs/src/proxy/di/proxyTypes.js.map +7 -0
  46. package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.js +2 -0
  47. package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.js.map +7 -0
  48. package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.test.js +2 -0
  49. package/lib/cjs/src/proxy/domain/ProxyContextFieldLoader.test.js.map +7 -0
  50. package/lib/cjs/src/proxy/model/ProxyDelegateCall.js +2 -0
  51. package/lib/cjs/src/proxy/model/ProxyDelegateCall.js.map +7 -0
  52. package/lib/cjs/src/shared/domain/ContextFieldLoader.js +1 -1
  53. package/lib/cjs/src/shared/domain/ContextFieldLoader.js.map +2 -2
  54. package/lib/cjs/src/shared/domain/ContextLoader.js +1 -1
  55. package/lib/cjs/src/shared/domain/ContextLoader.js.map +1 -1
  56. package/lib/cjs/src/shared/model/TransactionContext.js +1 -1
  57. package/lib/cjs/src/shared/model/TransactionContext.js.map +1 -1
  58. package/lib/cjs/src/shared/model/TransactionFieldContext.js +2 -0
  59. package/lib/cjs/src/shared/model/TransactionFieldContext.js.map +7 -0
  60. package/lib/cjs/src/shared/model/TransactionSubset.js.map +1 -1
  61. package/lib/cjs/src/shared/model/TypedDataClearSignContext.js +1 -1
  62. package/lib/cjs/src/shared/model/TypedDataClearSignContext.js.map +3 -3
  63. package/lib/cjs/src/shared/model/TypedDataContext.js +1 -1
  64. package/lib/cjs/src/shared/model/TypedDataContext.js.map +1 -1
  65. package/lib/cjs/src/token/domain/TokenContextFieldLoader.js +1 -1
  66. package/lib/cjs/src/token/domain/TokenContextFieldLoader.js.map +3 -3
  67. package/lib/cjs/src/token/domain/TokenContextFieldLoader.test.js +2 -0
  68. package/lib/cjs/src/token/domain/TokenContextFieldLoader.test.js.map +7 -0
  69. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js +1 -1
  70. package/lib/cjs/src/transaction/data/HttpTransactionDataSource.js.map +2 -2
  71. package/lib/cjs/src/transaction/di/transactionModuleFactory.js +1 -1
  72. package/lib/cjs/src/transaction/di/transactionModuleFactory.js.map +3 -3
  73. package/lib/cjs/src/transaction/di/transactionTypes.js +1 -1
  74. package/lib/cjs/src/transaction/di/transactionTypes.js.map +2 -2
  75. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js +1 -1
  76. package/lib/cjs/src/transaction/domain/TransactionContextLoader.js.map +3 -3
  77. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js +1 -1
  78. package/lib/cjs/src/transaction/domain/TransactionContextLoader.test.js.map +3 -3
  79. package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.js +1 -1
  80. package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.js.map +2 -2
  81. package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js +2 -0
  82. package/lib/cjs/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js.map +7 -0
  83. package/lib/cjs/src/typed-data/data/FiltersDto.js +1 -1
  84. package/lib/cjs/src/typed-data/data/FiltersDto.js.map +1 -1
  85. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
  86. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.js.map +3 -3
  87. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  88. package/lib/cjs/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
  89. package/lib/cjs/src/typed-data/data/TypedDataDataSource.js +1 -1
  90. package/lib/cjs/src/typed-data/data/TypedDataDataSource.js.map +1 -1
  91. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js +1 -1
  92. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +3 -3
  93. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
  94. package/lib/cjs/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +3 -3
  95. package/lib/esm/package.json +1 -1
  96. package/lib/esm/src/ContextModuleBuilder.js +1 -1
  97. package/lib/esm/src/ContextModuleBuilder.js.map +3 -3
  98. package/lib/esm/src/ContextModuleBuilder.test.js +1 -1
  99. package/lib/esm/src/ContextModuleBuilder.test.js.map +3 -3
  100. package/lib/esm/src/DefaultContextModule.js +1 -1
  101. package/lib/esm/src/DefaultContextModule.js.map +3 -3
  102. package/lib/esm/src/DefaultContextModule.test.js +1 -1
  103. package/lib/esm/src/DefaultContextModule.test.js.map +3 -3
  104. package/lib/esm/src/di.js +1 -1
  105. package/lib/esm/src/di.js.map +3 -3
  106. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js +1 -1
  107. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.js.map +3 -3
  108. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js +1 -1
  109. package/lib/esm/src/dynamic-network/domain/DynamicNetworkContextLoader.test.js.map +2 -2
  110. package/lib/esm/src/index.js +1 -1
  111. package/lib/esm/src/index.js.map +2 -2
  112. package/lib/esm/src/nft/domain/NftContextFieldLoader.js +1 -1
  113. package/lib/esm/src/nft/domain/NftContextFieldLoader.js.map +3 -3
  114. package/lib/esm/src/nft/domain/NftContextFieldLoader.test.js +2 -0
  115. package/lib/esm/src/nft/domain/NftContextFieldLoader.test.js.map +7 -0
  116. package/lib/esm/src/proxy/data/HttpProxyDataSource.js +2 -0
  117. package/lib/esm/src/proxy/data/HttpProxyDataSource.js.map +7 -0
  118. package/lib/esm/src/proxy/data/HttpProxyDataSource.test.js +2 -0
  119. package/lib/esm/src/proxy/data/HttpProxyDataSource.test.js.map +7 -0
  120. package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.js +2 -0
  121. package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.js.map +7 -0
  122. package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.test.js +2 -0
  123. package/lib/esm/src/proxy/data/HttpSafeProxyDataSource.test.js.map +7 -0
  124. package/lib/esm/src/proxy/data/ProxyDataSource.js +1 -0
  125. package/lib/esm/src/proxy/data/dto/SafeProxyImplementationAddressDto.js +1 -0
  126. package/lib/esm/src/proxy/di/proxyModuleFactory.js +2 -0
  127. package/lib/esm/src/proxy/di/proxyModuleFactory.js.map +7 -0
  128. package/lib/esm/src/proxy/di/proxyModuleFactory.test.js +2 -0
  129. package/lib/esm/src/proxy/di/proxyModuleFactory.test.js.map +7 -0
  130. package/lib/esm/src/proxy/di/proxyTypes.js +2 -0
  131. package/lib/esm/src/proxy/di/proxyTypes.js.map +7 -0
  132. package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.js +2 -0
  133. package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.js.map +7 -0
  134. package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.test.js +2 -0
  135. package/lib/esm/src/proxy/domain/ProxyContextFieldLoader.test.js.map +7 -0
  136. package/lib/esm/src/proxy/model/ProxyDelegateCall.js.map +7 -0
  137. package/lib/esm/src/shared/domain/ContextFieldLoader.js +1 -1
  138. package/lib/esm/src/shared/domain/ContextFieldLoader.js.map +2 -2
  139. package/lib/esm/src/shared/model/TransactionFieldContext.js +1 -0
  140. package/lib/esm/src/shared/model/TransactionFieldContext.js.map +7 -0
  141. package/lib/esm/src/shared/model/TypedDataClearSignContext.js +1 -1
  142. package/lib/esm/src/shared/model/TypedDataClearSignContext.js.map +3 -3
  143. package/lib/esm/src/token/domain/TokenContextFieldLoader.js +1 -1
  144. package/lib/esm/src/token/domain/TokenContextFieldLoader.js.map +3 -3
  145. package/lib/esm/src/token/domain/TokenContextFieldLoader.test.js +2 -0
  146. package/lib/esm/src/token/domain/TokenContextFieldLoader.test.js.map +7 -0
  147. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js +1 -1
  148. package/lib/esm/src/transaction/data/HttpTransactionDataSource.js.map +2 -2
  149. package/lib/esm/src/transaction/di/transactionModuleFactory.js +1 -1
  150. package/lib/esm/src/transaction/di/transactionModuleFactory.js.map +3 -3
  151. package/lib/esm/src/transaction/di/transactionTypes.js +1 -1
  152. package/lib/esm/src/transaction/di/transactionTypes.js.map +2 -2
  153. package/lib/esm/src/transaction/domain/TransactionContextLoader.js +1 -1
  154. package/lib/esm/src/transaction/domain/TransactionContextLoader.js.map +3 -3
  155. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js +1 -1
  156. package/lib/esm/src/transaction/domain/TransactionContextLoader.test.js.map +3 -3
  157. package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.js +1 -1
  158. package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.js.map +3 -3
  159. package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js +2 -0
  160. package/lib/esm/src/trusted-name/domain/TrustedNameContextFieldLoader.test.js.map +7 -0
  161. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js +1 -1
  162. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.js.map +3 -3
  163. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js +1 -1
  164. package/lib/esm/src/typed-data/data/HttpTypedDataDataSource.test.js.map +3 -3
  165. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js +1 -1
  166. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.js.map +3 -3
  167. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js +1 -1
  168. package/lib/esm/src/typed-data/domain/DefaultTypedDataContextLoader.test.js.map +3 -3
  169. package/lib/types/src/ContextModule.d.ts +2 -4
  170. package/lib/types/src/ContextModule.d.ts.map +1 -1
  171. package/lib/types/src/ContextModuleBuilder.d.ts +8 -1
  172. package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -1
  173. package/lib/types/src/DefaultContextModule.d.ts +3 -6
  174. package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
  175. package/lib/types/src/config/model/ContextModuleConfig.d.ts +7 -0
  176. package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -1
  177. package/lib/types/src/di.d.ts.map +1 -1
  178. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts +1 -2
  179. package/lib/types/src/dynamic-network/domain/DynamicNetworkContextLoader.d.ts.map +1 -1
  180. package/lib/types/src/index.d.ts +39 -0
  181. package/lib/types/src/index.d.ts.map +1 -1
  182. package/lib/types/src/nft/domain/NftContextFieldLoader.d.ts +9 -4
  183. package/lib/types/src/nft/domain/NftContextFieldLoader.d.ts.map +1 -1
  184. package/lib/types/src/nft/domain/NftContextFieldLoader.test.d.ts +2 -0
  185. package/lib/types/src/nft/domain/NftContextFieldLoader.test.d.ts.map +1 -0
  186. package/lib/types/src/proxy/data/HttpProxyDataSource.d.ts +13 -0
  187. package/lib/types/src/proxy/data/HttpProxyDataSource.d.ts.map +1 -0
  188. package/lib/types/src/proxy/data/HttpProxyDataSource.test.d.ts.map +1 -0
  189. package/lib/types/src/proxy/data/HttpSafeProxyDataSource.d.ts +13 -0
  190. package/lib/types/src/proxy/data/HttpSafeProxyDataSource.d.ts.map +1 -0
  191. package/lib/types/src/proxy/data/HttpSafeProxyDataSource.test.d.ts +2 -0
  192. package/lib/types/src/proxy/data/HttpSafeProxyDataSource.test.d.ts.map +1 -0
  193. package/lib/types/src/proxy/data/ProxyDataSource.d.ts +15 -0
  194. package/lib/types/src/proxy/data/ProxyDataSource.d.ts.map +1 -0
  195. package/lib/types/src/proxy/data/dto/ProxyDelegateCallDto.d.ts.map +1 -0
  196. package/lib/types/src/proxy/data/dto/ProxyImplementationAddressDto.d.ts.map +1 -0
  197. package/lib/types/src/proxy/data/dto/SafeProxyImplementationAddressDto.d.ts +8 -0
  198. package/lib/types/src/proxy/data/dto/SafeProxyImplementationAddressDto.d.ts.map +1 -0
  199. package/lib/types/src/proxy/di/proxyModuleFactory.d.ts +4 -0
  200. package/lib/types/src/proxy/di/proxyModuleFactory.d.ts.map +1 -0
  201. package/lib/types/src/proxy/di/proxyModuleFactory.test.d.ts +2 -0
  202. package/lib/types/src/proxy/di/proxyModuleFactory.test.d.ts.map +1 -0
  203. package/lib/types/src/proxy/di/proxyTypes.d.ts +5 -0
  204. package/lib/types/src/proxy/di/proxyTypes.d.ts.map +1 -0
  205. package/lib/types/src/proxy/domain/ProxyContextFieldLoader.d.ts +22 -0
  206. package/lib/types/src/proxy/domain/ProxyContextFieldLoader.d.ts.map +1 -0
  207. package/lib/types/src/proxy/domain/ProxyContextFieldLoader.test.d.ts +2 -0
  208. package/lib/types/src/proxy/domain/ProxyContextFieldLoader.test.d.ts.map +1 -0
  209. package/lib/types/src/proxy/model/ProxyDelegateCall.d.ts +5 -0
  210. package/lib/types/src/proxy/model/ProxyDelegateCall.d.ts.map +1 -0
  211. package/lib/types/src/shared/domain/ContextFieldLoader.d.ts +3 -4
  212. package/lib/types/src/shared/domain/ContextFieldLoader.d.ts.map +1 -1
  213. package/lib/types/src/shared/domain/ContextLoader.d.ts +1 -2
  214. package/lib/types/src/shared/domain/ContextLoader.d.ts.map +1 -1
  215. package/lib/types/src/shared/model/TransactionContext.d.ts +0 -17
  216. package/lib/types/src/shared/model/TransactionContext.d.ts.map +1 -1
  217. package/lib/types/src/shared/model/TransactionFieldContext.d.ts +26 -0
  218. package/lib/types/src/shared/model/TransactionFieldContext.d.ts.map +1 -0
  219. package/lib/types/src/shared/model/TypedDataClearSignContext.d.ts +33 -1
  220. package/lib/types/src/shared/model/TypedDataClearSignContext.d.ts.map +1 -1
  221. package/lib/types/src/shared/model/TypedDataContext.d.ts +3 -0
  222. package/lib/types/src/shared/model/TypedDataContext.d.ts.map +1 -1
  223. package/lib/types/src/token/domain/TokenContextFieldLoader.d.ts +8 -4
  224. package/lib/types/src/token/domain/TokenContextFieldLoader.d.ts.map +1 -1
  225. package/lib/types/src/token/domain/TokenContextFieldLoader.test.d.ts +2 -0
  226. package/lib/types/src/token/domain/TokenContextFieldLoader.test.d.ts.map +1 -0
  227. package/lib/types/src/transaction/data/HttpTransactionDataSource.d.ts.map +1 -1
  228. package/lib/types/src/transaction/di/transactionModuleFactory.d.ts.map +1 -1
  229. package/lib/types/src/transaction/di/transactionTypes.d.ts +0 -1
  230. package/lib/types/src/transaction/di/transactionTypes.d.ts.map +1 -1
  231. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts +2 -4
  232. package/lib/types/src/transaction/domain/TransactionContextLoader.d.ts.map +1 -1
  233. package/lib/types/src/trusted-name/domain/TrustedNameContextFieldLoader.d.ts +12 -4
  234. package/lib/types/src/trusted-name/domain/TrustedNameContextFieldLoader.d.ts.map +1 -1
  235. package/lib/types/src/trusted-name/domain/TrustedNameContextFieldLoader.test.d.ts +2 -0
  236. package/lib/types/src/trusted-name/domain/TrustedNameContextFieldLoader.test.d.ts.map +1 -0
  237. package/lib/types/src/typed-data/data/FiltersDto.d.ts +32 -2
  238. package/lib/types/src/typed-data/data/FiltersDto.d.ts.map +1 -1
  239. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts +3 -0
  240. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.d.ts.map +1 -1
  241. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts +1 -0
  242. package/lib/types/src/typed-data/data/HttpTypedDataDataSource.test.d.ts.map +1 -1
  243. package/lib/types/src/typed-data/data/TypedDataDataSource.d.ts +2 -1
  244. package/lib/types/src/typed-data/data/TypedDataDataSource.d.ts.map +1 -1
  245. package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts +12 -1
  246. package/lib/types/src/typed-data/domain/DefaultTypedDataContextLoader.d.ts.map +1 -1
  247. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  248. package/package.json +5 -5
  249. package/lib/cjs/src/transaction/data/HttpProxyDataSource.js +0 -2
  250. package/lib/cjs/src/transaction/data/HttpProxyDataSource.js.map +0 -7
  251. package/lib/cjs/src/transaction/data/HttpProxyDataSource.test.js +0 -2
  252. package/lib/cjs/src/transaction/data/HttpProxyDataSource.test.js.map +0 -7
  253. package/lib/cjs/src/transaction/model/ProxyDelegateCall.js +0 -2
  254. package/lib/cjs/src/transaction/model/ProxyDelegateCall.js.map +0 -7
  255. package/lib/cjs/src/transaction/model/ProxyImplementationAddress.js +0 -2
  256. package/lib/cjs/src/transaction/model/ProxyImplementationAddress.js.map +0 -7
  257. package/lib/esm/src/transaction/data/HttpProxyDataSource.js +0 -2
  258. package/lib/esm/src/transaction/data/HttpProxyDataSource.js.map +0 -7
  259. package/lib/esm/src/transaction/data/HttpProxyDataSource.test.js +0 -2
  260. package/lib/esm/src/transaction/data/HttpProxyDataSource.test.js.map +0 -7
  261. package/lib/esm/src/transaction/model/ProxyImplementationAddress.js +0 -1
  262. package/lib/types/src/transaction/data/HttpProxyDataSource.d.ts +0 -33
  263. package/lib/types/src/transaction/data/HttpProxyDataSource.d.ts.map +0 -1
  264. package/lib/types/src/transaction/data/HttpProxyDataSource.test.d.ts.map +0 -1
  265. package/lib/types/src/transaction/data/dto/ProxyDelegateCallDto.d.ts.map +0 -1
  266. package/lib/types/src/transaction/data/dto/ProxyImplementationAddressDto.d.ts.map +0 -1
  267. package/lib/types/src/transaction/model/ProxyDelegateCall.d.ts +0 -5
  268. package/lib/types/src/transaction/model/ProxyDelegateCall.d.ts.map +0 -1
  269. package/lib/types/src/transaction/model/ProxyImplementationAddress.d.ts +0 -4
  270. package/lib/types/src/transaction/model/ProxyImplementationAddress.d.ts.map +0 -1
  271. /package/lib/cjs/src/{transaction → proxy}/data/dto/ProxyDelegateCallDto.js +0 -0
  272. /package/lib/cjs/src/{transaction → proxy}/data/dto/ProxyImplementationAddressDto.js +0 -0
  273. /package/lib/esm/src/{transaction/data/dto/ProxyDelegateCallDto.js.map → proxy/data/ProxyDataSource.js.map} +0 -0
  274. /package/lib/esm/src/{transaction → proxy}/data/dto/ProxyDelegateCallDto.js +0 -0
  275. /package/lib/esm/src/{transaction/data/dto/ProxyImplementationAddressDto.js.map → proxy/data/dto/ProxyDelegateCallDto.js.map} +0 -0
  276. /package/lib/esm/src/{transaction → proxy}/data/dto/ProxyImplementationAddressDto.js +0 -0
  277. /package/lib/esm/src/{transaction/model/ProxyDelegateCall.js.map → proxy/data/dto/ProxyImplementationAddressDto.js.map} +0 -0
  278. /package/lib/esm/src/{transaction/model/ProxyImplementationAddress.js.map → proxy/data/dto/SafeProxyImplementationAddressDto.js.map} +0 -0
  279. /package/lib/esm/src/{transaction → proxy}/model/ProxyDelegateCall.js +0 -0
  280. /package/lib/types/src/{transaction → proxy}/data/HttpProxyDataSource.test.d.ts +0 -0
  281. /package/lib/types/src/{transaction → proxy}/data/dto/ProxyDelegateCallDto.d.ts +0 -0
  282. /package/lib/types/src/{transaction → proxy}/data/dto/ProxyImplementationAddressDto.d.ts +0 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/transaction/data/HttpTransactionDataSource.ts"],
4
- "sourcesContent": ["import axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport {\n type ContextModuleCalMode,\n type ContextModuleConfig,\n} from \"@/config/model/ContextModuleConfig\";\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport { PkiCertificateInfo } from \"@/pki/model/PkiCertificateInfo\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport {\n ClearSignContextReference,\n ClearSignContextReferenceType,\n ClearSignContextSuccess,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { GenericPath } from \"@/shared/model/GenericPath\";\nimport { INFO_SIGNATURE_TAG } from \"@/shared/model/SignatureTags\";\nimport { HexStringUtils } from \"@/shared/utils/HexStringUtils\";\nimport PACKAGE from \"@root/package.json\";\n\nimport {\n CalldataDescriptor,\n CalldataDescriptorContainerPathV1,\n CalldataDescriptorParam,\n CalldataDescriptorPathElementsV1,\n CalldataDescriptorPathElementV1,\n CalldataDescriptorV1,\n CalldataDescriptorValueBinaryPathV1,\n CalldataDescriptorValueConstantV1,\n CalldataDescriptorValueV1,\n CalldataDto,\n CalldataEnumV1,\n CalldataFieldV1,\n CalldataSignatures,\n CalldataTransactionDescriptor,\n CalldataTransactionInfoV1,\n} from \"./dto/CalldataDto\";\nimport {\n GetTransactionDescriptorsParams,\n TransactionDataSource,\n} from \"./TransactionDataSource\";\n\n@injectable()\nexport class HttpTransactionDataSource implements TransactionDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly _certificateLoader: PkiCertificateLoader,\n ) {}\n\n public async getTransactionDescriptors({\n chainId,\n address,\n selector,\n deviceModelId,\n }: GetTransactionDescriptorsParams): Promise<\n Either<Error, ClearSignContextSuccess[]>\n > {\n let dto: CalldataDto[] | undefined;\n try {\n const response = await axios.request<CalldataDto[]>({\n method: \"GET\",\n url: `${this.config.cal.url}/dapps`,\n params: {\n output: \"descriptors_calldata\",\n chain_id: chainId,\n contracts: address,\n // TODO revert to branch\n ref: `commit:14e65f0b9821ed63c40d5162fabfa818b24d5260`,\n },\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n });\n dto = response.data;\n } catch (error) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Failed to fetch transaction informations: ${error}`,\n ),\n );\n }\n\n if (!Array.isArray(dto)) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Response is not an array`,\n ),\n );\n }\n\n if (dto.length === 0) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: No data for contract ${address} and selector ${selector}`,\n ),\n );\n }\n\n for (const calldata of dto) {\n // Normalize the address and selector\n address = address.toLowerCase();\n selector = `0x${selector.slice(2).toLowerCase()}`;\n const calldataDescriptor =\n calldata.descriptors_calldata?.[address]?.[selector];\n\n if (\n !calldataDescriptor ||\n !this.isCalldataDescriptorV1(calldataDescriptor, this.config.cal.mode)\n ) {\n continue;\n }\n\n const infoData = calldataDescriptor.transaction_info.descriptor.data;\n const infoSignature =\n calldataDescriptor.transaction_info.descriptor.signatures[\n this.config.cal.mode\n ];\n\n const certificateInfos: PkiCertificateInfo = {\n targetDevice: deviceModelId,\n keyUsage: KeyUsage.Calldata,\n keyId: KeyId.CalCalldataKey,\n };\n const certificate: PkiCertificate | undefined =\n await this._certificateLoader.loadCertificate(certificateInfos);\n\n const info: ClearSignContextSuccess = {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: HexStringUtils.appendSignatureToPayload(\n infoData,\n infoSignature,\n INFO_SIGNATURE_TAG,\n ),\n certificate,\n };\n\n const enums: ClearSignContextSuccess[] = [];\n for (const [id, values] of Object.entries(calldataDescriptor.enums)) {\n for (const [\n value,\n { data, signatures },\n ] of Object.entries<CalldataTransactionDescriptor>(values)) {\n enums.push({\n type: ClearSignContextType.ENUM,\n id: Number(id),\n value: Number(value),\n payload: HexStringUtils.appendSignatureToPayload(\n data,\n signatures[this.config.cal.mode]!,\n INFO_SIGNATURE_TAG,\n ),\n certificate,\n });\n }\n }\n\n const fields: ClearSignContextSuccess[] = calldataDescriptor.fields.map(\n (field) => ({\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: field.descriptor,\n reference: this.getReference(field.param),\n }),\n );\n return Right([info, ...enums, ...fields]);\n }\n\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Invalid response for contract ${address} and selector ${selector}`,\n ),\n );\n }\n\n private getReference(\n param: CalldataDescriptorParam,\n ): ClearSignContextReference | undefined {\n if (\n param.type === \"TOKEN_AMOUNT\" &&\n param.token !== undefined &&\n param.token.type === \"path\"\n ) {\n return {\n type: ClearSignContextReferenceType.TOKEN,\n valuePath: this.toGenericPath(param.token.binary_path),\n };\n } else if (\n param.type === \"TOKEN_AMOUNT\" &&\n param.token !== undefined &&\n param.token.type === \"constant\"\n ) {\n return {\n type: ClearSignContextReferenceType.TOKEN,\n value: param.token.value,\n };\n } else if (param.type === \"NFT\" && param.collection.type === \"path\") {\n return {\n type: ClearSignContextReferenceType.NFT,\n valuePath: this.toGenericPath(param.collection.binary_path),\n };\n } else if (param.type === \"NFT\" && param.collection.type === \"constant\") {\n return {\n type: ClearSignContextReferenceType.NFT,\n value: param.collection.value,\n };\n } else if (param.type === \"TRUSTED_NAME\" && param.value.type === \"path\") {\n return {\n type: ClearSignContextReferenceType.TRUSTED_NAME,\n valuePath: this.toGenericPath(param.value.binary_path),\n types: param.types,\n sources: param.sources,\n };\n } else if (param.type === \"ENUM\" && param.value.type === \"path\") {\n return {\n type: ClearSignContextReferenceType.ENUM,\n valuePath: this.toGenericPath(param.value.binary_path),\n id: param.id,\n };\n } else if (\n param.type === \"CALLDATA\" &&\n param.value.type === \"path\" &&\n param.callee.type === \"path\"\n ) {\n return {\n type: ClearSignContextReferenceType.CALLDATA,\n valuePath: this.toGenericPath(param.value.binary_path),\n callee: this.toGenericPath(param.callee.binary_path),\n selector:\n param.selector?.type === \"path\"\n ? this.toGenericPath(param.selector.binary_path)\n : undefined,\n amount:\n param.amount?.type === \"path\"\n ? this.toGenericPath(param.amount.binary_path)\n : undefined,\n spender:\n param.spender?.type === \"path\"\n ? this.toGenericPath(param.spender.binary_path)\n : undefined,\n chainId:\n param.chainId?.type === \"path\"\n ? this.toGenericPath(param.chainId.binary_path)\n : undefined,\n };\n }\n return undefined;\n }\n\n private toGenericPath(\n path: CalldataDescriptorContainerPathV1 | CalldataDescriptorPathElementsV1,\n ): GenericPath {\n if (path.type === \"CONTAINER\") {\n return path.value;\n }\n return path.elements.map((element) => {\n if (element.type === \"ARRAY\") {\n const { weight: itemSize, ...rest } = element;\n return {\n itemSize,\n ...rest,\n };\n } else if (element.type === \"LEAF\") {\n const { leaf_type: leafType, ...rest } = element;\n return {\n leafType,\n ...rest,\n };\n }\n return element;\n });\n }\n\n private isCalldataDescriptorV1(\n data: CalldataDescriptor,\n mode: ContextModuleCalMode,\n ): data is CalldataDescriptorV1 & {\n transaction_info: {\n descriptor: {\n signatures: { [_key in ContextModuleCalMode]: string };\n };\n };\n } {\n return (\n typeof data === \"object\" &&\n data.type === \"calldata\" &&\n data.version === \"v1\" &&\n this.isTransactionInfoV1(data.transaction_info, mode) &&\n this.isEnumV1(data.enums, mode) &&\n Array.isArray(data.fields) &&\n data.fields.every((f) => this.isFieldV1(f))\n );\n }\n\n private isTransactionInfoV1(\n data: CalldataTransactionInfoV1,\n mode: ContextModuleCalMode,\n ): data is CalldataTransactionInfoV1 & {\n descriptor: {\n signatures: { [_key in ContextModuleCalMode]: string };\n };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.descriptor === \"object\" &&\n typeof data.descriptor.data === \"string\" &&\n typeof data.descriptor.signatures === \"object\" &&\n typeof data.descriptor.signatures[mode] === \"string\"\n );\n }\n\n private isEnumV1(\n calldata: CalldataEnumV1,\n mode: ContextModuleCalMode,\n ): calldata is CalldataEnumV1 {\n return (\n typeof calldata === \"object\" &&\n Object.entries(calldata).every(\n ([id, values]) =>\n typeof id === \"string\" &&\n typeof values === \"object\" &&\n Object.entries<CalldataTransactionDescriptor>(values).every(\n ([value, obj]) =>\n typeof value === \"string\" &&\n typeof obj === \"object\" &&\n typeof obj.data === \"string\" &&\n obj.signatures !== undefined &&\n this.isCalldataSignatures(obj.signatures, mode),\n ),\n )\n );\n }\n\n private isCalldataSignatures(\n data: CalldataSignatures,\n mode: ContextModuleCalMode,\n ): data is CalldataSignatures & { [_key in ContextModuleCalMode]: string } {\n return typeof data === \"object\" && typeof data[mode] === \"string\";\n }\n\n private isFieldV1(data: CalldataFieldV1): boolean {\n return (\n typeof data === \"object\" &&\n typeof data.descriptor === \"string\" &&\n typeof data.param === \"object\" &&\n typeof data.param.value === \"object\" &&\n this.isDescriptorValueV1(data.param.value) &&\n (data.param.type === \"RAW\" ||\n data.param.type === \"AMOUNT\" ||\n data.param.type === \"DATETIME\" ||\n data.param.type === \"DURATION\" ||\n data.param.type === \"UNIT\" ||\n data.param.type === \"ENUM\" ||\n (data.param.type === \"NFT\" &&\n this.isDescriptorValueV1(data.param.collection)) ||\n (data.param.type === \"TOKEN_AMOUNT\" &&\n (data.param.token === undefined ||\n this.isDescriptorValueV1(data.param.token))) ||\n (data.param.type === \"TRUSTED_NAME\" &&\n Array.isArray(data.param.types) &&\n Array.isArray(data.param.sources) &&\n data.param.types.every((t) => typeof t === \"string\") &&\n data.param.sources.every((t) => typeof t === \"string\")) ||\n (data.param.type === \"CALLDATA\" &&\n this.isDescriptorValueV1(data.param.value) &&\n this.isDescriptorValueV1(data.param.callee) &&\n (data.param.selector === undefined ||\n this.isDescriptorValueV1(data.param.selector)) &&\n (data.param.amount === undefined ||\n this.isDescriptorValueV1(data.param.amount))))\n );\n }\n\n private isDescriptorValueV1(data: CalldataDescriptorValueV1): boolean {\n return (\n typeof data === \"object\" &&\n typeof data.type_family === \"string\" &&\n [\n \"UINT\",\n \"INT\",\n \"UFIXED\",\n \"FIXED\",\n \"ADDRESS\",\n \"BOOL\",\n \"BYTES\",\n \"STRING\",\n ].includes(data.type_family) &&\n (typeof data.type_size === \"undefined\" ||\n typeof data.type_size === \"number\") &&\n ((data.type === \"path\" &&\n this.isCalldataDescriptorValueBinaryPathV1(data)) ||\n (data.type === \"constant\" &&\n this.isCalldataDescriptorValueConstantV1(data)))\n );\n }\n\n private isCalldataDescriptorValueConstantV1(\n data: CalldataDescriptorValueConstantV1,\n ): boolean {\n return (\n typeof data === \"object\" &&\n data.type === \"constant\" &&\n typeof data.value === \"string\"\n );\n }\n\n private isCalldataDescriptorValueBinaryPathV1(\n data: CalldataDescriptorValueBinaryPathV1,\n ): boolean {\n return (\n typeof data === \"object\" &&\n ((data.type === \"path\" &&\n data.binary_path.type === \"CONTAINER\" &&\n [\"FROM\", \"TO\", \"VALUE\"].includes(data.binary_path.value)) ||\n (data.binary_path.type === \"DATA\" &&\n Array.isArray(data.binary_path.elements) &&\n data.binary_path.elements.every((e) => this.isPathElementV1(e))))\n );\n }\n\n private isPathElementV1(data: CalldataDescriptorPathElementV1): boolean {\n return (\n typeof data === \"object\" &&\n (data.type === \"REF\" ||\n (data.type === \"TUPLE\" && typeof data.offset === \"number\") ||\n (data.type === \"ARRAY\" &&\n typeof data.weight === \"number\" &&\n (typeof data.start === \"undefined\" ||\n typeof data.start === \"number\") &&\n (typeof data.end === \"undefined\" || typeof data.end === \"number\")) ||\n (data.type === \"LEAF\" &&\n typeof data.leaf_type === \"string\" &&\n [\"ARRAY_LEAF\", \"TUPLE_LEAF\", \"STATIC_LEAF\", \"DYNAMIC_LEAF\"].includes(\n data.leaf_type,\n )) ||\n (data.type === \"SLICE\" &&\n (typeof data.start === \"undefined\" ||\n typeof data.start === \"number\") &&\n (typeof data.end === \"undefined\" || typeof data.end === \"number\")))\n );\n }\n}\n"],
5
- "mappings": "iOAAA,OAAOA,MAAW,QAClB,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAK5B,OAAS,YAAAC,MAAgB,oBAEzB,OAAS,SAAAC,MAAa,oBACtB,OAAS,YAAAC,MAAgB,uBAGzB,OACE,gCAAAC,EACA,8BAAAC,MACK,gCACP,OAEE,iCAAAC,EAEA,wBAAAC,MACK,kCAEP,OAAS,sBAAAC,MAA0B,+BACnC,OAAS,kBAAAC,MAAsB,gCAC/B,OAAOC,MAAa,qBAyBb,IAAMC,EAAN,KAAiE,CACtE,YAC+CC,EAE5BC,EACjB,CAH6C,YAAAD,EAE5B,wBAAAC,CAChB,CAEH,MAAa,0BAA0B,CACrC,QAAAC,EACA,QAAAC,EACA,SAAAC,EACA,cAAAC,CACF,EAEE,CACA,IAAIC,EACJ,GAAI,CAgBFA,GAfiB,MAAMC,EAAM,QAAuB,CAClD,OAAQ,MACR,IAAK,GAAG,KAAK,OAAO,IAAI,GAAG,SAC3B,OAAQ,CACN,OAAQ,uBACR,SAAUL,EACV,UAAWC,EAEX,IAAK,iDACP,EACA,QAAS,CACP,CAACK,CAA4B,EAAG,kBAAkBC,EAAQ,OAAO,GACjE,CAACC,CAA0B,EAAG,KAAK,OAAO,WAC5C,CACF,CAAC,GACc,IACjB,OAASC,EAAO,CACd,OAAO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vB,OAAOA,EAAK,IAAQ,KAAe,OAAOA,EAAK,KAAQ,UAEhE,CACF,EA9Ya9B,EAAN8C,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,GACzBF,EAAA,EAAAC,EAAOE,EAAS,oBAAoB,IAH5BnD",
4
+ "sourcesContent": ["import axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport {\n type ContextModuleCalMode,\n type ContextModuleConfig,\n} from \"@/config/model/ContextModuleConfig\";\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport { PkiCertificateInfo } from \"@/pki/model/PkiCertificateInfo\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport {\n ClearSignContextReference,\n ClearSignContextReferenceType,\n ClearSignContextSuccess,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { GenericPath } from \"@/shared/model/GenericPath\";\nimport { INFO_SIGNATURE_TAG } from \"@/shared/model/SignatureTags\";\nimport { HexStringUtils } from \"@/shared/utils/HexStringUtils\";\nimport PACKAGE from \"@root/package.json\";\n\nimport {\n CalldataDescriptor,\n CalldataDescriptorContainerPathV1,\n CalldataDescriptorParam,\n CalldataDescriptorPathElementsV1,\n CalldataDescriptorPathElementV1,\n CalldataDescriptorV1,\n CalldataDescriptorValueBinaryPathV1,\n CalldataDescriptorValueConstantV1,\n CalldataDescriptorValueV1,\n CalldataDto,\n CalldataEnumV1,\n CalldataFieldV1,\n CalldataSignatures,\n CalldataTransactionDescriptor,\n CalldataTransactionInfoV1,\n} from \"./dto/CalldataDto\";\nimport {\n GetTransactionDescriptorsParams,\n TransactionDataSource,\n} from \"./TransactionDataSource\";\n\n@injectable()\nexport class HttpTransactionDataSource implements TransactionDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n @inject(pkiTypes.PkiCertificateLoader)\n private readonly _certificateLoader: PkiCertificateLoader,\n ) {}\n\n public async getTransactionDescriptors({\n chainId,\n address,\n selector,\n deviceModelId,\n }: GetTransactionDescriptorsParams): Promise<\n Either<Error, ClearSignContextSuccess[]>\n > {\n let dto: CalldataDto[] | undefined;\n try {\n const response = await axios.request<CalldataDto[]>({\n method: \"GET\",\n url: `${this.config.cal.url}/dapps`,\n params: {\n output: \"descriptors_calldata\",\n chain_id: chainId,\n contracts: address,\n // TODO revert to branch\n ref: `commit:cdd7d0f9cec33eb969a12641810cc7b06efeec1c`,\n },\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n });\n dto = response.data;\n } catch (error) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Failed to fetch transaction informations: ${error}`,\n ),\n );\n }\n\n if (!Array.isArray(dto)) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Response is not an array`,\n ),\n );\n }\n\n if (dto.length === 0) {\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: No data for contract ${address} and selector ${selector}`,\n ),\n );\n }\n\n for (const calldata of dto) {\n // Normalize the address and selector\n address = address.toLowerCase();\n selector = `0x${selector.slice(2).toLowerCase()}`;\n const calldataDescriptor =\n calldata.descriptors_calldata?.[address]?.[selector];\n\n if (\n !calldataDescriptor ||\n !this.isCalldataDescriptorV1(calldataDescriptor, this.config.cal.mode)\n ) {\n continue;\n }\n\n const infoData = calldataDescriptor.transaction_info.descriptor.data;\n const infoSignature =\n calldataDescriptor.transaction_info.descriptor.signatures[\n this.config.cal.mode\n ];\n\n const certificateInfos: PkiCertificateInfo = {\n targetDevice: deviceModelId,\n keyUsage: KeyUsage.Calldata,\n keyId: KeyId.CalCalldataKey,\n };\n const certificate: PkiCertificate | undefined =\n await this._certificateLoader.loadCertificate(certificateInfos);\n\n const info: ClearSignContextSuccess = {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: HexStringUtils.appendSignatureToPayload(\n infoData,\n infoSignature,\n INFO_SIGNATURE_TAG,\n ),\n certificate,\n };\n\n const enums: ClearSignContextSuccess[] = [];\n for (const [id, values] of Object.entries(calldataDescriptor.enums)) {\n for (const [\n value,\n { data, signatures },\n ] of Object.entries<CalldataTransactionDescriptor>(values)) {\n enums.push({\n type: ClearSignContextType.ENUM,\n id: Number(id),\n value: Number(value),\n payload: HexStringUtils.appendSignatureToPayload(\n data,\n signatures[this.config.cal.mode]!,\n INFO_SIGNATURE_TAG,\n ),\n certificate,\n });\n }\n }\n\n const fields: ClearSignContextSuccess[] = calldataDescriptor.fields.map(\n (field) => ({\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: field.descriptor,\n reference: this.getReference(field.param),\n }),\n );\n return Right([info, ...enums, ...fields]);\n }\n\n return Left(\n new Error(\n `[ContextModule] HttpTransactionDataSource: Invalid response for contract ${address} and selector ${selector}`,\n ),\n );\n }\n\n private getReference(\n param: CalldataDescriptorParam,\n ): ClearSignContextReference | undefined {\n if (\n param.type === \"TOKEN_AMOUNT\" &&\n param.token !== undefined &&\n param.token.type === \"path\"\n ) {\n return {\n type: ClearSignContextReferenceType.TOKEN,\n valuePath: this.toGenericPath(param.token.binary_path),\n };\n } else if (\n param.type === \"TOKEN_AMOUNT\" &&\n param.token !== undefined &&\n param.token.type === \"constant\"\n ) {\n return {\n type: ClearSignContextReferenceType.TOKEN,\n value: param.token.value,\n };\n } else if (param.type === \"NFT\" && param.collection.type === \"path\") {\n return {\n type: ClearSignContextReferenceType.NFT,\n valuePath: this.toGenericPath(param.collection.binary_path),\n };\n } else if (param.type === \"NFT\" && param.collection.type === \"constant\") {\n return {\n type: ClearSignContextReferenceType.NFT,\n value: param.collection.value,\n };\n } else if (param.type === \"TRUSTED_NAME\" && param.value.type === \"path\") {\n return {\n type: ClearSignContextReferenceType.TRUSTED_NAME,\n valuePath: this.toGenericPath(param.value.binary_path),\n types: param.types,\n sources: param.sources,\n };\n } else if (param.type === \"ENUM\" && param.value.type === \"path\") {\n return {\n type: ClearSignContextReferenceType.ENUM,\n valuePath: this.toGenericPath(param.value.binary_path),\n id: param.id,\n };\n } else if (\n param.type === \"CALLDATA\" &&\n param.value.type === \"path\" &&\n param.callee.type === \"path\"\n ) {\n return {\n type: ClearSignContextReferenceType.CALLDATA,\n valuePath: this.toGenericPath(param.value.binary_path),\n callee: this.toGenericPath(param.callee.binary_path),\n selector:\n param.selector?.type === \"path\"\n ? this.toGenericPath(param.selector.binary_path)\n : undefined,\n amount:\n param.amount?.type === \"path\"\n ? this.toGenericPath(param.amount.binary_path)\n : undefined,\n spender:\n param.spender?.type === \"path\"\n ? this.toGenericPath(param.spender.binary_path)\n : undefined,\n chainId:\n param.chainId?.type === \"path\"\n ? this.toGenericPath(param.chainId.binary_path)\n : undefined,\n };\n }\n return undefined;\n }\n\n private toGenericPath(\n path: CalldataDescriptorContainerPathV1 | CalldataDescriptorPathElementsV1,\n ): GenericPath {\n if (path.type === \"CONTAINER\") {\n return path.value;\n }\n return path.elements.map((element) => {\n if (element.type === \"ARRAY\") {\n const { weight: itemSize, ...rest } = element;\n return {\n itemSize,\n ...rest,\n };\n } else if (element.type === \"LEAF\") {\n const { leaf_type: leafType, ...rest } = element;\n return {\n leafType,\n ...rest,\n };\n }\n return element;\n });\n }\n\n private isCalldataDescriptorV1(\n data: CalldataDescriptor,\n mode: ContextModuleCalMode,\n ): data is CalldataDescriptorV1 & {\n transaction_info: {\n descriptor: {\n signatures: { [_key in ContextModuleCalMode]: string };\n };\n };\n } {\n return (\n typeof data === \"object\" &&\n data.type === \"calldata\" &&\n data.version === \"v1\" &&\n this.isTransactionInfoV1(data.transaction_info, mode) &&\n this.isEnumV1(data.enums, mode) &&\n Array.isArray(data.fields) &&\n data.fields.every((f) => this.isFieldV1(f))\n );\n }\n\n private isTransactionInfoV1(\n data: CalldataTransactionInfoV1,\n mode: ContextModuleCalMode,\n ): data is CalldataTransactionInfoV1 & {\n descriptor: {\n signatures: { [_key in ContextModuleCalMode]: string };\n };\n } {\n return (\n typeof data === \"object\" &&\n typeof data.descriptor === \"object\" &&\n typeof data.descriptor.data === \"string\" &&\n typeof data.descriptor.signatures === \"object\" &&\n typeof data.descriptor.signatures[mode] === \"string\"\n );\n }\n\n private isEnumV1(\n calldata: CalldataEnumV1,\n mode: ContextModuleCalMode,\n ): calldata is CalldataEnumV1 {\n return (\n typeof calldata === \"object\" &&\n Object.entries(calldata).every(\n ([id, values]) =>\n typeof id === \"string\" &&\n typeof values === \"object\" &&\n Object.entries<CalldataTransactionDescriptor>(values).every(\n ([value, obj]) =>\n typeof value === \"string\" &&\n typeof obj === \"object\" &&\n typeof obj.data === \"string\" &&\n obj.signatures !== undefined &&\n this.isCalldataSignatures(obj.signatures, mode),\n ),\n )\n );\n }\n\n private isCalldataSignatures(\n data: CalldataSignatures,\n mode: ContextModuleCalMode,\n ): data is CalldataSignatures & { [_key in ContextModuleCalMode]: string } {\n return typeof data === \"object\" && typeof data[mode] === \"string\";\n }\n\n private isFieldV1(data: CalldataFieldV1): boolean {\n return (\n typeof data === \"object\" &&\n typeof data.descriptor === \"string\" &&\n typeof data.param === \"object\" &&\n typeof data.param.value === \"object\" &&\n this.isDescriptorValueV1(data.param.value) &&\n (data.param.type === \"RAW\" ||\n data.param.type === \"AMOUNT\" ||\n data.param.type === \"DATETIME\" ||\n data.param.type === \"DURATION\" ||\n data.param.type === \"UNIT\" ||\n data.param.type === \"ENUM\" ||\n (data.param.type === \"NFT\" &&\n this.isDescriptorValueV1(data.param.collection)) ||\n (data.param.type === \"TOKEN_AMOUNT\" &&\n (data.param.token === undefined ||\n this.isDescriptorValueV1(data.param.token))) ||\n (data.param.type === \"TRUSTED_NAME\" &&\n Array.isArray(data.param.types) &&\n Array.isArray(data.param.sources) &&\n data.param.types.every((t) => typeof t === \"string\") &&\n data.param.sources.every((t) => typeof t === \"string\")) ||\n (data.param.type === \"CALLDATA\" &&\n this.isDescriptorValueV1(data.param.value) &&\n this.isDescriptorValueV1(data.param.callee) &&\n (data.param.selector === undefined ||\n this.isDescriptorValueV1(data.param.selector)) &&\n (data.param.amount === undefined ||\n this.isDescriptorValueV1(data.param.amount)) &&\n (data.param.spender === undefined ||\n this.isDescriptorValueV1(data.param.spender)) &&\n (data.param.chainId === undefined ||\n this.isDescriptorValueV1(data.param.chainId))))\n );\n }\n\n private isDescriptorValueV1(data: CalldataDescriptorValueV1): boolean {\n return (\n typeof data === \"object\" &&\n typeof data.type_family === \"string\" &&\n [\n \"UINT\",\n \"INT\",\n \"UFIXED\",\n \"FIXED\",\n \"ADDRESS\",\n \"BOOL\",\n \"BYTES\",\n \"STRING\",\n ].includes(data.type_family) &&\n (typeof data.type_size === \"undefined\" ||\n typeof data.type_size === \"number\") &&\n ((data.type === \"path\" &&\n this.isCalldataDescriptorValueBinaryPathV1(data)) ||\n (data.type === \"constant\" &&\n this.isCalldataDescriptorValueConstantV1(data)))\n );\n }\n\n private isCalldataDescriptorValueConstantV1(\n data: CalldataDescriptorValueConstantV1,\n ): boolean {\n return (\n typeof data === \"object\" &&\n data.type === \"constant\" &&\n typeof data.value === \"string\"\n );\n }\n\n private isCalldataDescriptorValueBinaryPathV1(\n data: CalldataDescriptorValueBinaryPathV1,\n ): boolean {\n return (\n typeof data === \"object\" &&\n ((data.type === \"path\" &&\n data.binary_path.type === \"CONTAINER\" &&\n [\"FROM\", \"TO\", \"VALUE\"].includes(data.binary_path.value)) ||\n (data.binary_path.type === \"DATA\" &&\n Array.isArray(data.binary_path.elements) &&\n data.binary_path.elements.every((e) => this.isPathElementV1(e))))\n );\n }\n\n private isPathElementV1(data: CalldataDescriptorPathElementV1): boolean {\n return (\n typeof data === \"object\" &&\n (data.type === \"REF\" ||\n (data.type === \"TUPLE\" && typeof data.offset === \"number\") ||\n (data.type === \"ARRAY\" &&\n typeof data.weight === \"number\" &&\n (typeof data.start === \"undefined\" ||\n typeof data.start === \"number\") &&\n (typeof data.end === \"undefined\" || typeof data.end === \"number\")) ||\n (data.type === \"LEAF\" &&\n typeof data.leaf_type === \"string\" &&\n [\"ARRAY_LEAF\", \"TUPLE_LEAF\", \"STATIC_LEAF\", \"DYNAMIC_LEAF\"].includes(\n data.leaf_type,\n )) ||\n (data.type === \"SLICE\" &&\n (typeof data.start === \"undefined\" ||\n typeof data.start === \"number\") &&\n (typeof data.end === \"undefined\" || typeof data.end === \"number\")))\n );\n }\n}\n"],
5
+ "mappings": "iOAAA,OAAOA,MAAW,QAClB,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAK5B,OAAS,YAAAC,MAAgB,oBAEzB,OAAS,SAAAC,MAAa,oBACtB,OAAS,YAAAC,MAAgB,uBAGzB,OACE,gCAAAC,EACA,8BAAAC,MACK,gCACP,OAEE,iCAAAC,EAEA,wBAAAC,MACK,kCAEP,OAAS,sBAAAC,MAA0B,+BACnC,OAAS,kBAAAC,MAAsB,gCAC/B,OAAOC,MAAa,qBAyBb,IAAMC,EAAN,KAAiE,CACtE,YAC+CC,EAE5BC,EACjB,CAH6C,YAAAD,EAE5B,wBAAAC,CAChB,CAEH,MAAa,0BAA0B,CACrC,QAAAC,EACA,QAAAC,EACA,SAAAC,EACA,cAAAC,CACF,EAEE,CACA,IAAIC,EACJ,GAAI,CAgBFA,GAfiB,MAAMC,EAAM,QAAuB,CAClD,OAAQ,MACR,IAAK,GAAG,KAAK,OAAO,IAAI,GAAG,SAC3B,OAAQ,CACN,OAAQ,uBACR,SAAUL,EACV,UAAWC,EAEX,IAAK,iDACP,EACA,QAAS,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AAK,MAAU,KACrB,OAAOA,EAAK,OAAU,YACvB,OAAOA,EAAK,IAAQ,KAAe,OAAOA,EAAK,KAAQ,WACzDA,EAAK,OAAS,QACb,OAAOA,EAAK,WAAc,UAC1B,CAAC,aAAc,aAAc,cAAe,cAAc,EAAE,SAC1DA,EAAK,SACP,GACDA,EAAK,OAAS,UACZ,OAAOA,EAAK,MAAU,KACrB,OAAOA,EAAK,OAAU,YACvB,OAAOA,EAAK,IAAQ,KAAe,OAAOA,EAAK,KAAQ,UAEhE,CACF,EAlZa9B,EAAN8C,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,GACzBF,EAAA,EAAAC,EAAOE,EAAS,oBAAoB,IAH5BnD",
6
6
  "names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "pkiTypes", "KeyId", "KeyUsage", "LEDGER_CLIENT_VERSION_HEADER", "LEDGER_ORIGIN_TOKEN_HEADER", "ClearSignContextReferenceType", "ClearSignContextType", "INFO_SIGNATURE_TAG", "HexStringUtils", "PACKAGE", "HttpTransactionDataSource", "config", "_certificateLoader", "chainId", "address", "selector", "deviceModelId", "dto", "axios", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "LEDGER_ORIGIN_TOKEN_HEADER", "error", "Left", "calldata", "calldataDescriptor", "infoData", "infoSignature", "certificateInfos", "KeyUsage", "KeyId", "certificate", "info", "ClearSignContextType", "HexStringUtils", "INFO_SIGNATURE_TAG", "enums", "id", "values", "value", "data", "signatures", "fields", "field", "Right", "param", "ClearSignContextReferenceType", "path", "element", "itemSize", "rest", "leafType", "mode", "f", "obj", "e", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes", "pkiTypes"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ContainerModule as r}from"inversify";import{HttpProxyDataSource as a}from"../../transaction/data/HttpProxyDataSource";import{HttpTransactionDataSource as n}from"../../transaction/data/HttpTransactionDataSource";import{transactionTypes as t}from"../../transaction/di/transactionTypes";import{TransactionContextLoader as e}from"../../transaction/domain/TransactionContextLoader";const u=()=>new r(({bind:o})=>{o(t.TransactionDataSource).to(n),o(t.TransactionContextLoader).to(e),o(t.ProxyDataSource).to(a)});export{u as transactionModuleFactory};
1
+ import{ContainerModule as r}from"inversify";import{HttpTransactionDataSource as a}from"../../transaction/data/HttpTransactionDataSource";import{transactionTypes as t}from"../../transaction/di/transactionTypes";import{TransactionContextLoader as n}from"../../transaction/domain/TransactionContextLoader";const s=()=>new r(({bind:o})=>{o(t.TransactionDataSource).to(a),o(t.TransactionContextLoader).to(n)});export{s as transactionModuleFactory};
2
2
  //# sourceMappingURL=transactionModuleFactory.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/transaction/di/transactionModuleFactory.ts"],
4
- "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpProxyDataSource } from \"@/transaction/data/HttpProxyDataSource\";\nimport { HttpTransactionDataSource } from \"@/transaction/data/HttpTransactionDataSource\";\nimport { transactionTypes } from \"@/transaction/di/transactionTypes\";\nimport { TransactionContextLoader } from \"@/transaction/domain/TransactionContextLoader\";\n\nexport const transactionModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(transactionTypes.TransactionDataSource).to(HttpTransactionDataSource);\n bind(transactionTypes.TransactionContextLoader).to(\n TransactionContextLoader,\n );\n bind(transactionTypes.ProxyDataSource).to(HttpProxyDataSource);\n });\n"],
5
- "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,uBAAAC,MAA2B,yCACpC,OAAS,6BAAAC,MAAiC,+CAC1C,OAAS,oBAAAC,MAAwB,oCACjC,OAAS,4BAAAC,MAAgC,gDAElC,MAAMC,EAA2B,IACtC,IAAIL,EAAgB,CAAC,CAAE,KAAAM,CAAK,IAAM,CAChCA,EAAKH,EAAiB,qBAAqB,EAAE,GAAGD,CAAyB,EACzEI,EAAKH,EAAiB,wBAAwB,EAAE,GAC9CC,CACF,EACAE,EAAKH,EAAiB,eAAe,EAAE,GAAGF,CAAmB,CAC/D,CAAC",
6
- "names": ["ContainerModule", "HttpProxyDataSource", "HttpTransactionDataSource", "transactionTypes", "TransactionContextLoader", "transactionModuleFactory", "bind"]
4
+ "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpTransactionDataSource } from \"@/transaction/data/HttpTransactionDataSource\";\nimport { transactionTypes } from \"@/transaction/di/transactionTypes\";\nimport { TransactionContextLoader } from \"@/transaction/domain/TransactionContextLoader\";\n\nexport const transactionModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(transactionTypes.TransactionDataSource).to(HttpTransactionDataSource);\n bind(transactionTypes.TransactionContextLoader).to(\n TransactionContextLoader,\n );\n });\n"],
5
+ "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,6BAAAC,MAAiC,+CAC1C,OAAS,oBAAAC,MAAwB,oCACjC,OAAS,4BAAAC,MAAgC,gDAElC,MAAMC,EAA2B,IACtC,IAAIJ,EAAgB,CAAC,CAAE,KAAAK,CAAK,IAAM,CAChCA,EAAKH,EAAiB,qBAAqB,EAAE,GAAGD,CAAyB,EACzEI,EAAKH,EAAiB,wBAAwB,EAAE,GAC9CC,CACF,CACF,CAAC",
6
+ "names": ["ContainerModule", "HttpTransactionDataSource", "transactionTypes", "TransactionContextLoader", "transactionModuleFactory", "bind"]
7
7
  }
@@ -1,2 +1,2 @@
1
- const o={TransactionDataSource:Symbol.for("TransactionDataSource"),TransactionContextLoader:Symbol.for("TransactionContextLoader"),ProxyDataSource:Symbol.for("ProxyDataSource")};export{o as transactionTypes};
1
+ const o={TransactionDataSource:Symbol.for("TransactionDataSource"),TransactionContextLoader:Symbol.for("TransactionContextLoader")};export{o as transactionTypes};
2
2
  //# sourceMappingURL=transactionTypes.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/transaction/di/transactionTypes.ts"],
4
- "sourcesContent": ["export const transactionTypes = {\n TransactionDataSource: Symbol.for(\"TransactionDataSource\"),\n TransactionContextLoader: Symbol.for(\"TransactionContextLoader\"),\n ProxyDataSource: Symbol.for(\"ProxyDataSource\"),\n};\n"],
5
- "mappings": "AAAO,MAAMA,EAAmB,CAC9B,sBAAuB,OAAO,IAAI,uBAAuB,EACzD,yBAA0B,OAAO,IAAI,0BAA0B,EAC/D,gBAAiB,OAAO,IAAI,iBAAiB,CAC/C",
4
+ "sourcesContent": ["export const transactionTypes = {\n TransactionDataSource: Symbol.for(\"TransactionDataSource\"),\n TransactionContextLoader: Symbol.for(\"TransactionContextLoader\"),\n};\n"],
5
+ "mappings": "AAAO,MAAMA,EAAmB,CAC9B,sBAAuB,OAAO,IAAI,uBAAuB,EACzD,yBAA0B,OAAO,IAAI,0BAA0B,CACjE",
6
6
  "names": ["transactionTypes"]
7
7
  }
@@ -1,2 +1,2 @@
1
- var k=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var C=(n,e,t,r)=>{for(var a=r>1?void 0:r?v(e,t):e,o=n.length-1,c;o>=0;o--)(c=n[o])&&(a=(r?c(e,t,a):c(a))||a);return r&&a&&k(e,t,a),a},d=(n,e)=>(t,r)=>e(t,r,n);import{DeviceModelId as L,isHexaString as R}from"@ledgerhq/device-management-kit";import{inject as f,injectable as h}from"inversify";import{pkiTypes as I}from"../../pki/di/pkiTypes";import{KeyId as T}from"../../pki/model/KeyId";import{KeyUsage as A}from"../../pki/model/KeyUsage";import{ClearSignContextType as p}from"../../shared/model/ClearSignContext";import{transactionTypes as g}from"../../transaction/di/transactionTypes";let s=class{constructor(e,t,r){this.transactionDataSource=e;this.proxyDataSource=t;this.certificateLoader=r}async load(e){if(e.deviceModelId===L.NANO_S)return[];const{to:t,data:r,selector:a,chainId:o,deviceModelId:c,challenge:y}=e;if(t===void 0||r==="0x")return[];if(!R(a))return[{type:p.ERROR,error:new Error("Invalid selector")}];const u=await this.proxyDataSource.getProxyDelegateCall({calldata:r,proxyAddress:t,chainId:o,challenge:y||""}),[D,l]=u.caseOf({Left:()=>[t,void 0],Right:i=>[i.delegateAddresses.find(P=>P===t)||i.delegateAddresses[0],i.signedDescriptor]});let m;l&&(m=await this.certificateLoader.loadCertificate({keyId:T.CalCalldataKey,keyUsage:A.Calldata,targetDevice:e.deviceModelId}));const x=l?[{type:p.PROXY_DELEGATE_CALL,payload:l,certificate:m}]:[],S=(await this.transactionDataSource.getTransactionDescriptors({deviceModelId:c,address:D,chainId:o,selector:a})).caseOf({Left:i=>[{type:p.ERROR,error:i}],Right:i=>i});return[...x,...S]}};s=C([h(),d(0,f(g.TransactionDataSource)),d(1,f(g.ProxyDataSource)),d(2,f(I.PkiCertificateLoader))],s);export{s as TransactionContextLoader};
1
+ var u=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var m=(s,e,t,o)=>{for(var r=o>1?void 0:o?f(e,t):e,a=s.length-1,n;a>=0;a--)(n=s[a])&&(r=(o?n(e,t,r):n(r))||r);return o&&r&&u(e,t,r),r},l=(s,e)=>(t,o)=>e(t,o,s);import{DeviceModelId as S,isHexaString as C}from"@ledgerhq/device-management-kit";import{inject as y,injectable as g}from"inversify";import{proxyTypes as D}from"../../proxy/di/proxyTypes";import{ClearSignContextType as i}from"../../shared/model/ClearSignContext";import{transactionTypes as R}from"../../transaction/di/transactionTypes";let d=class{constructor(e,t){this.transactionDataSource=e;this.proxyDataSource=t}async load(e){if(e.deviceModelId===S.NANO_S)return[];const{to:t,data:o,selector:r,chainId:a,deviceModelId:n}=e;if(t===void 0)return[];if(!C(r))return[{type:i.ERROR,error:new Error("Invalid selector")}];const p=await this.transactionDataSource.getTransactionDescriptors({deviceModelId:n,address:t,chainId:a,selector:r});return p.isRight()&&p.extract().length>0?p.extract():(await this.proxyDataSource.getProxyImplementationAddress({calldata:o,proxyAddress:t,chainId:a,challenge:""})).caseOf({Right:async({implementationAddress:c})=>{if(!c)return[{type:i.ERROR,error:new Error(`[ContextModule] TransactionContextLoader: No delegate address found for proxy ${t}`)}];const x=await this.transactionDataSource.getTransactionDescriptors({deviceModelId:n,address:c,chainId:a,selector:r});return x.isRight()&&x.extract().length>0?[{type:i.PROXY_DELEGATE_CALL,payload:"0x"},...x.extract()]:[{type:i.ERROR,error:new Error(`[ContextModule] TransactionContextLoader: Unable to fetch contexts from contract address using proxy delegate call ${c}`)}]},Left:c=>Promise.resolve([{type:i.ERROR,error:new Error(`[ContextModule] TransactionContextLoader: Unable to fetch contexts from contract address ${t}`)}])})}};d=m([g(),l(0,y(R.TransactionDataSource)),l(1,y(D.ProxyDataSource))],d);export{d as TransactionContextLoader};
2
2
  //# sourceMappingURL=TransactionContextLoader.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/transaction/domain/TransactionContextLoader.ts"],
4
- "sourcesContent": ["import { DeviceModelId, isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { pkiTypes } from \"@/pki/di/pkiTypes\";\nimport type { PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { KeyId } from \"@/pki/model/KeyId\";\nimport { KeyUsage } from \"@/pki/model/KeyUsage\";\nimport { PkiCertificate } from \"@/pki/model/PkiCertificate\";\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { TransactionContext } from \"@/shared/model/TransactionContext\";\nimport type { ProxyDataSource } from \"@/transaction/data/HttpProxyDataSource\";\nimport type { TransactionDataSource } from \"@/transaction/data/TransactionDataSource\";\nimport { transactionTypes } from \"@/transaction/di/transactionTypes\";\nimport { ProxyDelegateCall } from \"@/transaction/model/ProxyDelegateCall\";\n\n@injectable()\nexport class TransactionContextLoader implements ContextLoader {\n constructor(\n @inject(transactionTypes.TransactionDataSource)\n private transactionDataSource: TransactionDataSource,\n @inject(transactionTypes.ProxyDataSource)\n private proxyDataSource: ProxyDataSource,\n @inject(pkiTypes.PkiCertificateLoader)\n private certificateLoader: PkiCertificateLoader,\n ) {}\n\n async load(ctx: TransactionContext): Promise<ClearSignContext[]> {\n if (ctx.deviceModelId === DeviceModelId.NANO_S) {\n return [];\n }\n\n const { to, data, selector, chainId, deviceModelId, challenge } = ctx;\n if (to === undefined || data === \"0x\") {\n return [];\n }\n\n if (!isHexaString(selector)) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ];\n }\n\n const proxyDelegateCall = await this.proxyDataSource.getProxyDelegateCall({\n calldata: data,\n proxyAddress: to,\n chainId,\n challenge: challenge || \"\",\n });\n\n // get the resolved address from the list of delegate addresses\n // if the transaction.to is not in the list of delegate addresses,\n // return the first element as the resolved address,\n // and undefined as the proxy delegate call descriptor\n // if the transaction.to is in the list of delegate addresses,\n // return the transaction.to as the resolved address,\n // and the proxy delegate call descriptor\n const [resolvedAddress, proxyDelegateCallDescriptor]: [\n string,\n string | undefined,\n ] = proxyDelegateCall.caseOf({\n Left: () => [to!, undefined],\n Right: (proxyData: ProxyDelegateCall): [string, string | undefined] => {\n return [\n proxyData.delegateAddresses.find((address) => address === to) ||\n proxyData.delegateAddresses[0]!,\n proxyData.signedDescriptor,\n ];\n },\n });\n\n let certificate: PkiCertificate | undefined = undefined;\n if (proxyDelegateCallDescriptor) {\n certificate = await this.certificateLoader.loadCertificate({\n keyId: KeyId.CalCalldataKey,\n keyUsage: KeyUsage.Calldata,\n targetDevice: ctx.deviceModelId,\n });\n }\n\n const proxyDelegateCallContext: ClearSignContext[] =\n proxyDelegateCallDescriptor\n ? [\n {\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: proxyDelegateCallDescriptor,\n certificate: certificate,\n },\n ]\n : [];\n\n const transactionContexts = (\n await this.transactionDataSource.getTransactionDescriptors({\n deviceModelId,\n address: resolvedAddress,\n chainId,\n selector,\n })\n ).caseOf({\n Left: (error): ClearSignContext[] => [\n {\n type: ClearSignContextType.ERROR,\n error,\n },\n ],\n Right: (contexts): ClearSignContext[] => contexts,\n });\n\n return [...proxyDelegateCallContext, ...transactionContexts];\n }\n}\n"],
5
- "mappings": "iOAAA,OAAS,iBAAAA,EAAe,gBAAAC,MAAoB,kCAC5C,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YAEnC,OAAS,YAAAC,MAAgB,oBAEzB,OAAS,SAAAC,MAAa,oBACtB,OAAS,YAAAC,MAAgB,uBAGzB,OAEE,wBAAAC,MACK,kCAIP,OAAS,oBAAAC,MAAwB,oCAI1B,IAAMC,EAAN,KAAwD,CAC7D,YAEUC,EAEAC,EAEAC,EACR,CALQ,2BAAAF,EAEA,qBAAAC,EAEA,uBAAAC,CACP,CAEH,MAAM,KAAKC,EAAsD,CAC/D,GAAIA,EAAI,gBAAkBC,EAAc,OACtC,MAAO,CAAC,EAGV,KAAM,CAAE,GAAAC,EAAI,KAAAC,EAAM,SAAAC,EAAU,QAAAC,EAAS,cAAAC,EAAe,UAAAC,CAAU,EAAIP,EAClE,GAAIE,IAAO,QAAaC,IAAS,KAC/B,MAAO,CAAC,EAGV,GAAI,CAACK,EAAaJ,CAAQ,EACxB,MAAO,CACL,CACE,KAAMK,EAAqB,MAC3B,MAAO,IAAI,MAAM,kBAAkB,CACrC,CACF,EAGF,MAAMC,EAAoB,MAAM,KAAK,gBAAgB,qBAAqB,CACxE,SAAUP,EACV,aAAcD,EACd,QAAAG,EACA,UAAWE,GAAa,EAC1B,CAAC,EASK,CAACI,EAAiBC,CAA2B,EAG/CF,EAAkB,OAAO,CAC3B,KAAM,IAAM,CAACR,EAAK,MAAS,EAC3B,MAAQW,GACC,CACLA,EAAU,kBAAkB,KAAMC,GAAYA,IAAYZ,CAAE,GAC1DW,EAAU,kBAAkB,CAAC,EAC/BA,EAAU,gBACZ,CAEJ,CAAC,EAED,IAAIE,EACAH,IACFG,EAAc,MAAM,KAAK,kBAAkB,gBAAgB,CACzD,MAAOC,EAAM,eACb,SAAUC,EAAS,SACnB,aAAcjB,EAAI,aACpB,CAAC,GAGH,MAAMkB,EACJN,EACI,CACE,CACE,KAAMH,EAAqB,oBAC3B,QAASG,EACT,YAAaG,CACf,CACF,EACA,CAAC,EAEDI,GACJ,MAAM,KAAK,sBAAsB,0BAA0B,CACzD,cAAAb,EACA,QAASK,EACT,QAAAN,EACA,SAAAD,CACF,CAAC,GACD,OAAO,CACP,KAAOgB,GAA8B,CACnC,CACE,KAAMX,EAAqB,MAC3B,MAAAW,CACF,CACF,EACA,MAAQC,GAAiCA,CAC3C,CAAC,EAED,MAAO,CAAC,GAAGH,EAA0B,GAAGC,CAAmB,CAC7D,CACF,EAhGavB,EAAN0B,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAiB,qBAAqB,GAE7CF,EAAA,EAAAC,EAAOC,EAAiB,eAAe,GAEvCF,EAAA,EAAAC,EAAOE,EAAS,oBAAoB,IAN5B/B",
6
- "names": ["DeviceModelId", "isHexaString", "inject", "injectable", "pkiTypes", "KeyId", "KeyUsage", "ClearSignContextType", "transactionTypes", "TransactionContextLoader", "transactionDataSource", "proxyDataSource", "certificateLoader", "ctx", "DeviceModelId", "to", "data", "selector", "chainId", "deviceModelId", "challenge", "isHexaString", "ClearSignContextType", "proxyDelegateCall", "resolvedAddress", "proxyDelegateCallDescriptor", "proxyData", "address", "certificate", "KeyId", "KeyUsage", "proxyDelegateCallContext", "transactionContexts", "error", "contexts", "__decorateClass", "injectable", "__decorateParam", "inject", "transactionTypes", "pkiTypes"]
4
+ "sourcesContent": ["import { DeviceModelId, isHexaString } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport type {\n ProxyDataSource,\n ProxyImplementationAddress,\n} from \"@/proxy/data/ProxyDataSource\";\nimport { proxyTypes } from \"@/proxy/di/proxyTypes\";\nimport { ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { TransactionContext } from \"@/shared/model/TransactionContext\";\nimport type { TransactionDataSource } from \"@/transaction/data/TransactionDataSource\";\nimport { transactionTypes } from \"@/transaction/di/transactionTypes\";\n\n@injectable()\nexport class TransactionContextLoader implements ContextLoader {\n constructor(\n @inject(transactionTypes.TransactionDataSource)\n private transactionDataSource: TransactionDataSource,\n @inject(proxyTypes.ProxyDataSource)\n private proxyDataSource: ProxyDataSource,\n ) {}\n\n async load(ctx: TransactionContext): Promise<ClearSignContext[]> {\n if (ctx.deviceModelId === DeviceModelId.NANO_S) {\n return [];\n }\n\n const { to, data, selector, chainId, deviceModelId } = ctx;\n if (to === undefined) {\n return [];\n }\n\n if (!isHexaString(selector)) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ];\n }\n\n // try to fetch the transaction descriptors from the transaction data source\n // using the smart contract address to\n const transactionContexts =\n await this.transactionDataSource.getTransactionDescriptors({\n deviceModelId,\n address: to,\n chainId,\n selector,\n });\n\n if (\n transactionContexts.isRight() &&\n transactionContexts.extract().length > 0\n ) {\n return transactionContexts.extract();\n }\n\n // if the transaction descriptors are not found, try to fetch the proxy delegate call\n // and return the proxy delegate call context\n const proxyImplementationAddress =\n await this.proxyDataSource.getProxyImplementationAddress({\n calldata: data,\n proxyAddress: to,\n chainId,\n challenge: \"\",\n });\n\n return proxyImplementationAddress.caseOf<Promise<ClearSignContext[]>>({\n Right: async ({ implementationAddress }: ProxyImplementationAddress) => {\n if (!implementationAddress) {\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n `[ContextModule] TransactionContextLoader: No delegate address found for proxy ${to}`,\n ),\n },\n ];\n }\n\n const transactionProxyContexts =\n await this.transactionDataSource.getTransactionDescriptors({\n deviceModelId,\n address: implementationAddress,\n chainId,\n selector,\n });\n\n if (\n transactionProxyContexts.isRight() &&\n transactionProxyContexts.extract().length > 0\n ) {\n return [\n // This payload is not used as the clear sign context is not used, only the subcontext that will be\n // fetched during the provide, with a correct challenge\n {\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: \"0x\",\n },\n ...transactionProxyContexts.extract(),\n ];\n }\n\n return [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n `[ContextModule] TransactionContextLoader: Unable to fetch contexts from contract address using proxy delegate call ${implementationAddress}`,\n ),\n },\n ];\n },\n Left: (_) => {\n return Promise.resolve([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n `[ContextModule] TransactionContextLoader: Unable to fetch contexts from contract address ${to}`,\n ),\n },\n ]);\n },\n });\n }\n}\n"],
5
+ "mappings": "iOAAA,OAAS,iBAAAA,EAAe,gBAAAC,MAAoB,kCAC5C,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YAMnC,OAAS,cAAAC,MAAkB,wBAE3B,OAEE,wBAAAC,MACK,kCAGP,OAAS,oBAAAC,MAAwB,oCAG1B,IAAMC,EAAN,KAAwD,CAC7D,YAEUC,EAEAC,EACR,CAHQ,2BAAAD,EAEA,qBAAAC,CACP,CAEH,MAAM,KAAKC,EAAsD,CAC/D,GAAIA,EAAI,gBAAkBC,EAAc,OACtC,MAAO,CAAC,EAGV,KAAM,CAAE,GAAAC,EAAI,KAAAC,EAAM,SAAAC,EAAU,QAAAC,EAAS,cAAAC,CAAc,EAAIN,EACvD,GAAIE,IAAO,OACT,MAAO,CAAC,EAGV,GAAI,CAACK,EAAaH,CAAQ,EACxB,MAAO,CACL,CACE,KAAMI,EAAqB,MAC3B,MAAO,IAAI,MAAM,kBAAkB,CACrC,CACF,EAKF,MAAMC,EACJ,MAAM,KAAK,sBAAsB,0BAA0B,CACzD,cAAAH,EACA,QAASJ,EACT,QAAAG,EACA,SAAAD,CACF,CAAC,EAEH,OACEK,EAAoB,QAAQ,GAC5BA,EAAoB,QAAQ,EAAE,OAAS,EAEhCA,EAAoB,QAAQ,GAMnC,MAAM,KAAK,gBAAgB,8BAA8B,CACvD,SAAUN,EACV,aAAcD,EACd,QAAAG,EACA,UAAW,EACb,CAAC,GAE+B,OAAoC,CACpE,MAAO,MAAO,CAAE,sBAAAK,CAAsB,IAAkC,CACtE,GAAI,CAACA,EACH,MAAO,CACL,CACE,KAAMF,EAAqB,MAC3B,MAAO,IAAI,MACT,iFAAiFN,CAAE,EACrF,CACF,CACF,EAGF,MAAMS,EACJ,MAAM,KAAK,sBAAsB,0BAA0B,CACzD,cAAAL,EACA,QAASI,EACT,QAAAL,EACA,SAAAD,CACF,CAAC,EAEH,OACEO,EAAyB,QAAQ,GACjCA,EAAyB,QAAQ,EAAE,OAAS,EAErC,CAGL,CACE,KAAMH,EAAqB,oBAC3B,QAAS,IACX,EACA,GAAGG,EAAyB,QAAQ,CACtC,EAGK,CACL,CACE,KAAMH,EAAqB,MAC3B,MAAO,IAAI,MACT,sHAAsHE,CAAqB,EAC7I,CACF,CACF,CACF,EACA,KAAOE,GACE,QAAQ,QAAQ,CACrB,CACE,KAAMJ,EAAqB,MAC3B,MAAO,IAAI,MACT,4FAA4FN,CAAE,EAChG,CACF,CACF,CAAC,CAEL,CAAC,CACH,CACF,EA/GaL,EAANgB,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAiB,qBAAqB,GAE7CF,EAAA,EAAAC,EAAOE,EAAW,eAAe,IAJzBrB",
6
+ "names": ["DeviceModelId", "isHexaString", "inject", "injectable", "proxyTypes", "ClearSignContextType", "transactionTypes", "TransactionContextLoader", "transactionDataSource", "proxyDataSource", "ctx", "DeviceModelId", "to", "data", "selector", "chainId", "deviceModelId", "isHexaString", "ClearSignContextType", "transactionContexts", "implementationAddress", "transactionProxyContexts", "_", "__decorateClass", "injectable", "__decorateParam", "inject", "transactionTypes", "proxyTypes"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{Left as c,Right as n}from"purify-ts";import{ClearSignContextType as e}from"../../shared/model/ClearSignContext";import{TransactionContextLoader as p}from"../../transaction/domain/TransactionContextLoader";describe("TransactionContextLoader",()=>{const r=vi.fn(),s=vi.fn(),d={getTransactionDescriptors:r},l={getProxyDelegateCall:s,getProxyImplementationAddress:vi.fn()},i={loadCertificate:vi.fn()},o=new p(d,l,i);beforeEach(()=>{vi.resetAllMocks()}),it("should return an empty array if no destination address is provided",async()=>{const a={},t=await o.load(a);expect(t).toEqual([])}),it("should return an empty array if no data provided",async()=>{const a={to:"0x0",data:"0x"},t=await o.load(a);expect(t).toEqual([])}),it("should return an error if selector is invalid",async()=>{const a={to:"0x7",chainId:3,data:"0xzf68b302000000000000000000000000000000000000000000000000000000000002"},t=await o.load(a);expect(t).toEqual([{type:e.ERROR,error:new Error("Invalid selector")}])}),it("should return an error if data source fails",async()=>{s.mockResolvedValue(c(new Error("data source error"))),r.mockResolvedValue(c(new Error("data source error")));const a={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await o.load(a);expect(r).toHaveBeenCalledWith({address:"0x7",chainId:3,selector:"0xaf68b302"}),expect(t).toEqual([{type:e.ERROR,error:new Error("data source error")}])}),it("should return the contexts on success",async()=>{r.mockResolvedValue(n([{type:e.TRANSACTION_INFO,payload:"1234567890"},{type:e.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])),s.mockResolvedValue(c(new Error("data source error")));const a={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await o.load(a);expect(t).toEqual([{type:e.TRANSACTION_INFO,payload:"1234567890"},{type:e.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])}),it("should return the proxy delegate call context on success",async()=>{r.mockResolvedValue(n([{type:e.TRANSACTION_INFO,payload:"1234567890"},{type:e.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])),s.mockResolvedValue(n({delegateAddresses:["0x7"],signedDescriptor:"0x1234567890abcdef"}));const a={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await o.load(a);expect(t).toEqual([{type:e.PROXY_DELEGATE_CALL,payload:"0x1234567890abcdef"},{type:e.TRANSACTION_INFO,payload:"1234567890"},{type:e.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])}),it("should return the proxy delegate call context if the transaction.to is in the delegate addresses and the transaction.to is not the first element",async()=>{r.mockResolvedValue(n([{type:e.TRANSACTION_INFO,payload:"1234567890"},{type:e.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])),s.mockResolvedValue(n({delegateAddresses:["0x7","0x8"],signedDescriptor:"0x1234567890abcdef"}));const a={to:"0x8",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await o.load(a);expect(t).toEqual([{type:e.PROXY_DELEGATE_CALL,payload:"0x1234567890abcdef"},{type:e.TRANSACTION_INFO,payload:"1234567890"},{type:e.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])}),it("should return the proxy delegate call context if the transaction.to is not in the delegate addresses",async()=>{r.mockResolvedValue(n([{type:e.TRANSACTION_INFO,payload:"1234567890"},{type:e.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])),s.mockResolvedValue(n({delegateAddresses:["0x8"],signedDescriptor:"0x1234567890abcdef"}));const a={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await o.load(a);expect(t).toEqual([{type:e.PROXY_DELEGATE_CALL,payload:"0x1234567890abcdef"},{type:e.TRANSACTION_INFO,payload:"1234567890"},{type:e.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])})});
1
+ import{DeviceModelId as i}from"@ledgerhq/device-management-kit";import{Left as c,Right as s}from"purify-ts";import{ClearSignContextType as a}from"../../shared/model/ClearSignContext";import{TransactionContextLoader as x}from"../../transaction/domain/TransactionContextLoader";describe("TransactionContextLoader",()=>{const o=vi.fn(),n=vi.fn(),d={getTransactionDescriptors:o},l={getProxyImplementationAddress:n},r=new x(d,l);beforeEach(()=>{vi.resetAllMocks()}),it("should return an empty array if no destination address is provided",async()=>{const e={},t=await r.load(e);expect(t).toEqual([])}),it("should return an empty array if 'to' is undefined",async()=>{const e={to:void 0,data:"0x"},t=await r.load(e);expect(t).toEqual([])}),it("should return an error if selector is invalid",async()=>{const e={to:"0x7",chainId:3,data:"0xzf68b302000000000000000000000000000000000000000000000000000000000002"},t=await r.load(e);expect(t).toEqual([{type:a.ERROR,error:new Error("Invalid selector")}])}),it("should return an error if data source fails",async()=>{n.mockResolvedValue(c(new Error("data source error"))),o.mockResolvedValue(c(new Error("data source error")));const e={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await r.load(e);expect(o).toHaveBeenCalledWith({address:"0x7",chainId:3,selector:"0xaf68b302"}),expect(t).toEqual([{type:a.ERROR,error:new Error("[ContextModule] TransactionContextLoader: Unable to fetch contexts from contract address 0x7")}])}),it("should return the contexts on success",async()=>{o.mockResolvedValue(s([{type:a.TRANSACTION_INFO,payload:"1234567890"},{type:a.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])),n.mockResolvedValue(c(new Error("data source error")));const e={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await r.load(e);expect(t).toEqual([{type:a.TRANSACTION_INFO,payload:"1234567890"},{type:a.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])}),it("should return the proxy delegate call context on success",async()=>{o.mockResolvedValueOnce(s([])),o.mockResolvedValue(s([{type:a.TRANSACTION_INFO,payload:"1234567890"},{type:a.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])),n.mockResolvedValue(s({implementationAddress:"0x1234567890abcdef",signedDescriptor:"0x1234567890abcdef"}));const e={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await r.load(e);expect(t).toEqual([{type:a.PROXY_DELEGATE_CALL,payload:"0x"},{type:a.TRANSACTION_INFO,payload:"1234567890"},{type:a.TRANSACTION_FIELD_DESCRIPTION,payload:"deadbeef"}])}),it("should return an empty array if device model is NANO_S",async()=>{const e={deviceModelId:i.NANO_S,to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await r.load(e);expect(t).toEqual([]),expect(o).not.toHaveBeenCalled(),expect(n).not.toHaveBeenCalled()}),it("should return an error when proxy delegate call succeeds but transaction descriptors for resolved address fail",async()=>{o.mockResolvedValueOnce(s([])),o.mockResolvedValueOnce(c(new Error("data source error"))),n.mockResolvedValue(s({implementationAddress:"0xResolvedAddress",signedDescriptor:"0x1234567890abcdef"}));const e={to:"0x7",chainId:3,data:"0xaf68b302000000000000000000000000000000000000000000000000000000000002",selector:"0xaf68b302"},t=await r.load(e);expect(o).toHaveBeenCalledTimes(2),expect(o).toHaveBeenNthCalledWith(2,{address:"0xResolvedAddress",chainId:3,selector:"0xaf68b302"}),expect(t).toEqual([{type:a.ERROR,error:new Error("[ContextModule] TransactionContextLoader: Unable to fetch contexts from contract address using proxy delegate call 0xResolvedAddress")}])})});
2
2
  //# sourceMappingURL=TransactionContextLoader.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/transaction/domain/TransactionContextLoader.test.ts"],
4
- "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { type PkiCertificateLoader } from \"@/pki/domain/PkiCertificateLoader\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport type { TransactionContext } from \"@/shared/model/TransactionContext\";\nimport type { ProxyDataSource } from \"@/transaction/data/HttpProxyDataSource\";\nimport type { TransactionDataSource } from \"@/transaction/data/TransactionDataSource\";\nimport { TransactionContextLoader } from \"@/transaction/domain/TransactionContextLoader\";\n\ndescribe(\"TransactionContextLoader\", () => {\n const getTransactionDescriptorsMock = vi.fn();\n const getProxyDelegateCallMock = vi.fn();\n const mockTransactionDataSource: TransactionDataSource = {\n getTransactionDescriptors: getTransactionDescriptorsMock,\n };\n const mockProxyDatasource: ProxyDataSource = {\n getProxyDelegateCall: getProxyDelegateCallMock,\n getProxyImplementationAddress: vi.fn(),\n };\n const mockCertificateLoader: PkiCertificateLoader = {\n loadCertificate: vi.fn(),\n };\n const loader = new TransactionContextLoader(\n mockTransactionDataSource,\n mockProxyDatasource,\n mockCertificateLoader,\n );\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should return an empty array if no destination address is provided\", async () => {\n // GIVEN\n const transaction = {} as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if no data provided\", async () => {\n // GIVEN\n const transaction = { to: \"0x0\", data: \"0x\" } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an error if selector is invalid\", async () => {\n // GIVEN\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xzf68b302000000000000000000000000000000000000000000000000000000000002\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ]);\n });\n\n it(\"should return an error if data source fails\", async () => {\n // GIVEN\n getProxyDelegateCallMock.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n getTransactionDescriptorsMock.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(getTransactionDescriptorsMock).toHaveBeenCalledWith({\n address: \"0x7\",\n chainId: 3,\n selector: \"0xaf68b302\",\n });\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"data source error\"),\n },\n ]);\n });\n\n it(\"should return the contexts on success\", async () => {\n // GIVEN\n getTransactionDescriptorsMock.mockResolvedValue(\n Right([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]),\n );\n getProxyDelegateCallMock.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]);\n });\n\n it(\"should return the proxy delegate call context on success\", async () => {\n // GIVEN\n getTransactionDescriptorsMock.mockResolvedValue(\n Right([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]),\n );\n getProxyDelegateCallMock.mockResolvedValue(\n Right({\n delegateAddresses: [\"0x7\"],\n signedDescriptor: \"0x1234567890abcdef\",\n }),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: \"0x1234567890abcdef\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]);\n });\n\n it(\"should return the proxy delegate call context if the transaction.to is in the delegate addresses and the transaction.to is not the first element\", async () => {\n // GIVEN\n getTransactionDescriptorsMock.mockResolvedValue(\n Right([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]),\n );\n getProxyDelegateCallMock.mockResolvedValue(\n Right({\n delegateAddresses: [\"0x7\", \"0x8\"],\n signedDescriptor: \"0x1234567890abcdef\",\n }),\n );\n const transaction = {\n to: \"0x8\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: \"0x1234567890abcdef\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]);\n });\n\n it(\"should return the proxy delegate call context if the transaction.to is not in the delegate addresses\", async () => {\n // GIVEN\n getTransactionDescriptorsMock.mockResolvedValue(\n Right([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]),\n );\n getProxyDelegateCallMock.mockResolvedValue(\n Right({\n delegateAddresses: [\"0x8\"],\n signedDescriptor: \"0x1234567890abcdef\",\n }),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: \"0x1234567890abcdef\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INF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AC",
6
- "names": ["Left", "Right", "ClearSignContextType", "TransactionContextLoader", "getTransactionDescriptorsMock", "getProxyDelegateCallMock", "mockTransactionDataSource", "mockProxyDatasource", "mockCertificateLoader", "loader", "transaction", "result"]
4
+ "sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport type { ProxyDataSource } from \"@/proxy/data/ProxyDataSource\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport type { TransactionContext } from \"@/shared/model/TransactionContext\";\nimport type { TransactionDataSource } from \"@/transaction/data/TransactionDataSource\";\nimport { TransactionContextLoader } from \"@/transaction/domain/TransactionContextLoader\";\n\ndescribe(\"TransactionContextLoader\", () => {\n const getTransactionDescriptorsMock = vi.fn();\n const getProxyImplementationAddress = vi.fn();\n const mockTransactionDataSource: TransactionDataSource = {\n getTransactionDescriptors: getTransactionDescriptorsMock,\n };\n const mockProxyDatasource: ProxyDataSource = {\n getProxyImplementationAddress: getProxyImplementationAddress,\n };\n const loader = new TransactionContextLoader(\n mockTransactionDataSource,\n mockProxyDatasource,\n );\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should return an empty array if no destination address is provided\", async () => {\n // GIVEN\n const transaction = {} as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an empty array if 'to' is undefined\", async () => {\n // GIVEN\n const transaction = { to: undefined, data: \"0x\" } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n });\n\n it(\"should return an error if selector is invalid\", async () => {\n // GIVEN\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xzf68b302000000000000000000000000000000000000000000000000000000000002\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"Invalid selector\"),\n },\n ]);\n });\n\n it(\"should return an error if data source fails\", async () => {\n // GIVEN\n getProxyImplementationAddress.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n getTransactionDescriptorsMock.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(getTransactionDescriptorsMock).toHaveBeenCalledWith({\n address: \"0x7\",\n chainId: 3,\n selector: \"0xaf68b302\",\n });\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] TransactionContextLoader: Unable to fetch contexts from contract address 0x7\",\n ),\n },\n ]);\n });\n\n it(\"should return the contexts on success\", async () => {\n // GIVEN\n getTransactionDescriptorsMock.mockResolvedValue(\n Right([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]),\n );\n getProxyImplementationAddress.mockResolvedValue(\n Left(new Error(\"data source error\")),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]);\n });\n\n it(\"should return the proxy delegate call context on success\", async () => {\n // GIVEN\n getTransactionDescriptorsMock.mockResolvedValueOnce(Right([])); // No transaction descriptors found for the first call\n getTransactionDescriptorsMock.mockResolvedValue(\n Right([\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]),\n );\n getProxyImplementationAddress.mockResolvedValue(\n Right({\n implementationAddress: \"0x1234567890abcdef\",\n signedDescriptor: \"0x1234567890abcdef\",\n }),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([\n {\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: \"0x\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"1234567890\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"deadbeef\",\n },\n ]);\n });\n\n it(\"should return an empty array if device model is NANO_S\", async () => {\n // GIVEN\n const transaction = {\n deviceModelId: DeviceModelId.NANO_S,\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(result).toEqual([]);\n expect(getTransactionDescriptorsMock).not.toHaveBeenCalled();\n expect(getProxyImplementationAddress).not.toHaveBeenCalled();\n });\n\n it(\"should return an error when proxy delegate call succeeds but transaction descriptors for resolved address fail\", async () => {\n // GIVEN\n getTransactionDescriptorsMock.mockResolvedValueOnce(Right([])); // No transaction descriptors found for the first call\n getTransactionDescriptorsMock.mockResolvedValueOnce(\n Left(new Error(\"data source error\")),\n ); // Second call fails\n getProxyImplementationAddress.mockResolvedValue(\n Right({\n implementationAddress: \"0xResolvedAddress\",\n signedDescriptor: \"0x1234567890abcdef\",\n }),\n );\n const transaction = {\n to: \"0x7\",\n chainId: 3,\n data: \"0xaf68b302000000000000000000000000000000000000000000000000000000000002\",\n selector: \"0xaf68b302\",\n } as TransactionContext;\n\n // WHEN\n const result = await loader.load(transaction);\n\n // THEN\n expect(getTransactionDescriptorsMock).toHaveBeenCalledTimes(2);\n expect(getTransactionDescriptorsMock).toHaveBeenNthCalledWith(2, {\n address: \"0xResolvedAddress\",\n chainId: 3,\n selector: \"0xaf68b302\",\n });\n expect(result).toEqual([\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\n \"[ContextModule] TransactionContextLoader: Unable to fetch contexts from contract address using proxy delegate call 0xResolvedAddress\",\n ),\n },\n ]);\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,iBAAAA,MAAqB,kCAC9B,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAG5B,OAAS,wBAAAC,MAA4B,kCAGrC,OAAS,4BAAAC,MAAgC,gDAEzC,SAAS,2BAA4B,IAAM,CACzC,MAAMC,EAAgC,GAAG,GAAG,EACtCC,EAAgC,GAAG,GAAG,EACtCC,EAAmD,CACvD,0BAA2BF,CAC7B,EACMG,EAAuC,CAC3C,8BAA+BF,CACjC,EACMG,EAAS,IAAIL,EACjBG,EACAC,CACF,EAEA,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,GAAG,qEAAsE,SAAY,CAEnF,MAAME,EAAc,CAAC,EAGfC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,EAED,GAAG,oDAAqD,SAAY,CAElE,MAAMD,EAAc,CAAE,GAAI,OAAW,KAAM,IAAK,EAG1CC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,CAAC,EAED,GAAG,gDAAiD,SAAY,CAE9D,MAAMD,EAAc,CAClB,GAAI,MACJ,QAAS,EACT,KAAM,wEACR,EAGMC,EAAS,MAAMF,EAAO,KAAKC,CAAW,EAG5C,OAAOC,CAAM,EAAE,QAAQ,CACrB,CACE,KAAMR,EAAqB,MAC3B,MAAO,IAAI,MAAM,kB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"Right", "ClearSignContextType", "TransactionContextLoader", "getTransactionDescriptorsMock", "getProxyImplementationAddress", "mockTransactionDataSource", "mockProxyDatasource", "loader", "transaction", "result"]
7
7
  }
@@ -1,2 +1,2 @@
1
- var m=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var s=(r,e,o,t)=>{for(var a=t>1?void 0:t?p(e,o):e,i=r.length-1,d;i>=0;i--)(d=r[i])&&(a=(t?d(e,o,a):d(a))||a);return t&&a&&m(e,o,a),a},c=(r,e)=>(o,t)=>e(o,t,r);import{inject as S,injectable as T}from"inversify";import{ContextFieldLoaderKind as C}from"../../shared/domain/ContextFieldLoader";import{ClearSignContextType as l}from"../../shared/model/ClearSignContext";import{trustedNameTypes as u}from"../../trusted-name/di/trustedNameTypes";let n=class{constructor(e){this._dataSource=e}kind=C.TRUSTED_NAME;async loadField(e){return(await this._dataSource.getTrustedNamePayload({chainId:e.chainId,address:e.address,challenge:e.challenge,types:e.types,sources:e.sources})).caseOf({Left:t=>({type:l.ERROR,error:t}),Right:t=>({type:l.TRUSTED_NAME,payload:t})})}};n=s([T(),c(0,S(u.TrustedNameDataSource))],n);export{n as TrustedNameContextFieldLoader};
1
+ var p=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var c=(r,e,n,t)=>{for(var a=t>1?void 0:t?m(e,n):e,o=r.length-1,i;o>=0;o--)(i=r[o])&&(a=(t?i(e,n,a):i(a))||a);return t&&a&&p(e,n,a),a},d=(r,e)=>(n,t)=>e(n,t,r);import{inject as l,injectable as g}from"inversify";import{ContextFieldLoaderKind as y}from"../../shared/domain/ContextFieldLoader";import{ClearSignContextType as u}from"../../shared/model/ClearSignContext";import{trustedNameTypes as S}from"../../trusted-name/di/trustedNameTypes";let s=class{constructor(e){this._dataSource=e}canHandle(e){return typeof e=="object"&&e!==null&&"kind"in e&&e.kind===y.TRUSTED_NAME&&"chainId"in e&&"address"in e&&"challenge"in e&&"types"in e&&"sources"in e}async loadField(e){return(await this._dataSource.getTrustedNamePayload({chainId:e.chainId,address:e.address,challenge:e.challenge,types:e.types,sources:e.sources})).caseOf({Left:t=>({type:u.ERROR,error:t}),Right:t=>({type:u.TRUSTED_NAME,payload:t})})}};s=c([g(),d(0,l(S.TrustedNameDataSource))],s);export{s as TrustedNameContextFieldLoader};
2
2
  //# sourceMappingURL=TrustedNameContextFieldLoader.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/trusted-name/domain/TrustedNameContextFieldLoader.ts"],
4
- "sourcesContent": ["import { inject, injectable } from \"inversify\";\n\nimport {\n ContextFieldLoader,\n ContextFieldLoaderKind,\n} from \"@/shared/domain/ContextFieldLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport { TransactionFieldContext } from \"@/shared/model/TransactionContext\";\nimport * as TrustedNameDataSource from \"@/trusted-name/data/TrustedNameDataSource\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\n@injectable()\nexport class TrustedNameContextFieldLoader\n implements ContextFieldLoader<ContextFieldLoaderKind.TRUSTED_NAME>\n{\n kind: ContextFieldLoaderKind.TRUSTED_NAME =\n ContextFieldLoaderKind.TRUSTED_NAME;\n\n constructor(\n @inject(trustedNameTypes.TrustedNameDataSource)\n private _dataSource: TrustedNameDataSource.TrustedNameDataSource,\n ) {}\n\n async loadField(\n field: TransactionFieldContext<ContextFieldLoaderKind.TRUSTED_NAME>,\n ): Promise<ClearSignContext> {\n const payload = await this._dataSource.getTrustedNamePayload({\n chainId: field.chainId,\n address: field.address,\n challenge: field.challenge,\n types: field.types,\n sources: field.sources,\n });\n return payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: value,\n }),\n });\n }\n}\n"],
5
- "mappings": "iOAAA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YAEnC,OAEE,0BAAAC,MACK,qCACP,OAEE,wBAAAC,MACK,kCAGP,OAAS,oBAAAC,MAAwB,qCAG1B,IAAMC,EAAN,KAEP,CAIE,YAEUC,EACR,CADQ,iBAAAA,CACP,CANH,KACEC,EAAuB,aAOzB,MAAM,UACJC,EAC2B,CAQ3B,OAPgB,MAAM,KAAK,YAAY,sBAAsB,CAC3D,QAASA,EAAM,QACf,QAASA,EAAM,QACf,UAAWA,EAAM,UACjB,MAAOA,EAAM,MACb,QAASA,EAAM,OACjB,CAAC,GACc,OAAO,CACpB,KAAOC,IAA6B,CAClC,KAAMC,EAAqB,MAC3B,MAAAD,CACF,GACA,MAAQE,IAA6B,CACnC,KAAMD,EAAqB,aAC3B,QAASC,CACX,EACF,CAAC,CACH,CACF,EAhCaN,EAANO,EAAA,CADNC,EAAW,EAQPC,EAAA,EAAAC,EAAOC,EAAiB,qBAAqB,IAPrCX",
6
- "names": ["inject", "injectable", "ContextFieldLoaderKind", "ClearSignContextType", "trustedNameTypes", "TrustedNameContextFieldLoader", "_dataSource", "ContextFieldLoaderKind", "field", "error", "ClearSignContextType", "value", "__decorateClass", "injectable", "__decorateParam", "inject", "trustedNameTypes"]
4
+ "sourcesContent": ["import { inject, injectable } from \"inversify\";\n\nimport {\n ContextFieldLoader,\n ContextFieldLoaderKind,\n} from \"@/shared/domain/ContextFieldLoader\";\nimport {\n ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\nimport * as TrustedNameDataSource from \"@/trusted-name/data/TrustedNameDataSource\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\ntype TrustedNameFieldInput = {\n kind: ContextFieldLoaderKind.TRUSTED_NAME;\n chainId: number;\n address: string;\n challenge: string;\n types: string[];\n sources: string[];\n};\n\n@injectable()\nexport class TrustedNameContextFieldLoader\n implements ContextFieldLoader<TrustedNameFieldInput>\n{\n constructor(\n @inject(trustedNameTypes.TrustedNameDataSource)\n private _dataSource: TrustedNameDataSource.TrustedNameDataSource,\n ) {}\n\n canHandle(field: unknown): field is TrustedNameFieldInput {\n return (\n typeof field === \"object\" &&\n field !== null &&\n \"kind\" in field &&\n field.kind === ContextFieldLoaderKind.TRUSTED_NAME &&\n \"chainId\" in field &&\n \"address\" in field &&\n \"challenge\" in field &&\n \"types\" in field &&\n \"sources\" in field\n );\n }\n\n async loadField(field: TrustedNameFieldInput): Promise<ClearSignContext> {\n const payload = await this._dataSource.getTrustedNamePayload({\n chainId: field.chainId,\n address: field.address,\n challenge: field.challenge,\n types: field.types,\n sources: field.sources,\n });\n return payload.caseOf({\n Left: (error): ClearSignContext => ({\n type: ClearSignContextType.ERROR,\n error,\n }),\n Right: (value): ClearSignContext => ({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: value,\n }),\n });\n }\n}\n"],
5
+ "mappings": "iOAAA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YAEnC,OAEE,0BAAAC,MACK,qCACP,OAEE,wBAAAC,MACK,kCAEP,OAAS,oBAAAC,MAAwB,qCAY1B,IAAMC,EAAN,KAEP,CACE,YAEUC,EACR,CADQ,iBAAAA,CACP,CAEH,UAAUC,EAAgD,CACxD,OACE,OAAOA,GAAU,UACjBA,IAAU,MACV,SAAUA,GACVA,EAAM,OAASC,EAAuB,cACtC,YAAaD,GACb,YAAaA,GACb,cAAeA,GACf,UAAWA,GACX,YAAaA,CAEjB,CAEA,MAAM,UAAUA,EAAyD,CAQvE,OAPgB,MAAM,KAAK,YAAY,sBAAsB,CAC3D,QAASA,EAAM,QACf,QAASA,EAAM,QACf,UAAWA,EAAM,UACjB,MAAOA,EAAM,MACb,QAASA,EAAM,OACjB,CAAC,GACc,OAAO,CACpB,KAAOE,IAA6B,CAClC,KAAMC,EAAqB,MAC3B,MAAAD,CACF,GACA,MAAQE,IAA6B,CACnC,KAAMD,EAAqB,aAC3B,QAASC,CACX,EACF,CAAC,CACH,CACF,EAzCaN,EAANO,EAAA,CADNC,EAAW,EAKPC,EAAA,EAAAC,EAAOC,EAAiB,qBAAqB,IAJrCX",
6
+ "names": ["inject", "injectable", "ContextFieldLoaderKind", "ClearSignContextType", "trustedNameTypes", "TrustedNameContextFieldLoader", "_dataSource", "field", "ContextFieldLoaderKind", "error", "ClearSignContextType", "value", "__decorateClass", "injectable", "__decorateParam", "inject", "trustedNameTypes"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ import{Left as r,Right as c}from"purify-ts";import{ContextFieldLoaderKind as n}from"../../shared/domain/ContextFieldLoader";import{ClearSignContextType as o}from"../../shared/model/ClearSignContext";import{TrustedNameContextFieldLoader as i}from"../../trusted-name/domain/TrustedNameContextFieldLoader";describe("TrustedNameContextFieldLoader",()=>{const t={getTrustedNamePayload:vi.fn(),getDomainNamePayload:vi.fn()},d=new i(t),e={kind:n.TRUSTED_NAME,chainId:1,address:"0x1234567890abcdef",challenge:"test-challenge",types:["contract","token"],sources:["ledger","ens"]},l="0x123456789abcdef0";beforeEach(()=>{vi.resetAllMocks()}),describe("canHandle",()=>{it("should return true for valid trusted name field",()=>{const a={kind:n.TRUSTED_NAME,chainId:1,address:"0x1234567890abcdef",challenge:"test-challenge",types:["contract","token"],sources:["ledger","ens"]};expect(d.canHandle(a)).toBe(!0)}),describe("should return false for invalid fields",()=>{const a=[{name:"null",value:null},{name:"undefined",value:void 0},{name:"string",value:"invalid"},{name:"number",value:123},{name:"boolean",value:!0},{name:"array",value:[]},{name:"empty object",value:{}},{name:"object missing kind",value:{chainId:1,address:"0x123",challenge:"test",types:["contract"],sources:["ledger"]}},{name:"object missing chainId",value:{kind:n.TRUSTED_NAME,address:"0x123",challenge:"test",types:["contract"],sources:["ledger"]}},{name:"object missing address",value:{kind:n.TRUSTED_NAME,chainId:1,challenge:"test",types:["contract"],sources:["ledger"]}},{name:"object missing challenge",value:{kind:n.TRUSTED_NAME,chainId:1,address:"0x123",types:["contract"],sources:["ledger"]}},{name:"object missing types",value:{kind:n.TRUSTED_NAME,chainId:1,address:"0x123",challenge:"test",sources:["ledger"]}},{name:"object missing sources",value:{kind:n.TRUSTED_NAME,chainId:1,address:"0x123",challenge:"test",types:["contract"]}},{name:"object with wrong kind",value:{kind:n.TOKEN,chainId:1,address:"0x123",challenge:"test",types:["contract"],sources:["ledger"]}}];test.each(a)("$name",({value:s})=>{expect(d.canHandle(s)).toBe(!1)})})}),describe("loadField",()=>{it("should return error context when trusted name data source fails",async()=>{const a=new Error("Trusted name data source error");vi.spyOn(t,"getTrustedNamePayload").mockResolvedValue(r(a));const s=await d.loadField(e);expect(t.getTrustedNamePayload).toHaveBeenCalledWith({chainId:e.chainId,address:e.address,challenge:e.challenge,types:e.types,sources:e.sources}),expect(s).toEqual({type:o.ERROR,error:a})}),it("should return trusted name context when successful",async()=>{vi.spyOn(t,"getTrustedNamePayload").mockResolvedValue(c(l));const a=await d.loadField(e);expect(t.getTrustedNamePayload).toHaveBeenCalledWith({chainId:e.chainId,address:e.address,challenge:e.challenge,types:e.types,sources:e.sources}),expect(a).toEqual({type:o.TRUSTED_NAME,payload:l})}),it("should handle different chain IDs and addresses correctly",async()=>{const a={...e,chainId:137,address:"0xdeadbeef",challenge:"custom-challenge"};vi.spyOn(t,"getTrustedNamePayload").mockResolvedValue(c(l));const s=await d.loadField(a);expect(t.getTrustedNamePayload).toHaveBeenCalledWith({chainId:137,address:"0xdeadbeef",challenge:"custom-challenge",types:e.types,sources:e.sources}),expect(s).toEqual({type:o.TRUSTED_NAME,payload:l})}),it("should handle different types and sources correctly",async()=>{const a={...e,types:["wallet","exchange"],sources:["coingecko","1inch"]};vi.spyOn(t,"getTrustedNamePayload").mockResolvedValue(c(l));const s=await d.loadField(a);expect(t.getTrustedNamePayload).toHaveBeenCalledWith({chainId:e.chainId,address:e.address,challenge:e.challenge,types:["wallet","exchange"],sources:["coingecko","1inch"]}),expect(s).toEqual({type:o.TRUSTED_NAME,payload:l})}),it("should preserve error message from trusted name data source",async()=>{const a=new Error("Network timeout error");vi.spyOn(t,"getTrustedNamePayload").mockResolvedValue(r(a));const s=await d.loadField(e);expect(s).toEqual({type:o.ERROR,error:a})}),it("should handle empty trusted name payload",async()=>{const a="";vi.spyOn(t,"getTrustedNamePayload").mockResolvedValue(c(a));const s=await d.loadField(e);expect(s).toEqual({type:o.TRUSTED_NAME,payload:a})}),it("should handle empty types and sources arrays",async()=>{const a={...e,types:[],sources:[]};vi.spyOn(t,"getTrustedNamePayload").mockResolvedValue(c(l));const s=await d.loadField(a);expect(t.getTrustedNamePayload).toHaveBeenCalledWith({chainId:e.chainId,address:e.address,challenge:e.challenge,types:[],sources:[]}),expect(s).toEqual({type:o.TRUSTED_NAME,payload:l})}),it("should handle single type and source",async()=>{const a={...e,types:["contract"],sources:["ens"]};vi.spyOn(t,"getTrustedNamePayload").mockResolvedValue(c(l));const s=await d.loadField(a);expect(t.getTrustedNamePayload).toHaveBeenCalledWith({chainId:e.chainId,address:e.address,challenge:e.challenge,types:["contract"],sources:["ens"]}),expect(s).toEqual({type:o.TRUSTED_NAME,payload:l})})})});
2
+ //# sourceMappingURL=TrustedNameContextFieldLoader.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/trusted-name/domain/TrustedNameContextFieldLoader.test.ts"],
4
+ "sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { ContextFieldLoaderKind } from \"@/shared/domain/ContextFieldLoader\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\nimport { type TransactionFieldContext } from \"@/shared/model/TransactionFieldContext\";\nimport { type TrustedNameDataSource } from \"@/trusted-name/data/TrustedNameDataSource\";\nimport { TrustedNameContextFieldLoader } from \"@/trusted-name/domain/TrustedNameContextFieldLoader\";\n\ndescribe(\"TrustedNameContextFieldLoader\", () => {\n const mockTrustedNameDataSource: TrustedNameDataSource = {\n getTrustedNamePayload: vi.fn(),\n getDomainNamePayload: vi.fn(),\n };\n const trustedNameContextFieldLoader = new TrustedNameContextFieldLoader(\n mockTrustedNameDataSource,\n );\n\n const mockTransactionField: TransactionFieldContext<ContextFieldLoaderKind.TRUSTED_NAME> =\n {\n kind: ContextFieldLoaderKind.TRUSTED_NAME,\n chainId: 1,\n address: \"0x1234567890abcdef\",\n challenge: \"test-challenge\",\n types: [\"contract\", \"token\"],\n sources: [\"ledger\", \"ens\"],\n };\n\n const mockTrustedNamePayload = \"0x123456789abcdef0\";\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"canHandle\", () => {\n it(\"should return true for valid trusted name field\", () => {\n // GIVEN\n const validField = {\n kind: ContextFieldLoaderKind.TRUSTED_NAME,\n chainId: 1,\n address: \"0x1234567890abcdef\",\n challenge: \"test-challenge\",\n types: [\"contract\", \"token\"],\n sources: [\"ledger\", \"ens\"],\n };\n\n // THEN\n expect(trustedNameContextFieldLoader.canHandle(validField)).toBe(true);\n });\n\n describe(\"should return false for invalid fields\", () => {\n const invalidFields = [\n { name: \"null\", value: null },\n { name: \"undefined\", value: undefined },\n { name: \"string\", value: \"invalid\" },\n { name: \"number\", value: 123 },\n { name: \"boolean\", value: true },\n { name: \"array\", value: [] },\n { name: \"empty object\", value: {} },\n {\n name: \"object missing kind\",\n value: {\n chainId: 1,\n address: \"0x123\",\n challenge: \"test\",\n types: [\"contract\"],\n sources: [\"ledger\"],\n },\n },\n {\n name: \"object missing chainId\",\n value: {\n kind: ContextFieldLoaderKind.TRUSTED_NAME,\n address: \"0x123\",\n challenge: \"test\",\n types: [\"contract\"],\n sources: [\"ledger\"],\n },\n },\n {\n name: \"object missing address\",\n value: {\n kind: ContextFieldLoaderKind.TRUSTED_NAME,\n chainId: 1,\n challenge: \"test\",\n types: [\"contract\"],\n sources: [\"ledger\"],\n },\n },\n {\n name: \"object missing challenge\",\n value: {\n kind: ContextFieldLoaderKind.TRUSTED_NAME,\n chainId: 1,\n address: \"0x123\",\n types: [\"contract\"],\n sources: [\"ledger\"],\n },\n },\n {\n name: \"object missing types\",\n value: {\n kind: ContextFieldLoaderKind.TRUSTED_NAME,\n chainId: 1,\n address: \"0x123\",\n challenge: \"test\",\n sources: [\"ledger\"],\n },\n },\n {\n name: \"object missing sources\",\n value: {\n kind: ContextFieldLoaderKind.TRUSTED_NAME,\n chainId: 1,\n address: \"0x123\",\n challenge: \"test\",\n types: [\"contract\"],\n },\n },\n {\n name: \"object with wrong kind\",\n value: {\n kind: ContextFieldLoaderKind.TOKEN,\n chainId: 1,\n address: \"0x123\",\n challenge: \"test\",\n types: [\"contract\"],\n sources: [\"ledger\"],\n },\n },\n ];\n\n test.each(invalidFields)(\"$name\", ({ value }) => {\n expect(trustedNameContextFieldLoader.canHandle(value)).toBe(false);\n });\n });\n });\n\n describe(\"loadField\", () => {\n it(\"should return error context when trusted name data source fails\", async () => {\n // GIVEN\n const error = new Error(\"Trusted name data source error\");\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Left(error));\n\n // WHEN\n const result =\n await trustedNameContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: mockTransactionField.chainId,\n address: mockTransactionField.address,\n challenge: mockTransactionField.challenge,\n types: mockTransactionField.types,\n sources: mockTransactionField.sources,\n });\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: error,\n });\n });\n\n it(\"should return trusted name context when successful\", async () => {\n // GIVEN\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(mockTrustedNamePayload));\n\n // WHEN\n const result =\n await trustedNameContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: mockTransactionField.chainId,\n address: mockTransactionField.address,\n challenge: mockTransactionField.challenge,\n types: mockTransactionField.types,\n sources: mockTransactionField.sources,\n });\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: mockTrustedNamePayload,\n });\n });\n\n it(\"should handle different chain IDs and addresses correctly\", async () => {\n // GIVEN\n const customField = {\n ...mockTransactionField,\n chainId: 137,\n address: \"0xdeadbeef\",\n challenge: \"custom-challenge\",\n };\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(mockTrustedNamePayload));\n\n // WHEN\n const result = await trustedNameContextFieldLoader.loadField(customField);\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: 137,\n address: \"0xdeadbeef\",\n challenge: \"custom-challenge\",\n types: mockTransactionField.types,\n sources: mockTransactionField.sources,\n });\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: mockTrustedNamePayload,\n });\n });\n\n it(\"should handle different types and sources correctly\", async () => {\n // GIVEN\n const customField = {\n ...mockTransactionField,\n types: [\"wallet\", \"exchange\"],\n sources: [\"coingecko\", \"1inch\"],\n };\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(mockTrustedNamePayload));\n\n // WHEN\n const result = await trustedNameContextFieldLoader.loadField(customField);\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: mockTransactionField.chainId,\n address: mockTransactionField.address,\n challenge: mockTransactionField.challenge,\n types: [\"wallet\", \"exchange\"],\n sources: [\"coingecko\", \"1inch\"],\n });\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: mockTrustedNamePayload,\n });\n });\n\n it(\"should preserve error message from trusted name data source\", async () => {\n // GIVEN\n const specificError = new Error(\"Network timeout error\");\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Left(specificError));\n\n // WHEN\n const result =\n await trustedNameContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: specificError,\n });\n });\n\n it(\"should handle empty trusted name payload\", async () => {\n // GIVEN\n const emptyPayload = \"\";\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(emptyPayload));\n\n // WHEN\n const result =\n await trustedNameContextFieldLoader.loadField(mockTransactionField);\n\n // THEN\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: emptyPayload,\n });\n });\n\n it(\"should handle empty types and sources arrays\", async () => {\n // GIVEN\n const fieldWithEmptyArrays = {\n ...mockTransactionField,\n types: [],\n sources: [],\n };\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(mockTrustedNamePayload));\n\n // WHEN\n const result =\n await trustedNameContextFieldLoader.loadField(fieldWithEmptyArrays);\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: mockTransactionField.chainId,\n address: mockTransactionField.address,\n challenge: mockTransactionField.challenge,\n types: [],\n sources: [],\n });\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: mockTrustedNamePayload,\n });\n });\n\n it(\"should handle single type and source\", async () => {\n // GIVEN\n const fieldWithSingleElements = {\n ...mockTransactionField,\n types: [\"contract\"],\n sources: [\"ens\"],\n };\n vi.spyOn(\n mockTrustedNameDataSource,\n \"getTrustedNamePayload\",\n ).mockResolvedValue(Right(mockTrustedNamePayload));\n\n // WHEN\n const result = await trustedNameContextFieldLoader.loadField(\n fieldWithSingleElements,\n );\n\n // THEN\n expect(\n mockTrustedNameDataSource.getTrustedNamePayload,\n ).toHaveBeenCalledWith({\n chainId: mockTransactionField.chainId,\n address: mockTransactionField.address,\n challenge: mockTransactionField.challenge,\n types: [\"contract\"],\n sources: [\"ens\"],\n });\n expect(result).toEqual({\n type: ClearSignContextType.TRUSTED_NAME,\n payload: mockTrustedNamePayload,\n });\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAAS,QAAAA,EAAM,SA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B,EACA,GAAG,MACDF,EACA,uBACF,EAAE,kBAAkBJ,EAAMO,CAAsB,CAAC,EAGjD,MAAMK,EAAS,MAAMP,EAA8B,UACjDY,CACF,EAGA,OACEb,EAA0B,qBAC5B,EAAE,qBAAqB,CACrB,QAASE,EAAqB,QAC9B,QAASA,EAAqB,QAC9B,UAAWA,EAAqB,UAChC,MAAO,CAAC,UAAU,EAClB,QAAS,CAAC,KAAK,CACjB,CAAC,EACD,OAAOM,CAAM,EAAE,QAAQ,CACrB,KAAMV,EAAqB,aAC3B,QAASK,CACX,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["Left", "Right", "ContextFieldLoaderKind", "ClearSignContextType", "TrustedNameContextFieldLoader", "mockTrustedNameDataSource", "trustedNameContextFieldLoader", "mockTransactionField", "mockTrustedNamePayload", "validField", "invalidFields", "value", "error", "result", "customField", "specificError", "emptyPayload", "fieldWithEmptyArrays", "fieldWithSingleElements"]
7
+ }
@@ -1,2 +1,2 @@
1
- var y=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var d=(p,e,t,i)=>{for(var n=i>1?void 0:i?g(e,t):e,r=p.length-1,s;r>=0;r--)(s=p[r])&&(n=(i?s(e,t,n):s(n))||n);return i&&n&&y(e,t,n),n},m=(p,e)=>(t,i)=>e(t,i,p);import h from"axios";import C from"crypto-js/sha224";import{inject as _,injectable as I}from"inversify";import{Left as l,Right as F}from"purify-ts";import{configTypes as M}from"../../config/di/configTypes";import{LEDGER_CLIENT_VERSION_HEADER as D,LEDGER_ORIGIN_TOKEN_HEADER as T}from"../../shared/constant/HttpHeaders";import x from"../../../package.json";let f=class{constructor(e){this.config=e}async getTypedDataFilters({chainId:e,address:t,schema:i,version:n}){let r;try{const s=await h.request({method:"GET",url:`${this.config.cal.url}/dapps`,params:{contracts:t,chain_id:e,output:"descriptors_eip712",descriptors_eip712_version:n,descriptors_eip712:"<set>",ref:`branch:${this.config.cal.branch}`},headers:{[D]:`context-module/${x.version}`,[T]:this.config.originToken}}),a=C(JSON.stringify(this.sortTypes(i)).replace(" ","")).toString();t=t.toLowerCase();const u=s.data?.[0]?.descriptors_eip712?.[t]?.[a];if(!u)return l(new Error(`[ContextModule] HttpTypedDataDataSource: no typed data filters for address ${t} on chain ${e} for schema ${a}`));if(!u.schema||!Array.isArray(u.instructions))return l(new Error(`[ContextModule] HttpTypedDataDataSource: no message info for address ${t} on chain ${e} for schema ${a}`));const c=[];for(const o of u.instructions)if(this.isInstructionContractInfo(o,this.config.cal.mode))r={displayName:o.display_name,signature:o.signatures[this.config.cal.mode],filtersCount:o.field_mappers_count};else if(n==="v1"&&this.isInstructionFieldV1(o,this.config.cal.mode))c.push({type:"raw",displayName:o.display_name,path:o.field_path,signature:o.signatures[this.config.cal.mode]});else if(this.isInstructionFieldV2(o,this.config.cal.mode))c.push({type:o.format,displayName:o.display_name,path:o.field_path,signature:o.signatures[this.config.cal.mode]});else if(this.isInstructionFieldV2WithCoinRef(o,this.config.cal.mode))c.push({type:o.format,displayName:o.display_name,path:o.field_path,signature:o.signatures[this.config.cal.mode],tokenIndex:o.coin_ref});else if(this.isInstructionFieldV2WithName(o,this.config.cal.mode))c.push({type:o.format,displayName:o.display_name,path:o.field_path,signature:o.signatures[this.config.cal.mode],types:o.name_types,sources:o.name_sources,typesAndSourcesPayload:this.formatTrustedNameTypesAndSources(o)});else return l(new Error(`[ContextModule] HttpTypedDataDataSource: invalid typed data field for address ${t} on chain ${e} for schema ${a}`));return r?F({messageInfo:r,filters:c}):l(new Error(`[ContextModule] HttpTypedDataDataSource: no message info for address ${t} on chain ${e} for schema ${a}`))}catch{return l(new Error("[ContextModule] HttpTypedDataDataSource: Failed to fetch typed data informations"))}}formatTrustedNameTypesAndSources(e){const t=e.name_types.length,i=e.name_sources.length,n=e.descriptor.slice((t+i)*2*-1,i*2*-1),r=e.descriptor.slice(i*2*-1),s=t.toString(16).padStart(2,"0"),a=i.toString(16).padStart(2,"0");return s+n+a+r}isInstructionFieldV1(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"}isInstructionFieldV2(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"&&typeof e.format=="string"&&["raw","datetime"].includes(e.format)&&e.coin_ref===void 0}isInstructionFieldV2WithCoinRef(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"&&typeof e.format=="string"&&["token","amount"].includes(e.format)&&typeof e.coin_ref=="number"}isInstructionFieldV2WithName(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"&&typeof e.format=="string"&&e.format==="trusted-name"&&e.coin_ref===void 0&&Array.isArray(e.name_types)&&Array.isArray(e.name_sources)&&e.name_types.every(i=>typeof i=="string")&&e.name_sources.every(i=>typeof i=="string")}isInstructionContractInfo(e,t){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_mappers_count=="number"&&typeof e.signatures=="object"&&typeof e.signatures[t]=="string"&&e.field_path===void 0}sortTypes(e){return Object.fromEntries(Object.entries(e).sort(([t],[i])=>t.localeCompare(i)).map(([t,i])=>[t,i.map(n=>({name:n.name,type:n.type}))]))}};f=d([I(),m(0,_(M.Config))],f);export{f as HttpTypedDataDataSource};
1
+ var _=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var m=(c,e,n,i)=>{for(var o=i>1?void 0:i?h(e,n):e,r=c.length-1,s;r>=0;r--)(s=c[r])&&(o=(i?s(e,n,o):s(o))||o);return i&&o&&_(e,n,o),o},g=(c,e)=>(n,i)=>e(n,i,c);import C from"axios";import I from"crypto-js/sha224";import{inject as F,injectable as x}from"inversify";import{Left as p,Right as M}from"purify-ts";import{configTypes as D}from"../../config/di/configTypes";import{LEDGER_CLIENT_VERSION_HEADER as T,LEDGER_ORIGIN_TOKEN_HEADER as b}from"../../shared/constant/HttpHeaders";import{TypedDataCalldataParamPresence as u}from"../../shared/model/TypedDataClearSignContext";import v from"../../../package.json";let d=class{constructor(e){this.config=e}async getTypedDataFilters({chainId:e,address:n,schema:i,version:o}){let r;try{const s=await C.request({method:"GET",url:`${this.config.cal.url}/dapps`,params:{contracts:n,chain_id:e,output:"descriptors_eip712",descriptors_eip712_version:o,descriptors_eip712:"<set>",ref:"commit:cdd7d0f9cec33eb969a12641810cc7b06efeec1c"},headers:{[T]:`context-module/${v.version}`,[b]:this.config.originToken}}),a=I(JSON.stringify(this.sortTypes(i)).replace(" ","")).toString();n=n.toLowerCase();const f=s.data?.[0]?.descriptors_eip712?.[n]?.[a];if(!f)return p(new Error(`[ContextModule] HttpTypedDataDataSource: no typed data filters for address ${n} on chain ${e} for schema ${a}`));if(!f.schema||!Array.isArray(f.instructions))return p(new Error(`[ContextModule] HttpTypedDataDataSource: no message info for address ${n} on chain ${e} for schema ${a}`));const l=[],y={};for(const t of f.instructions)if(this.isInstructionContractInfo(t,this.config.cal.mode))r={displayName:t.display_name,signature:t.signatures[this.config.cal.mode],filtersCount:t.field_mappers_count};else if(o==="v1"&&this.isInstructionFieldV1(t,this.config.cal.mode))l.push({type:"raw",displayName:t.display_name,path:t.field_path,signature:t.signatures[this.config.cal.mode]});else if(this.isInstructionFieldV2(t,this.config.cal.mode))l.push({type:t.format,displayName:t.display_name,path:t.field_path,signature:t.signatures[this.config.cal.mode]});else if(this.isInstructionFieldV2WithCoinRef(t,this.config.cal.mode))l.push({type:t.format,displayName:t.display_name,path:t.field_path,signature:t.signatures[this.config.cal.mode],tokenIndex:t.coin_ref});else if(this.isInstructionFieldV2WithName(t,this.config.cal.mode))l.push({type:t.format,displayName:t.display_name,path:t.field_path,signature:t.signatures[this.config.cal.mode],types:t.name_types,sources:t.name_sources,typesAndSourcesPayload:this.formatTrustedNameTypesAndSources(t)});else if(this.isInstructionCalldataInfo(t,this.config.cal.mode))y[t.calldata_index]={displayName:t.display_name,calldataIndex:t.calldata_index,valueFlag:t.value_filter_flag,calleeFlag:this.convertCalldataPresenceFlag(t.callee_filter_flag),amountFlag:t.amount_filter_flag,spenderFlag:this.convertCalldataPresenceFlag(t.spender_filter_flag),chainIdFlag:t.chain_id_filter_flag,selectorFlag:t.selector_filter_flag,signature:t.signatures[this.config.cal.mode]};else if(this.isInstructionFieldV2Calldata(t,this.config.cal.mode))l.push({type:t.format,displayName:t.display_name,path:t.field_path,signature:t.signatures[this.config.cal.mode],calldataIndex:t.calldata_index});else return p(new Error(`[ContextModule] HttpTypedDataDataSource: invalid typed data field for address ${n} on chain ${e} for schema ${a}`));return r?M({messageInfo:r,filters:l,calldatasInfos:y}):p(new Error(`[ContextModule] HttpTypedDataDataSource: no message info for address ${n} on chain ${e} for schema ${a}`))}catch{return p(new Error("[ContextModule] HttpTypedDataDataSource: Failed to fetch typed data informations"))}}convertCalldataPresenceFlag(e){switch(e){case"none":return u.None;case"present":return u.Present;case"verifying_contract":return u.VerifyingContract;default:{const n=e;throw new Error(`Unhandled flag: ${n}`)}}}formatTrustedNameTypesAndSources(e){const n=e.name_types.length,i=e.name_sources.length,o=e.descriptor.slice((n+i)*2*-1,i*2*-1),r=e.descriptor.slice(i*2*-1),s=n.toString(16).padStart(2,"0"),a=i.toString(16).padStart(2,"0");return s+o+a+r}isInstructionFieldV1(e,n){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[n]=="string"}isInstructionFieldV2(e,n){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[n]=="string"&&typeof e.format=="string"&&["raw","datetime"].includes(e.format)&&e.coin_ref===void 0}isInstructionFieldV2WithCoinRef(e,n){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[n]=="string"&&typeof e.format=="string"&&["token","amount"].includes(e.format)&&typeof e.coin_ref=="number"}isInstructionFieldV2WithName(e,n){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[n]=="string"&&typeof e.format=="string"&&e.format==="trusted-name"&&e.coin_ref===void 0&&Array.isArray(e.name_types)&&Array.isArray(e.name_sources)&&e.name_types.every(i=>typeof i=="string")&&e.name_sources.every(i=>typeof i=="string")}isInstructionContractInfo(e,n){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_mappers_count=="number"&&typeof e.signatures=="object"&&typeof e.signatures[n]=="string"&&e.field_path===void 0}isInstructionCalldataInfo(e,n){return typeof e=="object"&&typeof e.type=="string"&&e.type==="calldata"&&typeof e.display_name=="string"&&typeof e.calldata_index=="number"&&typeof e.value_filter_flag=="boolean"&&typeof e.chain_id_filter_flag=="boolean"&&typeof e.selector_filter_flag=="boolean"&&typeof e.amount_filter_flag=="boolean"&&["none","present","verifying_contract"].includes(e.callee_filter_flag)&&["none","present","verifying_contract"].includes(e.spender_filter_flag)&&typeof e.signatures=="object"&&typeof e.signatures[n]=="string"}isInstructionFieldV2Calldata(e,n){return typeof e=="object"&&typeof e.display_name=="string"&&typeof e.field_path=="string"&&typeof e.signatures=="object"&&typeof e.signatures[n]=="string"&&typeof e.format=="string"&&["calldata-value","calldata-callee","calldata-chain-id","calldata-selector","calldata-amount","calldata-spender"].includes(e.format)&&typeof e.calldata_index=="number"}sortTypes(e){return Object.fromEntries(Object.entries(e).sort(([n],[i])=>n.localeCompare(i)).map(([n,i])=>[n,i.map(o=>({name:o.name,type:o.type}))]))}};d=m([x(),g(0,F(D.Config))],d);export{d as HttpTypedDataDataSource};
2
2
  //# sourceMappingURL=HttpTypedDataDataSource.js.map