@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.
- package/lib/__tests__/families/bitcoin/wallet-btc/bitcoin.test.js +290 -225
- package/lib/__tests__/families/bitcoin/wallet-btc/bitcoin.test.js.map +1 -1
- package/lib/__tests__/families/bitcoin/wallet-btc/utils.test.js +2 -0
- package/lib/__tests__/families/bitcoin/wallet-btc/utils.test.js.map +1 -1
- package/lib/__tests__/families/bitcoin/wallet-btc/wallet.errorpropagation.test.d.ts +2 -0
- package/lib/__tests__/families/bitcoin/wallet-btc/wallet.errorpropagation.test.d.ts.map +1 -0
- package/lib/__tests__/families/bitcoin/wallet-btc/wallet.errorpropagation.test.js +86 -0
- package/lib/__tests__/families/bitcoin/wallet-btc/wallet.errorpropagation.test.js.map +1 -0
- package/lib/__tests__/families/bitcoin/wallet-btc/xpub.getAddress.js +38 -0
- package/lib/__tests__/families/bitcoin/wallet-btc/xpub.getAddress.js.map +1 -1
- package/lib/__tests__/families/bitcoin/wallet-btc/xpub.txs.integration.test.js +4 -4
- package/lib/__tests__/families/bitcoin/wallet-btc/xpub.txs.integration.test.js.map +1 -1
- package/lib/account/support.js +1 -1
- package/lib/account/support.js.map +1 -1
- package/lib/apps/support.js +1 -1
- package/lib/bot/engine.d.ts.map +1 -1
- package/lib/bot/engine.js +77 -45
- package/lib/bot/engine.js.map +1 -1
- package/lib/bot/index.d.ts.map +1 -1
- package/lib/bot/index.js +44 -20
- package/lib/bot/index.js.map +1 -1
- package/lib/bot/types.d.ts +1 -0
- package/lib/bot/types.d.ts.map +1 -1
- package/lib/bridge/jsHelpers.d.ts +25 -2
- package/lib/bridge/jsHelpers.d.ts.map +1 -1
- package/lib/bridge/jsHelpers.js +94 -60
- package/lib/bridge/jsHelpers.js.map +1 -1
- package/lib/cross.d.ts.map +1 -1
- package/lib/cross.js +5 -3
- package/lib/cross.js.map +1 -1
- package/lib/exchange/swap/getCompleteSwapHistory.js +17 -14
- package/lib/exchange/swap/getCompleteSwapHistory.js.map +1 -1
- package/lib/families/algorand/js-synchronization.d.ts.map +1 -1
- package/lib/families/algorand/js-synchronization.js +2 -5
- package/lib/families/algorand/js-synchronization.js.map +1 -1
- package/lib/families/bitcoin/js-synchronisation.d.ts.map +1 -1
- package/lib/families/bitcoin/js-synchronisation.js +5 -2
- package/lib/families/bitcoin/js-synchronisation.js.map +1 -1
- package/lib/families/bitcoin/specs.d.ts.map +1 -1
- package/lib/families/bitcoin/specs.js +4 -2
- package/lib/families/bitcoin/specs.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/base.d.ts +5 -6
- package/lib/families/bitcoin/wallet-btc/crypto/base.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/base.js +149 -59
- package/lib/families/bitcoin/wallet-btc/crypto/base.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/bip32.d.ts +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/bip32.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/bip32.js +59 -9
- package/lib/families/bitcoin/wallet-btc/crypto/bip32.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.d.ts +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.js +76 -24
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.d.ts +2 -2
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.js +55 -2
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/decred.d.ts +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/decred.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/decred.js +61 -14
- package/lib/families/bitcoin/wallet-btc/crypto/decred.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/index.d.ts +1 -0
- package/lib/families/bitcoin/wallet-btc/crypto/index.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/index.js +4 -1
- package/lib/families/bitcoin/wallet-btc/crypto/index.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/secp256k1.d.ts +16 -0
- package/lib/families/bitcoin/wallet-btc/crypto/secp256k1.d.ts.map +1 -0
- package/lib/families/bitcoin/wallet-btc/crypto/secp256k1.js +28 -0
- package/lib/families/bitcoin/wallet-btc/crypto/secp256k1.js.map +1 -0
- package/lib/families/bitcoin/wallet-btc/crypto/types.d.ts +2 -2
- package/lib/families/bitcoin/wallet-btc/crypto/types.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zec.d.ts +2 -2
- package/lib/families/bitcoin/wallet-btc/crypto/zec.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zec.js +72 -10
- package/lib/families/bitcoin/wallet-btc/crypto/zec.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zen.d.ts +2 -2
- package/lib/families/bitcoin/wallet-btc/crypto/zen.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zen.js +60 -6
- package/lib/families/bitcoin/wallet-btc/crypto/zen.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/storage/index.d.ts +20 -4
- package/lib/families/bitcoin/wallet-btc/storage/index.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/storage/index.js +45 -8
- package/lib/families/bitcoin/wallet-btc/storage/index.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/storage/types.d.ts +3 -3
- package/lib/families/bitcoin/wallet-btc/storage/types.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/xpub.js +38 -31
- package/lib/families/bitcoin/wallet-btc/xpub.js.map +1 -1
- package/lib/families/celo/js-synchronisation.d.ts +2 -3
- package/lib/families/celo/js-synchronisation.d.ts.map +1 -1
- package/lib/families/celo/js-synchronisation.js +2 -5
- package/lib/families/celo/js-synchronisation.js.map +1 -1
- package/lib/families/cosmos/bridge/js.d.ts.map +1 -1
- package/lib/families/cosmos/bridge/js.js +1 -1
- package/lib/families/cosmos/bridge/js.js.map +1 -1
- package/lib/families/cosmos/js-synchronisation.d.ts +8 -2
- package/lib/families/cosmos/js-synchronisation.d.ts.map +1 -1
- package/lib/families/cosmos/js-synchronisation.js +3 -3
- package/lib/families/cosmos/js-synchronisation.js.map +1 -1
- package/lib/families/crypto_org/js-synchronisation.d.ts +2 -3
- package/lib/families/crypto_org/js-synchronisation.d.ts.map +1 -1
- package/lib/families/crypto_org/js-synchronisation.js +2 -3
- package/lib/families/crypto_org/js-synchronisation.js.map +1 -1
- package/lib/families/elrond/js-synchronisation.d.ts +2 -3
- package/lib/families/elrond/js-synchronisation.d.ts.map +1 -1
- package/lib/families/elrond/js-synchronisation.js +2 -3
- package/lib/families/elrond/js-synchronisation.js.map +1 -1
- package/lib/families/ethereum/bridge/js.js +2 -2
- package/lib/families/ethereum/bridge/js.js.map +1 -1
- package/lib/families/ethereum/synchronisation.d.ts.map +1 -1
- package/lib/families/ethereum/synchronisation.js +11 -10
- package/lib/families/ethereum/synchronisation.js.map +1 -1
- package/lib/families/filecoin/bridge/account.js +1 -1
- package/lib/families/filecoin/bridge/account.js.map +1 -1
- package/lib/families/filecoin/bridge/currency.js +1 -1
- package/lib/families/filecoin/bridge/currency.js.map +1 -1
- package/lib/families/filecoin/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/filecoin/speculos-deviceActions.js +14 -6
- package/lib/families/filecoin/speculos-deviceActions.js.map +1 -1
- package/lib/families/neo/bridge/js.js +2 -2
- package/lib/families/neo/bridge/js.js.map +1 -1
- package/lib/families/polkadot/js-synchronisation.d.ts.map +1 -1
- package/lib/families/polkadot/js-synchronisation.js +2 -5
- package/lib/families/polkadot/js-synchronisation.js.map +1 -1
- package/lib/families/solana/api/chain/index.d.ts +1 -1
- package/lib/families/solana/api/chain/index.d.ts.map +1 -1
- package/lib/families/solana/api/chain/index.js +13 -2
- package/lib/families/solana/api/chain/index.js.map +1 -1
- package/lib/families/solana/api/traced.d.ts +3 -0
- package/lib/families/solana/api/traced.d.ts.map +1 -0
- package/lib/families/solana/api/traced.js +82 -0
- package/lib/families/solana/api/traced.js.map +1 -0
- package/lib/families/solana/bridge/bridge.js +2 -2
- package/lib/families/solana/bridge/bridge.js.map +1 -1
- package/lib/families/solana/bridge/js.d.ts.map +1 -1
- package/lib/families/solana/bridge/js.js +12 -1
- package/lib/families/solana/bridge/js.js.map +1 -1
- package/lib/families/stellar/js-synchronization.d.ts +2 -3
- package/lib/families/stellar/js-synchronization.d.ts.map +1 -1
- package/lib/families/stellar/js-synchronization.js +2 -5
- package/lib/families/stellar/js-synchronization.js.map +1 -1
- package/lib/families/tezos/bridge/js.js +13 -12
- package/lib/families/tezos/bridge/js.js.map +1 -1
- package/lib/families/tezos/specs.d.ts.map +1 -1
- package/lib/families/tezos/specs.js +4 -3
- package/lib/families/tezos/specs.js.map +1 -1
- package/lib/families/tron/bridge/js.js +2 -2
- package/lib/families/tron/bridge/js.js.map +1 -1
- package/lib/featureFlags/FeatureToggle.d.ts +2 -2
- package/lib/featureFlags/FeatureToggle.d.ts.map +1 -1
- package/lib/featureFlags/FeatureToggle.js +1 -2
- package/lib/featureFlags/FeatureToggle.js.map +1 -1
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +3 -0
- package/lib/featureFlags/defaultFeatures.js.map +1 -1
- package/lib/featureFlags/index.d.ts +3 -2
- package/lib/featureFlags/index.d.ts.map +1 -1
- package/lib/featureFlags/index.js +8 -2
- package/lib/featureFlags/index.js.map +1 -1
- package/lib/featureFlags/types.d.ts +1 -1
- package/lib/featureFlags/types.d.ts.map +1 -1
- package/lib/featureFlags/useFeature.d.ts +2 -1
- package/lib/featureFlags/useFeature.d.ts.map +1 -1
- package/lib/featureFlags/useFeature.js +2 -2
- package/lib/featureFlags/useFeature.js.map +1 -1
- package/lib/hw/actions/app.d.ts.map +1 -1
- package/lib/hw/actions/app.js +2 -1
- package/lib/hw/actions/app.js.map +1 -1
- package/lib/market/MarketDataProvider.d.ts +4 -3
- package/lib/market/MarketDataProvider.d.ts.map +1 -1
- package/lib/market/MarketDataProvider.js +21 -60
- package/lib/market/MarketDataProvider.js.map +1 -1
- package/lib/notifications/AnnouncementProvider/machine.d.ts +21 -4
- package/lib/notifications/AnnouncementProvider/machine.d.ts.map +1 -1
- package/lib/notifications/ServiceStatusProvider/machine.d.ts +21 -4
- package/lib/notifications/ServiceStatusProvider/machine.d.ts.map +1 -1
- package/lib/platform/providers/GlobalCatalogProvider/api/mock.json +13 -0
- package/lib/platform/providers/RemoteLiveAppProvider/api/mock.json +256 -65
- package/package.json +7 -7
- package/src/__tests__/families/bitcoin/wallet-btc/bitcoin.test.ts +17 -16
- package/src/__tests__/families/bitcoin/wallet-btc/utils.test.ts +2 -0
- package/src/__tests__/families/bitcoin/wallet-btc/wallet.errorpropagation.test.ts +41 -0
- package/src/__tests__/families/bitcoin/wallet-btc/xpub.getAddress.ts +46 -0
- package/src/__tests__/families/bitcoin/wallet-btc/xpub.txs.integration.test.ts +4 -4
- package/src/account/support.ts +1 -1
- package/src/apps/support.ts +1 -1
- package/src/bot/engine.ts +21 -1
- package/src/bot/index.ts +45 -5
- package/src/bot/types.ts +2 -0
- package/src/bridge/jsHelpers.ts +126 -72
- package/src/cross.ts +4 -3
- package/src/exchange/swap/getCompleteSwapHistory.ts +1 -1
- package/src/families/algorand/js-synchronization.ts +2 -6
- package/src/families/bitcoin/js-synchronisation.ts +5 -2
- package/src/families/bitcoin/specs.ts +3 -2
- package/src/families/bitcoin/wallet-btc/crypto/base.ts +59 -44
- package/src/families/bitcoin/wallet-btc/crypto/bip32.ts +8 -3
- package/src/families/bitcoin/wallet-btc/crypto/bitcoin.ts +8 -8
- package/src/families/bitcoin/wallet-btc/crypto/bitcoincash.ts +8 -6
- package/src/families/bitcoin/wallet-btc/crypto/decred.ts +4 -3
- package/src/families/bitcoin/wallet-btc/crypto/index.ts +1 -0
- package/src/families/bitcoin/wallet-btc/crypto/secp256k1.ts +32 -0
- package/src/families/bitcoin/wallet-btc/crypto/types.ts +2 -2
- package/src/families/bitcoin/wallet-btc/crypto/zec.ts +20 -9
- package/src/families/bitcoin/wallet-btc/crypto/zen.ts +5 -5
- package/src/families/bitcoin/wallet-btc/storage/index.ts +66 -22
- package/src/families/bitcoin/wallet-btc/storage/types.ts +3 -3
- package/src/families/bitcoin/wallet-btc/xpub.ts +3 -3
- package/src/families/celo/js-synchronisation.ts +2 -7
- package/src/families/cosmos/bridge/js.ts +3 -6
- package/src/families/cosmos/js-synchronisation.ts +9 -5
- package/src/families/crypto_org/js-synchronisation.ts +2 -5
- package/src/families/elrond/js-synchronisation.ts +2 -5
- package/src/families/ethereum/bridge/js.ts +2 -2
- package/src/families/ethereum/synchronisation.ts +6 -3
- package/src/families/filecoin/bridge/account.ts +1 -1
- package/src/families/filecoin/bridge/currency.ts +1 -1
- package/src/families/filecoin/speculos-deviceActions.ts +11 -3
- package/src/families/neo/bridge/js.ts +2 -2
- package/src/families/polkadot/js-synchronisation.ts +2 -6
- package/src/families/solana/api/chain/index.ts +19 -2
- package/src/families/solana/api/traced.ts +99 -0
- package/src/families/solana/bridge/bridge.ts +2 -2
- package/src/families/solana/bridge/js.ts +12 -1
- package/src/families/stellar/js-synchronization.ts +2 -7
- package/src/families/tezos/bridge/js.ts +12 -12
- package/src/families/tezos/specs.ts +5 -3
- package/src/families/tron/bridge/js.ts +2 -2
- package/src/featureFlags/FeatureToggle.tsx +3 -1
- package/src/featureFlags/defaultFeatures.ts +3 -0
- package/src/featureFlags/index.ts +5 -2
- package/src/featureFlags/types.ts +2 -1
- package/src/featureFlags/useFeature.ts +4 -2
- package/src/hw/actions/app.ts +2 -1
- package/src/market/MarketDataProvider.tsx +73 -98
- package/src/platform/providers/GlobalCatalogProvider/api/mock.json +14 -1
- 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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
141
|
+
resetTotalSpent = true;
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
if (!errors.amount && account.balance.lte(0)) {
|
|
146
|
-
|
|
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
|
-
|
|
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:
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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;
|
package/src/hw/actions/app.ts
CHANGED
|
@@ -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: (
|
|
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
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
-
|
|
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 (
|
|
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,
|
|
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
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
(
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
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
|
-
|
|
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
|
+
}
|