@ledgerhq/live-common 25.0.0-next.0 → 25.0.0-next.3
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__/accounts/importAccounts.js +1 -1
- package/lib/__tests__/test-helpers/setup.js +1 -1
- package/lib/account/helpers.d.ts +5 -1
- package/lib/account/helpers.d.ts.map +1 -1
- package/lib/account/helpers.js +28 -1
- package/lib/account/helpers.js.map +1 -1
- package/lib/apps/filtering.test.js +1 -1
- package/lib/bot/specs.d.ts +1 -0
- package/lib/bot/specs.d.ts.map +1 -1
- package/lib/bot/specs.js +6 -1
- package/lib/bot/specs.js.map +1 -1
- package/lib/countervalues/api/api.d.ts.map +1 -1
- package/lib/countervalues/api/api.js +25 -13
- package/lib/countervalues/api/api.js.map +1 -1
- package/lib/countervalues/logic.d.ts.map +1 -1
- package/lib/countervalues/logic.integration.test.d.ts +1 -1
- package/lib/countervalues/logic.integration.test.d.ts.map +1 -1
- package/lib/countervalues/logic.integration.test.js +78 -2
- package/lib/countervalues/logic.integration.test.js.map +1 -1
- package/lib/countervalues/logic.js +5 -1
- package/lib/countervalues/logic.js.map +1 -1
- package/lib/countervalues/modules/index.d.ts +1 -1
- package/lib/countervalues/modules/index.d.ts.map +1 -1
- package/lib/countervalues/modules/index.js +3 -1
- package/lib/countervalues/modules/index.js.map +1 -1
- package/lib/countervalues/types.d.ts +1 -0
- package/lib/countervalues/types.d.ts.map +1 -1
- package/lib/currencies/helpers.d.ts +9 -0
- package/lib/currencies/helpers.d.ts.map +1 -0
- package/lib/currencies/helpers.js +78 -0
- package/lib/currencies/helpers.js.map +1 -0
- package/lib/currencies/helpers.test.d.ts +2 -0
- package/lib/currencies/helpers.test.d.ts.map +1 -0
- package/lib/currencies/helpers.test.js +20 -0
- package/lib/currencies/helpers.test.js.map +1 -0
- package/lib/currencies/index.d.ts +1 -0
- package/lib/currencies/index.d.ts.map +1 -1
- package/lib/currencies/index.js +1 -0
- package/lib/currencies/index.js.map +1 -1
- package/lib/currencies/react.d.ts +4 -0
- package/lib/currencies/react.d.ts.map +1 -0
- package/lib/currencies/react.js +16 -0
- package/lib/currencies/react.js.map +1 -0
- package/lib/env.d.ts +10 -5
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +5 -0
- package/lib/env.js.map +1 -1
- package/lib/env.react.d.ts +1 -1
- package/lib/env.react.d.ts.map +1 -1
- package/lib/errors.d.ts +1 -2
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +3 -4
- package/lib/errors.js.map +1 -1
- package/lib/families/solana/api/chain/instruction/token/types.d.ts +3 -3
- package/lib/families/stellar/api/horizon.d.ts +29 -7
- package/lib/families/stellar/api/horizon.d.ts.map +1 -1
- package/lib/families/stellar/api/horizon.js +114 -58
- package/lib/families/stellar/api/horizon.js.map +1 -1
- package/lib/families/stellar/api/index.d.ts +1 -1
- package/lib/families/stellar/api/index.d.ts.map +1 -1
- package/lib/families/stellar/api/index.js +5 -1
- package/lib/families/stellar/api/index.js.map +1 -1
- package/lib/families/stellar/bridge/mock.d.ts.map +1 -1
- package/lib/families/stellar/bridge/mock.js +4 -1
- package/lib/families/stellar/bridge/mock.js.map +1 -1
- package/lib/families/stellar/bridge.integration.test.js +12 -4
- package/lib/families/stellar/bridge.integration.test.js.map +1 -1
- package/lib/families/stellar/cli-transaction.d.ts +3 -1
- package/lib/families/stellar/cli-transaction.d.ts.map +1 -1
- package/lib/families/stellar/cli-transaction.js +48 -2
- package/lib/families/stellar/cli-transaction.js.map +1 -1
- package/lib/families/stellar/deviceTransactionConfig.d.ts +7 -1
- package/lib/families/stellar/deviceTransactionConfig.d.ts.map +1 -1
- package/lib/families/stellar/deviceTransactionConfig.js +12 -1
- package/lib/families/stellar/deviceTransactionConfig.js.map +1 -1
- package/lib/families/stellar/errors.d.ts +12 -0
- package/lib/families/stellar/errors.d.ts.map +1 -0
- package/lib/families/stellar/errors.js +16 -0
- package/lib/families/stellar/errors.js.map +1 -0
- package/lib/families/stellar/js-buildTransaction.d.ts.map +1 -1
- package/lib/families/stellar/js-buildTransaction.js +34 -16
- package/lib/families/stellar/js-buildTransaction.js.map +1 -1
- package/lib/families/stellar/js-createTransaction.d.ts.map +1 -1
- package/lib/families/stellar/js-createTransaction.js +4 -1
- package/lib/families/stellar/js-createTransaction.js.map +1 -1
- package/lib/families/stellar/js-estimateMaxSpendable.js +2 -1
- package/lib/families/stellar/js-estimateMaxSpendable.js.map +1 -1
- package/lib/families/stellar/js-getTransactionStatus.d.ts.map +1 -1
- package/lib/families/stellar/js-getTransactionStatus.js +127 -57
- package/lib/families/stellar/js-getTransactionStatus.js.map +1 -1
- package/lib/families/stellar/js-prepareTransaction.d.ts.map +1 -1
- package/lib/families/stellar/js-prepareTransaction.js +25 -7
- package/lib/families/stellar/js-prepareTransaction.js.map +1 -1
- package/lib/families/stellar/js-signOperation.d.ts.map +1 -1
- package/lib/families/stellar/js-signOperation.js +33 -6
- package/lib/families/stellar/js-signOperation.js.map +1 -1
- package/lib/families/stellar/js-synchronization.d.ts +1 -1
- package/lib/families/stellar/js-synchronization.d.ts.map +1 -1
- package/lib/families/stellar/js-synchronization.js +42 -16
- package/lib/families/stellar/js-synchronization.js.map +1 -1
- package/lib/families/stellar/logic.d.ts +21 -14
- package/lib/families/stellar/logic.d.ts.map +1 -1
- package/lib/families/stellar/logic.js +158 -57
- package/lib/families/stellar/logic.js.map +1 -1
- package/lib/families/stellar/specs.d.ts.map +1 -1
- package/lib/families/stellar/specs.js +182 -7
- package/lib/families/stellar/specs.js.map +1 -1
- package/lib/families/stellar/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/stellar/speculos-deviceActions.js +60 -28
- package/lib/families/stellar/speculos-deviceActions.js.map +1 -1
- package/lib/families/stellar/tokens.d.ts +11 -0
- package/lib/families/stellar/tokens.d.ts.map +1 -0
- package/lib/families/stellar/tokens.js +82 -0
- package/lib/families/stellar/tokens.js.map +1 -0
- package/lib/families/stellar/transaction.d.ts +2 -2
- package/lib/families/stellar/transaction.d.ts.map +1 -1
- package/lib/families/stellar/transaction.js +32 -6
- package/lib/families/stellar/transaction.js.map +1 -1
- package/lib/families/stellar/types.d.ts +45 -0
- package/lib/families/stellar/types.d.ts.map +1 -1
- package/lib/families/stellar/types.js +7 -1
- package/lib/families/stellar/types.js.map +1 -1
- package/lib/generated/cli-transaction.d.ts +1 -0
- package/lib/generated/cli-transaction.d.ts.map +1 -1
- package/lib/generated/transaction.d.ts +1 -1
- package/lib/platform/PlatformAppProvider/api/api.mock.js +11 -11
- package/lib/platform/PlatformAppProvider/api/api.mock.js.map +1 -1
- package/lib/platform/PlatformAppProvider/helpers.d.ts +0 -7
- package/lib/platform/PlatformAppProvider/helpers.d.ts.map +1 -1
- package/lib/platform/PlatformAppProvider/helpers.js +1 -29
- package/lib/platform/PlatformAppProvider/helpers.js.map +1 -1
- package/lib/platform/converters.d.ts +4 -4
- package/lib/platform/converters.d.ts.map +1 -1
- package/lib/platform/converters.js +40 -2
- package/lib/platform/converters.js.map +1 -1
- package/lib/platform/filters.d.ts +18 -0
- package/lib/platform/filters.d.ts.map +1 -0
- package/lib/platform/filters.js +63 -0
- package/lib/platform/filters.js.map +1 -0
- package/lib/platform/helpers.d.ts +7 -0
- package/lib/platform/helpers.d.ts.map +1 -0
- package/lib/platform/helpers.js +22 -0
- package/lib/platform/helpers.js.map +1 -0
- package/lib/platform/logic.d.ts +1 -5
- package/lib/platform/logic.d.ts.map +1 -1
- package/lib/platform/logic.js +1 -18
- package/lib/platform/logic.js.map +1 -1
- package/lib/platform/providers/RemoteLiveAppProvider/api/mock.json +87 -246
- package/lib/platform/react.d.ts +11 -0
- package/lib/platform/react.d.ts.map +1 -0
- package/lib/platform/react.js +61 -0
- package/lib/platform/react.js.map +1 -0
- package/lib/platform/types.d.ts +8 -2
- package/lib/platform/types.d.ts.map +1 -1
- package/lib/platform/types.js +15 -0
- package/lib/platform/types.js.map +1 -1
- package/lib/platform/version.test.js +1 -1
- package/lib/walletconnect/walletconnect.test.js +0 -2
- package/lib/walletconnect/walletconnect.test.js.map +1 -1
- package/package.json +5 -4
- package/src/__tests__/accounts/importAccounts.ts +1 -1
- package/src/__tests__/test-helpers/setup.ts +1 -1
- package/src/account/helpers.ts +51 -0
- package/src/apps/filtering.test.ts +1 -1
- package/src/bot/specs.ts +7 -1
- package/src/countervalues/api/api.ts +25 -8
- package/src/countervalues/logic.integration.test.ts +71 -1
- package/src/countervalues/logic.ts +3 -1
- package/src/countervalues/modules/index.ts +3 -1
- package/src/countervalues/types.ts +2 -0
- package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +1 -0
- package/src/currencies/helpers.test.ts +21 -0
- package/src/currencies/helpers.ts +69 -0
- package/src/currencies/index.ts +1 -0
- package/src/currencies/react.ts +16 -0
- package/src/env.ts +5 -0
- package/src/errors.ts +1 -6
- package/src/families/stellar/__snapshots__/bridge.integration.test.ts.snap +765 -339
- package/src/families/stellar/api/horizon.ts +115 -33
- package/src/families/stellar/api/index.ts +4 -0
- package/src/families/stellar/bridge/mock.ts +3 -0
- package/src/families/stellar/bridge.integration.test.ts +10 -2
- package/src/families/stellar/cli-transaction.ts +75 -2
- package/src/families/stellar/deviceTransactionConfig.ts +22 -0
- package/src/families/stellar/errors.ts +34 -0
- package/src/families/stellar/js-buildTransaction.ts +56 -16
- package/src/families/stellar/js-createTransaction.ts +3 -0
- package/src/families/stellar/js-estimateMaxSpendable.ts +1 -1
- package/src/families/stellar/js-getTransactionStatus.ts +152 -60
- package/src/families/stellar/js-prepareTransaction.ts +4 -3
- package/src/families/stellar/js-signOperation.ts +37 -6
- package/src/families/stellar/js-synchronization.ts +53 -11
- package/src/families/stellar/logic.ts +198 -62
- package/src/families/stellar/specs.ts +227 -8
- package/src/families/stellar/speculos-deviceActions.ts +66 -22
- package/src/families/stellar/tokens.ts +118 -0
- package/src/families/stellar/transaction.ts +31 -3
- package/src/families/stellar/types.ts +52 -0
- package/src/platform/PlatformAppProvider/api/api.mock.ts +11 -11
- package/src/platform/PlatformAppProvider/helpers.ts +0 -48
- package/src/platform/converters.ts +60 -6
- package/src/platform/filters.ts +102 -0
- package/src/platform/helpers.ts +33 -0
- package/src/platform/logic.ts +1 -20
- package/src/platform/providers/RemoteLiveAppProvider/api/mock.json +87 -246
- package/src/platform/react.ts +93 -0
- package/src/platform/types.ts +23 -1
- package/src/platform/version.test.ts +1 -1
- package/src/walletconnect/walletconnect.test.ts +0 -3
|
@@ -3,26 +3,44 @@ import type { Transaction } from "./types";
|
|
|
3
3
|
import { formatCurrencyUnit } from "../../currencies";
|
|
4
4
|
import { deviceActionFlow } from "../../bot/specs";
|
|
5
5
|
|
|
6
|
-
const expectedAmount = ({ account, status }) =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const expectedAmount = ({ account, status, transaction }) => {
|
|
7
|
+
if (transaction.assetCode && transaction.assetIssuer) {
|
|
8
|
+
const amount = formatCurrencyUnit(account.unit, status.amount, {
|
|
9
|
+
disableRounding: true,
|
|
10
|
+
useGrouping: false,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
return `${amount} ${transaction.assetCode}@${truncateAddress(
|
|
14
|
+
transaction.assetIssuer,
|
|
15
|
+
3,
|
|
16
|
+
4
|
|
17
|
+
)}`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
formatCurrencyUnit(account.unit, status.amount, {
|
|
22
|
+
disableRounding: true,
|
|
23
|
+
useGrouping: false,
|
|
24
|
+
}) + " XLM"
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const truncateAddress = (stellarAddress: string, start = 6, end = 6) =>
|
|
29
|
+
`${stellarAddress.slice(0, start)}..${stellarAddress.slice(-end)}`;
|
|
11
30
|
|
|
12
31
|
const acceptTransaction: DeviceAction<Transaction, any> = deviceActionFlow({
|
|
13
32
|
steps: [
|
|
14
33
|
{
|
|
15
|
-
title: "
|
|
34
|
+
title: "Review",
|
|
16
35
|
button: "Rr",
|
|
17
|
-
expectedValue: expectedAmount,
|
|
18
36
|
},
|
|
19
37
|
{
|
|
20
|
-
title: "
|
|
38
|
+
title: "Memo Text",
|
|
21
39
|
button: "Rr",
|
|
22
|
-
expectedValue:
|
|
40
|
+
expectedValue: ({ transaction }) => transaction.memoValue || "",
|
|
23
41
|
},
|
|
24
42
|
{
|
|
25
|
-
title: "Fee",
|
|
43
|
+
title: "Max Fee",
|
|
26
44
|
button: "Rr",
|
|
27
45
|
expectedValue: ({ account, status }) =>
|
|
28
46
|
formatCurrencyUnit(account.unit, status.estimatedFees, {
|
|
@@ -30,42 +48,68 @@ const acceptTransaction: DeviceAction<Transaction, any> = deviceActionFlow({
|
|
|
30
48
|
}) + " XLM",
|
|
31
49
|
},
|
|
32
50
|
{
|
|
33
|
-
title: "
|
|
51
|
+
title: "Sequence Num",
|
|
34
52
|
button: "Rr",
|
|
35
|
-
expectedValue: ({ transaction }) => transaction.recipient,
|
|
36
53
|
},
|
|
37
54
|
{
|
|
38
|
-
title: "
|
|
55
|
+
title: "Tx Source",
|
|
39
56
|
button: "Rr",
|
|
40
|
-
expectedValue: ({
|
|
57
|
+
expectedValue: ({ account }) => truncateAddress(account.freshAddress),
|
|
41
58
|
},
|
|
42
59
|
{
|
|
43
|
-
title: "
|
|
60
|
+
title: "Operation Type",
|
|
44
61
|
button: "Rr",
|
|
45
|
-
|
|
62
|
+
// Operation type can be Payment (or Create Account) or Change Trust.
|
|
63
|
+
// Create Account type is coming from operation, not transaction.
|
|
64
|
+
// Testing in `specs.ts`.
|
|
46
65
|
},
|
|
47
66
|
{
|
|
48
|
-
title: "
|
|
67
|
+
title: "Change Trust",
|
|
49
68
|
button: "Rr",
|
|
50
|
-
expectedValue: () =>
|
|
69
|
+
expectedValue: ({ transaction }) =>
|
|
70
|
+
`${transaction.assetCode || ""}@${truncateAddress(
|
|
71
|
+
transaction.assetIssuer || "",
|
|
72
|
+
3,
|
|
73
|
+
4
|
|
74
|
+
)}`,
|
|
75
|
+
maxY: 5,
|
|
51
76
|
},
|
|
52
77
|
{
|
|
53
|
-
title: "
|
|
78
|
+
title: "Create Account",
|
|
54
79
|
button: "Rr",
|
|
80
|
+
expectedValue: ({ transaction }) => transaction.recipient,
|
|
81
|
+
maxY: 5,
|
|
55
82
|
},
|
|
56
83
|
{
|
|
57
|
-
title: "
|
|
84
|
+
title: "Send",
|
|
58
85
|
button: "Rr",
|
|
59
|
-
expectedValue:
|
|
86
|
+
expectedValue: expectedAmount,
|
|
60
87
|
},
|
|
61
88
|
{
|
|
62
|
-
title: "
|
|
89
|
+
title: "Destination",
|
|
63
90
|
button: "Rr",
|
|
91
|
+
expectedValue: ({ transaction }) => transaction.recipient,
|
|
64
92
|
},
|
|
65
93
|
{
|
|
66
94
|
title: "Finalize",
|
|
67
95
|
button: "LRlr",
|
|
68
96
|
},
|
|
97
|
+
{
|
|
98
|
+
title: "Starting Balance",
|
|
99
|
+
button: "Rr",
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
title: "Network",
|
|
103
|
+
button: "Rr",
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
title: "Valid Before (UTC)",
|
|
107
|
+
button: "Rr",
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
title: "Valid After (UTC)",
|
|
111
|
+
button: "Rr",
|
|
112
|
+
},
|
|
69
113
|
],
|
|
70
114
|
});
|
|
71
115
|
export default {
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import { emptyHistoryCache } from "../../account";
|
|
3
|
+
import {
|
|
4
|
+
listTokensForCryptoCurrency,
|
|
5
|
+
findTokenById,
|
|
6
|
+
parseCurrencyUnit,
|
|
7
|
+
} from "../../currencies";
|
|
8
|
+
import type {
|
|
9
|
+
TokenAccount,
|
|
10
|
+
TokenCurrency,
|
|
11
|
+
Operation,
|
|
12
|
+
CryptoCurrency,
|
|
13
|
+
SyncConfig,
|
|
14
|
+
} from "../../types";
|
|
15
|
+
import type { BalanceAsset } from "./types";
|
|
16
|
+
import { encodeOperationId } from "../../operation";
|
|
17
|
+
|
|
18
|
+
export const getAssetIdFromTokenId = (tokenId: string): string =>
|
|
19
|
+
tokenId.split("/")[2];
|
|
20
|
+
|
|
21
|
+
const getAssetIdFromAsset = (asset: BalanceAsset) =>
|
|
22
|
+
`${asset.asset_code}:${asset.asset_issuer}`;
|
|
23
|
+
|
|
24
|
+
const buildStellarTokenAccount = ({
|
|
25
|
+
parentAccountId,
|
|
26
|
+
stellarAsset,
|
|
27
|
+
token,
|
|
28
|
+
operations,
|
|
29
|
+
}: {
|
|
30
|
+
parentAccountId: string;
|
|
31
|
+
stellarAsset: BalanceAsset;
|
|
32
|
+
token: TokenCurrency;
|
|
33
|
+
operations: Operation[];
|
|
34
|
+
}): TokenAccount => {
|
|
35
|
+
const assetId = getAssetIdFromTokenId(token.id);
|
|
36
|
+
const id = `${parentAccountId}+${assetId}`;
|
|
37
|
+
const balance = parseCurrencyUnit(
|
|
38
|
+
token.units[0],
|
|
39
|
+
stellarAsset.balance || "0"
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const reservedBalance = new BigNumber(stellarAsset.balance).minus(
|
|
43
|
+
stellarAsset.buying_liabilities || 0
|
|
44
|
+
);
|
|
45
|
+
const spendableBalance = parseCurrencyUnit(
|
|
46
|
+
token.units[0],
|
|
47
|
+
reservedBalance.toString()
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
type: "TokenAccount",
|
|
52
|
+
id,
|
|
53
|
+
parentId: parentAccountId,
|
|
54
|
+
starred: false,
|
|
55
|
+
token,
|
|
56
|
+
operationsCount: operations.length,
|
|
57
|
+
operations: operations.map((op) => ({
|
|
58
|
+
...op,
|
|
59
|
+
id: encodeOperationId(id, op.hash, op.extra.ledgerOpType),
|
|
60
|
+
accountId: id,
|
|
61
|
+
type: op.extra.ledgerOpType,
|
|
62
|
+
value: new BigNumber(op.extra.assetAmount) ?? op.value,
|
|
63
|
+
})),
|
|
64
|
+
pendingOperations: [],
|
|
65
|
+
balance,
|
|
66
|
+
spendableBalance,
|
|
67
|
+
swapHistory: [],
|
|
68
|
+
creationDate:
|
|
69
|
+
operations.length > 0
|
|
70
|
+
? operations[operations.length - 1].date
|
|
71
|
+
: new Date(),
|
|
72
|
+
balanceHistoryCache: emptyHistoryCache, // calculated in the jsHelpers
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const buildSubAccounts = ({
|
|
77
|
+
currency,
|
|
78
|
+
accountId,
|
|
79
|
+
assets,
|
|
80
|
+
syncConfig,
|
|
81
|
+
operations,
|
|
82
|
+
}: {
|
|
83
|
+
currency: CryptoCurrency;
|
|
84
|
+
accountId: string;
|
|
85
|
+
assets: BalanceAsset[];
|
|
86
|
+
syncConfig: SyncConfig;
|
|
87
|
+
operations: Operation[];
|
|
88
|
+
}): TokenAccount[] | undefined => {
|
|
89
|
+
const { blacklistedTokenIds = [] } = syncConfig;
|
|
90
|
+
const allTokens = listTokensForCryptoCurrency(currency);
|
|
91
|
+
|
|
92
|
+
if (allTokens.length === 0 || assets.length === 0) {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const tokenAccounts: TokenAccount[] = [];
|
|
97
|
+
|
|
98
|
+
assets.map((asset) => {
|
|
99
|
+
const token = findTokenById(`stellar/asset/${getAssetIdFromAsset(asset)}`);
|
|
100
|
+
|
|
101
|
+
if (token && !blacklistedTokenIds.includes(token.id)) {
|
|
102
|
+
tokenAccounts.push(
|
|
103
|
+
buildStellarTokenAccount({
|
|
104
|
+
parentAccountId: accountId,
|
|
105
|
+
stellarAsset: asset,
|
|
106
|
+
token,
|
|
107
|
+
operations: operations.filter(
|
|
108
|
+
(op) =>
|
|
109
|
+
op.extra.assetCode === asset.asset_code &&
|
|
110
|
+
op.extra.assetIssuer === asset.asset_issuer
|
|
111
|
+
),
|
|
112
|
+
})
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
return tokenAccounts;
|
|
118
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BigNumber } from "bignumber.js";
|
|
2
2
|
import type { Transaction, TransactionRaw } from "./types";
|
|
3
|
+
import { getAssetCodeIssuer } from "./logic";
|
|
3
4
|
import {
|
|
4
5
|
fromTransactionCommonRaw,
|
|
5
6
|
toTransactionCommonRaw,
|
|
@@ -9,9 +10,22 @@ import { getAccountUnit } from "../../account";
|
|
|
9
10
|
import { formatCurrencyUnit } from "../../currencies";
|
|
10
11
|
|
|
11
12
|
export const formatTransaction = (
|
|
12
|
-
{
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
{
|
|
14
|
+
amount,
|
|
15
|
+
recipient,
|
|
16
|
+
fees,
|
|
17
|
+
memoValue,
|
|
18
|
+
useAllAmount,
|
|
19
|
+
subAccountId,
|
|
20
|
+
}: Transaction,
|
|
21
|
+
mainAccount: Account
|
|
22
|
+
): string => {
|
|
23
|
+
const account =
|
|
24
|
+
(subAccountId &&
|
|
25
|
+
(mainAccount.subAccounts || []).find((a) => a.id === subAccountId)) ||
|
|
26
|
+
mainAccount;
|
|
27
|
+
|
|
28
|
+
return `
|
|
15
29
|
SEND ${
|
|
16
30
|
useAllAmount
|
|
17
31
|
? "MAX"
|
|
@@ -29,10 +43,13 @@ export const formatTransaction = (
|
|
|
29
43
|
disableRounding: true,
|
|
30
44
|
})
|
|
31
45
|
}${memoValue ? "\n memo=" + memoValue : ""}`;
|
|
46
|
+
};
|
|
32
47
|
|
|
33
48
|
const fromTransactionRaw = (tr: TransactionRaw): Transaction => {
|
|
34
49
|
const common = fromTransactionCommonRaw(tr);
|
|
35
50
|
const { networkInfo } = tr;
|
|
51
|
+
const [assetCode, assetIssuer] = getAssetCodeIssuer(tr);
|
|
52
|
+
|
|
36
53
|
return {
|
|
37
54
|
...common,
|
|
38
55
|
family: tr.family,
|
|
@@ -43,14 +60,20 @@ const fromTransactionRaw = (tr: TransactionRaw): Transaction => {
|
|
|
43
60
|
networkInfo: networkInfo && {
|
|
44
61
|
family: networkInfo.family,
|
|
45
62
|
fees: new BigNumber(networkInfo.fees),
|
|
63
|
+
baseFee: new BigNumber(networkInfo.baseFee),
|
|
46
64
|
baseReserve: new BigNumber(networkInfo.baseReserve),
|
|
65
|
+
networkCongestionLevel: networkInfo.networkCongestionLevel,
|
|
47
66
|
},
|
|
67
|
+
mode: tr.mode,
|
|
68
|
+
assetCode,
|
|
69
|
+
assetIssuer,
|
|
48
70
|
};
|
|
49
71
|
};
|
|
50
72
|
|
|
51
73
|
const toTransactionRaw = (t: Transaction): TransactionRaw => {
|
|
52
74
|
const common = toTransactionCommonRaw(t);
|
|
53
75
|
const { networkInfo } = t;
|
|
76
|
+
const [assetCode, assetIssuer] = getAssetCodeIssuer(t);
|
|
54
77
|
return {
|
|
55
78
|
...common,
|
|
56
79
|
family: t.family,
|
|
@@ -61,8 +84,13 @@ const toTransactionRaw = (t: Transaction): TransactionRaw => {
|
|
|
61
84
|
networkInfo: networkInfo && {
|
|
62
85
|
family: networkInfo.family,
|
|
63
86
|
fees: networkInfo.fees.toString(),
|
|
87
|
+
baseFee: networkInfo.baseFee.toString(),
|
|
64
88
|
baseReserve: networkInfo.baseReserve.toString(),
|
|
89
|
+
networkCongestionLevel: networkInfo.networkCongestionLevel,
|
|
65
90
|
},
|
|
91
|
+
mode: t.mode,
|
|
92
|
+
assetCode,
|
|
93
|
+
assetIssuer,
|
|
66
94
|
};
|
|
67
95
|
};
|
|
68
96
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ServerApi } from "stellar-sdk";
|
|
1
2
|
import type { BigNumber } from "bignumber.js";
|
|
2
3
|
import type {
|
|
3
4
|
TransactionCommon,
|
|
@@ -7,14 +8,25 @@ import type {
|
|
|
7
8
|
export type NetworkInfo = {
|
|
8
9
|
family: "stellar";
|
|
9
10
|
fees: BigNumber;
|
|
11
|
+
baseFee: BigNumber;
|
|
10
12
|
baseReserve: BigNumber;
|
|
13
|
+
networkCongestionLevel?: NetworkCongestionLevel;
|
|
11
14
|
};
|
|
12
15
|
|
|
13
16
|
export type NetworkInfoRaw = {
|
|
14
17
|
family: "stellar";
|
|
15
18
|
fees: string;
|
|
19
|
+
baseFee: string;
|
|
16
20
|
baseReserve: string;
|
|
21
|
+
networkCongestionLevel?: NetworkCongestionLevel;
|
|
17
22
|
};
|
|
23
|
+
|
|
24
|
+
export enum NetworkCongestionLevel {
|
|
25
|
+
LOW = "LOW",
|
|
26
|
+
MEDIUM = "MEDIUM",
|
|
27
|
+
HIGH = "HIGH",
|
|
28
|
+
}
|
|
29
|
+
|
|
18
30
|
export const StellarMemoType = [
|
|
19
31
|
"NO_MEMO",
|
|
20
32
|
"MEMO_TEXT",
|
|
@@ -23,6 +35,8 @@ export const StellarMemoType = [
|
|
|
23
35
|
"MEMO_RETURN",
|
|
24
36
|
];
|
|
25
37
|
|
|
38
|
+
export type StellarTransactionMode = "send" | "changeTrust";
|
|
39
|
+
|
|
26
40
|
export type Transaction = TransactionCommon & {
|
|
27
41
|
family: "stellar";
|
|
28
42
|
networkInfo: NetworkInfo | null | undefined;
|
|
@@ -30,7 +44,11 @@ export type Transaction = TransactionCommon & {
|
|
|
30
44
|
baseReserve: BigNumber | null | undefined;
|
|
31
45
|
memoType: string | null | undefined;
|
|
32
46
|
memoValue: string | null | undefined;
|
|
47
|
+
mode: StellarTransactionMode;
|
|
48
|
+
assetCode: string | undefined;
|
|
49
|
+
assetIssuer: string | undefined;
|
|
33
50
|
};
|
|
51
|
+
|
|
34
52
|
export type TransactionRaw = TransactionCommonRaw & {
|
|
35
53
|
family: "stellar";
|
|
36
54
|
networkInfo: NetworkInfoRaw | null | undefined;
|
|
@@ -38,4 +56,38 @@ export type TransactionRaw = TransactionCommonRaw & {
|
|
|
38
56
|
baseReserve: string | null | undefined;
|
|
39
57
|
memoType: string | null | undefined;
|
|
40
58
|
memoValue: string | null | undefined;
|
|
59
|
+
mode: StellarTransactionMode;
|
|
60
|
+
assetCode: string | undefined;
|
|
61
|
+
assetIssuer: string | undefined;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export type BalanceAsset = {
|
|
65
|
+
balance: string;
|
|
66
|
+
limit: string;
|
|
67
|
+
buying_liabilities: string;
|
|
68
|
+
selling_liabilities: string;
|
|
69
|
+
last_modified_ledger: number;
|
|
70
|
+
is_authorized: boolean;
|
|
71
|
+
is_authorized_to_maintain_liabilities: boolean;
|
|
72
|
+
asset_type: string;
|
|
73
|
+
asset_code: string;
|
|
74
|
+
asset_issuer: string;
|
|
75
|
+
liquidity_pool_id?: string;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export type RawOperation = ServerApi.OperationRecord & {
|
|
79
|
+
asset_code?: string;
|
|
80
|
+
asset_issuer?: string;
|
|
81
|
+
from?: string;
|
|
82
|
+
to?: string;
|
|
83
|
+
funder?: string;
|
|
84
|
+
trustor?: string;
|
|
85
|
+
account?: string;
|
|
86
|
+
transaction_successful: boolean;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export type Signer = {
|
|
90
|
+
weight: number;
|
|
91
|
+
key: string;
|
|
92
|
+
type: string;
|
|
41
93
|
};
|
|
@@ -10,7 +10,7 @@ const manifest: AppManifest[] = [
|
|
|
10
10
|
supportUrl: "https://paraswap.io",
|
|
11
11
|
icon: "https://cdn.live.ledger.com/icons/platform/paraswap.png",
|
|
12
12
|
platform: "all",
|
|
13
|
-
apiVersion: "0.0.1",
|
|
13
|
+
apiVersion: "^1.0.0 || ~0.0.1",
|
|
14
14
|
manifestVersion: "1",
|
|
15
15
|
branch: "stable",
|
|
16
16
|
params: ["accountId"],
|
|
@@ -56,7 +56,7 @@ const manifest: AppManifest[] = [
|
|
|
56
56
|
homepageUrl: "https://lido.fi/",
|
|
57
57
|
icon: "https://cdn.live.ledger.com/icons/platform/lido.png",
|
|
58
58
|
platform: "all",
|
|
59
|
-
apiVersion: "0.0.1",
|
|
59
|
+
apiVersion: "^1.0.0 || ~0.0.1",
|
|
60
60
|
manifestVersion: "1",
|
|
61
61
|
branch: "stable",
|
|
62
62
|
categories: ["staking", "defi"],
|
|
@@ -79,7 +79,7 @@ const manifest: AppManifest[] = [
|
|
|
79
79
|
homepageUrl: "https://www.sendwyre.com/",
|
|
80
80
|
icon: "https://cdn.live.ledger.com/icons/platform/wyre.png",
|
|
81
81
|
platform: "all",
|
|
82
|
-
apiVersion: "0.0.1",
|
|
82
|
+
apiVersion: "^1.0.0 || ~0.0.1",
|
|
83
83
|
manifestVersion: "1",
|
|
84
84
|
branch: "stable",
|
|
85
85
|
categories: ["exchange", "buy"],
|
|
@@ -109,7 +109,7 @@ const manifest: AppManifest[] = [
|
|
|
109
109
|
homepageUrl: "https://zerion.io/",
|
|
110
110
|
icon: "https://cdn.live.ledger.com/icons/platform/zerion.png",
|
|
111
111
|
platform: "all",
|
|
112
|
-
apiVersion: "0.0.1",
|
|
112
|
+
apiVersion: "^1.0.0 || ~0.0.1",
|
|
113
113
|
manifestVersion: "1",
|
|
114
114
|
branch: "stable",
|
|
115
115
|
categories: ["portfolio", "defi"],
|
|
@@ -132,7 +132,7 @@ const manifest: AppManifest[] = [
|
|
|
132
132
|
homepageUrl: "https://rainbow.me",
|
|
133
133
|
icon: "https://cdn.live.ledger.com/icons/platform/rainbow.png",
|
|
134
134
|
platform: "all",
|
|
135
|
-
apiVersion: "0.0.1",
|
|
135
|
+
apiVersion: "^1.0.0 || ~0.0.1",
|
|
136
136
|
manifestVersion: "1",
|
|
137
137
|
branch: "stable",
|
|
138
138
|
categories: ["nft"],
|
|
@@ -155,7 +155,7 @@ const manifest: AppManifest[] = [
|
|
|
155
155
|
homepageUrl: "https://aave.com/",
|
|
156
156
|
icon: "https://cdn.live.ledger.com/icons/platform/aave.png",
|
|
157
157
|
platform: "all",
|
|
158
|
-
apiVersion: "0.0.1",
|
|
158
|
+
apiVersion: "^1.0.0 || ~0.0.1",
|
|
159
159
|
manifestVersion: "1",
|
|
160
160
|
branch: "soon",
|
|
161
161
|
categories: ["lend"],
|
|
@@ -178,7 +178,7 @@ const manifest: AppManifest[] = [
|
|
|
178
178
|
homepageUrl: "https://compound.finance/",
|
|
179
179
|
icon: "https://cdn.live.ledger.com/icons/platform/compound.png",
|
|
180
180
|
platform: "all",
|
|
181
|
-
apiVersion: "0.0.1",
|
|
181
|
+
apiVersion: "^1.0.0 || ~0.0.1",
|
|
182
182
|
manifestVersion: "1",
|
|
183
183
|
branch: "soon",
|
|
184
184
|
categories: ["lend", "compound"],
|
|
@@ -201,7 +201,7 @@ const manifest: AppManifest[] = [
|
|
|
201
201
|
homepageUrl: "https://www.deversifi.com/",
|
|
202
202
|
icon: "https://cdn.live.ledger.com/icons/platform/deversifi.png",
|
|
203
203
|
platform: "all",
|
|
204
|
-
apiVersion: "0.0.1",
|
|
204
|
+
apiVersion: "^1.0.0 || ~0.0.1",
|
|
205
205
|
manifestVersion: "1",
|
|
206
206
|
branch: "soon",
|
|
207
207
|
categories: ["dex"],
|
|
@@ -224,7 +224,7 @@ const manifest: AppManifest[] = [
|
|
|
224
224
|
homepageUrl: "https://1inch.io/",
|
|
225
225
|
icon: "https://cdn.live.ledger.com/icons/platform/1inch.png",
|
|
226
226
|
platform: "all",
|
|
227
|
-
apiVersion: "0.0.1",
|
|
227
|
+
apiVersion: "^1.0.0 || ~0.0.1",
|
|
228
228
|
manifestVersion: "1",
|
|
229
229
|
branch: "soon",
|
|
230
230
|
categories: ["swap", "defi"],
|
|
@@ -247,7 +247,7 @@ const manifest: AppManifest[] = [
|
|
|
247
247
|
homepageUrl: "https://developers.ledger.com/",
|
|
248
248
|
icon: "https://cdn.live.ledger.com/icons/platform/debugger.png",
|
|
249
249
|
platform: "all",
|
|
250
|
-
apiVersion: "0.0.1",
|
|
250
|
+
apiVersion: "^1.0.0 || ~0.0.1",
|
|
251
251
|
manifestVersion: "1",
|
|
252
252
|
branch: "debug",
|
|
253
253
|
categories: ["tools"],
|
|
@@ -274,7 +274,7 @@ const manifest: AppManifest[] = [
|
|
|
274
274
|
homepageUrl: "https://developers.ledger.com/",
|
|
275
275
|
icon: "",
|
|
276
276
|
platform: "all",
|
|
277
|
-
apiVersion: "0.0.1",
|
|
277
|
+
apiVersion: "^1.0.0 || ~0.0.1",
|
|
278
278
|
manifestVersion: "1",
|
|
279
279
|
branch: "stable",
|
|
280
280
|
categories: ["tools"],
|
|
@@ -1,54 +1,6 @@
|
|
|
1
1
|
import type { AppManifest } from "../types";
|
|
2
|
-
import semver from "semver";
|
|
3
|
-
export type FilterParams = {
|
|
4
|
-
branches?: string[];
|
|
5
|
-
platform?: string;
|
|
6
|
-
private?: boolean;
|
|
7
|
-
version?: string;
|
|
8
|
-
};
|
|
9
2
|
import { getEnv } from "../../env";
|
|
10
3
|
|
|
11
|
-
function matchVersion(filterParams: FilterParams, manifest: AppManifest) {
|
|
12
|
-
return (
|
|
13
|
-
!filterParams.version ||
|
|
14
|
-
semver.satisfies(
|
|
15
|
-
semver.coerce(filterParams.version) || "",
|
|
16
|
-
manifest.apiVersion
|
|
17
|
-
)
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function matchBranches(filterParams: FilterParams, manifest: AppManifest) {
|
|
22
|
-
return (
|
|
23
|
-
!filterParams.branches || filterParams.branches.includes(manifest.branch)
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function matchPlatform(filterParams: FilterParams, manifest: AppManifest) {
|
|
28
|
-
return (
|
|
29
|
-
!filterParams.platform ||
|
|
30
|
-
manifest.platform === "all" ||
|
|
31
|
-
filterParams.platform === manifest.platform
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function matchPrivate(filterParams: FilterParams, manifest: AppManifest) {
|
|
36
|
-
return filterParams.private === true || !(manifest.private === true);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function filterPlatformApps(
|
|
40
|
-
appManifests: AppManifest[],
|
|
41
|
-
filterParams: FilterParams
|
|
42
|
-
): AppManifest[] {
|
|
43
|
-
return appManifests.filter((appManifest: AppManifest) => {
|
|
44
|
-
return (
|
|
45
|
-
matchBranches(filterParams, appManifest) &&
|
|
46
|
-
matchPlatform(filterParams, appManifest) &&
|
|
47
|
-
matchPrivate(filterParams, appManifest) &&
|
|
48
|
-
matchVersion(filterParams, appManifest)
|
|
49
|
-
);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
4
|
export function mergeManifestLists(
|
|
53
5
|
list1: AppManifest[],
|
|
54
6
|
list2: AppManifest[]
|
|
@@ -1,13 +1,44 @@
|
|
|
1
1
|
import byFamily from "../generated/platformAdapter";
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import { isTokenAccount, isSubAccount } from "../account";
|
|
3
|
+
import { Account, AccountLike, Transaction } from "../types";
|
|
4
|
+
import {
|
|
5
5
|
PlatformAccount,
|
|
6
6
|
PlatformCurrency,
|
|
7
7
|
PlatformTransaction,
|
|
8
|
+
PlatformCurrencyType,
|
|
9
|
+
PlatformTokenStandard,
|
|
10
|
+
PlatformSupportedCurrency,
|
|
8
11
|
} from "./types";
|
|
9
12
|
|
|
10
|
-
export function accountToPlatformAccount(
|
|
13
|
+
export function accountToPlatformAccount(
|
|
14
|
+
account: AccountLike,
|
|
15
|
+
parentAccount?: Account
|
|
16
|
+
): PlatformAccount {
|
|
17
|
+
if (isSubAccount(account)) {
|
|
18
|
+
if (!parentAccount) {
|
|
19
|
+
throw new Error("No 'parentAccount' account provided for token account");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
id: account.id,
|
|
24
|
+
balance: account.balance,
|
|
25
|
+
address: parentAccount.freshAddress,
|
|
26
|
+
blockHeight: parentAccount.blockHeight,
|
|
27
|
+
lastSyncDate: parentAccount.lastSyncDate,
|
|
28
|
+
...(isTokenAccount(account)
|
|
29
|
+
? {
|
|
30
|
+
name: `${parentAccount.name} (${account.token.ticker})`,
|
|
31
|
+
currency: account.token.id,
|
|
32
|
+
spendableBalance: account.spendableBalance,
|
|
33
|
+
}
|
|
34
|
+
: {
|
|
35
|
+
name: account.name,
|
|
36
|
+
currency: account.currency.id,
|
|
37
|
+
spendableBalance: parentAccount.spendableBalance,
|
|
38
|
+
}),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
11
42
|
return {
|
|
12
43
|
id: account.id,
|
|
13
44
|
name: account.name,
|
|
@@ -19,11 +50,34 @@ export function accountToPlatformAccount(account: Account): PlatformAccount {
|
|
|
19
50
|
lastSyncDate: account.lastSyncDate,
|
|
20
51
|
};
|
|
21
52
|
}
|
|
53
|
+
|
|
22
54
|
export function currencyToPlatformCurrency(
|
|
23
|
-
currency:
|
|
55
|
+
currency: PlatformSupportedCurrency
|
|
24
56
|
): PlatformCurrency {
|
|
57
|
+
if (currency.type === "TokenCurrency") {
|
|
58
|
+
if (currency.parentCurrency.family !== "ethereum") {
|
|
59
|
+
throw new Error("Only ERC20 tokens are supported");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
type: PlatformCurrencyType.TokenCurrency,
|
|
64
|
+
standard: PlatformTokenStandard.ERC20,
|
|
65
|
+
id: currency.id,
|
|
66
|
+
ticker: currency.ticker,
|
|
67
|
+
contract: currency.contractAddress,
|
|
68
|
+
name: currency.name,
|
|
69
|
+
parent: currency.parentCurrency.id,
|
|
70
|
+
color: currency.parentCurrency.color,
|
|
71
|
+
units: currency.units.map((unit) => ({
|
|
72
|
+
name: unit.name,
|
|
73
|
+
code: unit.code,
|
|
74
|
+
magnitude: unit.magnitude,
|
|
75
|
+
})),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
25
79
|
return {
|
|
26
|
-
type:
|
|
80
|
+
type: PlatformCurrencyType.CryptoCurrency,
|
|
27
81
|
id: currency.id,
|
|
28
82
|
ticker: currency.ticker,
|
|
29
83
|
name: currency.name,
|