@ledgerhq/live-common 34.54.0 → 34.55.0-nightly.20251210100832

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 (617) hide show
  1. package/lib/__tests__/test-helpers/bridge.js +1 -1
  2. package/lib/__tests__/test-helpers/bridge.js.map +1 -1
  3. package/lib/__tests__/test-helpers/environment.js +3 -0
  4. package/lib/__tests__/test-helpers/environment.js.map +1 -1
  5. package/lib/account/index.d.ts +1 -0
  6. package/lib/account/index.d.ts.map +1 -1
  7. package/lib/account/index.js +4 -1
  8. package/lib/account/index.js.map +1 -1
  9. package/lib/account/recentAddresses.d.ts +10 -0
  10. package/lib/account/recentAddresses.d.ts.map +1 -0
  11. package/lib/account/recentAddresses.js +60 -0
  12. package/lib/account/recentAddresses.js.map +1 -0
  13. package/lib/account/serialization.js +1 -1
  14. package/lib/account/serialization.js.map +1 -1
  15. package/lib/account/support.js +1 -1
  16. package/lib/account/support.js.map +1 -1
  17. package/lib/bridge/generic-alpaca/accountBridge.d.ts +1 -1
  18. package/lib/bridge/generic-alpaca/accountBridge.d.ts.map +1 -1
  19. package/lib/bridge/generic-alpaca/accountBridge.js +2 -1
  20. package/lib/bridge/generic-alpaca/accountBridge.js.map +1 -1
  21. package/lib/bridge/generic-alpaca/broadcast.d.ts.map +1 -1
  22. package/lib/bridge/generic-alpaca/broadcast.js +3 -3
  23. package/lib/bridge/generic-alpaca/broadcast.js.map +1 -1
  24. package/lib/bridge/generic-alpaca/currencyBridge.d.ts.map +1 -1
  25. package/lib/bridge/generic-alpaca/currencyBridge.js +3 -3
  26. package/lib/bridge/generic-alpaca/currencyBridge.js.map +1 -1
  27. package/lib/bridge/generic-alpaca/estimateMaxSpendable.d.ts.map +1 -1
  28. package/lib/bridge/generic-alpaca/estimateMaxSpendable.js +2 -1
  29. package/lib/bridge/generic-alpaca/estimateMaxSpendable.js.map +1 -1
  30. package/lib/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
  31. package/lib/bridge/generic-alpaca/getAccountShape.js +24 -8
  32. package/lib/bridge/generic-alpaca/getAccountShape.js.map +1 -1
  33. package/lib/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
  34. package/lib/bridge/generic-alpaca/getTransactionStatus.js +16 -1
  35. package/lib/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
  36. package/lib/bridge/generic-alpaca/postSync.d.ts +16 -0
  37. package/lib/bridge/generic-alpaca/postSync.d.ts.map +1 -0
  38. package/lib/bridge/generic-alpaca/postSync.js +44 -0
  39. package/lib/bridge/generic-alpaca/postSync.js.map +1 -0
  40. package/lib/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
  41. package/lib/bridge/generic-alpaca/prepareTransaction.js +45 -4
  42. package/lib/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
  43. package/lib/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
  44. package/lib/bridge/generic-alpaca/signOperation.js +18 -2
  45. package/lib/bridge/generic-alpaca/signOperation.js.map +1 -1
  46. package/lib/bridge/generic-alpaca/signer/Eth.d.ts +2 -0
  47. package/lib/bridge/generic-alpaca/signer/Eth.d.ts.map +1 -1
  48. package/lib/bridge/generic-alpaca/signer/Eth.js +8 -1
  49. package/lib/bridge/generic-alpaca/signer/Eth.js.map +1 -1
  50. package/lib/bridge/generic-alpaca/signer/index.d.ts.map +1 -1
  51. package/lib/bridge/generic-alpaca/signer/index.js +7 -0
  52. package/lib/bridge/generic-alpaca/signer/index.js.map +1 -1
  53. package/lib/bridge/generic-alpaca/types.d.ts +4 -0
  54. package/lib/bridge/generic-alpaca/types.d.ts.map +1 -1
  55. package/lib/bridge/generic-alpaca/utils.d.ts.map +1 -1
  56. package/lib/bridge/generic-alpaca/utils.js +12 -3
  57. package/lib/bridge/generic-alpaca/utils.js.map +1 -1
  58. package/lib/bridge/impl.d.ts.map +1 -1
  59. package/lib/bridge/impl.js +14 -3
  60. package/lib/bridge/impl.js.map +1 -1
  61. package/lib/currencies/helpers.d.ts +1 -0
  62. package/lib/currencies/helpers.d.ts.map +1 -1
  63. package/lib/currencies/helpers.js +7 -1
  64. package/lib/currencies/helpers.js.map +1 -1
  65. package/lib/domain/getTokensWithFunds.d.ts +7 -1
  66. package/lib/domain/getTokensWithFunds.d.ts.map +1 -1
  67. package/lib/domain/getTokensWithFunds.js +15 -4
  68. package/lib/domain/getTokensWithFunds.js.map +1 -1
  69. package/lib/domain/getTotalStakeableAssets.d.ts +10 -0
  70. package/lib/domain/getTotalStakeableAssets.d.ts.map +1 -0
  71. package/lib/domain/getTotalStakeableAssets.js +35 -0
  72. package/lib/domain/getTotalStakeableAssets.js.map +1 -0
  73. package/lib/e2e/data/deviceLabelsData.d.ts.map +1 -1
  74. package/lib/e2e/data/deviceLabelsData.js +1 -0
  75. package/lib/e2e/data/deviceLabelsData.js.map +1 -1
  76. package/lib/e2e/data/regexes.d.ts +2 -0
  77. package/lib/e2e/data/regexes.d.ts.map +1 -0
  78. package/lib/e2e/data/regexes.js +5 -0
  79. package/lib/e2e/data/regexes.js.map +1 -0
  80. package/lib/e2e/enum/Device.d.ts +1 -0
  81. package/lib/e2e/enum/Device.d.ts.map +1 -1
  82. package/lib/e2e/enum/Device.js +1 -0
  83. package/lib/e2e/enum/Device.js.map +1 -1
  84. package/lib/e2e/families/cardano.d.ts.map +1 -1
  85. package/lib/e2e/families/cardano.js +29 -14
  86. package/lib/e2e/families/cardano.js.map +1 -1
  87. package/lib/e2e/index.d.ts +35 -3
  88. package/lib/e2e/index.d.ts.map +1 -1
  89. package/lib/e2e/index.js +21 -1
  90. package/lib/e2e/index.js.map +1 -1
  91. package/lib/e2e/speculos.d.ts.map +1 -1
  92. package/lib/e2e/speculos.js +31 -4
  93. package/lib/e2e/speculos.js.map +1 -1
  94. package/lib/e2e/speculosAppVersion.d.ts.map +1 -1
  95. package/lib/e2e/speculosAppVersion.js +6 -2
  96. package/lib/e2e/speculosAppVersion.js.map +1 -1
  97. package/lib/e2e/swap.d.ts.map +1 -1
  98. package/lib/e2e/swap.js +7 -6
  99. package/lib/e2e/swap.js.map +1 -1
  100. package/lib/env.react.d.ts +1 -1
  101. package/lib/env.react.d.ts.map +1 -1
  102. package/lib/exchange/swap/api/v5/fetchCurrencyFrom.js +1 -1
  103. package/lib/exchange/swap/api/v5/fetchCurrencyFrom.js.map +1 -1
  104. package/lib/exchange/swap/getIncompatibleCurrencyKeys.d.ts.map +1 -1
  105. package/lib/exchange/swap/getIncompatibleCurrencyKeys.js +4 -0
  106. package/lib/exchange/swap/getIncompatibleCurrencyKeys.js.map +1 -1
  107. package/lib/exchange/swap/postSwapState.d.ts.map +1 -1
  108. package/lib/exchange/swap/postSwapState.js +10 -6
  109. package/lib/exchange/swap/postSwapState.js.map +1 -1
  110. package/lib/exchange/swap/transactionStrategies.d.ts +3 -2
  111. package/lib/exchange/swap/transactionStrategies.d.ts.map +1 -1
  112. package/lib/exchange/swap/transactionStrategies.js +26 -7
  113. package/lib/exchange/swap/transactionStrategies.js.map +1 -1
  114. package/lib/exchange/swap/types.d.ts +3 -1
  115. package/lib/exchange/swap/types.d.ts.map +1 -1
  116. package/lib/families/bitcoin/walletApiAdapter.d.ts.map +1 -1
  117. package/lib/families/bitcoin/walletApiAdapter.js +3 -0
  118. package/lib/families/bitcoin/walletApiAdapter.js.map +1 -1
  119. package/lib/families/canton/config.d.ts.map +1 -1
  120. package/lib/families/canton/config.js +4 -4
  121. package/lib/families/canton/config.js.map +1 -1
  122. package/lib/families/canton/react.d.ts +2 -0
  123. package/lib/families/canton/react.d.ts.map +1 -1
  124. package/lib/families/canton/react.js +40 -1
  125. package/lib/families/canton/react.js.map +1 -1
  126. package/lib/families/celo/setup.d.ts.map +1 -1
  127. package/lib/families/celo/setup.js +11 -0
  128. package/lib/families/celo/setup.js.map +1 -1
  129. package/lib/families/evm/bridge/mock.d.ts +1 -0
  130. package/lib/families/evm/bridge/mock.d.ts.map +1 -1
  131. package/lib/families/evm/bridge/mock.js +12 -0
  132. package/lib/families/evm/bridge/mock.js.map +1 -1
  133. package/lib/families/evm/setup.d.ts +1 -4
  134. package/lib/families/evm/setup.d.ts.map +1 -1
  135. package/lib/families/evm/setup.js +1 -8
  136. package/lib/families/evm/setup.js.map +1 -1
  137. package/lib/families/evm/walletApiAdapter.d.ts +7 -0
  138. package/lib/families/evm/walletApiAdapter.d.ts.map +1 -1
  139. package/lib/families/evm/walletApiAdapter.js +36 -2
  140. package/lib/families/evm/walletApiAdapter.js.map +1 -1
  141. package/lib/families/hedera/react.d.ts +6 -0
  142. package/lib/families/hedera/react.d.ts.map +1 -0
  143. package/lib/families/hedera/react.js +50 -0
  144. package/lib/families/hedera/react.js.map +1 -0
  145. package/lib/families/polkadot/config.js +1 -1
  146. package/lib/families/polkadot/config.js.map +1 -1
  147. package/lib/families/stacks/constants.d.ts +1 -1
  148. package/lib/families/stacks/constants.d.ts.map +1 -1
  149. package/lib/families/stacks/constants.js +1 -1
  150. package/lib/families/stacks/constants.js.map +1 -1
  151. package/lib/featureFlags/defaultFeatures.d.ts +2 -0
  152. package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
  153. package/lib/featureFlags/defaultFeatures.js +22 -1
  154. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  155. package/lib/featureFlags/firebaseFeatureFlags.js +1 -1
  156. package/lib/featureFlags/firebaseFeatureFlags.js.map +1 -1
  157. package/lib/featureFlags/stakePrograms/index.js +4 -4
  158. package/lib/featureFlags/stakePrograms/index.js.map +1 -1
  159. package/lib/featureFlags/useFeature.d.ts +1 -1
  160. package/lib/featureFlags/useFeature.d.ts.map +1 -1
  161. package/lib/featureFlags/useHasOverriddenFeatureFlags.js +1 -1
  162. package/lib/featureFlags/useHasOverriddenFeatureFlags.js.map +1 -1
  163. package/lib/generated/bridge/js.d.ts +0 -1
  164. package/lib/generated/bridge/js.d.ts.map +1 -1
  165. package/lib/generated/bridge/js.js +30 -32
  166. package/lib/generated/bridge/js.js.map +1 -1
  167. package/lib/generated/bridge/mock.d.ts +1 -0
  168. package/lib/generated/bridge/mock.d.ts.map +1 -1
  169. package/lib/helpers/cryptoIconSize.d.ts +3 -0
  170. package/lib/helpers/cryptoIconSize.d.ts.map +1 -0
  171. package/lib/helpers/cryptoIconSize.js +40 -0
  172. package/lib/helpers/cryptoIconSize.js.map +1 -0
  173. package/lib/helpers.d.ts +1 -0
  174. package/lib/helpers.d.ts.map +1 -1
  175. package/lib/helpers.js +15 -0
  176. package/lib/helpers.js.map +1 -1
  177. package/lib/hooks/useHtmlLinkSegments.d.ts +19 -0
  178. package/lib/hooks/useHtmlLinkSegments.d.ts.map +1 -0
  179. package/lib/hooks/useHtmlLinkSegments.js +128 -0
  180. package/lib/hooks/useHtmlLinkSegments.js.map +1 -0
  181. package/lib/hw/getAppAndVersion.d.ts +3 -1
  182. package/lib/hw/getAppAndVersion.d.ts.map +1 -1
  183. package/lib/hw/getAppAndVersion.js +2 -2
  184. package/lib/hw/getAppAndVersion.js.map +1 -1
  185. package/lib/hw/getBitcoinLikeInfo.js +1 -1
  186. package/lib/hw/getBitcoinLikeInfo.js.map +1 -1
  187. package/lib/load/speculos.d.ts.map +1 -1
  188. package/lib/load/speculos.js +1 -0
  189. package/lib/load/speculos.js.map +1 -1
  190. package/lib/mock/account.js +1 -1
  191. package/lib/mock/account.js.map +1 -1
  192. package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.d.ts.map +1 -1
  193. package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js +6 -0
  194. package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js.map +1 -1
  195. package/lib/operation.d.ts.map +1 -1
  196. package/lib/operation.js +7 -2
  197. package/lib/operation.js.map +1 -1
  198. package/lib/postOnboarding/reducer.d.ts +2 -0
  199. package/lib/postOnboarding/reducer.d.ts.map +1 -1
  200. package/lib/wallet-api/Exchange/SwapError.d.ts +93 -0
  201. package/lib/wallet-api/Exchange/SwapError.d.ts.map +1 -0
  202. package/lib/wallet-api/Exchange/SwapError.js +142 -0
  203. package/lib/wallet-api/Exchange/SwapError.js.map +1 -0
  204. package/lib/wallet-api/Exchange/handleSwapErrors.d.ts +40 -0
  205. package/lib/wallet-api/Exchange/handleSwapErrors.d.ts.map +1 -0
  206. package/lib/wallet-api/Exchange/handleSwapErrors.js +112 -0
  207. package/lib/wallet-api/Exchange/handleSwapErrors.js.map +1 -0
  208. package/lib/wallet-api/Exchange/index.d.ts +4 -0
  209. package/lib/wallet-api/Exchange/index.d.ts.map +1 -0
  210. package/lib/wallet-api/Exchange/index.js +27 -0
  211. package/lib/wallet-api/Exchange/index.js.map +1 -0
  212. package/lib/wallet-api/Exchange/parser.d.ts +46 -0
  213. package/lib/wallet-api/Exchange/parser.d.ts.map +1 -0
  214. package/lib/wallet-api/Exchange/parser.js +97 -0
  215. package/lib/wallet-api/Exchange/parser.js.map +1 -0
  216. package/lib/wallet-api/Exchange/server.d.ts.map +1 -1
  217. package/lib/wallet-api/Exchange/server.js +227 -174
  218. package/lib/wallet-api/Exchange/server.js.map +1 -1
  219. package/lib/wallet-api/Exchange/tracking.d.ts +7 -6
  220. package/lib/wallet-api/Exchange/tracking.d.ts.map +1 -1
  221. package/lib/wallet-api/Exchange/tracking.js +52 -13
  222. package/lib/wallet-api/Exchange/tracking.js.map +1 -1
  223. package/lib/wallet-api/constants.d.ts +1 -1
  224. package/lib/wallet-api/logic.d.ts +1 -1
  225. package/lib/wallet-api/logic.d.ts.map +1 -1
  226. package/lib/wallet-api/logic.js +5 -5
  227. package/lib/wallet-api/logic.js.map +1 -1
  228. package/lib/wallet-api/react.d.ts.map +1 -1
  229. package/lib/wallet-api/react.js +9 -6
  230. package/lib/wallet-api/react.js.map +1 -1
  231. package/lib/wallet-api/tracking.d.ts +5 -5
  232. package/lib/wallet-api/tracking.d.ts.map +1 -1
  233. package/lib/wallet-api/tracking.js +30 -10
  234. package/lib/wallet-api/tracking.js.map +1 -1
  235. package/lib/wallet-api/useDappLogic.d.ts.map +1 -1
  236. package/lib/wallet-api/useDappLogic.js +31 -20
  237. package/lib/wallet-api/useDappLogic.js.map +1 -1
  238. package/lib/wallet-api/utils/extractDappURLFromManifest.js +3 -3
  239. package/lib/wallet-api/utils/extractDappURLFromManifest.js.map +1 -1
  240. package/lib/wallet-api/utils/extractURLFromManifest.js +1 -1
  241. package/lib/wallet-api/utils/extractURLFromManifest.js.map +1 -1
  242. package/lib/walletSync/getEnvironmentParams.js +6 -6
  243. package/lib/walletSync/getEnvironmentParams.js.map +1 -1
  244. package/lib-es/__tests__/test-helpers/bridge.js +1 -1
  245. package/lib-es/__tests__/test-helpers/bridge.js.map +1 -1
  246. package/lib-es/__tests__/test-helpers/environment.js +3 -0
  247. package/lib-es/__tests__/test-helpers/environment.js.map +1 -1
  248. package/lib-es/account/index.d.ts +1 -0
  249. package/lib-es/account/index.d.ts.map +1 -1
  250. package/lib-es/account/index.js +1 -0
  251. package/lib-es/account/index.js.map +1 -1
  252. package/lib-es/account/recentAddresses.d.ts +10 -0
  253. package/lib-es/account/recentAddresses.d.ts.map +1 -0
  254. package/lib-es/account/recentAddresses.js +55 -0
  255. package/lib-es/account/recentAddresses.js.map +1 -0
  256. package/lib-es/account/serialization.js +1 -1
  257. package/lib-es/account/serialization.js.map +1 -1
  258. package/lib-es/account/support.js +1 -1
  259. package/lib-es/account/support.js.map +1 -1
  260. package/lib-es/bridge/generic-alpaca/accountBridge.d.ts +1 -1
  261. package/lib-es/bridge/generic-alpaca/accountBridge.d.ts.map +1 -1
  262. package/lib-es/bridge/generic-alpaca/accountBridge.js +2 -1
  263. package/lib-es/bridge/generic-alpaca/accountBridge.js.map +1 -1
  264. package/lib-es/bridge/generic-alpaca/broadcast.d.ts.map +1 -1
  265. package/lib-es/bridge/generic-alpaca/broadcast.js +3 -3
  266. package/lib-es/bridge/generic-alpaca/broadcast.js.map +1 -1
  267. package/lib-es/bridge/generic-alpaca/currencyBridge.d.ts.map +1 -1
  268. package/lib-es/bridge/generic-alpaca/currencyBridge.js +3 -3
  269. package/lib-es/bridge/generic-alpaca/currencyBridge.js.map +1 -1
  270. package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.d.ts.map +1 -1
  271. package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js +2 -1
  272. package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js.map +1 -1
  273. package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
  274. package/lib-es/bridge/generic-alpaca/getAccountShape.js +24 -8
  275. package/lib-es/bridge/generic-alpaca/getAccountShape.js.map +1 -1
  276. package/lib-es/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
  277. package/lib-es/bridge/generic-alpaca/getTransactionStatus.js +16 -1
  278. package/lib-es/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
  279. package/lib-es/bridge/generic-alpaca/postSync.d.ts +16 -0
  280. package/lib-es/bridge/generic-alpaca/postSync.d.ts.map +1 -0
  281. package/lib-es/bridge/generic-alpaca/postSync.js +37 -0
  282. package/lib-es/bridge/generic-alpaca/postSync.js.map +1 -0
  283. package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
  284. package/lib-es/bridge/generic-alpaca/prepareTransaction.js +45 -4
  285. package/lib-es/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
  286. package/lib-es/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
  287. package/lib-es/bridge/generic-alpaca/signOperation.js +18 -2
  288. package/lib-es/bridge/generic-alpaca/signOperation.js.map +1 -1
  289. package/lib-es/bridge/generic-alpaca/signer/Eth.d.ts +2 -0
  290. package/lib-es/bridge/generic-alpaca/signer/Eth.d.ts.map +1 -1
  291. package/lib-es/bridge/generic-alpaca/signer/Eth.js +4 -0
  292. package/lib-es/bridge/generic-alpaca/signer/Eth.js.map +1 -1
  293. package/lib-es/bridge/generic-alpaca/signer/index.d.ts.map +1 -1
  294. package/lib-es/bridge/generic-alpaca/signer/index.js +7 -0
  295. package/lib-es/bridge/generic-alpaca/signer/index.js.map +1 -1
  296. package/lib-es/bridge/generic-alpaca/types.d.ts +4 -0
  297. package/lib-es/bridge/generic-alpaca/types.d.ts.map +1 -1
  298. package/lib-es/bridge/generic-alpaca/utils.d.ts.map +1 -1
  299. package/lib-es/bridge/generic-alpaca/utils.js +12 -3
  300. package/lib-es/bridge/generic-alpaca/utils.js.map +1 -1
  301. package/lib-es/bridge/impl.d.ts.map +1 -1
  302. package/lib-es/bridge/impl.js +14 -3
  303. package/lib-es/bridge/impl.js.map +1 -1
  304. package/lib-es/currencies/helpers.d.ts +1 -0
  305. package/lib-es/currencies/helpers.d.ts.map +1 -1
  306. package/lib-es/currencies/helpers.js +5 -0
  307. package/lib-es/currencies/helpers.js.map +1 -1
  308. package/lib-es/domain/getTokensWithFunds.d.ts +7 -1
  309. package/lib-es/domain/getTokensWithFunds.d.ts.map +1 -1
  310. package/lib-es/domain/getTokensWithFunds.js +13 -3
  311. package/lib-es/domain/getTokensWithFunds.js.map +1 -1
  312. package/lib-es/domain/getTotalStakeableAssets.d.ts +10 -0
  313. package/lib-es/domain/getTotalStakeableAssets.d.ts.map +1 -0
  314. package/lib-es/domain/getTotalStakeableAssets.js +31 -0
  315. package/lib-es/domain/getTotalStakeableAssets.js.map +1 -0
  316. package/lib-es/e2e/data/deviceLabelsData.d.ts.map +1 -1
  317. package/lib-es/e2e/data/deviceLabelsData.js +1 -0
  318. package/lib-es/e2e/data/deviceLabelsData.js.map +1 -1
  319. package/lib-es/e2e/data/regexes.d.ts +2 -0
  320. package/lib-es/e2e/data/regexes.d.ts.map +1 -0
  321. package/lib-es/e2e/data/regexes.js +2 -0
  322. package/lib-es/e2e/data/regexes.js.map +1 -0
  323. package/lib-es/e2e/enum/Device.d.ts +1 -0
  324. package/lib-es/e2e/enum/Device.d.ts.map +1 -1
  325. package/lib-es/e2e/enum/Device.js +1 -0
  326. package/lib-es/e2e/enum/Device.js.map +1 -1
  327. package/lib-es/e2e/families/cardano.d.ts.map +1 -1
  328. package/lib-es/e2e/families/cardano.js +29 -14
  329. package/lib-es/e2e/families/cardano.js.map +1 -1
  330. package/lib-es/e2e/index.d.ts +35 -3
  331. package/lib-es/e2e/index.d.ts.map +1 -1
  332. package/lib-es/e2e/index.js +16 -0
  333. package/lib-es/e2e/index.js.map +1 -1
  334. package/lib-es/e2e/speculos.d.ts.map +1 -1
  335. package/lib-es/e2e/speculos.js +31 -4
  336. package/lib-es/e2e/speculos.js.map +1 -1
  337. package/lib-es/e2e/speculosAppVersion.d.ts.map +1 -1
  338. package/lib-es/e2e/speculosAppVersion.js +6 -2
  339. package/lib-es/e2e/speculosAppVersion.js.map +1 -1
  340. package/lib-es/e2e/swap.d.ts.map +1 -1
  341. package/lib-es/e2e/swap.js +7 -6
  342. package/lib-es/e2e/swap.js.map +1 -1
  343. package/lib-es/env.react.d.ts +1 -1
  344. package/lib-es/env.react.d.ts.map +1 -1
  345. package/lib-es/exchange/swap/api/v5/fetchCurrencyFrom.js +1 -1
  346. package/lib-es/exchange/swap/api/v5/fetchCurrencyFrom.js.map +1 -1
  347. package/lib-es/exchange/swap/getIncompatibleCurrencyKeys.d.ts.map +1 -1
  348. package/lib-es/exchange/swap/getIncompatibleCurrencyKeys.js +4 -0
  349. package/lib-es/exchange/swap/getIncompatibleCurrencyKeys.js.map +1 -1
  350. package/lib-es/exchange/swap/postSwapState.d.ts.map +1 -1
  351. package/lib-es/exchange/swap/postSwapState.js +10 -6
  352. package/lib-es/exchange/swap/postSwapState.js.map +1 -1
  353. package/lib-es/exchange/swap/transactionStrategies.d.ts +3 -2
  354. package/lib-es/exchange/swap/transactionStrategies.d.ts.map +1 -1
  355. package/lib-es/exchange/swap/transactionStrategies.js +26 -7
  356. package/lib-es/exchange/swap/transactionStrategies.js.map +1 -1
  357. package/lib-es/exchange/swap/types.d.ts +3 -1
  358. package/lib-es/exchange/swap/types.d.ts.map +1 -1
  359. package/lib-es/families/bitcoin/walletApiAdapter.d.ts.map +1 -1
  360. package/lib-es/families/bitcoin/walletApiAdapter.js +3 -0
  361. package/lib-es/families/bitcoin/walletApiAdapter.js.map +1 -1
  362. package/lib-es/families/canton/config.d.ts.map +1 -1
  363. package/lib-es/families/canton/config.js +4 -4
  364. package/lib-es/families/canton/config.js.map +1 -1
  365. package/lib-es/families/canton/react.d.ts +2 -0
  366. package/lib-es/families/canton/react.d.ts.map +1 -1
  367. package/lib-es/families/canton/react.js +38 -1
  368. package/lib-es/families/canton/react.js.map +1 -1
  369. package/lib-es/families/celo/setup.d.ts.map +1 -1
  370. package/lib-es/families/celo/setup.js +11 -0
  371. package/lib-es/families/celo/setup.js.map +1 -1
  372. package/lib-es/families/evm/bridge/mock.d.ts +1 -0
  373. package/lib-es/families/evm/bridge/mock.d.ts.map +1 -1
  374. package/lib-es/families/evm/bridge/mock.js +12 -0
  375. package/lib-es/families/evm/bridge/mock.js.map +1 -1
  376. package/lib-es/families/evm/setup.d.ts +1 -4
  377. package/lib-es/families/evm/setup.d.ts.map +1 -1
  378. package/lib-es/families/evm/setup.js +2 -8
  379. package/lib-es/families/evm/setup.js.map +1 -1
  380. package/lib-es/families/evm/walletApiAdapter.d.ts +7 -0
  381. package/lib-es/families/evm/walletApiAdapter.d.ts.map +1 -1
  382. package/lib-es/families/evm/walletApiAdapter.js +30 -1
  383. package/lib-es/families/evm/walletApiAdapter.js.map +1 -1
  384. package/lib-es/families/hedera/react.d.ts +6 -0
  385. package/lib-es/families/hedera/react.d.ts.map +1 -0
  386. package/lib-es/families/hedera/react.js +41 -0
  387. package/lib-es/families/hedera/react.js.map +1 -0
  388. package/lib-es/families/polkadot/config.js +1 -1
  389. package/lib-es/families/polkadot/config.js.map +1 -1
  390. package/lib-es/families/stacks/constants.d.ts +1 -1
  391. package/lib-es/families/stacks/constants.d.ts.map +1 -1
  392. package/lib-es/families/stacks/constants.js +1 -1
  393. package/lib-es/families/stacks/constants.js.map +1 -1
  394. package/lib-es/featureFlags/defaultFeatures.d.ts +2 -0
  395. package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
  396. package/lib-es/featureFlags/defaultFeatures.js +22 -1
  397. package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
  398. package/lib-es/featureFlags/firebaseFeatureFlags.js +1 -1
  399. package/lib-es/featureFlags/firebaseFeatureFlags.js.map +1 -1
  400. package/lib-es/featureFlags/stakePrograms/index.js +4 -4
  401. package/lib-es/featureFlags/stakePrograms/index.js.map +1 -1
  402. package/lib-es/featureFlags/useFeature.d.ts +1 -1
  403. package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
  404. package/lib-es/featureFlags/useHasOverriddenFeatureFlags.js +1 -1
  405. package/lib-es/featureFlags/useHasOverriddenFeatureFlags.js.map +1 -1
  406. package/lib-es/generated/bridge/js.d.ts +0 -1
  407. package/lib-es/generated/bridge/js.d.ts.map +1 -1
  408. package/lib-es/generated/bridge/js.js +0 -2
  409. package/lib-es/generated/bridge/js.js.map +1 -1
  410. package/lib-es/generated/bridge/mock.d.ts +1 -0
  411. package/lib-es/generated/bridge/mock.d.ts.map +1 -1
  412. package/lib-es/helpers/cryptoIconSize.d.ts +3 -0
  413. package/lib-es/helpers/cryptoIconSize.d.ts.map +1 -0
  414. package/lib-es/helpers/cryptoIconSize.js +35 -0
  415. package/lib-es/helpers/cryptoIconSize.js.map +1 -0
  416. package/lib-es/helpers.d.ts +1 -0
  417. package/lib-es/helpers.d.ts.map +1 -1
  418. package/lib-es/helpers.js +1 -0
  419. package/lib-es/helpers.js.map +1 -1
  420. package/lib-es/hooks/useHtmlLinkSegments.d.ts +19 -0
  421. package/lib-es/hooks/useHtmlLinkSegments.d.ts.map +1 -0
  422. package/lib-es/hooks/useHtmlLinkSegments.js +121 -0
  423. package/lib-es/hooks/useHtmlLinkSegments.js.map +1 -0
  424. package/lib-es/hw/getAppAndVersion.d.ts +3 -1
  425. package/lib-es/hw/getAppAndVersion.d.ts.map +1 -1
  426. package/lib-es/hw/getAppAndVersion.js +2 -2
  427. package/lib-es/hw/getAppAndVersion.js.map +1 -1
  428. package/lib-es/hw/getBitcoinLikeInfo.js +1 -1
  429. package/lib-es/hw/getBitcoinLikeInfo.js.map +1 -1
  430. package/lib-es/load/speculos.d.ts.map +1 -1
  431. package/lib-es/load/speculos.js +1 -0
  432. package/lib-es/load/speculos.js.map +1 -1
  433. package/lib-es/mock/account.js +1 -1
  434. package/lib-es/mock/account.js.map +1 -1
  435. package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.d.ts.map +1 -1
  436. package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js +6 -0
  437. package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js.map +1 -1
  438. package/lib-es/operation.d.ts.map +1 -1
  439. package/lib-es/operation.js +7 -2
  440. package/lib-es/operation.js.map +1 -1
  441. package/lib-es/postOnboarding/reducer.d.ts +2 -0
  442. package/lib-es/postOnboarding/reducer.d.ts.map +1 -1
  443. package/lib-es/wallet-api/Exchange/SwapError.d.ts +93 -0
  444. package/lib-es/wallet-api/Exchange/SwapError.d.ts.map +1 -0
  445. package/lib-es/wallet-api/Exchange/SwapError.js +128 -0
  446. package/lib-es/wallet-api/Exchange/SwapError.js.map +1 -0
  447. package/lib-es/wallet-api/Exchange/handleSwapErrors.d.ts +40 -0
  448. package/lib-es/wallet-api/Exchange/handleSwapErrors.d.ts.map +1 -0
  449. package/lib-es/wallet-api/Exchange/handleSwapErrors.js +106 -0
  450. package/lib-es/wallet-api/Exchange/handleSwapErrors.js.map +1 -0
  451. package/lib-es/wallet-api/Exchange/index.d.ts +4 -0
  452. package/lib-es/wallet-api/Exchange/index.d.ts.map +1 -0
  453. package/lib-es/wallet-api/Exchange/index.js +7 -0
  454. package/lib-es/wallet-api/Exchange/index.js.map +1 -0
  455. package/lib-es/wallet-api/Exchange/parser.d.ts +46 -0
  456. package/lib-es/wallet-api/Exchange/parser.d.ts.map +1 -0
  457. package/lib-es/wallet-api/Exchange/parser.js +90 -0
  458. package/lib-es/wallet-api/Exchange/parser.js.map +1 -0
  459. package/lib-es/wallet-api/Exchange/server.d.ts.map +1 -1
  460. package/lib-es/wallet-api/Exchange/server.js +224 -174
  461. package/lib-es/wallet-api/Exchange/server.js.map +1 -1
  462. package/lib-es/wallet-api/Exchange/tracking.d.ts +7 -6
  463. package/lib-es/wallet-api/Exchange/tracking.d.ts.map +1 -1
  464. package/lib-es/wallet-api/Exchange/tracking.js +52 -13
  465. package/lib-es/wallet-api/Exchange/tracking.js.map +1 -1
  466. package/lib-es/wallet-api/constants.d.ts +1 -1
  467. package/lib-es/wallet-api/logic.d.ts +1 -1
  468. package/lib-es/wallet-api/logic.d.ts.map +1 -1
  469. package/lib-es/wallet-api/logic.js +5 -5
  470. package/lib-es/wallet-api/logic.js.map +1 -1
  471. package/lib-es/wallet-api/react.d.ts.map +1 -1
  472. package/lib-es/wallet-api/react.js +9 -6
  473. package/lib-es/wallet-api/react.js.map +1 -1
  474. package/lib-es/wallet-api/tracking.d.ts +5 -5
  475. package/lib-es/wallet-api/tracking.d.ts.map +1 -1
  476. package/lib-es/wallet-api/tracking.js +30 -10
  477. package/lib-es/wallet-api/tracking.js.map +1 -1
  478. package/lib-es/wallet-api/useDappLogic.d.ts.map +1 -1
  479. package/lib-es/wallet-api/useDappLogic.js +31 -20
  480. package/lib-es/wallet-api/useDappLogic.js.map +1 -1
  481. package/lib-es/wallet-api/utils/extractDappURLFromManifest.js +3 -3
  482. package/lib-es/wallet-api/utils/extractDappURLFromManifest.js.map +1 -1
  483. package/lib-es/wallet-api/utils/extractURLFromManifest.js +1 -1
  484. package/lib-es/wallet-api/utils/extractURLFromManifest.js.map +1 -1
  485. package/lib-es/walletSync/getEnvironmentParams.js +6 -6
  486. package/lib-es/walletSync/getEnvironmentParams.js.map +1 -1
  487. package/package.json +82 -90
  488. package/src/__tests__/test-helpers/bridge.ts +1 -1
  489. package/src/__tests__/test-helpers/environment.ts +3 -0
  490. package/src/account/index.ts +6 -0
  491. package/src/account/recentAddresses.test.ts +104 -0
  492. package/src/account/recentAddresses.ts +84 -0
  493. package/src/account/serialization.ts +1 -1
  494. package/src/account/support.ts +1 -1
  495. package/src/bridge/generic-alpaca/accountBridge.ts +3 -2
  496. package/src/bridge/generic-alpaca/broadcast.ts +6 -3
  497. package/src/bridge/generic-alpaca/currencyBridge.ts +3 -3
  498. package/src/bridge/generic-alpaca/estimateMaxSpendable.ts +2 -1
  499. package/src/bridge/generic-alpaca/getAccountShape.ts +36 -13
  500. package/src/bridge/generic-alpaca/getTransactionStatus.ts +16 -1
  501. package/src/bridge/generic-alpaca/postSync.test.ts +97 -0
  502. package/src/bridge/generic-alpaca/postSync.ts +42 -0
  503. package/src/bridge/generic-alpaca/prepareTransaction.ts +51 -10
  504. package/src/bridge/generic-alpaca/signOperation.ts +18 -2
  505. package/src/bridge/generic-alpaca/signer/Eth.ts +5 -1
  506. package/src/bridge/generic-alpaca/signer/index.ts +7 -0
  507. package/src/bridge/generic-alpaca/tests/getAccountShape.test.ts +43 -10
  508. package/src/bridge/generic-alpaca/tests/prepareTransaction.test.ts +74 -0
  509. package/src/bridge/generic-alpaca/types.ts +4 -0
  510. package/src/bridge/generic-alpaca/utils.test.ts +4 -0
  511. package/src/bridge/generic-alpaca/utils.ts +15 -3
  512. package/src/bridge/impl.ts +16 -3
  513. package/src/currencies/helpers.test.ts +10 -1
  514. package/src/currencies/helpers.ts +6 -0
  515. package/src/domain/getTokensWithFunds.ts +18 -5
  516. package/src/domain/getTotalStakeableAssets.test.ts +267 -0
  517. package/src/domain/getTotalStakeableAssets.ts +47 -0
  518. package/src/e2e/data/deviceLabelsData.ts +1 -0
  519. package/src/e2e/data/regexes.ts +1 -0
  520. package/src/e2e/enum/Device.ts +1 -0
  521. package/src/e2e/families/cardano.ts +32 -14
  522. package/src/e2e/index.ts +20 -0
  523. package/src/e2e/speculos.ts +35 -4
  524. package/src/e2e/speculosAppVersion.ts +8 -2
  525. package/src/e2e/swap.ts +8 -7
  526. package/src/exchange/swap/api/v5/fetchCurrencyFrom.ts +1 -1
  527. package/src/exchange/swap/getIncompatibleCurrencyKeys.ts +4 -0
  528. package/src/exchange/swap/postSwapState.ts +10 -5
  529. package/src/exchange/swap/transactionStrategies.ts +30 -7
  530. package/src/exchange/swap/types.ts +3 -1
  531. package/src/families/bitcoin/walletApiAdapter.test.ts +36 -0
  532. package/src/families/bitcoin/walletApiAdapter.ts +4 -0
  533. package/src/families/canton/config.ts +5 -4
  534. package/src/families/canton/react.test.ts +147 -0
  535. package/src/families/canton/react.ts +45 -1
  536. package/src/families/celo/setup.ts +12 -0
  537. package/src/families/cosmos/datasets/__snapshots__/cosmos.integration.test.ts.snap +73 -4
  538. package/src/families/cosmos/datasets/__snapshots__/cryptoOrg.integration.test.ts.snap +2 -2
  539. package/src/families/cosmos/datasets/__snapshots__/injective.integration.test.ts.snap +2 -2
  540. package/src/families/cosmos/datasets/__snapshots__/mantra.integration.test.ts.snap +2 -2
  541. package/src/families/cosmos/datasets/__snapshots__/osmosis.integration.test.ts.snap +2 -2
  542. package/src/families/cosmos/datasets/__snapshots__/persistence.integration.test.ts.snap +4 -4
  543. package/src/families/cosmos/datasets/__snapshots__/stargaze.integration.test.ts.snap +2 -2
  544. package/src/families/evm/bridge/mock.ts +14 -0
  545. package/src/families/evm/setup.ts +3 -22
  546. package/src/families/evm/walletApiAdapter.ts +33 -1
  547. package/src/families/hedera/__snapshots__/bridge.integration.test.ts.snap +278 -17
  548. package/src/families/hedera/react.test.ts +272 -0
  549. package/src/families/hedera/react.ts +63 -0
  550. package/src/families/polkadot/__snapshots__/bridge.integration.test.ts.snap +6 -3653
  551. package/src/families/polkadot/config.ts +1 -1
  552. package/src/families/stacks/__snapshots__/bridge.integration.test.ts.snap +1537 -18
  553. package/src/families/stacks/__tests__/sync.integration.test.ts +2 -2
  554. package/src/families/stacks/constants.ts +1 -1
  555. package/src/families/stellar/__snapshots__/bridge.integration.test.ts.snap +9 -9
  556. package/src/featureFlags/defaultFeatures.ts +22 -1
  557. package/src/featureFlags/firebaseFeatureFlags.ts +1 -1
  558. package/src/featureFlags/stakePrograms/index.ts +4 -4
  559. package/src/featureFlags/useHasOverriddenFeatureFlags.ts +1 -1
  560. package/src/generated/bridge/js.ts +0 -2
  561. package/src/helpers/cryptoIconSize.ts +25 -0
  562. package/src/helpers.ts +2 -0
  563. package/src/hooks/__tests__/useHtmlLinkSegments.test.ts +105 -0
  564. package/src/hooks/useHtmlLinkSegments.ts +158 -0
  565. package/src/hw/getAppAndVersion.ts +2 -1
  566. package/src/hw/getBitcoinLikeInfo.ts +1 -1
  567. package/src/load/speculos.ts +1 -0
  568. package/src/mock/account.ts +1 -1
  569. package/src/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.ts +6 -0
  570. package/src/operation.ts +10 -2
  571. package/src/wallet-api/Exchange/SwapError.test.ts +126 -0
  572. package/src/wallet-api/Exchange/SwapError.ts +159 -0
  573. package/src/wallet-api/Exchange/handleSwapErrors.test.ts +46 -0
  574. package/src/wallet-api/Exchange/handleSwapErrors.ts +161 -0
  575. package/src/wallet-api/Exchange/index.ts +26 -0
  576. package/src/wallet-api/Exchange/parser.test.ts +86 -0
  577. package/src/wallet-api/Exchange/parser.ts +119 -0
  578. package/src/wallet-api/Exchange/server.ts +289 -232
  579. package/src/wallet-api/Exchange/tracking.ts +56 -13
  580. package/src/wallet-api/logic.ts +5 -4
  581. package/src/wallet-api/react.ts +10 -5
  582. package/src/wallet-api/tracking.ts +30 -10
  583. package/src/wallet-api/useDappLogic.ts +32 -20
  584. package/src/wallet-api/utils/extractDappURLFromManifest.ts +3 -3
  585. package/src/wallet-api/utils/extractURLFromManifest.ts +1 -1
  586. package/src/walletSync/getEnvironmentParams.ts +6 -6
  587. package/lib/currencies/cryptoIcons.d.ts +0 -3
  588. package/lib/currencies/cryptoIcons.d.ts.map +0 -1
  589. package/lib/currencies/cryptoIcons.js +0 -24
  590. package/lib/currencies/cryptoIcons.js.map +0 -1
  591. package/lib/react.d.ts +0 -16
  592. package/lib/react.d.ts.map +0 -1
  593. package/lib/react.js +0 -64
  594. package/lib/react.js.map +0 -1
  595. package/lib/reactNative.d.ts +0 -16
  596. package/lib/reactNative.d.ts.map +0 -1
  597. package/lib/reactNative.js +0 -43
  598. package/lib/reactNative.js.map +0 -1
  599. package/lib-es/currencies/cryptoIcons.d.ts +0 -3
  600. package/lib-es/currencies/cryptoIcons.d.ts.map +0 -1
  601. package/lib-es/currencies/cryptoIcons.js +0 -20
  602. package/lib-es/currencies/cryptoIcons.js.map +0 -1
  603. package/lib-es/react.d.ts +0 -16
  604. package/lib-es/react.d.ts.map +0 -1
  605. package/lib-es/react.js +0 -33
  606. package/lib-es/react.js.map +0 -1
  607. package/lib-es/reactNative.d.ts +0 -16
  608. package/lib-es/reactNative.d.ts.map +0 -1
  609. package/lib-es/reactNative.js +0 -15
  610. package/lib-es/reactNative.js.map +0 -1
  611. package/react.js +0 -1
  612. package/reactNative.js +0 -1
  613. package/src/currencies/cryptoIcons.test.ts +0 -54
  614. package/src/currencies/cryptoIcons.ts +0 -21
  615. package/src/react.tsx +0 -43
  616. package/src/reactNative.ts +0 -23
  617. package/src/reactNativeSvg.d.ts +0 -19
