@ledgerhq/live-common 27.2.0-nightly.3 → 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/specs.d.ts +0 -8
- package/lib/bot/specs.d.ts.map +1 -1
- package/lib/bot/specs.js +1 -45
- package/lib/bot/specs.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/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/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 +3 -7
- 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 +10 -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/package.json +17 -17
- package/src/bot/specs.ts +0 -39
- package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +35 -1
- 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/speculos-deviceActions.ts +26 -3
- 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 +6 -10
- package/src/families/evm/speculos-deviceActions.ts +35 -7
- package/src/families/filecoin/speculos-deviceActions.ts +11 -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/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/src/exchange/swap/getProviders.test.ts +0 -450
|
@@ -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",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getProviders.test.d.ts","sourceRoot":"","sources":["../../../src/exchange/swap/getProviders.test.ts"],"names":[],"mappings":""}
|