@ledgerhq/live-common 34.52.0 → 34.53.0-nightly.20251108023448

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 (478) hide show
  1. package/lib/DataModel.d.ts +2 -2
  2. package/lib/DataModel.d.ts.map +1 -1
  3. package/lib/DataModel.js +2 -2
  4. package/lib/DataModel.js.map +1 -1
  5. package/lib/__tests__/test-helpers/bridge.d.ts.map +1 -1
  6. package/lib/__tests__/test-helpers/bridge.js +103 -47
  7. package/lib/__tests__/test-helpers/bridge.js.map +1 -1
  8. package/lib/__tests__/test-helpers/setup.d.ts.map +1 -1
  9. package/lib/__tests__/test-helpers/setup.js +6 -5
  10. package/lib/__tests__/test-helpers/setup.js.map +1 -1
  11. package/lib/account/serialization.d.ts +1 -1
  12. package/lib/account/serialization.d.ts.map +1 -1
  13. package/lib/account/serialization.js +2 -2
  14. package/lib/account/serialization.js.map +1 -1
  15. package/lib/api/ofacGeoBlockApi.d.ts +4 -0
  16. package/lib/api/ofacGeoBlockApi.d.ts.map +1 -0
  17. package/lib/api/ofacGeoBlockApi.js +21 -0
  18. package/lib/api/ofacGeoBlockApi.js.map +1 -0
  19. package/lib/apps/config.d.ts.map +1 -1
  20. package/lib/apps/config.js +1 -0
  21. package/lib/apps/config.js.map +1 -1
  22. package/lib/bot/engine.d.ts +5 -5
  23. package/lib/bot/engine.d.ts.map +1 -1
  24. package/lib/bot/engine.js.map +1 -1
  25. package/lib/bridge/crypto-assets/index.d.ts.map +1 -1
  26. package/lib/bridge/crypto-assets/index.js +2 -2
  27. package/lib/bridge/crypto-assets/index.js.map +1 -1
  28. package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +2 -2
  29. package/lib/bridge/generic-alpaca/createTransaction.d.ts.map +1 -1
  30. package/lib/bridge/generic-alpaca/createTransaction.js +6 -1
  31. package/lib/bridge/generic-alpaca/createTransaction.js.map +1 -1
  32. package/lib/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
  33. package/lib/bridge/generic-alpaca/getTransactionStatus.js +1 -0
  34. package/lib/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
  35. package/lib/bridge/generic-alpaca/prepareTransaction.d.ts +2 -2
  36. package/lib/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
  37. package/lib/bridge/generic-alpaca/prepareTransaction.js +30 -26
  38. package/lib/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
  39. package/lib/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
  40. package/lib/bridge/generic-alpaca/signOperation.js +6 -4
  41. package/lib/bridge/generic-alpaca/signOperation.js.map +1 -1
  42. package/lib/bridge/generic-alpaca/signer/Eth.d.ts +2 -1
  43. package/lib/bridge/generic-alpaca/signer/Eth.d.ts.map +1 -1
  44. package/lib/bridge/generic-alpaca/signer/Eth.js +2 -1
  45. package/lib/bridge/generic-alpaca/signer/Eth.js.map +1 -1
  46. package/lib/bridge/generic-alpaca/types.d.ts +61 -2
  47. package/lib/bridge/generic-alpaca/types.d.ts.map +1 -1
  48. package/lib/bridge/generic-alpaca/utils.d.ts +1 -1
  49. package/lib/bridge/generic-alpaca/utils.d.ts.map +1 -1
  50. package/lib/bridge/generic-alpaca/utils.js +121 -7
  51. package/lib/bridge/generic-alpaca/utils.js.map +1 -1
  52. package/lib/bridge/index.d.ts +1 -1
  53. package/lib/bridge/index.d.ts.map +1 -1
  54. package/lib/bridge/index.js +2 -2
  55. package/lib/bridge/index.js.map +1 -1
  56. package/lib/currencies/index.d.ts +1 -1
  57. package/lib/currencies/index.d.ts.map +1 -1
  58. package/lib/currencies/index.js +1 -4
  59. package/lib/currencies/index.js.map +1 -1
  60. package/lib/dada-client/__mocks__/assets.mock.d.ts +383 -0
  61. package/lib/dada-client/__mocks__/assets.mock.d.ts.map +1 -0
  62. package/lib/dada-client/__mocks__/assets.mock.js +260 -0
  63. package/lib/dada-client/__mocks__/assets.mock.js.map +1 -0
  64. package/lib/dada-client/hooks/useAssetsData.d.ts +2 -1
  65. package/lib/dada-client/hooks/useAssetsData.d.ts.map +1 -1
  66. package/lib/dada-client/hooks/useAssetsData.js +2 -2
  67. package/lib/dada-client/hooks/useAssetsData.js.map +1 -1
  68. package/lib/dada-client/hooks/useLazyLedgerCurrency.d.ts +13 -0
  69. package/lib/dada-client/hooks/useLazyLedgerCurrency.d.ts.map +1 -0
  70. package/lib/dada-client/hooks/useLazyLedgerCurrency.js +34 -0
  71. package/lib/dada-client/hooks/useLazyLedgerCurrency.js.map +1 -0
  72. package/lib/dada-client/index.d.ts +2 -0
  73. package/lib/dada-client/index.d.ts.map +1 -0
  74. package/lib/dada-client/index.js +18 -0
  75. package/lib/dada-client/index.js.map +1 -0
  76. package/lib/dada-client/state-manager/api.js +1 -1
  77. package/lib/dada-client/state-manager/api.js.map +1 -1
  78. package/lib/dada-client/utils/currencySelection.d.ts +10 -0
  79. package/lib/dada-client/utils/currencySelection.d.ts.map +1 -0
  80. package/lib/dada-client/utils/currencySelection.js +34 -0
  81. package/lib/dada-client/utils/currencySelection.js.map +1 -0
  82. package/lib/deposit/helper.d.ts +1 -1
  83. package/lib/deposit/helper.d.ts.map +1 -1
  84. package/lib/deposit/helper.js +3 -2
  85. package/lib/deposit/helper.js.map +1 -1
  86. package/lib/e2e/data/deviceLabelsData.d.ts.map +1 -1
  87. package/lib/e2e/data/deviceLabelsData.js +2 -1
  88. package/lib/e2e/data/deviceLabelsData.js.map +1 -1
  89. package/lib/e2e/enum/DeviceLabels.d.ts +5 -1
  90. package/lib/e2e/enum/DeviceLabels.d.ts.map +1 -1
  91. package/lib/e2e/enum/DeviceLabels.js +4 -0
  92. package/lib/e2e/enum/DeviceLabels.js.map +1 -1
  93. package/lib/e2e/index.d.ts +4 -8
  94. package/lib/e2e/index.d.ts.map +1 -1
  95. package/lib/e2e/speculos.d.ts +1 -1
  96. package/lib/e2e/speculos.d.ts.map +1 -1
  97. package/lib/e2e/speculos.js +24 -5
  98. package/lib/e2e/speculos.js.map +1 -1
  99. package/lib/e2e/speculosAppVersion.d.ts.map +1 -1
  100. package/lib/e2e/speculosAppVersion.js +1 -0
  101. package/lib/e2e/speculosAppVersion.js.map +1 -1
  102. package/lib/families/cosmos/datasets/coreum.d.ts.map +1 -1
  103. package/lib/families/cosmos/datasets/coreum.js +2 -1
  104. package/lib/families/cosmos/datasets/coreum.js.map +1 -1
  105. package/lib/families/near/config.d.ts.map +1 -1
  106. package/lib/families/near/config.js +1 -0
  107. package/lib/families/near/config.js.map +1 -1
  108. package/lib/families/solana/setup.d.ts +1 -1
  109. package/lib/families/tron/data.mock.d.ts +4 -4
  110. package/lib/families/tron/data.mock.d.ts.map +1 -1
  111. package/lib/families/tron/data.mock.js +27 -13
  112. package/lib/families/tron/data.mock.js.map +1 -1
  113. package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
  114. package/lib/featureFlags/defaultFeatures.js +3 -4
  115. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  116. package/lib/featureFlags/stakePrograms/index.d.ts +1 -0
  117. package/lib/featureFlags/stakePrograms/index.d.ts.map +1 -1
  118. package/lib/featureFlags/stakePrograms/index.js +13 -1
  119. package/lib/featureFlags/stakePrograms/index.js.map +1 -1
  120. package/lib/featureFlags/useFeature.d.ts +1 -1
  121. package/lib/featureFlags/useFeature.d.ts.map +1 -1
  122. package/lib/generated/cli-transaction.d.ts +1 -1
  123. package/lib/generated/transaction.d.ts +1 -1
  124. package/lib/hw/actions/implementations.d.ts.map +1 -1
  125. package/lib/hw/actions/implementations.js +13 -7
  126. package/lib/hw/actions/implementations.js.map +1 -1
  127. package/lib/hw/connectAppEventMapper.d.ts.map +1 -1
  128. package/lib/hw/connectAppEventMapper.js +2 -2
  129. package/lib/hw/connectAppEventMapper.js.map +1 -1
  130. package/lib/market/hooks/useLargeMoverCurrencies.d.ts +1 -1
  131. package/lib/market/hooks/useMarketDataProvider.d.ts +2 -2
  132. package/lib/market/hooks/useMarketDataProvider.d.ts.map +1 -1
  133. package/lib/market/hooks/useMarketDataProvider.js +4 -7
  134. package/lib/market/hooks/useMarketDataProvider.js.map +1 -1
  135. package/lib/market/utils/currencyFormatter.d.ts +3 -4
  136. package/lib/market/utils/currencyFormatter.d.ts.map +1 -1
  137. package/lib/market/utils/currencyFormatter.js +3 -6
  138. package/lib/market/utils/currencyFormatter.js.map +1 -1
  139. package/lib/market/utils/queryKeys.d.ts +0 -1
  140. package/lib/market/utils/queryKeys.d.ts.map +1 -1
  141. package/lib/market/utils/queryKeys.js +0 -1
  142. package/lib/market/utils/queryKeys.js.map +1 -1
  143. package/lib/market/utils/types.d.ts +6 -8
  144. package/lib/market/utils/types.d.ts.map +1 -1
  145. package/lib/market/utils/types.js.map +1 -1
  146. package/lib/mock/fixtures/cryptoCurrencies.d.ts.map +1 -1
  147. package/lib/mock/fixtures/cryptoCurrencies.js +10 -1
  148. package/lib/mock/fixtures/cryptoCurrencies.js.map +1 -1
  149. package/lib/modularDrawer/__mocks__/currencies.mock.d.ts +1 -1
  150. package/lib/modularDrawer/__mocks__/currencies.mock.d.ts.map +1 -1
  151. package/lib/modularDrawer/__mocks__/currencies.mock.js +1 -1
  152. package/lib/modularDrawer/__mocks__/currencies.mock.js.map +1 -1
  153. package/lib/modularDrawer/utils/currencyUtils.d.ts +3 -3
  154. package/lib/modularDrawer/utils/currencyUtils.d.ts.map +1 -1
  155. package/lib/modularDrawer/utils/currencyUtils.js +8 -8
  156. package/lib/modularDrawer/utils/currencyUtils.js.map +1 -1
  157. package/lib/postOnboarding/hooks/usePostOnboardingHubState.d.ts.map +1 -1
  158. package/lib/postOnboarding/hooks/usePostOnboardingHubState.js +13 -4
  159. package/lib/postOnboarding/hooks/usePostOnboardingHubState.js.map +1 -1
  160. package/lib/postOnboarding/mock.d.ts +1 -0
  161. package/lib/postOnboarding/mock.d.ts.map +1 -1
  162. package/lib/postOnboarding/mock.js +3 -1
  163. package/lib/postOnboarding/mock.js.map +1 -1
  164. package/lib/postOnboarding/reducer.d.ts +16 -14
  165. package/lib/postOnboarding/reducer.d.ts.map +1 -1
  166. package/lib/transaction/index.d.ts +1 -1
  167. package/lib/transaction/index.d.ts.map +1 -1
  168. package/lib/transaction/index.js +2 -2
  169. package/lib/transaction/index.js.map +1 -1
  170. package/lib/utils/addressUtils.d.ts +15 -0
  171. package/lib/utils/addressUtils.d.ts.map +1 -0
  172. package/lib/utils/addressUtils.js +39 -0
  173. package/lib/utils/addressUtils.js.map +1 -0
  174. package/lib/wallet-api/ACRE/server.d.ts.map +1 -1
  175. package/lib/wallet-api/ACRE/server.js +19 -15
  176. package/lib/wallet-api/ACRE/server.js.map +1 -1
  177. package/lib/wallet-api/Exchange/server.d.ts.map +1 -1
  178. package/lib/wallet-api/Exchange/server.js +8 -5
  179. package/lib/wallet-api/Exchange/server.js.map +1 -1
  180. package/lib/wallet-api/logic.d.ts.map +1 -1
  181. package/lib/wallet-api/logic.js +29 -29
  182. package/lib/wallet-api/logic.js.map +1 -1
  183. package/lib/wallet-api/react.d.ts.map +1 -1
  184. package/lib/wallet-api/react.js +37 -29
  185. package/lib/wallet-api/react.js.map +1 -1
  186. package/lib/wallet-api/useDappLogic.d.ts.map +1 -1
  187. package/lib/wallet-api/useDappLogic.js +76 -60
  188. package/lib/wallet-api/useDappLogic.js.map +1 -1
  189. package/lib-es/DataModel.d.ts +2 -2
  190. package/lib-es/DataModel.d.ts.map +1 -1
  191. package/lib-es/DataModel.js +2 -2
  192. package/lib-es/DataModel.js.map +1 -1
  193. package/lib-es/__tests__/test-helpers/bridge.d.ts.map +1 -1
  194. package/lib-es/__tests__/test-helpers/bridge.js +103 -47
  195. package/lib-es/__tests__/test-helpers/bridge.js.map +1 -1
  196. package/lib-es/__tests__/test-helpers/setup.d.ts.map +1 -1
  197. package/lib-es/__tests__/test-helpers/setup.js +6 -5
  198. package/lib-es/__tests__/test-helpers/setup.js.map +1 -1
  199. package/lib-es/account/serialization.d.ts +1 -1
  200. package/lib-es/account/serialization.d.ts.map +1 -1
  201. package/lib-es/account/serialization.js +2 -2
  202. package/lib-es/account/serialization.js.map +1 -1
  203. package/lib-es/api/ofacGeoBlockApi.d.ts +4 -0
  204. package/lib-es/api/ofacGeoBlockApi.d.ts.map +1 -0
  205. package/lib-es/api/ofacGeoBlockApi.js +18 -0
  206. package/lib-es/api/ofacGeoBlockApi.js.map +1 -0
  207. package/lib-es/apps/config.d.ts.map +1 -1
  208. package/lib-es/apps/config.js +1 -0
  209. package/lib-es/apps/config.js.map +1 -1
  210. package/lib-es/bot/engine.d.ts +5 -5
  211. package/lib-es/bot/engine.d.ts.map +1 -1
  212. package/lib-es/bot/engine.js.map +1 -1
  213. package/lib-es/bridge/crypto-assets/index.d.ts.map +1 -1
  214. package/lib-es/bridge/crypto-assets/index.js +1 -1
  215. package/lib-es/bridge/crypto-assets/index.js.map +1 -1
  216. package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +2 -2
  217. package/lib-es/bridge/generic-alpaca/createTransaction.d.ts.map +1 -1
  218. package/lib-es/bridge/generic-alpaca/createTransaction.js +6 -1
  219. package/lib-es/bridge/generic-alpaca/createTransaction.js.map +1 -1
  220. package/lib-es/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
  221. package/lib-es/bridge/generic-alpaca/getTransactionStatus.js +1 -0
  222. package/lib-es/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
  223. package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts +2 -2
  224. package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
  225. package/lib-es/bridge/generic-alpaca/prepareTransaction.js +30 -26
  226. package/lib-es/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
  227. package/lib-es/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
  228. package/lib-es/bridge/generic-alpaca/signOperation.js +6 -4
  229. package/lib-es/bridge/generic-alpaca/signOperation.js.map +1 -1
  230. package/lib-es/bridge/generic-alpaca/signer/Eth.d.ts +2 -1
  231. package/lib-es/bridge/generic-alpaca/signer/Eth.d.ts.map +1 -1
  232. package/lib-es/bridge/generic-alpaca/signer/Eth.js +2 -1
  233. package/lib-es/bridge/generic-alpaca/signer/Eth.js.map +1 -1
  234. package/lib-es/bridge/generic-alpaca/types.d.ts +61 -2
  235. package/lib-es/bridge/generic-alpaca/types.d.ts.map +1 -1
  236. package/lib-es/bridge/generic-alpaca/utils.d.ts +1 -1
  237. package/lib-es/bridge/generic-alpaca/utils.d.ts.map +1 -1
  238. package/lib-es/bridge/generic-alpaca/utils.js +121 -7
  239. package/lib-es/bridge/generic-alpaca/utils.js.map +1 -1
  240. package/lib-es/bridge/index.d.ts +1 -1
  241. package/lib-es/bridge/index.d.ts.map +1 -1
  242. package/lib-es/bridge/index.js +2 -2
  243. package/lib-es/bridge/index.js.map +1 -1
  244. package/lib-es/currencies/index.d.ts +1 -1
  245. package/lib-es/currencies/index.d.ts.map +1 -1
  246. package/lib-es/currencies/index.js +1 -1
  247. package/lib-es/currencies/index.js.map +1 -1
  248. package/lib-es/dada-client/__mocks__/assets.mock.d.ts +383 -0
  249. package/lib-es/dada-client/__mocks__/assets.mock.d.ts.map +1 -0
  250. package/lib-es/dada-client/__mocks__/assets.mock.js +257 -0
  251. package/lib-es/dada-client/__mocks__/assets.mock.js.map +1 -0
  252. package/lib-es/dada-client/hooks/useAssetsData.d.ts +2 -1
  253. package/lib-es/dada-client/hooks/useAssetsData.d.ts.map +1 -1
  254. package/lib-es/dada-client/hooks/useAssetsData.js +2 -2
  255. package/lib-es/dada-client/hooks/useAssetsData.js.map +1 -1
  256. package/lib-es/dada-client/hooks/useLazyLedgerCurrency.d.ts +13 -0
  257. package/lib-es/dada-client/hooks/useLazyLedgerCurrency.d.ts.map +1 -0
  258. package/lib-es/dada-client/hooks/useLazyLedgerCurrency.js +27 -0
  259. package/lib-es/dada-client/hooks/useLazyLedgerCurrency.js.map +1 -0
  260. package/lib-es/dada-client/index.d.ts +2 -0
  261. package/lib-es/dada-client/index.d.ts.map +1 -0
  262. package/lib-es/dada-client/index.js +2 -0
  263. package/lib-es/dada-client/index.js.map +1 -0
  264. package/lib-es/dada-client/state-manager/api.js +1 -1
  265. package/lib-es/dada-client/state-manager/api.js.map +1 -1
  266. package/lib-es/dada-client/utils/currencySelection.d.ts +10 -0
  267. package/lib-es/dada-client/utils/currencySelection.d.ts.map +1 -0
  268. package/lib-es/dada-client/utils/currencySelection.js +30 -0
  269. package/lib-es/dada-client/utils/currencySelection.js.map +1 -0
  270. package/lib-es/deposit/helper.d.ts +1 -1
  271. package/lib-es/deposit/helper.d.ts.map +1 -1
  272. package/lib-es/deposit/helper.js +4 -3
  273. package/lib-es/deposit/helper.js.map +1 -1
  274. package/lib-es/e2e/data/deviceLabelsData.d.ts.map +1 -1
  275. package/lib-es/e2e/data/deviceLabelsData.js +2 -1
  276. package/lib-es/e2e/data/deviceLabelsData.js.map +1 -1
  277. package/lib-es/e2e/enum/DeviceLabels.d.ts +5 -1
  278. package/lib-es/e2e/enum/DeviceLabels.d.ts.map +1 -1
  279. package/lib-es/e2e/enum/DeviceLabels.js +4 -0
  280. package/lib-es/e2e/enum/DeviceLabels.js.map +1 -1
  281. package/lib-es/e2e/index.d.ts +4 -8
  282. package/lib-es/e2e/index.d.ts.map +1 -1
  283. package/lib-es/e2e/speculos.d.ts +1 -1
  284. package/lib-es/e2e/speculos.d.ts.map +1 -1
  285. package/lib-es/e2e/speculos.js +24 -5
  286. package/lib-es/e2e/speculos.js.map +1 -1
  287. package/lib-es/e2e/speculosAppVersion.d.ts.map +1 -1
  288. package/lib-es/e2e/speculosAppVersion.js +1 -0
  289. package/lib-es/e2e/speculosAppVersion.js.map +1 -1
  290. package/lib-es/families/cosmos/datasets/coreum.d.ts.map +1 -1
  291. package/lib-es/families/cosmos/datasets/coreum.js +2 -1
  292. package/lib-es/families/cosmos/datasets/coreum.js.map +1 -1
  293. package/lib-es/families/near/config.d.ts.map +1 -1
  294. package/lib-es/families/near/config.js +1 -0
  295. package/lib-es/families/near/config.js.map +1 -1
  296. package/lib-es/families/solana/setup.d.ts +1 -1
  297. package/lib-es/families/tron/data.mock.d.ts +4 -4
  298. package/lib-es/families/tron/data.mock.d.ts.map +1 -1
  299. package/lib-es/families/tron/data.mock.js +22 -12
  300. package/lib-es/families/tron/data.mock.js.map +1 -1
  301. package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
  302. package/lib-es/featureFlags/defaultFeatures.js +3 -4
  303. package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
  304. package/lib-es/featureFlags/stakePrograms/index.d.ts +1 -0
  305. package/lib-es/featureFlags/stakePrograms/index.d.ts.map +1 -1
  306. package/lib-es/featureFlags/stakePrograms/index.js +11 -0
  307. package/lib-es/featureFlags/stakePrograms/index.js.map +1 -1
  308. package/lib-es/featureFlags/useFeature.d.ts +1 -1
  309. package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
  310. package/lib-es/generated/cli-transaction.d.ts +1 -1
  311. package/lib-es/generated/transaction.d.ts +1 -1
  312. package/lib-es/hw/actions/implementations.d.ts.map +1 -1
  313. package/lib-es/hw/actions/implementations.js +15 -9
  314. package/lib-es/hw/actions/implementations.js.map +1 -1
  315. package/lib-es/hw/connectAppEventMapper.d.ts.map +1 -1
  316. package/lib-es/hw/connectAppEventMapper.js +3 -3
  317. package/lib-es/hw/connectAppEventMapper.js.map +1 -1
  318. package/lib-es/market/hooks/useLargeMoverCurrencies.d.ts +1 -1
  319. package/lib-es/market/hooks/useMarketDataProvider.d.ts +2 -2
  320. package/lib-es/market/hooks/useMarketDataProvider.d.ts.map +1 -1
  321. package/lib-es/market/hooks/useMarketDataProvider.js +2 -5
  322. package/lib-es/market/hooks/useMarketDataProvider.js.map +1 -1
  323. package/lib-es/market/utils/currencyFormatter.d.ts +3 -4
  324. package/lib-es/market/utils/currencyFormatter.d.ts.map +1 -1
  325. package/lib-es/market/utils/currencyFormatter.js +3 -6
  326. package/lib-es/market/utils/currencyFormatter.js.map +1 -1
  327. package/lib-es/market/utils/queryKeys.d.ts +0 -1
  328. package/lib-es/market/utils/queryKeys.d.ts.map +1 -1
  329. package/lib-es/market/utils/queryKeys.js +0 -1
  330. package/lib-es/market/utils/queryKeys.js.map +1 -1
  331. package/lib-es/market/utils/types.d.ts +6 -8
  332. package/lib-es/market/utils/types.d.ts.map +1 -1
  333. package/lib-es/market/utils/types.js.map +1 -1
  334. package/lib-es/mock/fixtures/cryptoCurrencies.d.ts.map +1 -1
  335. package/lib-es/mock/fixtures/cryptoCurrencies.js +11 -2
  336. package/lib-es/mock/fixtures/cryptoCurrencies.js.map +1 -1
  337. package/lib-es/modularDrawer/__mocks__/currencies.mock.d.ts +1 -1
  338. package/lib-es/modularDrawer/__mocks__/currencies.mock.d.ts.map +1 -1
  339. package/lib-es/modularDrawer/__mocks__/currencies.mock.js +1 -1
  340. package/lib-es/modularDrawer/__mocks__/currencies.mock.js.map +1 -1
  341. package/lib-es/modularDrawer/utils/currencyUtils.d.ts +3 -3
  342. package/lib-es/modularDrawer/utils/currencyUtils.d.ts.map +1 -1
  343. package/lib-es/modularDrawer/utils/currencyUtils.js +8 -8
  344. package/lib-es/modularDrawer/utils/currencyUtils.js.map +1 -1
  345. package/lib-es/postOnboarding/hooks/usePostOnboardingHubState.d.ts.map +1 -1
  346. package/lib-es/postOnboarding/hooks/usePostOnboardingHubState.js +13 -4
  347. package/lib-es/postOnboarding/hooks/usePostOnboardingHubState.js.map +1 -1
  348. package/lib-es/postOnboarding/mock.d.ts +1 -0
  349. package/lib-es/postOnboarding/mock.d.ts.map +1 -1
  350. package/lib-es/postOnboarding/mock.js +2 -0
  351. package/lib-es/postOnboarding/mock.js.map +1 -1
  352. package/lib-es/postOnboarding/reducer.d.ts +16 -14
  353. package/lib-es/postOnboarding/reducer.d.ts.map +1 -1
  354. package/lib-es/transaction/index.d.ts +1 -1
  355. package/lib-es/transaction/index.d.ts.map +1 -1
  356. package/lib-es/transaction/index.js +2 -2
  357. package/lib-es/transaction/index.js.map +1 -1
  358. package/lib-es/utils/addressUtils.d.ts +15 -0
  359. package/lib-es/utils/addressUtils.d.ts.map +1 -0
  360. package/lib-es/utils/addressUtils.js +35 -0
  361. package/lib-es/utils/addressUtils.js.map +1 -0
  362. package/lib-es/wallet-api/ACRE/server.d.ts.map +1 -1
  363. package/lib-es/wallet-api/ACRE/server.js +19 -15
  364. package/lib-es/wallet-api/ACRE/server.js.map +1 -1
  365. package/lib-es/wallet-api/Exchange/server.d.ts.map +1 -1
  366. package/lib-es/wallet-api/Exchange/server.js +9 -6
  367. package/lib-es/wallet-api/Exchange/server.js.map +1 -1
  368. package/lib-es/wallet-api/logic.d.ts.map +1 -1
  369. package/lib-es/wallet-api/logic.js +26 -26
  370. package/lib-es/wallet-api/logic.js.map +1 -1
  371. package/lib-es/wallet-api/react.d.ts.map +1 -1
  372. package/lib-es/wallet-api/react.js +38 -30
  373. package/lib-es/wallet-api/react.js.map +1 -1
  374. package/lib-es/wallet-api/useDappLogic.d.ts.map +1 -1
  375. package/lib-es/wallet-api/useDappLogic.js +74 -58
  376. package/lib-es/wallet-api/useDappLogic.js.map +1 -1
  377. package/package.json +51 -47
  378. package/src/DataModel.test.ts +74 -24
  379. package/src/DataModel.ts +4 -4
  380. package/src/__tests__/accounts/groupPerDay.ts +182 -177
  381. package/src/__tests__/csvExport.ts +3 -0
  382. package/src/__tests__/migration/account-migration.ts +2 -2
  383. package/src/__tests__/test-helpers/bridge.ts +426 -358
  384. package/src/__tests__/test-helpers/setup.ts +7 -6
  385. package/src/account/serialization.test.ts +6 -6
  386. package/src/account/serialization.ts +2 -2
  387. package/src/api/ofacGeoBlockApi.ts +19 -0
  388. package/src/apps/config.ts +1 -0
  389. package/src/bot/engine.ts +5 -5
  390. package/src/bridge/cache.test.ts +2 -0
  391. package/src/bridge/crypto-assets/index.test.ts +3 -9
  392. package/src/bridge/crypto-assets/index.ts +1 -1
  393. package/src/bridge/generic-alpaca/alpaca/network/network-alpaca.ts +3 -3
  394. package/src/bridge/generic-alpaca/createTransaction.ts +6 -1
  395. package/src/bridge/generic-alpaca/getTransactionStatus.ts +1 -0
  396. package/src/bridge/generic-alpaca/prepareTransaction.ts +36 -41
  397. package/src/bridge/generic-alpaca/signOperation.ts +10 -4
  398. package/src/bridge/generic-alpaca/signer/Eth.ts +4 -2
  399. package/src/bridge/generic-alpaca/tests/prepareTransaction.test.ts +29 -76
  400. package/src/bridge/generic-alpaca/tests/signOperation.test.ts +10 -2
  401. package/src/bridge/generic-alpaca/types.ts +80 -2
  402. package/src/bridge/generic-alpaca/utils.test.ts +58 -2
  403. package/src/bridge/generic-alpaca/utils.ts +151 -10
  404. package/src/bridge/index.ts +2 -2
  405. package/src/bridge/useBridgeTransaction.test.ts +9 -6
  406. package/src/currencies/cryptoIcons.test.ts +10 -5
  407. package/src/currencies/index.ts +0 -3
  408. package/src/currencies/sortByMarketcap.test.ts +4 -1
  409. package/src/dada-client/README.md +38 -0
  410. package/src/dada-client/__mocks__/assets.mock.ts +264 -0
  411. package/src/dada-client/hooks/__tests__/useLazyLedgerCurrency.test.ts +155 -0
  412. package/src/dada-client/hooks/useAssetsData.ts +14 -9
  413. package/src/dada-client/hooks/useLazyLedgerCurrency.ts +46 -0
  414. package/src/dada-client/index.ts +1 -0
  415. package/src/dada-client/state-manager/api.ts +1 -1
  416. package/src/dada-client/utils/__test__/currencySelection.test.ts +16 -0
  417. package/src/dada-client/utils/currencySelection.ts +33 -0
  418. package/src/deposit/deposit.integration.test.ts +15 -0
  419. package/src/deposit/deposit.test.ts +60 -40
  420. package/src/deposit/helper.ts +4 -8
  421. package/src/domain/getTokensWithFunds.test.ts +4 -0
  422. package/src/e2e/data/deviceLabelsData.ts +2 -1
  423. package/src/e2e/enum/DeviceLabels.ts +4 -0
  424. package/src/e2e/speculos.ts +26 -6
  425. package/src/e2e/speculosAppVersion.ts +1 -0
  426. package/src/families/aptos/__snapshots__/bridge.integration.test.ts.snap +12 -12
  427. package/src/families/bitcoin/__snapshots__/bridge.integration.test.ts.snap +1482 -843
  428. package/src/families/bitcoin/satstack.test.ts +33 -20
  429. package/src/families/cosmos/datasets/__snapshots__/babylon.integration.test.ts.snap +1 -1
  430. package/src/families/cosmos/datasets/__snapshots__/coreum.integration.test.ts.snap +4 -4
  431. package/src/families/cosmos/datasets/__snapshots__/cosmos.integration.test.ts.snap +251 -209
  432. package/src/families/cosmos/datasets/coreum.ts +2 -1
  433. package/src/families/hedera/__snapshots__/bridge.integration.test.ts.snap +675 -37
  434. package/src/families/multiversx/__snapshots__/bridge.integration.test.ts.snap +3 -3
  435. package/src/families/near/config.ts +1 -0
  436. package/src/families/polkadot/__snapshots__/bridge.integration.test.ts.snap +34 -34
  437. package/src/families/solana/__snapshots__/bridge.integration.test.ts.snap +3 -3
  438. package/src/families/stacks/__snapshots__/bridge.integration.test.ts.snap +10 -10
  439. package/src/families/stellar/__snapshots__/bridge.integration.test.ts.snap +1183 -625
  440. package/src/families/sui/__snapshots__/bridge.integration.test.ts.snap +428 -0
  441. package/src/families/tron/data.mock.ts +32 -16
  442. package/src/families/tron/react.test.ts +16 -4
  443. package/src/featureFlags/defaultFeatures.ts +3 -4
  444. package/src/featureFlags/stakePrograms/index.ts +14 -0
  445. package/src/hw/actions/implementations.ts +22 -11
  446. package/src/hw/connectAppEventMapper.ts +2 -4
  447. package/src/market/hooks/useMarketDataProvider.ts +4 -8
  448. package/src/market/utils/currencyFormatter.ts +4 -18
  449. package/src/market/utils/queryKeys.ts +0 -1
  450. package/src/market/utils/types.ts +6 -8
  451. package/src/mock/fixtures/cryptoCurrencies.ts +11 -2
  452. package/src/modularDrawer/__mocks__/currencies.mock.ts +1 -1
  453. package/src/modularDrawer/utils/__tests__/currencyUtils.test.ts +10 -10
  454. package/src/modularDrawer/utils/currencyUtils.ts +11 -10
  455. package/src/platform/serializers.test.ts +2 -2
  456. package/src/postOnboarding/hooks/usePostOnboardingHubState.test.ts +30 -3
  457. package/src/postOnboarding/hooks/usePostOnboardingHubState.ts +20 -6
  458. package/src/postOnboarding/mock.ts +2 -0
  459. package/src/transaction/index.ts +2 -2
  460. package/src/utils/__tests__/addressUtils.test.ts +229 -0
  461. package/src/utils/__tests__/getAccountTuplesForCurrency.test.ts +15 -4
  462. package/src/utils/addressUtils.ts +40 -0
  463. package/src/wallet-api/ACRE/server.test.ts +11 -8
  464. package/src/wallet-api/ACRE/server.ts +25 -22
  465. package/src/wallet-api/Exchange/server.ts +11 -8
  466. package/src/wallet-api/logic.test.ts +4 -0
  467. package/src/wallet-api/logic.ts +28 -32
  468. package/src/wallet-api/react.ts +37 -34
  469. package/src/wallet-api/useDappLogic.ts +103 -82
  470. package/lib/hooks/useOFACGeoBlockCheck.d.ts +0 -8
  471. package/lib/hooks/useOFACGeoBlockCheck.d.ts.map +0 -1
  472. package/lib/hooks/useOFACGeoBlockCheck.js +0 -32
  473. package/lib/hooks/useOFACGeoBlockCheck.js.map +0 -1
  474. package/lib-es/hooks/useOFACGeoBlockCheck.d.ts +0 -8
  475. package/lib-es/hooks/useOFACGeoBlockCheck.d.ts.map +0 -1
  476. package/lib-es/hooks/useOFACGeoBlockCheck.js +0 -28
  477. package/lib-es/hooks/useOFACGeoBlockCheck.js.map +0 -1
  478. package/src/hooks/useOFACGeoBlockCheck.ts +0 -37
