@ledgerhq/live-common 21.35.0 → 21.36.2

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 (236) hide show
  1. package/lib/__tests__/families/bitcoin/wallet-btc/bitcoin.test.js +290 -225
  2. package/lib/__tests__/families/bitcoin/wallet-btc/bitcoin.test.js.map +1 -1
  3. package/lib/__tests__/families/bitcoin/wallet-btc/utils.test.js +2 -0
  4. package/lib/__tests__/families/bitcoin/wallet-btc/utils.test.js.map +1 -1
  5. package/lib/__tests__/families/bitcoin/wallet-btc/wallet.errorpropagation.test.d.ts +2 -0
  6. package/lib/__tests__/families/bitcoin/wallet-btc/wallet.errorpropagation.test.d.ts.map +1 -0
  7. package/lib/__tests__/families/bitcoin/wallet-btc/wallet.errorpropagation.test.js +86 -0
  8. package/lib/__tests__/families/bitcoin/wallet-btc/wallet.errorpropagation.test.js.map +1 -0
  9. package/lib/__tests__/families/bitcoin/wallet-btc/xpub.getAddress.js +38 -0
  10. package/lib/__tests__/families/bitcoin/wallet-btc/xpub.getAddress.js.map +1 -1
  11. package/lib/__tests__/families/bitcoin/wallet-btc/xpub.txs.integration.test.js +4 -4
  12. package/lib/__tests__/families/bitcoin/wallet-btc/xpub.txs.integration.test.js.map +1 -1
  13. package/lib/account/support.js +1 -1
  14. package/lib/account/support.js.map +1 -1
  15. package/lib/apps/support.js +1 -1
  16. package/lib/bot/engine.d.ts.map +1 -1
  17. package/lib/bot/engine.js +77 -45
  18. package/lib/bot/engine.js.map +1 -1
  19. package/lib/bot/index.d.ts.map +1 -1
  20. package/lib/bot/index.js +44 -20
  21. package/lib/bot/index.js.map +1 -1
  22. package/lib/bot/types.d.ts +1 -0
  23. package/lib/bot/types.d.ts.map +1 -1
  24. package/lib/bridge/jsHelpers.d.ts +25 -2
  25. package/lib/bridge/jsHelpers.d.ts.map +1 -1
  26. package/lib/bridge/jsHelpers.js +94 -60
  27. package/lib/bridge/jsHelpers.js.map +1 -1
  28. package/lib/cross.d.ts.map +1 -1
  29. package/lib/cross.js +5 -3
  30. package/lib/cross.js.map +1 -1
  31. package/lib/exchange/swap/getCompleteSwapHistory.js +17 -14
  32. package/lib/exchange/swap/getCompleteSwapHistory.js.map +1 -1
  33. package/lib/families/algorand/js-synchronization.d.ts.map +1 -1
  34. package/lib/families/algorand/js-synchronization.js +2 -5
  35. package/lib/families/algorand/js-synchronization.js.map +1 -1
  36. package/lib/families/bitcoin/js-synchronisation.d.ts.map +1 -1
  37. package/lib/families/bitcoin/js-synchronisation.js +5 -2
  38. package/lib/families/bitcoin/js-synchronisation.js.map +1 -1
  39. package/lib/families/bitcoin/specs.d.ts.map +1 -1
  40. package/lib/families/bitcoin/specs.js +4 -2
  41. package/lib/families/bitcoin/specs.js.map +1 -1
  42. package/lib/families/bitcoin/wallet-btc/crypto/base.d.ts +5 -6
  43. package/lib/families/bitcoin/wallet-btc/crypto/base.d.ts.map +1 -1
  44. package/lib/families/bitcoin/wallet-btc/crypto/base.js +149 -59
  45. package/lib/families/bitcoin/wallet-btc/crypto/base.js.map +1 -1
  46. package/lib/families/bitcoin/wallet-btc/crypto/bip32.d.ts +1 -1
  47. package/lib/families/bitcoin/wallet-btc/crypto/bip32.d.ts.map +1 -1
  48. package/lib/families/bitcoin/wallet-btc/crypto/bip32.js +59 -9
  49. package/lib/families/bitcoin/wallet-btc/crypto/bip32.js.map +1 -1
  50. package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.d.ts +1 -1
  51. package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.d.ts.map +1 -1
  52. package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.js +76 -24
  53. package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.js.map +1 -1
  54. package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.d.ts +2 -2
  55. package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.d.ts.map +1 -1
  56. package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.js +55 -2
  57. package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.js.map +1 -1
  58. package/lib/families/bitcoin/wallet-btc/crypto/decred.d.ts +1 -1
  59. package/lib/families/bitcoin/wallet-btc/crypto/decred.d.ts.map +1 -1
  60. package/lib/families/bitcoin/wallet-btc/crypto/decred.js +61 -14
  61. package/lib/families/bitcoin/wallet-btc/crypto/decred.js.map +1 -1
  62. package/lib/families/bitcoin/wallet-btc/crypto/index.d.ts +1 -0
  63. package/lib/families/bitcoin/wallet-btc/crypto/index.d.ts.map +1 -1
  64. package/lib/families/bitcoin/wallet-btc/crypto/index.js +4 -1
  65. package/lib/families/bitcoin/wallet-btc/crypto/index.js.map +1 -1
  66. package/lib/families/bitcoin/wallet-btc/crypto/secp256k1.d.ts +16 -0
  67. package/lib/families/bitcoin/wallet-btc/crypto/secp256k1.d.ts.map +1 -0
  68. package/lib/families/bitcoin/wallet-btc/crypto/secp256k1.js +28 -0
  69. package/lib/families/bitcoin/wallet-btc/crypto/secp256k1.js.map +1 -0
  70. package/lib/families/bitcoin/wallet-btc/crypto/types.d.ts +2 -2
  71. package/lib/families/bitcoin/wallet-btc/crypto/types.d.ts.map +1 -1
  72. package/lib/families/bitcoin/wallet-btc/crypto/zec.d.ts +2 -2
  73. package/lib/families/bitcoin/wallet-btc/crypto/zec.d.ts.map +1 -1
  74. package/lib/families/bitcoin/wallet-btc/crypto/zec.js +72 -10
  75. package/lib/families/bitcoin/wallet-btc/crypto/zec.js.map +1 -1
  76. package/lib/families/bitcoin/wallet-btc/crypto/zen.d.ts +2 -2
  77. package/lib/families/bitcoin/wallet-btc/crypto/zen.d.ts.map +1 -1
  78. package/lib/families/bitcoin/wallet-btc/crypto/zen.js +60 -6
  79. package/lib/families/bitcoin/wallet-btc/crypto/zen.js.map +1 -1
  80. package/lib/families/bitcoin/wallet-btc/storage/index.d.ts +20 -4
  81. package/lib/families/bitcoin/wallet-btc/storage/index.d.ts.map +1 -1
  82. package/lib/families/bitcoin/wallet-btc/storage/index.js +45 -8
  83. package/lib/families/bitcoin/wallet-btc/storage/index.js.map +1 -1
  84. package/lib/families/bitcoin/wallet-btc/storage/types.d.ts +3 -3
  85. package/lib/families/bitcoin/wallet-btc/storage/types.d.ts.map +1 -1
  86. package/lib/families/bitcoin/wallet-btc/xpub.js +38 -31
  87. package/lib/families/bitcoin/wallet-btc/xpub.js.map +1 -1
  88. package/lib/families/celo/js-synchronisation.d.ts +2 -3
  89. package/lib/families/celo/js-synchronisation.d.ts.map +1 -1
  90. package/lib/families/celo/js-synchronisation.js +2 -5
  91. package/lib/families/celo/js-synchronisation.js.map +1 -1
  92. package/lib/families/cosmos/bridge/js.d.ts.map +1 -1
  93. package/lib/families/cosmos/bridge/js.js +1 -1
  94. package/lib/families/cosmos/bridge/js.js.map +1 -1
  95. package/lib/families/cosmos/js-synchronisation.d.ts +8 -2
  96. package/lib/families/cosmos/js-synchronisation.d.ts.map +1 -1
  97. package/lib/families/cosmos/js-synchronisation.js +3 -3
  98. package/lib/families/cosmos/js-synchronisation.js.map +1 -1
  99. package/lib/families/crypto_org/js-synchronisation.d.ts +2 -3
  100. package/lib/families/crypto_org/js-synchronisation.d.ts.map +1 -1
  101. package/lib/families/crypto_org/js-synchronisation.js +2 -3
  102. package/lib/families/crypto_org/js-synchronisation.js.map +1 -1
  103. package/lib/families/elrond/js-synchronisation.d.ts +2 -3
  104. package/lib/families/elrond/js-synchronisation.d.ts.map +1 -1
  105. package/lib/families/elrond/js-synchronisation.js +2 -3
  106. package/lib/families/elrond/js-synchronisation.js.map +1 -1
  107. package/lib/families/ethereum/bridge/js.js +2 -2
  108. package/lib/families/ethereum/bridge/js.js.map +1 -1
  109. package/lib/families/ethereum/synchronisation.d.ts.map +1 -1
  110. package/lib/families/ethereum/synchronisation.js +11 -10
  111. package/lib/families/ethereum/synchronisation.js.map +1 -1
  112. package/lib/families/filecoin/bridge/account.js +1 -1
  113. package/lib/families/filecoin/bridge/account.js.map +1 -1
  114. package/lib/families/filecoin/bridge/currency.js +1 -1
  115. package/lib/families/filecoin/bridge/currency.js.map +1 -1
  116. package/lib/families/filecoin/speculos-deviceActions.d.ts.map +1 -1
  117. package/lib/families/filecoin/speculos-deviceActions.js +14 -6
  118. package/lib/families/filecoin/speculos-deviceActions.js.map +1 -1
  119. package/lib/families/neo/bridge/js.js +2 -2
  120. package/lib/families/neo/bridge/js.js.map +1 -1
  121. package/lib/families/polkadot/js-synchronisation.d.ts.map +1 -1
  122. package/lib/families/polkadot/js-synchronisation.js +2 -5
  123. package/lib/families/polkadot/js-synchronisation.js.map +1 -1
  124. package/lib/families/solana/api/chain/index.d.ts +1 -1
  125. package/lib/families/solana/api/chain/index.d.ts.map +1 -1
  126. package/lib/families/solana/api/chain/index.js +13 -2
  127. package/lib/families/solana/api/chain/index.js.map +1 -1
  128. package/lib/families/solana/api/traced.d.ts +3 -0
  129. package/lib/families/solana/api/traced.d.ts.map +1 -0
  130. package/lib/families/solana/api/traced.js +82 -0
  131. package/lib/families/solana/api/traced.js.map +1 -0
  132. package/lib/families/solana/bridge/bridge.js +2 -2
  133. package/lib/families/solana/bridge/bridge.js.map +1 -1
  134. package/lib/families/solana/bridge/js.d.ts.map +1 -1
  135. package/lib/families/solana/bridge/js.js +12 -1
  136. package/lib/families/solana/bridge/js.js.map +1 -1
  137. package/lib/families/stellar/js-synchronization.d.ts +2 -3
  138. package/lib/families/stellar/js-synchronization.d.ts.map +1 -1
  139. package/lib/families/stellar/js-synchronization.js +2 -5
  140. package/lib/families/stellar/js-synchronization.js.map +1 -1
  141. package/lib/families/tezos/bridge/js.js +13 -12
  142. package/lib/families/tezos/bridge/js.js.map +1 -1
  143. package/lib/families/tezos/specs.d.ts.map +1 -1
  144. package/lib/families/tezos/specs.js +4 -3
  145. package/lib/families/tezos/specs.js.map +1 -1
  146. package/lib/families/tron/bridge/js.js +2 -2
  147. package/lib/families/tron/bridge/js.js.map +1 -1
  148. package/lib/featureFlags/FeatureToggle.d.ts +2 -2
  149. package/lib/featureFlags/FeatureToggle.d.ts.map +1 -1
  150. package/lib/featureFlags/FeatureToggle.js +1 -2
  151. package/lib/featureFlags/FeatureToggle.js.map +1 -1
  152. package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
  153. package/lib/featureFlags/defaultFeatures.js +3 -0
  154. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  155. package/lib/featureFlags/index.d.ts +3 -2
  156. package/lib/featureFlags/index.d.ts.map +1 -1
  157. package/lib/featureFlags/index.js +8 -2
  158. package/lib/featureFlags/index.js.map +1 -1
  159. package/lib/featureFlags/types.d.ts +1 -1
  160. package/lib/featureFlags/types.d.ts.map +1 -1
  161. package/lib/featureFlags/useFeature.d.ts +2 -1
  162. package/lib/featureFlags/useFeature.d.ts.map +1 -1
  163. package/lib/featureFlags/useFeature.js +2 -2
  164. package/lib/featureFlags/useFeature.js.map +1 -1
  165. package/lib/hw/actions/app.d.ts.map +1 -1
  166. package/lib/hw/actions/app.js +2 -1
  167. package/lib/hw/actions/app.js.map +1 -1
  168. package/lib/market/MarketDataProvider.d.ts +4 -3
  169. package/lib/market/MarketDataProvider.d.ts.map +1 -1
  170. package/lib/market/MarketDataProvider.js +21 -60
  171. package/lib/market/MarketDataProvider.js.map +1 -1
  172. package/lib/notifications/AnnouncementProvider/machine.d.ts +21 -4
  173. package/lib/notifications/AnnouncementProvider/machine.d.ts.map +1 -1
  174. package/lib/notifications/ServiceStatusProvider/machine.d.ts +21 -4
  175. package/lib/notifications/ServiceStatusProvider/machine.d.ts.map +1 -1
  176. package/lib/platform/providers/GlobalCatalogProvider/api/mock.json +13 -0
  177. package/lib/platform/providers/RemoteLiveAppProvider/api/mock.json +256 -65
  178. package/package.json +7 -7
  179. package/src/__tests__/families/bitcoin/wallet-btc/bitcoin.test.ts +17 -16
  180. package/src/__tests__/families/bitcoin/wallet-btc/utils.test.ts +2 -0
  181. package/src/__tests__/families/bitcoin/wallet-btc/wallet.errorpropagation.test.ts +41 -0
  182. package/src/__tests__/families/bitcoin/wallet-btc/xpub.getAddress.ts +46 -0
  183. package/src/__tests__/families/bitcoin/wallet-btc/xpub.txs.integration.test.ts +4 -4
  184. package/src/account/support.ts +1 -1
  185. package/src/apps/support.ts +1 -1
  186. package/src/bot/engine.ts +21 -1
  187. package/src/bot/index.ts +45 -5
  188. package/src/bot/types.ts +2 -0
  189. package/src/bridge/jsHelpers.ts +126 -72
  190. package/src/cross.ts +4 -3
  191. package/src/exchange/swap/getCompleteSwapHistory.ts +1 -1
  192. package/src/families/algorand/js-synchronization.ts +2 -6
  193. package/src/families/bitcoin/js-synchronisation.ts +5 -2
  194. package/src/families/bitcoin/specs.ts +3 -2
  195. package/src/families/bitcoin/wallet-btc/crypto/base.ts +59 -44
  196. package/src/families/bitcoin/wallet-btc/crypto/bip32.ts +8 -3
  197. package/src/families/bitcoin/wallet-btc/crypto/bitcoin.ts +8 -8
  198. package/src/families/bitcoin/wallet-btc/crypto/bitcoincash.ts +8 -6
  199. package/src/families/bitcoin/wallet-btc/crypto/decred.ts +4 -3
  200. package/src/families/bitcoin/wallet-btc/crypto/index.ts +1 -0
  201. package/src/families/bitcoin/wallet-btc/crypto/secp256k1.ts +32 -0
  202. package/src/families/bitcoin/wallet-btc/crypto/types.ts +2 -2
  203. package/src/families/bitcoin/wallet-btc/crypto/zec.ts +20 -9
  204. package/src/families/bitcoin/wallet-btc/crypto/zen.ts +5 -5
  205. package/src/families/bitcoin/wallet-btc/storage/index.ts +66 -22
  206. package/src/families/bitcoin/wallet-btc/storage/types.ts +3 -3
  207. package/src/families/bitcoin/wallet-btc/xpub.ts +3 -3
  208. package/src/families/celo/js-synchronisation.ts +2 -7
  209. package/src/families/cosmos/bridge/js.ts +3 -6
  210. package/src/families/cosmos/js-synchronisation.ts +9 -5
  211. package/src/families/crypto_org/js-synchronisation.ts +2 -5
  212. package/src/families/elrond/js-synchronisation.ts +2 -5
  213. package/src/families/ethereum/bridge/js.ts +2 -2
  214. package/src/families/ethereum/synchronisation.ts +6 -3
  215. package/src/families/filecoin/bridge/account.ts +1 -1
  216. package/src/families/filecoin/bridge/currency.ts +1 -1
  217. package/src/families/filecoin/speculos-deviceActions.ts +11 -3
  218. package/src/families/neo/bridge/js.ts +2 -2
  219. package/src/families/polkadot/js-synchronisation.ts +2 -6
  220. package/src/families/solana/api/chain/index.ts +19 -2
  221. package/src/families/solana/api/traced.ts +99 -0
  222. package/src/families/solana/bridge/bridge.ts +2 -2
  223. package/src/families/solana/bridge/js.ts +12 -1
  224. package/src/families/stellar/js-synchronization.ts +2 -7
  225. package/src/families/tezos/bridge/js.ts +12 -12
  226. package/src/families/tezos/specs.ts +5 -3
  227. package/src/families/tron/bridge/js.ts +2 -2
  228. package/src/featureFlags/FeatureToggle.tsx +3 -1
  229. package/src/featureFlags/defaultFeatures.ts +3 -0
  230. package/src/featureFlags/index.ts +5 -2
  231. package/src/featureFlags/types.ts +2 -1
  232. package/src/featureFlags/useFeature.ts +4 -2
  233. package/src/hw/actions/app.ts +2 -1
  234. package/src/market/MarketDataProvider.tsx +73 -98
  235. package/src/platform/providers/GlobalCatalogProvider/api/mock.json +14 -1
  236. package/src/platform/providers/RemoteLiveAppProvider/api/mock.json +930 -739