@@ -0,0 +1,104 @@
1
+ import { RecentAddressesStore, setupRecentAddressesStore, getRecentAddressesStore } from ".";
2
+ import { RECENT_ADDRESSES_COUNT_LIMIT } from "./recentAddresses";
3
+
4
+ describe("RecentAddressesStore", () => {
5
+ const onAddAddressCompleteMock = jest.fn();
6
+ let store: RecentAddressesStore;
7
+
8
+ beforeEach(() => {
9
+ onAddAddressCompleteMock.mockClear();
10
+ setupRecentAddressesStore({}, onAddAddressCompleteMock);
11
+ store = getRecentAddressesStore();
12
+ });
13
+
14
+ it("should add one address and return this only address", async () => {
15
+ const newAddress = "0x66c4371aE8FFeD2ec1c2EBbbcCfb7E494181E1E3";
16
+ await store.addAddress("ethereum", newAddress);
17
+ const addresses = store.getAddresses("ethereum");
18
+ expect(addresses).toEqual([newAddress]);
19
+ expect(onAddAddressCompleteMock).toHaveBeenCalledTimes(1);
20
+ expect(onAddAddressCompleteMock).toHaveBeenCalledWith({ ethereum: [newAddress] });
21
+ });
22
+
23
+ it("should add a second address and return addresses sorted by insertion", async () => {
24
+ const newAddress = "0x66c4371aE8FFeD2ec1c2EBbbcCfb7E494181E1E3";
25
+ await store.addAddress("ethereum", newAddress);
26
+ let addresses = store.getAddresses("ethereum");
27
+ expect(addresses).toEqual([newAddress]);
28
+ expect(onAddAddressCompleteMock).toHaveBeenCalledTimes(1);
29
+ expect(onAddAddressCompleteMock).toHaveBeenCalledWith({ ethereum: [newAddress] });
30
+
31
+ const newAddress2 = "0xB69B37A4Fb4A18b3258f974ff6e9f529AD2647b1";
32
+ await store.addAddress("ethereum", newAddress2);
33
+ addresses = store.getAddresses("ethereum");
34
+ expect(addresses).toEqual([newAddress2, newAddress]);
35
+ expect(onAddAddressCompleteMock).toHaveBeenCalledTimes(2);
36
+ expect(onAddAddressCompleteMock).toHaveBeenCalledWith({ ethereum: [newAddress2, newAddress] });
37
+ });
38
+
39
+ it("should replace at first place when an address is already saved", async () => {
40
+ const newAddress = "0x66c4371aE8FFeD2ec1c2EBbbcCfb7E494181E1E3";
41
+ await store.addAddress("ethereum", newAddress);
42
+ let addresses = store.getAddresses("ethereum");
43
+ expect(addresses).toEqual([newAddress]);
44
+ expect(onAddAddressCompleteMock).toHaveBeenCalledTimes(1);
45
+ expect(onAddAddressCompleteMock).toHaveBeenCalledWith({ ethereum: [newAddress] });
46
+
47
+ const newAddress2 = "0xB69B37A4Fb4A18b3258f974ff6e9f529AD2647b1";
48
+ await store.addAddress("ethereum", newAddress2);
49
+ addresses = store.getAddresses("ethereum");
50
+ expect(addresses).toEqual([newAddress2, newAddress]);
51
+ expect(onAddAddressCompleteMock).toHaveBeenCalledTimes(2);
52
+ expect(onAddAddressCompleteMock).toHaveBeenCalledWith({ ethereum: [newAddress2, newAddress] });
53
+
54
+ await store.addAddress("ethereum", newAddress);
55
+ addresses = store.getAddresses("ethereum");
56
+ expect(addresses).toEqual([newAddress, newAddress2]);
57
+ expect(onAddAddressCompleteMock).toHaveBeenCalledTimes(3);
58
+ expect(onAddAddressCompleteMock).toHaveBeenCalledWith({ ethereum: [newAddress, newAddress2] });
59
+ });
60
+
61
+ it("should replace at first place and remove last element when addresses exceed count limit", async () => {
62
+ let expectedAddresses: string[] = [];
63
+ for (let index = 0; index < RECENT_ADDRESSES_COUNT_LIMIT; index++) {
64
+ await store.addAddress("ethereum", `0x66c4371aE8FFeD2ec1c2EBbbcCfb7E494181E1E3${index}`);
65
+ expectedAddresses.unshift(`0x66c4371aE8FFeD2ec1c2EBbbcCfb7E494181E1E3${index}`);
66
+ }
67
+
68
+ let addresses = store.getAddresses("ethereum");
69
+ expect(addresses).toEqual(expectedAddresses);
70
+ expect(onAddAddressCompleteMock).toHaveBeenCalledTimes(RECENT_ADDRESSES_COUNT_LIMIT);
71
+ expect(onAddAddressCompleteMock).toHaveBeenCalledWith({ ethereum: expectedAddresses });
72
+
73
+ const newAddress2 = "0xB69B37A4Fb4A18b3258f974ff6e9f529AD2647b1";
74
+ expectedAddresses.splice(expectedAddresses.length - 1, 1);
75
+ expectedAddresses = [newAddress2, ...expectedAddresses];
76
+
77
+ await store.addAddress("ethereum", newAddress2);
78
+ addresses = store.getAddresses("ethereum");
79
+ expect(addresses).toEqual(expectedAddresses);
80
+ expect(onAddAddressCompleteMock).toHaveBeenCalledTimes(RECENT_ADDRESSES_COUNT_LIMIT + 1);
81
+ expect(onAddAddressCompleteMock).toHaveBeenCalledWith({ ethereum: expectedAddresses });
82
+ });
83
+
84
+ it("should add an address of a different currency", async () => {
85
+ const newAddress = "0x66c4371aE8FFeD2ec1c2EBbbcCfb7E494181E1E3";
86
+ await store.addAddress("ethereum", newAddress);
87
+
88
+ let addresses = store.getAddresses("ethereum");
89
+ expect(addresses).toEqual([newAddress]);
90
+ expect(onAddAddressCompleteMock).toHaveBeenCalledTimes(1);
91
+ expect(onAddAddressCompleteMock).toHaveBeenCalledWith({ ethereum: [newAddress] });
92
+
93
+ const newAddress2 = "bc1pxlmrudqyq8qd8pfsc4mpmlaw56x6vtcr9m8nvp8kj3gckefc4kmqhkg4l7";
94
+ await store.addAddress("bitcoin", newAddress2);
95
+
96
+ addresses = store.getAddresses("bitcoin");
97
+ expect(addresses).toEqual([newAddress2]);
98
+ expect(onAddAddressCompleteMock).toHaveBeenCalledTimes(2);
99
+ expect(onAddAddressCompleteMock).toHaveBeenCalledWith({
100
+ ethereum: [newAddress],
101
+ bitcoin: [newAddress2],
102
+ });
103
+ });
104
+ });
@@ -0,0 +1,84 @@
1
+ export const RECENT_ADDRESSES_COUNT_LIMIT = 12;
2
+
3
+ export type RecentAddressesCache = Record<string, string[]>;
4
+
5
+ export interface RecentAddressesStore {
6
+ addAddress(currency: string, address: string): void;
7
+ syncAddresses(cache: RecentAddressesCache): void;
8
+ getAddresses(currency: string): string[];
9
+ }
10
+
11
+ type CallbackMode = "triggerCallback" | "skipCallback";
12
+
13
+ let recentAddressesStore: RecentAddressesStore | null = null;
14
+
15
+ export function getRecentAddressesStore(): RecentAddressesStore {
16
+ if (recentAddressesStore === null) {
17
+ throw new Error(
18
+ "Recent addresses store instance is null, please call function setupRecentAddressesStore in application initialization",
19
+ );
20
+ }
21
+ return recentAddressesStore;
22
+ }
23
+
24
+ export function setupRecentAddressesStore(
25
+ addressesByCurrency: RecentAddressesCache,
26
+ onAddAddressComplete: (addressesByCurrency: RecentAddressesCache) => void,
27
+ ): void {
28
+ recentAddressesStore = new RecentAddressesStoreImpl(addressesByCurrency, onAddAddressComplete);
29
+ }
30
+
31
+ class RecentAddressesStoreImpl implements RecentAddressesStore {
32
+ private addressesByCurrency: RecentAddressesCache = {};
33
+ private readonly onAddAddressComplete: (addressesByCurrency: Record<string, string[]>) => void;
34
+
35
+ constructor(
36
+ addressesByCurrency: RecentAddressesCache,
37
+ onAddAddressComplete: (addressesByCurrency: RecentAddressesCache) => void,
38
+ ) {
39
+ this.addressesByCurrency = { ...addressesByCurrency };
40
+ this.onAddAddressComplete = onAddAddressComplete;
41
+ }
42
+
43
+ addAddress(currency: string, address: string): void {
44
+ this.addAddressToCache(currency, address, "triggerCallback");
45
+ }
46
+
47
+ syncAddresses(cache: RecentAddressesCache): void {
48
+ const previousAddresses = { ...this.addressesByCurrency };
49
+ this.addressesByCurrency = { ...cache };
50
+ for (const currency in previousAddresses) {
51
+ for (const address of previousAddresses[currency]) {
52
+ this.addAddressToCache(currency, address, "skipCallback");
53
+ }
54
+ }
55
+
56
+ this.onAddAddressComplete(this.addressesByCurrency);
57
+ }
58
+
59
+ getAddresses(currency: string): string[] {
60
+ const addresses = this.addressesByCurrency[currency];
61
+ return addresses ?? [];
62
+ }
63
+
64
+ private addAddressToCache(currency: string, address: string, callbackMode: CallbackMode): void {
65
+ if (!this.addressesByCurrency[currency]) {
66
+ this.addressesByCurrency[currency] = [];
67
+ }
68
+
69
+ const addresses = this.addressesByCurrency[currency];
70
+ const addressIndex = addresses.indexOf(address);
71
+ if (addressIndex !== -1) {
72
+ addresses.splice(addressIndex, 1);
73
+ } else if (addresses.length >= RECENT_ADDRESSES_COUNT_LIMIT) {
74
+ addresses.pop();
75
+ }
76
+
77
+ addresses.unshift(address);
78
+ this.addressesByCurrency[currency] = [...addresses];
79
+
80
+ if (callbackMode === "triggerCallback") {
81
+ this.onAddAddressComplete(this.addressesByCurrency);
82
+ }
83
+ }
84
+ }
@@ -99,7 +99,7 @@ const inferFamilyFromAccountId: (accountId: string) => string | null | undefined
99
99
  try {
100
100
  const { currencyId } = decodeAccountId(accountId);
101
101
  return getCryptoCurrencyById(currencyId).family;
102
- } catch (e) {
102
+ } catch {
103
103
  return null;
104
104
  }