@@ -31,7 +31,6 @@ import type {
31
31
  } from "@ledgerhq/types-live";
32
32
  import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
33
33
  import { firstValueFrom } from "rxjs";
34
- import { getDefaultAccountName } from "@ledgerhq/live-wallet/accountName";
35
34
 
36
35
  const warnDev = process.env.CI ? (..._args) => {} : (...msg) => console.warn(...msg);
37
36
  // FIXME move out into DatasetTest to be defined in
@@ -68,17 +67,19 @@ export function testBridge<T extends TransactionCommon>(data: DatasetTest<T>): v
68
67
  // covers all bridges through many different accounts
69
68
  // to test the common shared properties of bridges.
70
69
  const accountsRelated: Array<{
71
- account: Account;
70
+ accountRaw: any;
72
71
  currencyData: CurrenciesData<T>;
73
72
  accountData: any;
74
73
  impl: string;
74
+ currency: CryptoCurrency;
75
75
  }> = [];
76
76
  const currenciesRelated: Array<{
77
77
  currencyData: CurrenciesData<T>;
78
78
  currency: CryptoCurrency;
79
79
  }> = [];
80
80
  const { implementations, currencies } = data;
81
- Object.keys(currencies).forEach(currencyId => {
81
+
82
+ for (const currencyId of Object.keys(currencies)) {
82
83
  const currencyData = currencies[currencyId];
83
84
  const currency = getCryptoCurrencyById(currencyId);
84
85
  currenciesRelated.push({
@@ -87,31 +88,32 @@ export function testBridge<T extends TransactionCommon>(data: DatasetTest<T>): v
87
88
  });
88
89
 
89
90
  const accounts = currencyData.accounts || [];
90
- accounts.forEach(accountData =>
91
- implementations.forEach(impl => {
91
+ for (const accountData of accounts) {
92
+ for (const impl of implementations) {
92
93
  if (accountData.implementations && !accountData.implementations.includes(impl)) {
93
- return;
94
+ continue;
94
95
  }
95
96
 
96
- const account = fromAccountRaw({
97
+ const accountRaw = {
97
98
  ...accountData.raw,
98
99
  id: encodeAccountId({
99
100
  ...decodeAccountId(accountData.raw.id),
100
101
  type: impl,
101
102
  }),
102
- });
103
+ };
103
104
  accountsRelated.push({
104
105
  currencyData,
105
106
  accountData,
106
- account,
107
+ accountRaw,
107
108
  impl,
109
+ currency,
108
110
  });
109
- }),
110
- );
111
- });
111
+ }
112
+ }
113
+ }
112
114
  const accountsFoundInScanAccountsMap = {};