@@ -76,7 +76,7 @@ const getTransactionStatus = async (
76
76
  feeTooHigh?: Error;
77
77
  recipient?: Error;
78
78
  } = {};
79
- let amountMustReset = false;
79
+ let resetTotalSpent = false;
80
80
 
81
81
  // Recipient validation logic
82
82
  if (t.mode !== "undelegate") {
@@ -100,7 +100,7 @@ const getTransactionStatus = async (
100
100
  const estimatedFees = t.estimatedFees || new BigNumber(0);
101
101
  if (t.mode === "send") {
102
102
  if (!errors.amount && t.amount.eq(0) && !t.useAllAmount) {
103
- amountMustReset = true;
103
+ resetTotalSpent = true;
104
104
  errors.amount = new AmountRequired();
105
105
  } else if (t.amount.gt(0) && estimatedFees.times(10).gt(t.amount)) {
106
106
  warnings.feeTooHigh = new FeeTooHigh();
@@ -128,7 +128,7 @@ const getTransactionStatus = async (
128
128
  // remap taquito errors
129
129
  if (t.taquitoError.endsWith("balance_too_low")) {
130
130
  if (t.mode === "send") {
131
- amountMustReset = true;
131
+ resetTotalSpent = true;
132
132
  errors.amount = new NotEnoughBalance();
133
133
  } else {
134
134
  errors.amount = new NotEnoughBalanceToDelegate();
@@ -138,12 +138,12 @@ const getTransactionStatus = async (
138
138
  } else if (!errors.amount) {
139
139
  // unidentified error case
140
140
  errors.amount = new Error(t.taquitoError);
141
- amountMustReset = true;
141
+ resetTotalSpent = true;
142
142
  }
143
143
  }
144
144
 
145
145
  if (!errors.amount && account.balance.lte(0)) {
146
- amountMustReset = true;
146
+ resetTotalSpent = true;
147
147
  errors.amount = new NotEnoughBalance();
148
148
  }
149
149
 
@@ -154,20 +154,20 @@ const getTransactionStatus = async (
154
154
  t.amount.lt(EXISTENTIAL_DEPOSIT) &&
155
155
  (await api.getAccountByAddress(t.recipient)).type === "empty"
156
156
  ) {
157
- amountMustReset = true;
157
+ resetTotalSpent = true;
158
158
  errors.amount = new NotEnoughBalanceBecauseDestinationNotCreated("", {
159
159
  minimalAmount: "0.275 XTZ",
160
160
  });
161
161
  }
162
162
 
163
- const amount = amountMustReset ? new BigNumber(0) : t.amount;
164
-
165
163
  const result = {
166
164
  errors,
167
165
  warnings,
168
166
  estimatedFees,
169
- amount,
170
- totalSpent: amount.plus(estimatedFees),
167
+ amount: t.amount,
168
+ totalSpent: resetTotalSpent
169
+ ? new BigNumber(0)
170
+ : t.amount.plus(estimatedFees),
171
171
  };
172
172
  return Promise.resolve(result);
173
173
  };
@@ -344,9 +344,9 @@ const broadcast = async ({ signedOperation: { operation, signature } }) => {
344
344
  return patchOperationWithHash(operation, hash);
345
345
  };
346
346
 
347
- const scanAccounts = makeScanAccounts(getAccountShape);
347
+ const scanAccounts = makeScanAccounts({ getAccountShape });
348
348
 
349
- const sync = makeSync(getAccountShape);
349
+ const sync = makeSync({ getAccountShape });
350
350
 
351
351
  const getPreloadStrategy = (_currency) => ({
352
352
  preloadMaxAge: 30 * 1000,
@@ -26,6 +26,8 @@ function expectRevealed(account) {
26
26
 
27
27
  const tezosUnit = getCryptoCurrencyById("tezos").units[0];
28
28
 
29
+ const safeMinimumForDestinationNotCreated = parseCurrencyUnit(tezosUnit, "0.6");
30
+
29
31
  const tezos: AppSpec<Transaction> = {
30
32
  name: "Tezos",
31
33
  currency: getCryptoCurrencyById("tezos"),
@@ -51,7 +53,7 @@ const tezos: AppSpec<Transaction> = {
51
53
  const amount = maxSpendable.div(2).integerValue();
52
54
  if (
53
55
  sibling.balance.eq(0) &&
54
- amount.lt(parseCurrencyUnit(tezosUnit, "0.3"))
56
+ amount.lt(safeMinimumForDestinationNotCreated)
55
57
  ) {
56
58
  throw new Error("need more funds to send to new address");
57
59
  }
@@ -71,7 +73,7 @@ const tezos: AppSpec<Transaction> = {
71
73
  const amount = maxSpendable.div(2).integerValue();
72
74
  if (
73
75
  sibling.balance.eq(0) &&
74
- amount.lt(parseCurrencyUnit(tezosUnit, "0.3"))
76
+ amount.lt(safeMinimumForDestinationNotCreated)
75
77
  ) {
76
78
  throw new Error("need more funds to send to new address");
77
79
  }
@@ -93,7 +95,7 @@ const tezos: AppSpec<Transaction> = {
93
95
  const recipient = sibling.freshAddress;
94
96
  if (
95
97
  sibling.balance.eq(0) &&
96
- maxSpendable.lt(parseCurrencyUnit(tezosUnit, "0.3"))
98
+ maxSpendable.lt(safeMinimumForDestinationNotCreated)
97
99
  ) {
98
100
  throw new Error("need more funds to send to new address");
99
101
  }
@@ -466,7 +466,7 @@ const getAccountShape = async (info: GetAccountShapeArg0, syncConfig) => {
466
466
  };
467
467
  };
468
468
 
469
- const scanAccounts = makeScanAccounts(getAccountShape);
469
+ const scanAccounts = makeScanAccounts({ getAccountShape });
470
470
  // the balance does not update straightaway so we should ignore recent operations if they are in pending for a bit
471
471
  const preferPendingOperationsUntilBlockValidation = 35;
472
472
 
@@ -490,7 +490,7 @@ const postSync = (initial: Account, parent: Account): Account => {
490
490
  return parent;
491
491
  };
492
492
 
493
- const sync = makeSync(getAccountShape, postSync);
493
+ const sync = makeSync({ getAccountShape, postSync });
494
494
 
495
495
  const currencyBridge: CurrencyBridge = {
496
496
  preload: async () => {
@@ -9,7 +9,7 @@ type Props = {
9
9
  children?: ReactNode;
10
10
  };
11
11
 
12
- export const FeatureToggle = ({
12
+ const FeatureToggle = ({
13
13
  feature: featureId,
14
14
  fallback,
15
15
  children,
@@ -22,3 +22,5 @@ export const FeatureToggle = ({
22
22
 
23
23
  return <>{children || null}</>;
24
24
  };
25
+
26
+ export default FeatureToggle;
@@ -4,4 +4,7 @@ export const defaultFeatures: DefaultFeatures = {
4
4
  learn: {
5
5
  enabled: false,
6
6
  },
7
+ pushNotifications: {
8
+ enabled: false,
9
+ },
7
10
  };
@@ -1,4 +1,7 @@
1
+ import useFeature from "./useFeature";
2
+ import FeatureToggle from "./FeatureToggle";
3
+
4
+ export { useFeature, FeatureToggle };
5
+
1
6
  export * from "./defaultFeatures";
2
- export * from "./FeatureToggle";
3
7
  export * from "./provider";
4
- export * from "./useFeature";
@@ -1,4 +1,5 @@
1
- export type FeatureId = "learn"; // Add others with union (e.g. "learn" | "market" | "foo")
1
+ // Add others with union (e.g. "learn" | "market" | "foo")
2
+ export type FeatureId = "learn" | "pushNotifications";
2
3
 
3
4
  // We use objects instead of direct booleans for potential future improvements
4
5
  // like feature versioning etc
@@ -1,8 +1,10 @@
1
1
  import { useFeatureFlags } from "./provider";
2
2
  import { Feature, FeatureId } from "./types";
3
3
 
4
- export default function useFeature(key: FeatureId): Feature | null {
4
+ const useFeature = (key: FeatureId): Feature | null => {
5
5
  const featureFlags = useFeatureFlags();
6
6
 
7
7
  return featureFlags.getFeature(key);
8
- }
8
+ };
9
+
10
+ export default useFeature;
@@ -634,7 +634,8 @@ export const createAction = (
634
634
  ...state,
635
635
  inWrongDeviceForAccount:
636
636
  state.derivation && appRequest.account
637
- ? state.derivation.address !== appRequest.account.freshAddress
637
+ ? state.derivation.address !== appRequest.account.freshAddress &&
638
+ state.derivation.address !== appRequest.account.seedIdentifier // Use-case added for Hedera
638
639
  ? {
639
640
  accountName: getAccountName(appRequest.account),
640
641
  }
@@ -7,7 +7,6 @@ import React, {
7
7
  ReactElement,
8
8
  useReducer,
9
9
  useEffect,
10
- useState,
11
10
  } from "react";
12
11
 
13
12
  import { useDebounce } from "../hooks/useDebounce";
@@ -19,9 +18,9 @@ import {
19
18
  MarketCurrencyChartDataRequestParams,
20
19
  CurrencyData,
21
20
  SingleCoinState,
21
+ SupportedCoins,
22
22
  } from "./types";
23
23
  import defaultFetchApi from "./api/api";
24
-
25
24
  type Props = {
26
25
  children: React.ReactNode;
27
26
  fetchApi?: MarketDataApi;
@@ -31,7 +30,7 @@ type Props = {
31
30
  type API = {
32
31
  refresh: (param?: MarketListRequestParams) => void;
33
32
  refreshChart: (param?: MarketCurrencyChartDataRequestParams) => void;
34
- selectCurrency: (key: string) => void;
33
+ selectCurrency: (id?: string, data?: CurrencyData, range?: string) => void;
35
34
  loadNextPage: () => Promise<boolean>;
36
35
  setCounterCurrency: (counterCurrency: string) => void;
37
36
  };
@@ -113,23 +112,25 @@ function marketDataReducer(state, action) {
113
112
  };
114
113
  }
115
114
  case ACTIONS.UPDATE_SINGLE_MARKET_DATA: {
116
- const marketData = [...state.marketData.map((data) => ({ ...data }))];
117
- const index = marketData.findIndex(({ id }) => id === action.payload.id);
118
- if (index >= 0) {
119
- marketData[index] = { ...marketData[index], ...action.payload };
120
- }
121
- return { ...state, marketData, loading: false };
115
+ return {
116
+ ...state,
117
+ selectedCoinData: { ...state.selectedCoinData, ...action.payload },
118
+ loading: false,
119
+ };
122
120
  }
123
121
  case ACTIONS.UPDATE_SINGLE_CHART_DATA: {
124
- const marketData = [...state.marketData.map((data) => ({ ...data }))];
125
- const index = marketData.findIndex(({ id }) => id === action.payload.id);
126
- if (index >= 0) {
127
- marketData[index].chartData = {
128
- ...marketData[index].chartData,
129
- ...action.payload.chartData,
130
- };
131
- }
132
- return { ...state, marketData, loading: false };
122
+ const chartRequestParams = {
123
+ ...state.chartRequestParams,
124
+ loadingChart: false,
125
+ };
126
+ const selectedCoinData = { ...state.selectedCoinData };
127
+
128
+ selectedCoinData.chartData = {
129
+ ...selectedCoinData.chartData,
130
+ ...action.payload.chartData,
131
+ };
132
+
133
+ return { ...state, selectedCoinData, chartRequestParams };
133
134
  }
134
135
 
135
136
  case ACTIONS.REFRESH_MARKET_DATA: {
@@ -184,12 +185,23 @@ function marketDataReducer(state, action) {
184
185
  return { ...state, loadingChart: action.payload };
185
186
  case ACTIONS.SET_ERROR:
186
187
  return { ...state, error: action.payload, loading: false };
187
- case ACTIONS.SELECT_CURRENCY:
188
+ case ACTIONS.SELECT_CURRENCY: {
189
+ const chartRequestParams = {
190
+ ...state.chartRequestParams,
191
+ counterCurrency: state.requestParams.counterCurrency,
192
+ range: action.payload.range || state.requestParams.range,
193
+ id: action.payload.id,
194
+ loadingChart: !!action.payload.id,
195
+ lastRequestTime: Date.now(),
196
+ };
188
197
  return {
189
198
  ...state,
190
- selectedCurrency: action.payload,
191
- loading: !!action.payload,
199
+ selectedCurrency: action.payload.id,
200
+ selectedCoinData: action.payload.data,
201
+ loading: !!action.payload.id,
202
+ chartRequestParams,
192
203
  };
204
+ }
193
205
  default:
194
206
  return state;
195
207
  }
@@ -207,15 +219,15 @@ export const MarketDataProvider = ({
207
219
  });
208
220
  const api = fetchApi || defaultFetchApi;
209
221
  const {
210
- marketData,
211
222
  requestParams,
212
223
  chartRequestParams,
213
224
  loading,
214
225
  loadingChart,
215
226
  page,
227
+ selectedCoinData,
216
228
  } = useDebounce(state, 300);
217
229
 
218
- const handleError = useCallback((payload) => {
230
+ const handleError = useCallback((payload: Error) => {
219
231
  dispatch({ type: ACTIONS.SET_ERROR, payload });
220
232
  }, []);
221
233
 
@@ -224,7 +236,7 @@ export const MarketDataProvider = ({
224
236
  const ticker = countervalue.ticker.toLowerCase();
225
237
  api.supportedCounterCurrencies().then(
226
238
  (supportedCounterCurrencies) =>
227
- api.setSupportedCoinsList().then((coins) => {
239
+ api.setSupportedCoinsList().then((coins: SupportedCoins) => {
228
240
  dispatch({
229
241
  type: ACTIONS.IS_READY,
230
242
  payload: {
@@ -250,12 +262,9 @@ export const MarketDataProvider = ({
250
262
  chartRequestParams?.counterCurrency &&
251
263
  !loadingChart
252
264
  ) {
253
- const currentMarketData = marketData.find(
254
- ({ id }: CurrencyData) => id === chartRequestParams.id
255
- );
256
265
  const range = chartRequestParams.range;
257
266
 
258
- if (currentMarketData && !currentMarketData?.chartData?.[range]) {
267
+ if (selectedCoinData && !selectedCoinData?.chartData?.[range]) {
259
268
  api.currencyChartData(chartRequestParams).then(
260
269
  (chartData) =>
261
270
  dispatch({
@@ -270,14 +279,10 @@ export const MarketDataProvider = ({
270
279
  payload: false,
271
280
  });
272
281
  }
273
- }, [chartRequestParams, marketData, loadingChart, api, handleError]);
282
+ }, [chartRequestParams, selectedCoinData, api, handleError, loadingChart]);
274
283
 
275
284
  useEffect(() => {
276
- if (
277
- chartRequestParams?.id &&
278
- chartRequestParams?.counterCurrency &&
279
- !loading
280
- ) {
285
+ if (chartRequestParams?.id && chartRequestParams?.counterCurrency) {
281
286
  dispatch({ type: ACTIONS.SET_LOADING, payload: true });
282
287
  api
283
288
  .listPaginated({
@@ -321,37 +326,34 @@ export const MarketDataProvider = ({
321
326
  dispatch({ type: ACTIONS.REFRESH_CHART_DATA, payload });
322
327
  }, []);
323
328
 
324
- const selectCurrency = useCallback((id) => {
325
- dispatch({
326
- type: ACTIONS.REFRESH_CHART_DATA,
327
- payload: {
328
- id,
329
- },
330
- });
329
+ const selectCurrency = useCallback((id, data, range) => {
330
+ dispatch({ type: ACTIONS.SELECT_CURRENCY, payload: { id, data, range } });
331
331
  }, []);
332
332
 
333
- const loadNextPage = useCallback(() => {
334
- return new Promise((resolve, reject) => {
335
- if (loading) {
336
- reject(new Error());
337
- } else {
338
- const newPage = page + 1;
339
- api.listPaginated({ ...requestParams, page: newPage }).then(
340
- (marketData) => {
341
- dispatch({
342
- type: ACTIONS.UPDATE_MARKET_DATA,
343
- payload: { marketData, page: newPage },
344
- });
345
- resolve(true);
346
- },
347
- (err) => {
348
- handleError(err);
349
- reject(new Error(err));
350
- }
351
- );
352
- }
353
- });
354
- }, [loading, page, api, requestParams, handleError]);
333
+ const loadNextPage = useCallback(
334
+ () =>
335
+ new Promise((resolve, reject) => {
336
+ if (loading) {
337
+ reject(new Error());
338
+ } else {
339
+ const newPage = page + 1;
340
+ api.listPaginated({ ...requestParams, page: newPage }).then(
341
+ (marketData) => {
342
+ dispatch({
343
+ type: ACTIONS.UPDATE_MARKET_DATA,
344
+ payload: { marketData, page: newPage },
345
+ });
346
+ resolve(true);
347
+ },
348
+ (err) => {
349
+ handleError(err);
350
+ reject(new Error(err));
351
+ }
352
+ );
353
+ }
354
+ }),
355
+ [loading, page, api, requestParams, handleError]
356
+ );
355
357
 
356
358
  const setCounterCurrency = useCallback(
357
359
  (payload) => dispatch({ type: ACTIONS.UPDATE_COUNTERVALUE, payload }),
@@ -379,16 +381,16 @@ export function useMarketData(): MarketDataContextType {
379
381
  }
380
382
 
381
383
  type SingleCoinProviderData = SingleCoinState & {
384
+ selectCurrency: (id?: string, data?: CurrencyData, range?: string) => void;
382
385
  refreshChart: (param?: MarketCurrencyChartDataRequestParams) => void;
383
386
  setCounterCurrency: (counterCurrency: string) => void;
384
387
  };
385
388
 
386
- export function useSingleCoinMarketData(
387
- currencyId: string
388
- ): SingleCoinProviderData {
389
+ export function useSingleCoinMarketData(): SingleCoinProviderData {
389
390
  const {
390
- marketData,
391
391
  selectedCurrency,
392
+ selectedCoinData,
393
+ selectCurrency,
392
394
  chartRequestParams,
393
395
  loading,
394
396
  loadingChart,
@@ -399,9 +401,10 @@ export function useSingleCoinMarketData(
399
401
  supportedCounterCurrencies,
400
402
  } = useContext(MarketDataContext);
401
403
 
402
- const [state, setState] = useState<SingleCoinProviderData>({
403
- selectedCoinData: undefined,
404
+ return {
404
405
  selectedCurrency,
406
+ selectedCoinData,
407
+ selectCurrency,
405
408
  chartRequestParams,
406
409
  loading,
407
410
  loadingChart,
@@ -410,33 +413,5 @@ export function useSingleCoinMarketData(
410
413
  refreshChart,
411
414
  setCounterCurrency,
412
415
  supportedCounterCurrencies,
413
- });
414
-
415
- useEffect(() => {
416
- if (marketData)
417
- setState((s) => ({
418
- ...s,
419
- selectedCoinData:
420
- marketData.find(({ id }) => id === currencyId) || s.selectedCoinData,
421
- selectedCurrency,
422
- chartRequestParams,
423
- loading,
424
- loadingChart,
425
- error,
426
- counterCurrency,
427
- supportedCounterCurrencies,
428
- }));
429
- }, [
430
- marketData,
431
- currencyId,
432
- selectedCurrency,
433
- chartRequestParams,
434
- loading,
435
- loadingChart,
436
- error,
437
- counterCurrency,
438
- supportedCounterCurrencies,
439
- ]);
440
-
441
- return state;
416
+ };
442
417
  }
@@ -394,6 +394,19 @@
394
394
  "platform": "all",
395
395
  "branch": "debug",
396
396
  "currencies": "*"
397
+ },
398
+ {
399
+ "appId": "dummy-live-app",
400
+ "type": "LIVE_APP",
401
+ "tags": [
402
+ "tools"
403
+ ],
404
+ "categories": [
405
+ "other"
406
+ ],
407
+ "platform": "all",
408
+ "branch": "stable",
409
+ "currencies": "*"
397
410
  }
398
411
  ]
399
- }
412
+ }