105
105
  },
@@ -13,7 +13,7 @@ export function canSend(account: AccountLike, parentAccount: Account | null | un
13
13
  getMainAccount(account, parentAccount),
14
14
  );
15
15
  return true;
16
- } catch (e) {
16
+ } catch {
17
17
  return false;
18
18
  }
19
19
  }
@@ -1,4 +1,4 @@
1
- import { AccountBridge } from "@ledgerhq/types-live";
1
+ import type { AccountBridge } from "@ledgerhq/types-live";
2
2
  import { makeSync } from "../jsHelpers";
3
3
  import { genericGetAccountShape } from "./getAccountShape";
4
4
  import {
@@ -16,6 +16,7 @@ import { genericBroadcast } from "./broadcast";
16
16
  import { genericSignOperation } from "./signOperation";
17
17
  import { genericSignRawOperation } from "./signRawOperation";
18
18
  import type { AlpacaSigner } from "./signer/types";
19
+ import { postSync } from "./postSync";
19
20
 
20
21
  export function getAlpacaAccountBridge(
21
22
  network: string,
@@ -24,7 +25,7 @@ export function getAlpacaAccountBridge(
24
25
  ): AccountBridge<any> {
25
26
  const signer = customSigner ?? getSigner(network);
26
27
  return {
27
- sync: makeSync({ getAccountShape: genericGetAccountShape(network, kind) }),
28
+ sync: makeSync({ getAccountShape: genericGetAccountShape(network, kind), postSync }),
28
29
  receive: makeAccountBridgeReceive(getAddressWrapper(signer.getAddress)),
29
30
  createTransaction: createTransaction,
30
31
  updateTransaction: updateTransaction<any>,
@@ -1,11 +1,14 @@
1
1
  import { AccountBridge, TransactionCommon } from "@ledgerhq/types-live";
2
- import { patchOperationWithHash } from "../../operation";
2
+ import { patchOperationWithHash } from "@ledgerhq/coin-framework/operation";
3
3
  import { getAlpacaApi } from "./alpaca";
4
4
 
5
5
  export const genericBroadcast: (network, kind) => AccountBridge<TransactionCommon>["broadcast"] =
6
6
  (network, kind) =>
7
- async ({ signedOperation: { signature, operation }, account }) => {
8
- const hash = await getAlpacaApi(account.currency.id, kind).broadcast(signature);
7
+ async ({ signedOperation: { signature, operation }, account, broadcastConfig }) => {
8
+ const hash = await getAlpacaApi(account.currency.id, kind).broadcast(
9
+ signature,
10
+ broadcastConfig,
11
+ );
9
12
 
10
13
  return patchOperationWithHash(operation, hash);
11
14
  };
@@ -3,6 +3,7 @@ import { CurrencyBridge } from "@ledgerhq/types-live";
3
3
  import { genericGetAccountShape } from "./getAccountShape";
4
4
  import { getSigner } from "./signer";
5
5
  import type { AlpacaSigner } from "./signer/types";
6
+ import { postSync } from "./postSync";
6
7
 
7
8
  export function getAlpacaCurrencyBridge(
8
9
  network: string,
@@ -12,12 +13,11 @@ export function getAlpacaCurrencyBridge(
12
13
  const signer = customSigner ?? getSigner(network);
13
14
  return {
14
15
  preload: () => Promise.resolve({}),
15
- hydrate: () => {
16
- return;
17
- },
16
+ hydrate: () => undefined,
18
17
  scanAccounts: makeScanAccounts({
19
18
  getAccountShape: genericGetAccountShape(network, kind),
20
19
  getAddressFn: signer.getAddress.bind(signer),
20
+ postSync,
21
21
  }),
22
22
  };
23
23
  }
@@ -30,11 +30,12 @@ export function genericEstimateMaxSpendable(
30
30
  )
31
31
  ).value;
32
32
  }
33
+ // TODO Remove the call to `validateIntent` https://ledgerhq.atlassian.net/browse/LIVE-22229
33
34
  const { amount } = await alpacaApi.validateIntent(
34
35
  transactionToIntent(account, { ...draftTransaction }, alpacaApi.computeIntentType),
35
36
  { value: transaction?.fees ? BigInt(transaction.fees.toString()) : 0n },
36
37
  );
37
- if (["stellar", "tezos"].includes(network)) {
38
+ if (["stellar", "tezos", "evm"].includes(network)) {
38
39
  return amount > 0 ? new BigNumber(amount.toString()) : new BigNumber(0);
39
40
  }
40
41
  const bnFee = BigNumber(fees.toString());
@@ -17,6 +17,19 @@ function isNftCoreOp(operation: Operation): boolean {
17
17
  );
18
18
  }
19
19
 
20
+ function isIncomingCoreOp(operation: Operation): boolean {
21
+ const type =
22
+ typeof operation.details?.ledgerOpType === "string"
23
+ ? operation.details.ledgerOpType
24
+ : operation.type;
25
+
26
+ return type === "IN";
27
+ }
28
+
29
+ function isInternalLiveOp(operation: OperationCommon): boolean {
30
+ return !!operation.extra?.internal;
31
+ }
32
+
20
33
  export function genericGetAccountShape(network: string, kind: string): GetAccountShape {
21
34
  return async (info, syncConfig) => {
22
35
  const { address, initialAccount, currency, derivationMode } = info;
@@ -58,14 +71,14 @@ export function genericGetAccountShape(network: string, kind: string): GetAccoun
58
71
 
59
72
  // Calculate minHeight for pagination
60
73
  const minHeight = syncFromScratch ? 0 : (oldOps[0]?.blockHeight ?? 0) + 1;
61
- const paginationParams: Pagination = { minHeight, order: "asc" };
74
+ const paginationParams: Pagination = { minHeight, order: "desc" };
62
75
  if (lastPagingToken && !syncFromScratch) {
63
76
  paginationParams.lastPagingToken = lastPagingToken;
64
77
  }
65
78
 
66
79
  const [newCoreOps] = await alpacaApi.listOperations(address, paginationParams);
67
80
  const newOps = newCoreOps
68
- .filter(op => !isNftCoreOp(op))
81
+ .filter(op => !isNftCoreOp(op) && (!isIncomingCoreOp(op) || !op.tx.failed))
69
82
  .map(op => adaptCoreOperationToLiveOperation(accountId, op)) as OperationCommon[];
70
83
 
71
84
  const newAssetOperations = newOps.filter(
@@ -74,6 +87,7 @@ export function genericGetAccountShape(network: string, kind: string): GetAccoun
74
87
  operation?.extra?.assetOwner &&
75
88
  !["OPT_IN", "OPT_OUT"].includes(operation.type),
76
89
  );
90
+ const newInternalOperations = newOps.filter(isInternalLiveOp);
77
91
  const newSubAccounts = await buildSubAccounts({
78
92
  accountId,
79
93
  allTokenAssetsBalances,
@@ -85,22 +99,31 @@ export function genericGetAccountShape(network: string, kind: string): GetAccoun
85
99
  ? newSubAccounts
86
100
  : mergeSubAccounts(initialAccount?.subAccounts ?? [], newSubAccounts);
87
101
 
88
- const newOpsWithSubs = newOps.map(op => {
89
- const subOperations = inferSubOperations(op.hash, newSubAccounts);
102
+ const newOpsWithSubs = newOps
103
+ .filter(operation => !isInternalLiveOp(operation))
104
+ .map(op => {
105
+ const subOperations = inferSubOperations(op.hash, newSubAccounts);
106
+ const internalOperations = newInternalOperations.filter(it => it.hash === op.hash);
90
107
 
91
- return cleanedOperation({
92
- ...op,
93
- subOperations,
108
+ return cleanedOperation({
109
+ ...op,
110
+ subOperations,
111
+ internalOperations,
112
+ });
94
113
  });
95
- });
114
+ // Try to refresh known pending and broadcasted operations (if not already updated)
115
+ // Useful for integrations without explorers
116
+ const operationsToRefresh = initialAccount?.pendingOperations.filter(
117
+ pendingOp =>
118
+ pendingOp.hash && // operation has been broadcasted
119
+ !newOpsWithSubs.some(newOp => pendingOp.hash === newOp.hash), // operation is not confirmed yet
120
+ );
96
121
  const confirmedOperations =
97
- alpacaApi.refreshOperations && initialAccount?.pendingOperations.length
98
- ? await alpacaApi.refreshOperations(initialAccount.pendingOperations)
122
+ alpacaApi.refreshOperations && operationsToRefresh?.length
123
+ ? await alpacaApi.refreshOperations(operationsToRefresh)
99
124
  : [];
100
125
  const newOperations = [...confirmedOperations, ...newOpsWithSubs];
101
- const operations = syncFromScratch
102
- ? newOperations
103
- : (mergeOps(oldOps, newOperations) as OperationCommon[]);
126
+ const operations = mergeOps(syncFromScratch ? [] : oldOps, newOperations) as OperationCommon[];
104
127
 
105
128
  const res: Partial<Account> = {
106
129
  id: accountId,
@@ -26,6 +26,7 @@ export function genericGetTransactionStatus(
26
26
  feesStrategy: transaction.feesStrategy,
27
27
  data: transaction.data,
28
28
  type: transaction.type,
29
+ sponsored: transaction.sponsored,
29
30
  };
30
31
 
31
32
  if (alpacaApi.getChainSpecificRules) {
@@ -37,10 +38,24 @@ export function genericGetTransactionStatus(
37
38
  }
38
39
  }
39
40
 
41
+ const fees = BigInt(transaction.fees?.toString() || "0");
42
+ const feesParameters = {
43
+ ...(transaction.gasLimit ? { gasLimit: BigInt(transaction.gasLimit.toFixed()) } : {}),
44
+ ...(transaction.gasPrice ? { gasPrice: BigInt(transaction.gasPrice.toFixed()) } : {}),
45
+ ...(transaction.maxFeePerGas
46
+ ? { maxFeePerGas: BigInt(transaction.maxFeePerGas.toFixed()) }
47
+ : {}),
48
+ ...(transaction.maxPriorityFeePerGas
49
+ ? { maxPriorityFeePerGas: BigInt(transaction.maxPriorityFeePerGas.toFixed()) }
50
+ : {}),
51
+ ...(transaction.additionalFees
52
+ ? { additionalFees: BigInt(transaction.additionalFees.toFixed()) }
53
+ : {}),
54
+ };
40
55
  const { errors, warnings, estimatedFees, amount, totalSpent, totalFees } =
41
56
  await alpacaApi.validateIntent(
42
57
  transactionToIntent(account, draftTransaction, alpacaApi.computeIntentType),
43
- { value: transaction.fees ? BigInt(transaction.fees.toString()) : 0n },
58
+ { value: fees, parameters: feesParameters },
44
59
  );
45
60
 
46
61
  return {
@@ -0,0 +1,97 @@
1
+ import type { Account } from "@ledgerhq/types-live";
2
+ import { postSync } from "./postSync";
3
+ import BigNumber from "bignumber.js";
4
+
5
+ describe("postSync", () => {
6
+ it("removes confirmed and outdated native operations from the pending pool", () => {
7
+ const initialAccount = {
8
+ operations: [{ hash: "hash0", transactionSequenceNumber: new BigNumber(4), type: "OUT" }],
9
+ pendingOperations: [
10
+ { hash: "outdated", transactionSequenceNumber: new BigNumber(3), type: "IN" },
11
+ { hash: "hash1", transactionSequenceNumber: new BigNumber(5), type: "OUT" },
12
+ { hash: "hash2", transactionSequenceNumber: new BigNumber(6), type: "IN" },
13
+ ],
14
+ } as Account;
15
+ const synced = {
16
+ operations: [
17
+ { hash: "hash1", transactionSequenceNumber: new BigNumber(5), type: "OUT" },
18
+ { hash: "hash0", transactionSequenceNumber: new BigNumber(4), type: "OUT" },
19
+ ],
20
+ pendingOperations: [
21
+ { hash: "outdated", transactionSequenceNumber: new BigNumber(3), type: "IN" },
22
+ { hash: "hash1", transactionSequenceNumber: new BigNumber(5), type: "OUT" },
23
+ { hash: "hash2", transactionSequenceNumber: new BigNumber(6), type: "IN" },
24
+ ],
25
+ } as Account;
26
+
27
+ expect(postSync(initialAccount, synced)).toMatchObject({
28
+ operations: [
29
+ { hash: "hash1", transactionSequenceNumber: new BigNumber(5), type: "OUT" },
30
+ { hash: "hash0", transactionSequenceNumber: new BigNumber(4), type: "OUT" },
31
+ ],
32
+ pendingOperations: [
33
+ { hash: "hash2", transactionSequenceNumber: new BigNumber(6), type: "IN" },
34
+ ],
35
+ });
36
+ });
37
+
38
+ it("removes confirmed and outdated token operations from the pending pool", () => {
39
+ const initialAccount = {
40
+ operations: [{ hash: "hash0", transactionSequenceNumber: new BigNumber(4), type: "OUT" }],
41
+ pendingOperations: [
42
+ { hash: "outdated", transactionSequenceNumber: new BigNumber(3), type: "NONE" },
43
+ { hash: "hash1", transactionSequenceNumber: new BigNumber(5), type: "FEES" },
44
+ { hash: "hash2", transactionSequenceNumber: new BigNumber(6), type: "IN" },
45
+ ],
46
+ subAccounts: [
47
+ {
48
+ pendingOperations: [
49
+ { hash: "outdated", transactionSequenceNumber: new BigNumber(3), type: "IN" },
50
+ { hash: "hash1", transactionSequenceNumber: new BigNumber(5), type: "FEES" },
51
+ ],
52
+ },
53
+ ],
54
+ } as Account;
55
+ const synced = {
56
+ operations: [
57
+ { hash: "hash1", transactionSequenceNumber: new BigNumber(5), type: "FEES" },
58
+ { hash: "hash0", transactionSequenceNumber: new BigNumber(4), type: "OUT" },
59
+ ],
60
+ pendingOperations: [
61
+ { hash: "outdated", transactionSequenceNumber: new BigNumber(3), type: "NONE" },
62
+ { hash: "hash1", transactionSequenceNumber: new BigNumber(5), type: "FEES" },
63
+ { hash: "hash2", transactionSequenceNumber: new BigNumber(6), type: "IN" },
64
+ ],
65
+ subAccounts: [
66
+ {
67
+ operations: [{ hash: "hash1", transactionSequenceNumber: new BigNumber(5), type: "OUT" }],
68
+ pendingOperations: [
69
+ { hash: "outdated", transactionSequenceNumber: new BigNumber(3), type: "IN" },
70
+ ],
71
+ },
72
+ ],
73
+ } as Account;
74
+
75
+ expect(postSync(initialAccount, synced)).toMatchObject({
76
+ operations: [
77
+ { hash: "hash1", transactionSequenceNumber: new BigNumber(5), type: "FEES" },
78
+ { hash: "hash0", transactionSequenceNumber: new BigNumber(4), type: "OUT" },
79
+ ],
80
+ pendingOperations: [
81
+ { hash: "hash2", transactionSequenceNumber: new BigNumber(6), type: "IN" },
82
+ ],
83
+ subAccounts: [
84
+ {
85
+ operations: [
86
+ {
87
+ hash: "hash1",
88
+ transactionSequenceNumber: new BigNumber(5),
89
+ type: "OUT",
90
+ },
91
+ ],
92
+ pendingOperations: [],
93
+ },
94
+ ],
95
+ });
96
+ });
97
+ });
@@ -0,0 +1,42 @@
1
+ import type { Account, AccountLike, Operation } from "@ledgerhq/types-live";
2
+ import BigNumber from "bignumber.js";
3
+
4
+ /**
5
+ * After each sync or scan, remove operations from the pending pools if necessary
6
+ * Operations stay pending if and only if
7
+ * - they are confirmed, i.e. their hash appear in the operation list
8
+ * - they are not outdated, i.e. their sequence number is at least greater than the
9
+ * sequence number of the latest transaction
10
+ * NOTE Compared to the default behaviour
11
+ * - pending operations of token accounts are cleaned up, so we don't see both pending and completed
12
+ * sub operations in the operation details drawer
13
+ * - pending operations are cleaned if their hash already belong to the completed operations, preventing
14
+ * undesired replacement (ex: optimistic operation for self token sending on EVM is incomplete, since
15
+ * it only contains the OUT sub operation)
16
+ */
17
+ export function postSync(initial: Account, synced: Account): Account {
18
+ const lastOperation = synced.operations.find(op => ["OUT", "FEES"].includes(op.type));
19
+ const latestSequence = lastOperation?.transactionSequenceNumber || new BigNumber(-1);
20
+
21
+ function isPending(account: AccountLike, op: Operation): boolean {
22
+ return (
23
+ // Operation is not confirmed
24
+ !account.operations.some(o => o.hash === op.hash) &&
25
+ // Operation is not outdated
26
+ op.transactionSequenceNumber !== undefined &&
27
+ op.transactionSequenceNumber.gt(latestSequence)
28
+ );
29
+ }
30
+
31
+ const pendingOperations = initial.pendingOperations.length
32
+ ? initial.pendingOperations.filter(op => isPending(synced, op))
33
+ : [];
34
+ const subAccounts = synced.subAccounts?.length
35
+ ? synced.subAccounts.map(subAccount => ({
36
+ ...subAccount,
37
+ pendingOperations: subAccount.pendingOperations.filter(op => isPending(subAccount, op)),
38
+ }))
39
+ : [];
40
+
41
+ return { ...synced, pendingOperations, subAccounts };
42
+ }
@@ -31,6 +31,11 @@ function propagateField(estimation: FeeEstimation, field: string, dest: GenericT
31
31
  dest[field] = Number(value.toString());
32
32
  return;
33
33
  case "storageLimit":
34
+ case "gasLimit":
35
+ case "gasPrice":
36
+ case "maxFeePerGas":
37
+ case "maxPriorityFeePerGas":
38
+ case "additionalFees":
34
39
  dest[field] = new BigNumber(value.toString());
35
40
  return;
36
41
  default:
@@ -51,17 +56,42 @@ export function genericPrepareTransaction(
51
56
  ? await getAssetInfos(transaction, account.freshAddress, getAssetFromToken)
52
57
  : assetInfosFallback(transaction);
53
58
  const customParametersFees = transaction.customFees?.parameters?.fees;
59
+
60
+ /**
61
+ * Ticking `useAllAmount` constantly resets the amount to 0. This is problematic
62
+ * because some Blockchain need the actual transaction amount to compute the fees
63
+ * (Example with EVM and ERC20 transactions)
64
+ * In case of `useAllAmount` and token transaction, we read the token account spendable
65
+ * balance instead.
66
+ */
67
+ let amount = transaction.amount;
68
+ if (transaction.useAllAmount && transaction.subAccountId) {
69
+ const subAccount = account.subAccounts?.find(acc => acc.id === transaction.subAccountId);
70
+ amount = subAccount?.spendableBalance ?? amount;
71
+ }
72
+
73
+ // Pass any parameters that help estimating fees
74
+ // This includes `assetOwner` and `assetReference` that are not used by some apps that only rely on `subAccountId`
75
+ // TODO Remove `assetOwner` and `assetReference` in order to maintain one unique way of identifying the type of asset
76
+ // https://ledgerhq.atlassian.net/browse/LIVE-24044
77
+ const intent = transactionToIntent(
78
+ account,
79
+ {
80
+ ...transaction,
81
+ assetOwner,
82
+ assetReference,
83
+ amount,
84
+ },
85
+ computeIntentType,
86
+ );
54
87
  const estimation: FeeEstimation = customParametersFees
55
88
  ? { value: BigInt(customParametersFees.toFixed()) }
56
- : await estimateFees(
57
- transactionToIntent(
58
- account,
59
- {
60
- ...transaction,
61
- },
62
- computeIntentType,
63
- ),
64
- );
89
+ : await estimateFees(intent, {
90
+ gasPrice: transaction.gasPrice,
91
+ maxFeePerGas: transaction.maxFeePerGas,
92
+ maxPriorityFeePerGas: transaction.maxPriorityFeePerGas,
93
+ gasOptions: transaction.gasOptions,
94
+ });
65
95
  const fees = new BigNumber(estimation.value.toString());
66
96
 
67
97
  if (!bnEq(transaction.fees, fees)) {
@@ -78,7 +108,15 @@ export function genericPrepareTransaction(
78
108
  };
79
109
 
80
110
  // Propagate needed fields
81
- const fieldsToPropagate = ["type", "storageLimit"];
111
+ const fieldsToPropagate = [
112
+ "type",
113
+ "storageLimit",
114
+ "gasLimit",
115
+ "gasPrice",
116
+ "maxFeePerGas",
117
+ "maxPriorityFeePerGas",
118
+ "additionalFees",
119
+ ];
82
120
 
83
121
  for (const field of fieldsToPropagate) {
84
122
  propagateField(estimation, field, next);
@@ -86,11 +124,14 @@ export function genericPrepareTransaction(
86
124
 
87
125
  // align with stellar/xrp: when send max (or staking intents), reflect validated amount in UI
88
126
  if (transaction.useAllAmount || ["stake", "unstake"].includes(transaction.mode ?? "")) {
127
+ // TODO Remove the call to `validateIntent` https://ledgerhq.atlassian.net/browse/LIVE-22228
89
128
  const { amount } = await validateIntent(
90
129
  transactionToIntent(
91
130
  account,
92
131
  {
93
132
  ...transaction,
133
+ assetOwner,
134
+ assetReference,
94
135
  },
95
136
  computeIntentType,
96
137
  ),