113
115
 
114
- currenciesRelated.map(({ currencyData, currency }) => {
116
+ currenciesRelated.forEach(({ currencyData, currency }) => {
115
117
  const bridge = getCurrencyBridge(currency);
116
118
 
117
119
  const scanAccounts = async apdus => {
@@ -337,29 +339,67 @@ export function testBridge<T extends TransactionCommon>(data: DatasetTest<T>): v
337
339
  });
338
340
 
339
341
  accountsRelated
340
- .map(({ account, ...rest }) => {
341
- const bridge = getAccountBridge(account, null);
342
- if (!bridge) throw new Error("no bridge for " + account.id);
342
+ .map(({ accountRaw, ...rest }) => {
343
+ let accountPromise;
344
+ let bridgePromise;
343
345
  let accountSyncedPromise;
344
346
 
345
347
  // lazy eval so we don't run this yet
346
- const getSynced = () =>
347
- accountSyncedPromise || (accountSyncedPromise = syncAccount(bridge, account));
348
+ const getAccount = () => accountPromise || (accountPromise = fromAccountRaw(accountRaw));
349
+
350
+ const getBridge = async () => {
351
+ if (!bridgePromise) {
352
+ bridgePromise = getAccount().then(account => {
353
+ const bridge = getAccountBridge(account, null);
354
+ if (!bridge) throw new Error("no bridge for " + account.id);
355
+ return bridge;
356
+ });
357
+ }
358
+ return bridgePromise;
359
+ };
360
+
361
+ const getSynced = async () => {
362
+ if (!accountSyncedPromise) {
363
+ const account = await getAccount();
364
+ const bridge = await getBridge();
365
+ accountSyncedPromise = syncAccount(bridge, account);
366
+ }
367
+ return accountSyncedPromise;
368
+ };
369
+
370
+ const currency = rest.currency;
348
371
 
349
372
  return {
350
373
  getSynced,
351
- bridge,
352
- initialAccount: account,
374
+ getBridge,
375
+ getAccount,
376
+ initialAccountRaw: accountRaw,
377
+ initialAccountId: accountRaw.id,
378
+ initialAccountCurrency: currency,
353
379
  ...rest,
354
380
  };
355
381
  })
356
382
  .forEach(arg => {
357
- const { getSynced, bridge, initialAccount, accountData, impl } = arg;
383
+ const {
384
+ getSynced,
385
+ getBridge,
386
+ getAccount,
387
+ initialAccountId,
388
+ initialAccountCurrency,
389
+ accountData,
390
+ impl,
391
+ } = arg;
358
392
 
359
393
  const makeTest = (name, fn) => {
360
394
  if (accountData.FIXME_tests && accountData.FIXME_tests.some(r => name.match(r))) {
361
395
  warnDev(
362
- "FIXME test was skipped. " + name + " for " + getDefaultAccountName(initialAccount),
396
+ "FIXME test was skipped. " +
397
+ name +
398
+ " for " +
399
+ initialAccountCurrency.name +
400
+ " (" +
401
+ initialAccountId +
402
+ ")",
363
403
  );
364
404
  return;
365
405
  }
@@ -367,389 +407,417 @@ export function testBridge<T extends TransactionCommon>(data: DatasetTest<T>): v
367
407
  test(name, fn);
368
408
  };
369
409
 
370
- describe(impl + " bridge on account " + getDefaultAccountName(initialAccount), () => {
371
- describe("sync", () => {
372
- makeTest("succeed", async () => {
373
- const account = await getSynced();
374
- expect(fromAccountRaw(toAccountRaw(account))).toBeDefined();
375
- });
376
-
377
- if (impl !== "mock") {
378
- const accFromScanAccounts = accountsFoundInScanAccountsMap[initialAccount.id];
379
-
380
- if (accFromScanAccounts) {
381
- makeTest("matches the same account from scanAccounts", async () => {
382
- const acc = await getSynced();
383
- expect(acc).toMatchObject(accFromScanAccounts);
384
- });
385
- }
386
- }
387
- makeTest("account have no NaN values", async () => {
388
- const account = await getSynced();
389
- [account, ...(account.subAccounts || [])].forEach(a => {
390
- expect(a.balance.isNaN()).toBe(false);
391
- expect(a.operations.find(op => op.value.isNaN())).toBe(undefined);
392
- expect(a.operations.find(op => op.fee.isNaN())).toBe(undefined);
410
+ describe(
411
+ impl + " bridge on account " + initialAccountCurrency.name + " (" + initialAccountId + ")",
412
+ () => {
413
+ describe("sync", () => {
414
+ makeTest("succeed", async () => {
415
+ const account = await getSynced();
416
+ expect(fromAccountRaw(toAccountRaw(account))).toBeDefined();
393
417
  });
394
- });
395
418
 
396
- if (
397
- !blacklistOpsSumEq.currencies.includes(initialAccount.currency.id) &&
398
- !blacklistOpsSumEq.impls.includes(impl)
399
- ) {
400
- makeTest("balance is sum of ops", async () => {
401
- const account = await getSynced();
402
- expectBalanceIsOpsSum(account);
419
+ if (impl !== "mock") {
420
+ const accFromScanAccounts = accountsFoundInScanAccountsMap[initialAccountId];
403
421
 
404
- if (account.subAccounts) {
405
- account.subAccounts.forEach(expectBalanceIsOpsSum);
422
+ if (accFromScanAccounts) {
423
+ makeTest("matches the same account from scanAccounts", async () => {
424
+ const acc = await getSynced();
425
+ expect(acc).toMatchObject(accFromScanAccounts);
426
+ });
406
427
  }
407
- });
408
- makeTest("balance and spendableBalance boundaries", async () => {
428
+ }
429
+ makeTest("account have no NaN values", async () => {
409
430
  const account = await getSynced();
410
- expect(account.balance).toBeInstanceOf(BigNumber);
411
- expect(account.spendableBalance).toBeInstanceOf(BigNumber);
412
- expect(account.balance.lt(0)).toBe(false);
413
- expect(account.spendableBalance.lt(0)).toBe(false);
414
- expect(account.spendableBalance.lte(account.balance)).toBe(true);
431
+ [account, ...(account.subAccounts || [])].forEach(a => {
432
+ expect(a.balance.isNaN()).toBe(false);
433
+ expect(a.operations.find(op => op.value.isNaN())).toBe(undefined);
434
+ expect(a.operations.find(op => op.fee.isNaN())).toBe(undefined);
435
+ });
415
436
  });
416
- }
417
437
 
418
- makeTest("existing operations object refs are preserved", async () => {
419
- const account = await getSynced();
420
- const count = Math.floor(account.operations.length / 2);
421
- const operations = account.operations.slice(count);
422
- const copy = {
423
- ...account,
424
- operations,
425
- blockHeight: 0,
426
- };
427
- const synced = await syncAccount(bridge, copy);
428
- if (initialAccount.id.includes("ripple")) return; // ripple wont work because of the current implementation of pagination
429
- expect(synced.operations.length).toBe(account.operations.length);
430
- // same ops are restored
431
- expect(synced.operations).toEqual(account.operations);
432
- if (initialAccount.id.startsWith("ethereumjs")) return; // ethereumjs seems to have a bug on this, we ignore because the impl will be dropped.
433
-
434
- // existing ops are keeping refs
435
- synced.operations.slice(count).forEach((op, i) => {
436
- expect(op).toStrictEqual(operations[i]);
437
- });
438
- });
439
- makeTest("pendingOperations are cleaned up", async () => {
440
- const account = await getSynced();
441
- if (initialAccount.id.includes("ripple")) return; // ripple wont work because of the current implementation of pagination
438
+ if (
439
+ !blacklistOpsSumEq.currencies.includes(initialAccountCurrency.id) &&
440
+ !blacklistOpsSumEq.impls.includes(impl)
441
+ ) {
442
+ makeTest("balance is sum of ops", async () => {
443
+ const account = await getSynced();
444
+ expectBalanceIsOpsSum(account);
442
445
 
443
- if (account.operations.length) {
444
- const operations = account.operations.slice(1);
445
- const pendingOperations = [account.operations[0]];
446
+ if (account.subAccounts) {
447
+ account.subAccounts.forEach(expectBalanceIsOpsSum);
448
+ }
449
+ });
450
+ makeTest("balance and spendableBalance boundaries", async () => {
451
+ const account = await getSynced();
452
+ expect(account.balance).toBeInstanceOf(BigNumber);
453
+ expect(account.spendableBalance).toBeInstanceOf(BigNumber);
454
+ expect(account.balance.lt(0)).toBe(false);
455
+ expect(account.spendableBalance.lt(0)).toBe(false);
456
+ expect(account.spendableBalance.lte(account.balance)).toBe(true);
457
+ });
458
+ }
459
+
460
+ makeTest("existing operations object refs are preserved", async () => {
461
+ const account = await getSynced();
462
+ const count = Math.floor(account.operations.length / 2);
463
+ const operations = account.operations.slice(count);
446
464
  const copy = {
447
465
  ...account,
448
466
  operations,
449
- pendingOperations,
450
467
  blockHeight: 0,
451
468
  };
469
+ const bridge = await getBridge();
452
470
  const synced = await syncAccount(bridge, copy);
471
+ if (initialAccountId.includes("ripple")) return; // ripple wont work because of the current implementation of pagination
472
+ expect(synced.operations.length).toBe(account.operations.length);
453
473
  // same ops are restored
454
474
  expect(synced.operations).toEqual(account.operations);
455
- // pendingOperations is empty
456
- expect(synced.pendingOperations).toEqual([]);
457
- }
458
- });
459
- makeTest("there are no Operation dups (by id)", async () => {
460
- const account = await getSynced();
461
- const seen = {};
462
- account.operations.forEach(op => {
463
- expect(seen[op.id]).toBeUndefined();
464
- seen[op.id] = op.id;
465
- });
466
- });
467
- });
475
+ if (initialAccountId.startsWith("ethereumjs")) return; // ethereumjs seems to have a bug on this, we ignore because the impl will be dropped.
468
476
 
469
- describe("createTransaction", () => {
470
- makeTest("empty transaction is an object with empty recipient and zero amount", () => {
471
- expect(bridge.createTransaction(initialAccount)).toMatchObject({
472
- amount: new BigNumber(0),
473
- recipient: "",
477
+ // existing ops are keeping refs
478
+ synced.operations.slice(count).forEach((op, i) => {
479
+ expect(op).toStrictEqual(operations[i]);
480
+ });
481
+ });
482
+ makeTest("pendingOperations are cleaned up", async () => {
483
+ const account = await getSynced();
484
+ if (initialAccountId.includes("ripple")) return; // ripple wont work because of the current implementation of pagination
485
+
486
+ if (account.operations.length) {
487
+ const operations = account.operations.slice(1);
488
+ const pendingOperations = [account.operations[0]];
489
+ const copy = {
490
+ ...account,
491
+ operations,
492
+ pendingOperations,
493
+ blockHeight: 0,
494
+ };
495
+ const bridge = await getBridge();
496
+ const synced = await syncAccount(bridge, copy);
497
+ // same ops are restored
498
+ expect(synced.operations).toEqual(account.operations);
499
+ // pendingOperations is empty
500
+ expect(synced.pendingOperations).toEqual([]);
501
+ }
502
+ });
503
+ makeTest("there are no Operation dups (by id)", async () => {
504
+ const account = await getSynced();
505
+ const seen = {};
506
+ account.operations.forEach(op => {
507
+ expect(seen[op.id]).toBeUndefined();
508
+ seen[op.id] = op.id;
509
+ });
474
510
  });
475
511
  });
476
- makeTest("empty transaction is equals to itself", () => {
477
- expect(bridge.createTransaction(initialAccount)).toEqual(
478
- bridge.createTransaction(initialAccount),
512
+
513
+ describe("createTransaction", () => {
514
+ makeTest(
515
+ "empty transaction is an object with empty recipient and zero amount",
516
+ async () => {
517
+ const account = await getAccount();
518
+ const bridge = await getBridge();
519
+ expect(bridge.createTransaction(account)).toMatchObject({
520
+ amount: new BigNumber(0),
521
+ recipient: "",
522
+ });
523
+ },
479
524
  );
525
+ makeTest("empty transaction is equals to itself", async () => {
526
+ const account = await getAccount();
527
+ const bridge = await getBridge();
528
+ expect(bridge.createTransaction(account)).toEqual(bridge.createTransaction(account));
529
+ });
530
+ makeTest("empty transaction correctly serialize", async () => {
531
+ const account = await getAccount();
532
+ const bridge = await getBridge();
533
+ const t = bridge.createTransaction(account);
534
+ expect(fromTransactionRaw(toTransactionRaw(t))).toEqual(t);
535
+ });
536
+ makeTest("transaction with amount and recipient correctly serialize", async () => {
537
+ const account = await getSynced();
538
+ const bridge = await getBridge();
539
+ const t = {
540
+ ...bridge.createTransaction(account),
541
+ amount: new BigNumber(1000),
542
+ recipient: account.freshAddress,
543
+ };
544
+ expect(fromTransactionRaw(toTransactionRaw(t))).toEqual(t);
545
+ });
480
546
  });
481
- makeTest("empty transaction correctly serialize", () => {
482
- const t = bridge.createTransaction(initialAccount);
483
- expect(fromTransactionRaw(toTransactionRaw(t))).toEqual(t);
484
- });
485
- makeTest("transaction with amount and recipient correctly serialize", async () => {
486
- const account = await getSynced();
487
- const t = {
488
- ...bridge.createTransaction(account),
489
- amount: new BigNumber(1000),
490
- recipient: account.freshAddress,
491
- };
492
- expect(fromTransactionRaw(toTransactionRaw(t))).toEqual(t);
493
- });
494
- });
495
547
 
496
- describe("updateTransaction", () => {
497
- // stability: function called twice will return the same object reference
498
- // (=== convergence so we can stop looping, typically because transaction will be a hook effect dependency of prepareTransaction)
499
- function expectStability(t, patch) {
500
- const t2 = bridge.updateTransaction(t, patch);
501
- const t3 = bridge.updateTransaction(t2, patch);
502
- expect(t2).toBe(t3);
503
- }
548
+ describe("updateTransaction", () => {
549
+ // stability: function called twice will return the same object reference
550
+ // (=== convergence so we can stop looping, typically because transaction will be a hook effect dependency of prepareTransaction)
551
+ async function expectStability(t, patch) {
552
+ const bridge = await getBridge();
553
+ const t2 = bridge.updateTransaction(t, patch);
554
+ const t3 = bridge.updateTransaction(t2, patch);
555
+ expect(t2).toBe(t3);
556
+ }
504
557
 
505
- makeTest("ref stability on empty transaction", async () => {
506
- const account = await getSynced();
507
- const tx = bridge.createTransaction(account);
508
- expectStability(tx, {});
509
- });
558
+ makeTest("ref stability on empty transaction", async () => {
559
+ const account = await getSynced();
560
+ const bridge = await getBridge();
561
+ const tx = bridge.createTransaction(account);
562
+ await expectStability(tx, {});
563
+ });
510
564
 
511
- makeTest("ref stability on self transaction", async () => {
512
- const account = await getSynced();
513
- const tx = bridge.createTransaction(account);
514
- expectStability(tx, {
515
- amount: new BigNumber(1000),
516
- recipient: account.freshAddress,
565
+ makeTest("ref stability on self transaction", async () => {
566
+ const account = await getSynced();
567
+ const bridge = await getBridge();
568
+ const tx = bridge.createTransaction(account);
569
+ await expectStability(tx, {
570
+ amount: new BigNumber(1000),
571
+ recipient: account.freshAddress,
572
+ });
517
573
  });
518
574
  });
519
- });
520
575
 
521
- describe("prepareTransaction", () => {
522
- // stability: function called twice will return the same object reference
523
- // (=== convergence so we can stop looping, typically because transaction will be a hook effect dependency of prepareTransaction)
524
- async function expectStability(account, t) {
525
- let t2 = await bridge.prepareTransaction(account, t);
526
- let t3 = await bridge.prepareTransaction(account, t2);
527
- t2 = omit(t2, arg.currencyData.IgnorePrepareTransactionFields || []);
528
- t3 = omit(t3, arg.currencyData.IgnorePrepareTransactionFields || []);
529
- expect(t2).toStrictEqual(t3);
530
- }
576
+ describe("prepareTransaction", () => {
577
+ // stability: function called twice will return the same object reference
578
+ // (=== convergence so we can stop looping, typically because transaction will be a hook effect dependency of prepareTransaction)
579
+ async function expectStability(account, t) {
580
+ const bridge = await getBridge();
581
+ let t2 = await bridge.prepareTransaction(account, t);
582
+ let t3 = await bridge.prepareTransaction(account, t2);
583
+ t2 = omit(t2, arg.currencyData.IgnorePrepareTransactionFields || []);
584
+ t3 = omit(t3, arg.currencyData.IgnorePrepareTransactionFields || []);
585
+ expect(t2).toStrictEqual(t3);
586
+ }
531
587
 
532
- makeTest("ref stability on empty transaction", async () => {
533
- const account = await getSynced();
534
- await expectStability(account, bridge.createTransaction(account));
535
- });
536
- makeTest("ref stability on self transaction", async () => {
537
- const account = await getSynced();
538
- await expectStability(account, {
539
- ...bridge.createTransaction(account),
540
- amount: new BigNumber(1000),
541
- recipient: account.freshAddress,
588
+ makeTest("ref stability on empty transaction", async () => {
589
+ const account = await getSynced();
590
+ const bridge = await getBridge();
591
+ await expectStability(account, bridge.createTransaction(account));
542
592
  });
543
- });
544
- makeTest("can be run in parallel and all yield same results", async () => {
545
- const account = await getSynced();
546
- const t = {
547
- ...bridge.createTransaction(account),
548
- amount: new BigNumber(1000),
549
- recipient: account.freshAddress,
550
- };
551
- const stable = await bridge.prepareTransaction(account, t);
552
- const first = omit(
553
- await bridge.prepareTransaction(account, stable),
554
- arg.currencyData.IgnorePrepareTransactionFields || [],
555
- );
556
- const concur = await Promise.all(
557
- Array(3)
558
- .fill(null)
559
- .map(() => bridge.prepareTransaction(account, stable)),
560
- );
561
- concur.forEach(r => {
562
- r = omit(r, arg.currencyData.IgnorePrepareTransactionFields || []);
563
- expect(r).toEqual(first);
593
+ makeTest("ref stability on self transaction", async () => {
594
+ const account = await getSynced();
595
+ const bridge = await getBridge();
596
+ await expectStability(account, {
597
+ ...bridge.createTransaction(account),
598
+ amount: new BigNumber(1000),
599
+ recipient: account.freshAddress,
600
+ });
601
+ });
602
+ makeTest("can be run in parallel and all yield same results", async () => {
603
+ const account = await getSynced();
604
+ const bridge = await getBridge();
605
+ const t = {
606
+ ...bridge.createTransaction(account),
607
+ amount: new BigNumber(1000),
608
+ recipient: account.freshAddress,
609
+ };
610
+ const stable = await bridge.prepareTransaction(account, t);
611
+ const first = omit(
612
+ await bridge.prepareTransaction(account, stable),
613
+ arg.currencyData.IgnorePrepareTransactionFields || [],
614
+ );
615
+ const concur = await Promise.all(
616
+ Array(3)
617
+ .fill(null)
618
+ .map(() => bridge.prepareTransaction(account, stable)),
619
+ );
620
+ concur.forEach(r => {
621
+ r = omit(r, arg.currencyData.IgnorePrepareTransactionFields || []);
622
+ expect(r).toEqual(first);
623
+ });
564
624
  });
565
625
  });
566
- });
567
626
 
568
- describe("getTransactionStatus", () => {
569
- makeTest("can be called on an empty transaction", async () => {
570
- const account = await getSynced();
571
- const t = {
572
- ...bridge.createTransaction(account),
573
- feePerByte: new BigNumber(0.0001),
574
- };
575
- const s = await bridge.getTransactionStatus(account, t);
576
- expect(s).toBeDefined();
577
- expect(s.errors).toHaveProperty("recipient");
578
- expect(s).toHaveProperty("totalSpent");
579
- expect(s.totalSpent).toBeInstanceOf(BigNumber);
580
- expect(s).toHaveProperty("estimatedFees");
581
- expect(s.estimatedFees).toBeInstanceOf(BigNumber);
582
- expect(s).toHaveProperty("amount");
583
- expect(s.amount).toBeInstanceOf(BigNumber);
584
- expect(s.amount).toEqual(new BigNumber(0));
585
- });
586
- makeTest("can be called on an empty prepared transaction", async () => {
587
- const account = await getSynced();
588
- const t = await bridge.prepareTransaction(account, {
589
- ...bridge.createTransaction(account),
590
- feePerByte: new BigNumber(0.0001),
627
+ describe("getTransactionStatus", () => {
628
+ makeTest("can be called on an empty transaction", async () => {
629
+ const account = await getSynced();
630
+ const bridge = await getBridge();
631
+ const t = {
632
+ ...bridge.createTransaction(account),
633
+ feePerByte: new BigNumber(0.0001),
634
+ };
635
+ const s = await bridge.getTransactionStatus(account, t);
636
+ expect(s).toBeDefined();
637
+ expect(s.errors).toHaveProperty("recipient");
638
+ expect(s).toHaveProperty("totalSpent");
639
+ expect(s.totalSpent).toBeInstanceOf(BigNumber);
640
+ expect(s).toHaveProperty("estimatedFees");
641
+ expect(s.estimatedFees).toBeInstanceOf(BigNumber);
642
+ expect(s).toHaveProperty("amount");
643
+ expect(s.amount).toBeInstanceOf(BigNumber);
644
+ expect(s.amount).toEqual(new BigNumber(0));
591
645
  });
592
- const s = await bridge.getTransactionStatus(account, t);
593
- expect(s).toBeDefined(); // FIXME i'm not sure if we can establish more shared properties
594
- });
595
- makeTest("Default empty recipient have a recipientError", async () => {
596
- const account = await getSynced();
597
- const t = {
598
- ...bridge.createTransaction(account),
599
- feePerByte: new BigNumber(0.0001),
600
- };
601
- const status = await bridge.getTransactionStatus(account, t);
602
- expect(status.errors.recipient).toBeInstanceOf(RecipientRequired);
603
- });
604
- makeTest("invalid recipient have a recipientError", async () => {
605
- const account = await getSynced();
606
- const t = {
607
- ...bridge.createTransaction(account),
608
- feePerByte: new BigNumber(0.0001),
609
- recipient: "invalidADDRESS",
610
- };
611
- const status = await bridge.getTransactionStatus(account, t);
612
- expect(status.errors.recipient).toBeInstanceOf(InvalidAddress);
613
- });
614
- makeTest("Default empty amount has an amount error", async () => {
615
- const account = await getSynced();
616
- const t = await bridge.prepareTransaction(account, {
617
- ...bridge.createTransaction(account),
618
- feePerByte: new BigNumber(0.0001),
646
+ makeTest("can be called on an empty prepared transaction", async () => {
647
+ const bridge = await getBridge();
648
+ const account = await getSynced();
649
+ const t = await bridge.prepareTransaction(account, {
650
+ ...bridge.createTransaction(account),
651
+ feePerByte: new BigNumber(0.0001),
652
+ });
653
+ const s = await bridge.getTransactionStatus(account, t);
654
+ expect(s).toBeDefined(); // FIXME i'm not sure if we can establish more shared properties
655
+ });
656
+ makeTest("Default empty recipient have a recipientError", async () => {
657
+ const bridge = await getBridge();
658
+ const account = await getSynced();
659
+ const t = {
660
+ ...bridge.createTransaction(account),
661
+ feePerByte: new BigNumber(0.0001),
662
+ };
663
+ const status = await bridge.getTransactionStatus(account, t);
664
+ expect(status.errors.recipient).toBeInstanceOf(RecipientRequired);
665
+ });
666
+ makeTest("invalid recipient have a recipientError", async () => {
667
+ const bridge = await getBridge();
668
+ const account = await getSynced();
669
+ const t = {
670
+ ...bridge.createTransaction(account),
671
+ feePerByte: new BigNumber(0.0001),
672
+ recipient: "invalidADDRESS",
673
+ };
674
+ const status = await bridge.getTransactionStatus(account, t);
675
+ expect(status.errors.recipient).toBeInstanceOf(InvalidAddress);
676
+ });
677
+ makeTest("Default empty amount has an amount error", async () => {
678
+ const bridge = await getBridge();
679
+ const account = await getSynced();
680
+ const t = await bridge.prepareTransaction(account, {
681
+ ...bridge.createTransaction(account),
682
+ feePerByte: new BigNumber(0.0001),
683
+ });
684
+ const status = await bridge.getTransactionStatus(account, t);
685
+ expect(status.errors.amount).toBeInstanceOf(AmountRequired);
619
686
  });
620
- const status = await bridge.getTransactionStatus(account, t);
621
- expect(status.errors.amount).toBeInstanceOf(AmountRequired);
622
- });
623
687
 
624
- const accountDataTest = accountData.test;
688
+ const accountDataTest = accountData.test;
625
689
 
626
- if (accountDataTest) {
627
- makeTest("account specific test", async () =>
628
- accountDataTest(expect, await getSynced(), bridge),
629
- );
630
- }
690
+ if (accountDataTest) {
691
+ makeTest("account specific test", async () => {
692
+ const bridge = await getBridge();
693
+ return accountDataTest(expect, await getSynced(), bridge);
694
+ });
695
+ }
631
696
 
632
- (accountData.transactions || []).forEach(
633
- ({ name, transaction, expectedStatus, apdus, testSignedOperation, test: testFn }) => {
634
- makeTest("transaction " + name, async () => {
635
- const account: Account = await getSynced();
636
- let t =
637
- typeof transaction === "function"
638
- ? transaction(bridge.createTransaction(account), account, bridge)
639
- : transaction;
640
- t = await bridge.prepareTransaction(account, {
641
- feePerByte: new BigNumber(0.0001),
642
- ...t,
643
- });
644
- const s = await bridge.getTransactionStatus(account, t);
645
-
646
- if (expectedStatus) {
647
- const es =
648
- typeof expectedStatus === "function"
649
- ? expectedStatus(account, t, s)
650
- : expectedStatus;
651
- const { errors, warnings } = es;
652
-
653
- // we match errors and warnings
654
- errors && expect(s.errors).toMatchObject(errors);
655
- warnings && expect(s.warnings).toMatchObject(warnings);
656
- // now we match rest of fields but using the raw version for better readability
657
- const restRaw: Record<string, any> = toTransactionStatusRaw(
658
- {
659
- ...s,
660
- ...es,
661
- },
662
- account.currency.family,
663
- );
664
- delete restRaw.errors;
665
- delete restRaw.warnings;
697
+ (accountData.transactions || []).forEach(
698
+ ({ name, transaction, expectedStatus, apdus, testSignedOperation, test: testFn }) => {
699
+ makeTest("transaction " + name, async () => {
700
+ const bridge = await getBridge();
701
+ const account: Account = await getSynced();
702
+ let t =
703
+ typeof transaction === "function"
704
+ ? transaction(bridge.createTransaction(account), account, bridge)
705
+ : transaction;
706
+ t = await bridge.prepareTransaction(account, {
707
+ feePerByte: new BigNumber(0.0001),
708
+ ...t,
709
+ });
710
+ const s = await bridge.getTransactionStatus(account, t);
711
+
712
+ if (expectedStatus) {
713
+ const es =
714
+ typeof expectedStatus === "function"
715
+ ? expectedStatus(account, t, s)
716
+ : expectedStatus;
717
+ const { errors, warnings } = es;
718
+
719
+ // we match errors and warnings
720
+ errors && expect(s.errors).toMatchObject(errors);
721
+ warnings && expect(s.warnings).toMatchObject(warnings);
722
+ // now we match rest of fields but using the raw version for better readability
723
+ const restRaw: Record<string, any> = toTransactionStatusRaw(
724
+ {
725
+ ...s,
726
+ ...es,
727
+ },
728
+ account.currency.family,
729
+ );
730
+ delete restRaw.errors;
731
+ delete restRaw.warnings;
666
732
 
667
- for (const k in restRaw) {
668
- if (!(k in es)) {
669
- delete restRaw[k];
733
+ for (const k in restRaw) {
734
+ if (!(k in es)) {
735
+ delete restRaw[k];
736
+ }
670
737
  }
671
- }
672
738
 
673
- expect(
674
- toTransactionStatusRaw(s as TransactionStatusCommon, account.currency.family),
675
- ).toMatchObject(restRaw);
676
- }
739
+ expect(
740
+ toTransactionStatusRaw(s as TransactionStatusCommon, account.currency.family),
741
+ ).toMatchObject(restRaw);
742
+ }
677
743
 
678
- if (testFn) {
679
- await testFn(expect, t, s, bridge);
680
- }
744
+ if (testFn) {
745
+ await testFn(expect, t, s, bridge);
746
+ }
681
747
 
682
- if (Object.keys(s.errors).length === 0) {
683
- const { subAccountId } = t;
684
- const { subAccounts } = account;
685
-
686
- const inferSubAccount = () => {
687
- invariant(subAccounts, "sub accounts available");
688
- const a = (subAccounts as TokenAccount[]).find(a => a.id === subAccountId);
689
- invariant(a, "sub account not found");
690
- return a;
691
- };
692
-
693
- const obj = subAccountId
694
- ? {
695
- transaction: t as TransactionCommon,
696
- account: inferSubAccount() as AccountLike,
697
- parentAccount: account,
748
+ if (Object.keys(s.errors).length === 0) {
749
+ const { subAccountId } = t;
750
+ const { subAccounts } = account;
751
+
752
+ const inferSubAccount = () => {
753
+ invariant(subAccounts, "sub accounts available");
754
+ const a = (subAccounts as TokenAccount[]).find(a => a.id === subAccountId);
755
+ invariant(a, "sub account not found");
756
+ return a;
757
+ };
758
+
759
+ const obj = subAccountId
760
+ ? {
761
+ transaction: t as TransactionCommon,
762
+ account: inferSubAccount() as AccountLike,
763
+ parentAccount: account,
764
+ }
765
+ : {
766
+ transaction: t as TransactionCommon,
767
+ account: account as AccountLike,
768
+ };
769
+
770
+ if (
771
+ (typeof t.mode !== "string" || t.mode === "send") &&
772
+ t.model &&
773
+ t.model.kind !== "stake.createAccount"
774
+ ) {
775
+ const estimation = await bridge.estimateMaxSpendable(obj);
776
+ expect(estimation.gte(0)).toBe(true);
777
+ expect(estimation.lte(obj.account.balance)).toBe(true);
778
+
779
+ if (t.useAllAmount) {
780
+ expect(estimation.toString()).toBe(s.amount.toString());
698
781
  }
699
- : {
700
- transaction: t as TransactionCommon,
701
- account: account as AccountLike,
702
- };
703
-
704
- if (
705
- (typeof t.mode !== "string" || t.mode === "send") &&
706
- t.model &&
707
- t.model.kind !== "stake.createAccount"
708
- ) {
709
- const estimation = await bridge.estimateMaxSpendable(obj);
710
- expect(estimation.gte(0)).toBe(true);
711
- expect(estimation.lte(obj.account.balance)).toBe(true);
712
-
713
- if (t.useAllAmount) {
714
- expect(estimation.toString()).toBe(s.amount.toString());
715
782
  }
716
783
  }
717
- }
718
-
719
- if (apdus && impl !== "mock") {
720
- const deviceId = await mockDeviceWithAPDUs(apdus);
721
-
722
- try {
723
- const signedOperation = await firstValueFrom(
724
- bridge
725
- .signOperation({
726
- account,
727
- deviceId,
728
- transaction: t,
729
- })
730
- .pipe(
731
- filter(e => e.type === "signed"),
732
- map((e: any) => e.signedOperation),
733
- ),
734
- );
735
784
 
736
- if (testSignedOperation) {
737
- await testSignedOperation(expect, signedOperation, account, t, s, bridge);
785
+ if (apdus && impl !== "mock") {
786
+ const deviceId = await mockDeviceWithAPDUs(apdus);
787
+
788
+ try {
789
+ const signedOperation = await firstValueFrom(
790
+ bridge
791
+ .signOperation({
792
+ account,
793
+ deviceId,
794
+ transaction: t,
795
+ })
796
+ .pipe(
797
+ filter((e: any) => e.type === "signed"),
798
+ map((e: any) => e.signedOperation),
799
+ ),
800
+ );
801
+
802
+ if (testSignedOperation) {
803
+ await testSignedOperation(expect, signedOperation, account, t, s, bridge);
804
+ }
805
+ } finally {
806
+ releaseMockDevice(deviceId);
738
807
  }
739
- } finally {
740
- releaseMockDevice(deviceId);
741
808
  }
742
- }
743
- });
744
- },
745
- );
746
- });
747
- describe("signOperation and broadcast", () => {
748
- makeTest("method is available on bridge", async () => {
749
- expect(typeof bridge.signOperation).toBe("function");
750
- expect(typeof bridge.broadcast).toBe("function");
751
- }); // NB for now we are not going farther because most is covered by bash tests
752
- });
753
- });
809
+ });
810
+ },
811
+ );
812
+ });
813
+ describe("signOperation and broadcast", () => {
814
+ makeTest("method is available on bridge", async () => {
815
+ const bridge = await getBridge();
816
+ expect(typeof bridge.signOperation).toBe("function");
817
+ expect(typeof bridge.broadcast).toBe("function");
818
+ }); // NB for now we are not going farther because most is covered by bash tests
819
+ });
820
+ },
821
+ );
754
822
  });
755
823
  }