@ledgerhq/live-common 27.2.0-nightly.4 → 27.2.0
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/bot/index.d.ts.map +1 -1
- package/lib/bot/index.js +3 -8
- package/lib/bot/index.js.map +1 -1
- package/lib/bot/specs.d.ts +0 -9
- package/lib/bot/specs.d.ts.map +1 -1
- package/lib/bot/specs.js +1 -49
- package/lib/bot/specs.js.map +1 -1
- package/lib/currencies/support.d.ts.map +1 -1
- package/lib/currencies/support.js +1 -2
- package/lib/currencies/support.js.map +1 -1
- package/lib/derivation.d.ts.map +1 -1
- package/lib/derivation.js +4 -2
- package/lib/derivation.js.map +1 -1
- package/lib/env.js +1 -1
- package/lib/exchange/swap/getExchangeRates.d.ts.map +1 -1
- package/lib/exchange/swap/getExchangeRates.js +1 -1
- package/lib/exchange/swap/getExchangeRates.js.map +1 -1
- package/lib/exchange/swap/getProviders.d.ts.map +1 -1
- package/lib/exchange/swap/getProviders.js +5 -45
- package/lib/exchange/swap/getProviders.js.map +1 -1
- package/lib/exchange/swap/index.d.ts +1 -2
- package/lib/exchange/swap/index.d.ts.map +1 -1
- package/lib/exchange/swap/index.js +1 -11
- package/lib/exchange/swap/index.js.map +1 -1
- package/lib/exchange/swap/index.test.js +0 -22
- package/lib/exchange/swap/index.test.js.map +1 -1
- package/lib/exchange/swap/mock.js +1 -1
- package/lib/exchange/swap/mock.js.map +1 -1
- package/lib/exchange/swap/types.d.ts +0 -14
- package/lib/exchange/swap/types.d.ts.map +1 -1
- package/lib/families/algorand/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/algorand/speculos-deviceActions.js +29 -2
- package/lib/families/algorand/speculos-deviceActions.js.map +1 -1
- package/lib/families/bitcoin/specs.d.ts.map +1 -1
- package/lib/families/bitcoin/specs.js +1 -0
- package/lib/families/bitcoin/specs.js.map +1 -1
- package/lib/families/bitcoin/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/bitcoin/speculos-deviceActions.js +22 -2
- package/lib/families/bitcoin/speculos-deviceActions.js.map +1 -1
- package/lib/families/cardano/specs.d.ts.map +1 -1
- package/lib/families/cardano/specs.js +3 -4
- package/lib/families/cardano/specs.js.map +1 -1
- package/lib/families/cardano/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/cardano/speculos-deviceActions.js +10 -2
- package/lib/families/cardano/speculos-deviceActions.js.map +1 -1
- package/lib/families/celo/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/celo/speculos-deviceActions.js +10 -3
- package/lib/families/celo/speculos-deviceActions.js.map +1 -1
- package/lib/families/elrond/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/elrond/speculos-deviceActions.js +8 -3
- package/lib/families/elrond/speculos-deviceActions.js.map +1 -1
- package/lib/families/ethereum/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/ethereum/speculos-deviceActions.js +33 -10
- package/lib/families/ethereum/speculos-deviceActions.js.map +1 -1
- package/lib/families/evm/specs.d.ts.map +1 -1
- package/lib/families/evm/specs.js +5 -9
- package/lib/families/evm/specs.js.map +1 -1
- package/lib/families/evm/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/evm/speculos-deviceActions.js +25 -5
- package/lib/families/evm/speculos-deviceActions.js.map +1 -1
- package/lib/families/filecoin/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/filecoin/speculos-deviceActions.js +7 -6
- package/lib/families/filecoin/speculos-deviceActions.js.map +1 -1
- package/lib/families/polkadot/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/polkadot/speculos-deviceActions.js +10 -3
- package/lib/families/polkadot/speculos-deviceActions.js.map +1 -1
- package/lib/families/ripple/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/ripple/speculos-deviceActions.js +22 -2
- package/lib/families/ripple/speculos-deviceActions.js.map +1 -1
- package/lib/families/solana/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/solana/speculos-deviceActions.js +7 -5
- package/lib/families/solana/speculos-deviceActions.js.map +1 -1
- package/lib/families/stellar/api/horizon.d.ts.map +1 -1
- package/lib/families/stellar/api/horizon.js +10 -15
- package/lib/families/stellar/api/horizon.js.map +1 -1
- package/lib/families/stellar/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/stellar/speculos-deviceActions.js +8 -4
- package/lib/families/stellar/speculos-deviceActions.js.map +1 -1
- package/lib/families/tezos/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/tezos/speculos-deviceActions.js +11 -6
- package/lib/families/tezos/speculos-deviceActions.js.map +1 -1
- package/lib/families/tron/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/tron/speculos-deviceActions.js +14 -2
- package/lib/families/tron/speculos-deviceActions.js.map +1 -1
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +0 -3
- package/lib/featureFlags/defaultFeatures.js.map +1 -1
- package/lib/hw/extractOnboardingState.d.ts +1 -5
- package/lib/hw/extractOnboardingState.d.ts.map +1 -1
- package/lib/hw/extractOnboardingState.js +9 -17
- package/lib/hw/extractOnboardingState.js.map +1 -1
- package/lib/hw/extractOnboardingState.test.js +11 -21
- package/lib/hw/extractOnboardingState.test.js.map +1 -1
- package/package.json +19 -23
- package/src/bot/index.ts +12 -11
- package/src/bot/specs.ts +0 -45
- package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +35 -1
- package/src/currencies/support.ts +1 -2
- package/src/derivation.ts +4 -2
- package/src/env.ts +1 -1
- package/src/exchange/swap/getExchangeRates.ts +3 -7
- package/src/exchange/swap/getProviders.ts +8 -31
- package/src/exchange/swap/index.test.ts +1 -36
- package/src/exchange/swap/index.ts +0 -15
- package/src/exchange/swap/mock.ts +2 -2
- package/src/exchange/swap/types.ts +0 -11
- package/src/families/algorand/speculos-deviceActions.ts +35 -4
- package/src/families/bitcoin/specs.ts +1 -0
- package/src/families/bitcoin/speculos-deviceActions.ts +26 -3
- package/src/families/cardano/specs.ts +3 -4
- package/src/families/cardano/speculos-deviceActions.ts +14 -3
- package/src/families/celo/speculos-deviceActions.ts +14 -6
- package/src/families/elrond/speculos-deviceActions.ts +9 -4
- package/src/families/ethereum/speculos-deviceActions.ts +46 -16
- package/src/families/evm/specs.ts +8 -12
- package/src/families/evm/speculos-deviceActions.ts +35 -7
- package/src/families/filecoin/speculos-deviceActions.ts +8 -7
- package/src/families/polkadot/speculos-deviceActions.ts +16 -5
- package/src/families/ripple/speculos-deviceActions.ts +28 -3
- package/src/families/solana/speculos-deviceActions.ts +8 -6
- package/src/families/stellar/api/horizon.ts +6 -10
- package/src/families/stellar/speculos-deviceActions.ts +11 -5
- package/src/families/tezos/speculos-deviceActions.ts +16 -9
- package/src/families/tron/speculos-deviceActions.ts +12 -4
- package/src/featureFlags/defaultFeatures.ts +0 -3
- package/src/hw/extractOnboardingState.test.ts +12 -29
- package/src/hw/extractOnboardingState.ts +9 -17
- package/lib/exchange/swap/getProviders.test.d.ts +0 -2
- package/lib/exchange/swap/getProviders.test.d.ts.map +0 -1
- package/lib/exchange/swap/getProviders.test.js +0 -519
- package/lib/exchange/swap/getProviders.test.js.map +0 -1
- package/lib/postOnboarding/PostOnboardingProvider.d.ts +0 -20
- package/lib/postOnboarding/PostOnboardingProvider.d.ts.map +0 -1
- package/lib/postOnboarding/PostOnboardingProvider.js +0 -33
- package/lib/postOnboarding/PostOnboardingProvider.js.map +0 -1
- package/lib/postOnboarding/actions.d.ts +0 -20
- package/lib/postOnboarding/actions.d.ts.map +0 -1
- package/lib/postOnboarding/actions.js +0 -37
- package/lib/postOnboarding/actions.js.map +0 -1
- package/lib/postOnboarding/hooks/index.d.ts +0 -6
- package/lib/postOnboarding/hooks/index.d.ts.map +0 -1
- package/lib/postOnboarding/hooks/index.js +0 -22
- package/lib/postOnboarding/hooks/index.js.map +0 -1
- package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.d.ts +0 -8
- package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.d.ts.map +0 -1
- package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.js +0 -16
- package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.js.map +0 -1
- package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.test.d.ts +0 -2
- package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.test.d.ts.map +0 -1
- package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.test.js +0 -75
- package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.test.js.map +0 -1
- package/lib/postOnboarding/hooks/usePostOnboardingContext.d.ts +0 -3
- package/lib/postOnboarding/hooks/usePostOnboardingContext.d.ts.map +0 -1
- package/lib/postOnboarding/hooks/usePostOnboardingContext.js +0 -10
- package/lib/postOnboarding/hooks/usePostOnboardingContext.js.map +0 -1
- package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.d.ts +0 -8
- package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.d.ts.map +0 -1
- package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.js +0 -20
- package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.js.map +0 -1
- package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.test.d.ts +0 -2
- package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.test.d.ts.map +0 -1
- package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.test.js +0 -64
- package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.test.js.map +0 -1
- package/lib/postOnboarding/hooks/usePostOnboardingHubState.d.ts +0 -12
- package/lib/postOnboarding/hooks/usePostOnboardingHubState.d.ts.map +0 -1
- package/lib/postOnboarding/hooks/usePostOnboardingHubState.js +0 -65
- package/lib/postOnboarding/hooks/usePostOnboardingHubState.js.map +0 -1
- package/lib/postOnboarding/hooks/usePostOnboardingHubState.test.d.ts +0 -2
- package/lib/postOnboarding/hooks/usePostOnboardingHubState.test.d.ts.map +0 -1
- package/lib/postOnboarding/hooks/usePostOnboardingHubState.test.js +0 -129
- package/lib/postOnboarding/hooks/usePostOnboardingHubState.test.js.map +0 -1
- package/lib/postOnboarding/hooks/useStartPostOnboardingCallback.d.ts +0 -13
- package/lib/postOnboarding/hooks/useStartPostOnboardingCallback.d.ts.map +0 -1
- package/lib/postOnboarding/hooks/useStartPostOnboardingCallback.js +0 -34
- package/lib/postOnboarding/hooks/useStartPostOnboardingCallback.js.map +0 -1
- package/lib/postOnboarding/mock.d.ts +0 -8
- package/lib/postOnboarding/mock.d.ts.map +0 -1
- package/lib/postOnboarding/mock.js +0 -46
- package/lib/postOnboarding/mock.js.map +0 -1
- package/lib/postOnboarding/reducer.d.ts +0 -22
- package/lib/postOnboarding/reducer.d.ts.map +0 -1
- package/lib/postOnboarding/reducer.js +0 -71
- package/lib/postOnboarding/reducer.js.map +0 -1
- package/lib/postOnboarding/reducer.test.d.ts +0 -2
- package/lib/postOnboarding/reducer.test.d.ts.map +0 -1
- package/lib/postOnboarding/reducer.test.js +0 -251
- package/lib/postOnboarding/reducer.test.js.map +0 -1
- package/src/exchange/swap/getProviders.test.ts +0 -450
- package/src/postOnboarding/PostOnboardingProvider.tsx +0 -49
- package/src/postOnboarding/actions.ts +0 -40
- package/src/postOnboarding/hooks/index.ts +0 -5
- package/src/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.test.ts +0 -82
- package/src/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.ts +0 -12
- package/src/postOnboarding/hooks/usePostOnboardingContext.ts +0 -9
- package/src/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.test.ts +0 -83
- package/src/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.ts +0 -22
- package/src/postOnboarding/hooks/usePostOnboardingHubState.test.ts +0 -184
- package/src/postOnboarding/hooks/usePostOnboardingHubState.ts +0 -56
- package/src/postOnboarding/hooks/useStartPostOnboardingCallback.ts +0 -38
- package/src/postOnboarding/mock.ts +0 -53
- package/src/postOnboarding/reducer.test.ts +0 -247
- package/src/postOnboarding/reducer.ts +0 -105
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import type { DeviceAction } from "../../bot/types";
|
|
2
2
|
import type { Transaction } from "./types";
|
|
3
|
-
import {
|
|
3
|
+
import { formatCurrencyUnit } from "../../currencies";
|
|
4
|
+
import { deviceActionFlow } from "../../bot/specs";
|
|
5
|
+
import type { Unit } from "@ledgerhq/types-cryptoassets";
|
|
6
|
+
import BigNumber from "bignumber.js";
|
|
7
|
+
|
|
8
|
+
function expectedValue(unit: Unit, value: BigNumber) {
|
|
9
|
+
return formatCurrencyUnit(unit, value, {
|
|
10
|
+
showCode: true,
|
|
11
|
+
disableRounding: true,
|
|
12
|
+
showAllDigits: true,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
4
15
|
|
|
5
16
|
export const acceptTransaction: DeviceAction<Transaction, any> =
|
|
6
17
|
deviceActionFlow({
|
|
@@ -27,7 +38,7 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
|
|
|
27
38
|
button: "LRlr",
|
|
28
39
|
ignoreAssertionFailure: true,
|
|
29
40
|
expectedValue: ({ account, status }) =>
|
|
30
|
-
|
|
41
|
+
expectedValue(account.unit, status.amount),
|
|
31
42
|
},
|
|
32
43
|
{
|
|
33
44
|
title: "Asset fingerprint",
|
|
@@ -49,7 +60,7 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
|
|
|
49
60
|
button: "LRlr",
|
|
50
61
|
ignoreAssertionFailure: true,
|
|
51
62
|
expectedValue: ({ account, status }) =>
|
|
52
|
-
|
|
63
|
+
expectedValue(account.unit, status.estimatedFees),
|
|
53
64
|
},
|
|
54
65
|
{
|
|
55
66
|
title: "Transaction TTL",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DeviceAction } from "../../bot/types";
|
|
2
2
|
import type { Transaction } from "./types";
|
|
3
|
-
import { deviceActionFlow
|
|
4
|
-
|
|
3
|
+
import { deviceActionFlow } from "../../bot/specs";
|
|
4
|
+
import { formatCurrencyUnit } from "../../currencies";
|
|
5
5
|
const typeWording = {
|
|
6
6
|
send: "Send",
|
|
7
7
|
lock: "Lock",
|
|
@@ -23,10 +23,18 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
|
|
|
23
23
|
{
|
|
24
24
|
title: "Amount",
|
|
25
25
|
button: "Rr",
|
|
26
|
-
expectedValue: ({ account, status }) =>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
expectedValue: ({ account, status }) => {
|
|
27
|
+
const formattedValue =
|
|
28
|
+
"CELO " +
|
|
29
|
+
formatCurrencyUnit(account.unit, status.amount, {
|
|
30
|
+
disableRounding: true,
|
|
31
|
+
});
|
|
32
|
+
if (!formattedValue.includes(".")) {
|
|
33
|
+
// if the value is pure integer, in the app it will automatically add an .0
|
|
34
|
+
return formattedValue + ".0";
|
|
35
|
+
}
|
|
36
|
+
return formattedValue;
|
|
37
|
+
},
|
|
30
38
|
},
|
|
31
39
|
{
|
|
32
40
|
title: "Address",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DeviceAction } from "../../bot/types";
|
|
2
2
|
import type { Transaction } from "./types";
|
|
3
|
-
import { deviceActionFlow
|
|
3
|
+
import { deviceActionFlow } from "../../bot/specs";
|
|
4
|
+
import { formatCurrencyUnit } from "../../currencies";
|
|
4
5
|
|
|
5
6
|
export const acceptTransaction: DeviceAction<Transaction, any> =
|
|
6
7
|
deviceActionFlow({
|
|
@@ -14,9 +15,13 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
|
|
|
14
15
|
title: "Amount",
|
|
15
16
|
button: "Rr",
|
|
16
17
|
expectedValue: ({ account, transaction }) =>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
formatCurrencyUnit(account.unit, transaction.amount, {
|
|
19
|
+
showCode: true,
|
|
20
|
+
disableRounding: true,
|
|
21
|
+
joinFragmentsSeparator: " ",
|
|
22
|
+
})
|
|
23
|
+
.replace(/\s+/g, " ")
|
|
24
|
+
.replace("egld", "EGLD"), // FIXME
|
|
20
25
|
},
|
|
21
26
|
{
|
|
22
27
|
title: "Fee",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DeviceAction } from "../../bot/types";
|
|
2
2
|
import type { Transaction } from "./types";
|
|
3
|
-
import {
|
|
3
|
+
import { formatCurrencyUnit, findCompoundToken } from "../../currencies";
|
|
4
|
+
import { deviceActionFlow } from "../../bot/specs";
|
|
4
5
|
|
|
5
6
|
function subAccount(subAccountId, account) {
|
|
6
7
|
const sub = (account.subAccounts || []).find((a) => a.id === subAccountId);
|
|
@@ -9,8 +10,28 @@ function subAccount(subAccountId, account) {
|
|
|
9
10
|
return sub;
|
|
10
11
|
}
|
|
11
12
|
|
|
13
|
+
function expectedCompoundToken(t) {
|
|
14
|
+
if (!t) {
|
|
15
|
+
throw new Error("compound token was expected");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return t;
|
|
19
|
+
}
|
|
20
|
+
|
|
12
21
|
const maxFeesExpectedValue = ({ account, status }) =>
|
|
13
|
-
|
|
22
|
+
formatCurrencyUnit(
|
|
23
|
+
{
|
|
24
|
+
...account.unit,
|
|
25
|
+
code: account.currency.deviceTicker || account.unit.code,
|
|
26
|
+
prefixCode: true,
|
|
27
|
+
},
|
|
28
|
+
status.estimatedFees,
|
|
29
|
+
{
|
|
30
|
+
showCode: true,
|
|
31
|
+
disableRounding: true,
|
|
32
|
+
joinFragmentsSeparator: " ",
|
|
33
|
+
}
|
|
34
|
+
).replace(/\s/g, " ");
|
|
14
35
|
|
|
15
36
|
export const acceptTransaction: DeviceAction<Transaction, any> =
|
|
16
37
|
deviceActionFlow({
|
|
@@ -45,6 +66,16 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
|
|
|
45
66
|
return "Unlimited " + a.token.ticker;
|
|
46
67
|
}
|
|
47
68
|
|
|
69
|
+
const unit = !a
|
|
70
|
+
? {
|
|
71
|
+
...account.unit,
|
|
72
|
+
code: account.currency.deviceTicker || account.unit.code,
|
|
73
|
+
}
|
|
74
|
+
: (transaction.mode === "compound.withdraw" &&
|
|
75
|
+
transaction.useAllAmount
|
|
76
|
+
? expectedCompoundToken(findCompoundToken(a.token))
|
|
77
|
+
: a.token
|
|
78
|
+
).units[0];
|
|
48
79
|
const amount =
|
|
49
80
|
a &&
|
|
50
81
|
a.compoundBalance &&
|
|
@@ -52,20 +83,19 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
|
|
|
52
83
|
transaction.useAllAmount
|
|
53
84
|
? a.compoundBalance
|
|
54
85
|
: status.amount;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return formatDeviceAmount(account.currency, amount);
|
|
86
|
+
return formatCurrencyUnit(
|
|
87
|
+
{
|
|
88
|
+
...unit,
|
|
89
|
+
code: account.currency.deviceTicker || account.unit.code,
|
|
90
|
+
prefixCode: true,
|
|
91
|
+
},
|
|
92
|
+
amount,
|
|
93
|
+
{
|
|
94
|
+
showCode: true,
|
|
95
|
+
disableRounding: true,
|
|
96
|
+
joinFragmentsSeparator: " ",
|
|
97
|
+
}
|
|
98
|
+
).replace(/\s/g, " ");
|
|
69
99
|
},
|
|
70
100
|
},
|
|
71
101
|
{
|
|
@@ -3,7 +3,7 @@ import invariant from "invariant";
|
|
|
3
3
|
import { DeviceModelId } from "@ledgerhq/devices";
|
|
4
4
|
import { getCryptoCurrencyById, parseCurrencyUnit } from "../../currencies";
|
|
5
5
|
import { acceptTransaction } from "./speculos-deviceActions";
|
|
6
|
-
import {
|
|
6
|
+
import { pickSiblings } from "../../bot/specs";
|
|
7
7
|
import type { AppSpec } from "../../bot/types";
|
|
8
8
|
import type { Transaction } from "./types";
|
|
9
9
|
|
|
@@ -14,7 +14,7 @@ const transactionCheck =
|
|
|
14
14
|
({ maxSpendable }) => {
|
|
15
15
|
invariant(
|
|
16
16
|
maxSpendable.gt(
|
|
17
|
-
parseCurrencyUnit(getCryptoCurrencyById(currencyId).units[0], "
|
|
17
|
+
parseCurrencyUnit(getCryptoCurrencyById(currencyId).units[0], "0.01")
|
|
18
18
|
),
|
|
19
19
|
`${currencyId} balance is too low`
|
|
20
20
|
);
|
|
@@ -45,17 +45,13 @@ const evmBasicMutations = ({ maxAccount }) => [
|
|
|
45
45
|
"operation time to be older than 60s"
|
|
46
46
|
);
|
|
47
47
|
const estimatedGas = transaction.gasLimit.times(
|
|
48
|
-
transaction.gasPrice ||
|
|
48
|
+
transaction.gasPrice || 0
|
|
49
49
|
);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
estimatedGas.toNumber()
|
|
53
|
-
)
|
|
50
|
+
expect(operation.fee.toNumber()).toBeLessThanOrEqual(
|
|
51
|
+
estimatedGas.toNumber()
|
|
54
52
|
);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
accountBeforeTransaction.balance.minus(operation.value).toString()
|
|
58
|
-
)
|
|
53
|
+
expect(account.balance.toString()).toBe(
|
|
54
|
+
accountBeforeTransaction.balance.minus(operation.value).toString()
|
|
59
55
|
);
|
|
60
56
|
},
|
|
61
57
|
},
|
|
@@ -122,7 +118,7 @@ const songbird: AppSpec<Transaction> = {
|
|
|
122
118
|
};
|
|
123
119
|
|
|
124
120
|
const flare: AppSpec<Transaction> = {
|
|
125
|
-
name: "
|
|
121
|
+
name: "Moonbeam",
|
|
126
122
|
currency: getCryptoCurrencyById("flare"),
|
|
127
123
|
appQuery: {
|
|
128
124
|
model: DeviceModelId.nanoS,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DeviceAction } from "../../bot/types";
|
|
2
2
|
import type { Transaction } from "./types";
|
|
3
|
-
import {
|
|
3
|
+
import { formatCurrencyUnit } from "../../currencies";
|
|
4
|
+
import { deviceActionFlow } from "../../bot/specs";
|
|
4
5
|
|
|
5
6
|
function subAccount(subAccountId, account) {
|
|
6
7
|
const sub = (account.subAccounts || []).find((a) => a.id === subAccountId);
|
|
@@ -10,7 +11,19 @@ function subAccount(subAccountId, account) {
|
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
const maxFeesExpectedValue = ({ account, status }) =>
|
|
13
|
-
|
|
14
|
+
formatCurrencyUnit(
|
|
15
|
+
{
|
|
16
|
+
...account.unit,
|
|
17
|
+
code: account.currency.deviceTicker || account.unit.code,
|
|
18
|
+
prefixCode: true,
|
|
19
|
+
},
|
|
20
|
+
status.estimatedFees,
|
|
21
|
+
{
|
|
22
|
+
showCode: true,
|
|
23
|
+
disableRounding: true,
|
|
24
|
+
joinFragmentsSeparator: " ",
|
|
25
|
+
}
|
|
26
|
+
).replace(/\s/g, " ");
|
|
14
27
|
|
|
15
28
|
export const acceptTransaction: DeviceAction<Transaction, any> =
|
|
16
29
|
deviceActionFlow({
|
|
@@ -31,11 +44,26 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
|
|
|
31
44
|
? subAccount(transaction.subAccountId, account)
|
|
32
45
|
: null;
|
|
33
46
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
47
|
+
const unit = !a
|
|
48
|
+
? {
|
|
49
|
+
...account.unit,
|
|
50
|
+
code: account.currency.deviceTicker || account.unit.code,
|
|
51
|
+
}
|
|
52
|
+
: a.token.units[0];
|
|
53
|
+
const amount = status.amount;
|
|
54
|
+
return formatCurrencyUnit(
|
|
55
|
+
{
|
|
56
|
+
...unit,
|
|
57
|
+
code: account.currency.deviceTicker || account.unit.code,
|
|
58
|
+
prefixCode: true,
|
|
59
|
+
},
|
|
60
|
+
amount,
|
|
61
|
+
{
|
|
62
|
+
showCode: true,
|
|
63
|
+
disableRounding: true,
|
|
64
|
+
joinFragmentsSeparator: " ",
|
|
65
|
+
}
|
|
66
|
+
).replace(/\s/g, " ");
|
|
39
67
|
},
|
|
40
68
|
},
|
|
41
69
|
{
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DeviceAction } from "../../bot/types";
|
|
2
2
|
import type { Transaction } from "./types";
|
|
3
|
-
import { deviceActionFlow
|
|
3
|
+
import { deviceActionFlow } from "../../bot/specs";
|
|
4
|
+
import { formatCurrencyUnit } from "../../currencies";
|
|
4
5
|
|
|
5
6
|
export const acceptTransaction: DeviceAction<Transaction, any> =
|
|
6
7
|
deviceActionFlow({
|
|
@@ -24,8 +25,8 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
|
|
|
24
25
|
title: "Value",
|
|
25
26
|
button: "Rr",
|
|
26
27
|
expectedValue: ({ account, status }) =>
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
formatCurrencyUnit(account.unit, status.amount, {
|
|
29
|
+
disableRounding: true,
|
|
29
30
|
showAllDigits: true,
|
|
30
31
|
}),
|
|
31
32
|
},
|
|
@@ -38,8 +39,8 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
|
|
|
38
39
|
title: "Gas Premium",
|
|
39
40
|
button: "Rr",
|
|
40
41
|
expectedValue: ({ account, transaction }) =>
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
formatCurrencyUnit(account.unit, transaction.gasPremium, {
|
|
43
|
+
disableRounding: true,
|
|
43
44
|
showAllDigits: true,
|
|
44
45
|
}),
|
|
45
46
|
},
|
|
@@ -47,8 +48,8 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
|
|
|
47
48
|
title: "Gas Fee Cap",
|
|
48
49
|
button: "Rr",
|
|
49
50
|
expectedValue: ({ account, transaction }) =>
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
formatCurrencyUnit(account.unit, transaction.gasFeeCap, {
|
|
52
|
+
disableRounding: true,
|
|
52
53
|
showAllDigits: true,
|
|
53
54
|
}),
|
|
54
55
|
},
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DeviceAction } from "../../bot/types";
|
|
2
2
|
import type { PolkadotAccount, Transaction } from "./types";
|
|
3
|
-
import { deviceActionFlow
|
|
3
|
+
import { deviceActionFlow } from "../../bot/specs";
|
|
4
|
+
import { formatCurrencyUnit } from "../../currencies";
|
|
4
5
|
|
|
5
6
|
export const acceptTransaction: DeviceAction<Transaction, any> =
|
|
6
7
|
deviceActionFlow({
|
|
@@ -21,10 +22,20 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
|
|
|
21
22
|
{
|
|
22
23
|
title: "Amount",
|
|
23
24
|
button: "Rr",
|
|
24
|
-
expectedValue: ({ account, transaction }) =>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
expectedValue: ({ account, transaction }) => {
|
|
26
|
+
const formattedValue =
|
|
27
|
+
"DOT " +
|
|
28
|
+
formatCurrencyUnit(account.unit, transaction.amount, {
|
|
29
|
+
disableRounding: true,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (!formattedValue.includes(".")) {
|
|
33
|
+
// if the value is pure integer, in the app it will automatically add an .0
|
|
34
|
+
return formattedValue + ".0";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return formattedValue;
|
|
38
|
+
},
|
|
28
39
|
},
|
|
29
40
|
{
|
|
30
41
|
title: "Chain",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DeviceAction } from "../../bot/types";
|
|
2
2
|
import type { Transaction } from "./types";
|
|
3
|
-
import {
|
|
3
|
+
import { formatCurrencyUnit } from "../../currencies";
|
|
4
|
+
import { deviceActionFlow } from "../../bot/specs";
|
|
4
5
|
|
|
5
6
|
export const acceptTransaction: DeviceAction<Transaction, any> =
|
|
6
7
|
deviceActionFlow({
|
|
@@ -14,13 +15,37 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
|
|
|
14
15
|
title: "Amount",
|
|
15
16
|
button: "Rr",
|
|
16
17
|
expectedValue: ({ account, status }) =>
|
|
17
|
-
|
|
18
|
+
formatCurrencyUnit(
|
|
19
|
+
{
|
|
20
|
+
...account.unit,
|
|
21
|
+
code: account.currency.deviceTicker || account.unit.code,
|
|
22
|
+
prefixCode: true,
|
|
23
|
+
},
|
|
24
|
+
status.amount,
|
|
25
|
+
{
|
|
26
|
+
showCode: true,
|
|
27
|
+
disableRounding: true,
|
|
28
|
+
joinFragmentsSeparator: " ",
|
|
29
|
+
}
|
|
30
|
+
).replace(/\s/g, " "),
|
|
18
31
|
},
|
|
19
32
|
{
|
|
20
33
|
title: "Fee",
|
|
21
34
|
button: "Rr",
|
|
22
35
|
expectedValue: ({ account, status }) =>
|
|
23
|
-
|
|
36
|
+
formatCurrencyUnit(
|
|
37
|
+
{
|
|
38
|
+
...account.unit,
|
|
39
|
+
code: account.currency.deviceTicker || account.unit.code,
|
|
40
|
+
prefixCode: true,
|
|
41
|
+
},
|
|
42
|
+
status.estimatedFees,
|
|
43
|
+
{
|
|
44
|
+
showCode: true,
|
|
45
|
+
disableRounding: true,
|
|
46
|
+
joinFragmentsSeparator: " ",
|
|
47
|
+
}
|
|
48
|
+
).replace(/\s/g, " "),
|
|
24
49
|
},
|
|
25
50
|
{
|
|
26
51
|
title: "Destination Tag",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DeviceAction } from "../../bot/types";
|
|
2
2
|
import type { Transaction } from "./types";
|
|
3
|
-
import {
|
|
3
|
+
import { formatCurrencyUnit } from "../../currencies";
|
|
4
|
+
import { deviceActionFlow } from "../../bot/specs";
|
|
4
5
|
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets";
|
|
5
6
|
import BigNumber from "bignumber.js";
|
|
6
7
|
import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
@@ -16,11 +17,12 @@ function ellipsis(str: string) {
|
|
|
16
17
|
return `${str.slice(0, 7)}..${str.slice(-7)}`;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
function formatAmount(
|
|
20
|
-
const
|
|
21
|
-
return
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
function formatAmount(currency: CryptoCurrency, amount: number) {
|
|
21
|
+
const unit = getMainCurrency(currency).units[0];
|
|
22
|
+
return formatCurrencyUnit(unit, new BigNumber(amount), {
|
|
23
|
+
disableRounding: true,
|
|
24
|
+
showCode: true,
|
|
25
|
+
}).replace(/\s/g, " ");
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
export const acceptTransferTransaction: DeviceAction<Transaction, any> =
|
|
@@ -3,7 +3,7 @@ import StellarSdk, {
|
|
|
3
3
|
// @ts-expect-error stellar-sdk ts definition missing?
|
|
4
4
|
AccountRecord,
|
|
5
5
|
NotFoundError,
|
|
6
|
-
NetworkError
|
|
6
|
+
NetworkError,
|
|
7
7
|
} from "stellar-sdk";
|
|
8
8
|
import { getEnv } from "../../../env";
|
|
9
9
|
import { getCryptoCurrencyById, parseCurrencyUnit } from "../../../currencies";
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
rawOperationsToOperations,
|
|
15
15
|
getReservedBalance,
|
|
16
16
|
} from "../logic";
|
|
17
|
-
import { LedgerAPI4xx, LedgerAPI5xx
|
|
17
|
+
import { NetworkDown, LedgerAPI4xx, LedgerAPI5xx } from "@ledgerhq/errors";
|
|
18
18
|
import { requestInterceptor, responseInterceptor } from "../../../network";
|
|
19
19
|
import type { BalanceAsset } from "../types";
|
|
20
20
|
import { NetworkCongestionLevel, Signer } from "../types";
|
|
@@ -127,12 +127,8 @@ export const fetchAccount = async (
|
|
|
127
127
|
assets = account.balances?.filter((balance) => {
|
|
128
128
|
return balance.asset_type !== "native";
|
|
129
129
|
});
|
|
130
|
-
} catch (e
|
|
131
|
-
|
|
132
|
-
balance.balance = "0";
|
|
133
|
-
} else {
|
|
134
|
-
throw new NetworkError();
|
|
135
|
-
}
|
|
130
|
+
} catch (e) {
|
|
131
|
+
balance.balance = "0";
|
|
136
132
|
}
|
|
137
133
|
|
|
138
134
|
const formattedBalance = parseCurrencyUnit(
|
|
@@ -209,11 +205,11 @@ export const fetchOperations = async ({
|
|
|
209
205
|
}
|
|
210
206
|
|
|
211
207
|
if (
|
|
212
|
-
e instanceof
|
|
208
|
+
e instanceof NetworkError ||
|
|
213
209
|
errorMsg.match(/ECONNRESET|ECONNREFUSED|ENOTFOUND|EPIPE|ETIMEDOUT/) ||
|
|
214
210
|
errorMsg.match(/undefined is not an object/)
|
|
215
211
|
) {
|
|
216
|
-
throw new
|
|
212
|
+
throw new NetworkDown();
|
|
217
213
|
}
|
|
218
214
|
|
|
219
215
|
throw e;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { DeviceAction } from "../../bot/types";
|
|
2
2
|
import type { Transaction } from "./types";
|
|
3
3
|
import { formatCurrencyUnit } from "../../currencies";
|
|
4
|
-
import { deviceActionFlow
|
|
4
|
+
import { deviceActionFlow } from "../../bot/specs";
|
|
5
5
|
|
|
6
6
|
const expectedAmount = ({ account, status, transaction }) => {
|
|
7
7
|
if (transaction.assetCode && transaction.assetIssuer) {
|
|
8
|
-
const amount =
|
|
8
|
+
const amount = formatCurrencyUnit(account.unit, status.amount, {
|
|
9
|
+
disableRounding: true,
|
|
10
|
+
useGrouping: false,
|
|
11
|
+
});
|
|
9
12
|
|
|
10
13
|
return `${amount} ${transaction.assetCode}@${truncateAddress(
|
|
11
14
|
transaction.assetIssuer,
|
|
@@ -14,9 +17,12 @@ const expectedAmount = ({ account, status, transaction }) => {
|
|
|
14
17
|
)}`;
|
|
15
18
|
}
|
|
16
19
|
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
return (
|
|
21
|
+
formatCurrencyUnit(account.unit, status.amount, {
|
|
22
|
+
disableRounding: true,
|
|
23
|
+
useGrouping: false,
|
|
24
|
+
}) + " XLM"
|
|
25
|
+
);
|
|
20
26
|
};
|
|
21
27
|
|
|
22
28
|
const truncateAddress = (stellarAddress: string, start = 6, end = 6) =>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import type { DeviceAction } from "../../bot/types";
|
|
3
3
|
import type { Transaction } from "./types";
|
|
4
|
-
import {
|
|
4
|
+
import { formatCurrencyUnit } from "../../currencies";
|
|
5
|
+
import { deviceActionFlow } from "../../bot/specs";
|
|
5
6
|
|
|
6
7
|
export const acceptTransaction: DeviceAction<Transaction, any> =
|
|
7
8
|
deviceActionFlow({
|
|
@@ -37,18 +38,24 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
|
|
|
37
38
|
{
|
|
38
39
|
title: "Amount",
|
|
39
40
|
button: "Rr",
|
|
40
|
-
expectedValue: ({ account, transaction }) =>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
expectedValue: ({ account, transaction }) => {
|
|
42
|
+
const amount = transaction.amount;
|
|
43
|
+
return formatCurrencyUnit(account.unit, amount, {
|
|
44
|
+
disableRounding: true,
|
|
45
|
+
joinFragmentsSeparator: " ",
|
|
46
|
+
}).replace(/\s/g, " ");
|
|
47
|
+
},
|
|
44
48
|
},
|
|
45
49
|
{
|
|
46
50
|
title: "Fee",
|
|
47
51
|
button: "Rr",
|
|
48
|
-
expectedValue: ({ account, status }) =>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
expectedValue: ({ account, status }) => {
|
|
53
|
+
const amount = status.estimatedFees;
|
|
54
|
+
return formatCurrencyUnit(account.currency.units[0], amount, {
|
|
55
|
+
disableRounding: true,
|
|
56
|
+
joinFragmentsSeparator: " ",
|
|
57
|
+
}).replace(/\s/g, " ");
|
|
58
|
+
},
|
|
52
59
|
},
|
|
53
60
|
{
|
|
54
61
|
title: "Source",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DeviceAction } from "../../bot/types";
|
|
2
|
-
import { deviceActionFlow
|
|
2
|
+
import { deviceActionFlow } from "../../bot/specs";
|
|
3
|
+
import { formatCurrencyUnit } from "../../currencies";
|
|
3
4
|
import type { Transaction, Vote } from "./types";
|
|
4
5
|
|
|
5
6
|
function subAccount(subAccountId, account) {
|
|
@@ -39,9 +40,16 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
|
|
|
39
40
|
title: "Amount",
|
|
40
41
|
button: "Rr",
|
|
41
42
|
expectedValue: ({ account, status }) =>
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
formatCurrencyUnit(
|
|
44
|
+
{
|
|
45
|
+
...account.unit,
|
|
46
|
+
code: account.currency.deviceTicker || account.unit.code,
|
|
47
|
+
},
|
|
48
|
+
status.amount,
|
|
49
|
+
{
|
|
50
|
+
disableRounding: true,
|
|
51
|
+
}
|
|
52
|
+
),
|
|
45
53
|
},
|
|
46
54
|
{
|
|
47
55
|
title: "Token",
|