@ledgerhq/coin-stellar 6.26.0 → 6.26.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/.oxlintrc.json +7 -0
- package/CHANGELOG.md +12 -0
- package/LICENSE +194 -0
- package/knip.json +12 -0
- package/lib/api/index.d.ts +5 -5
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +12 -10
- package/lib/api/index.js.map +1 -1
- package/lib/config.d.ts +1 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +2 -0
- package/lib/config.js.map +1 -1
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +3 -1
- package/lib/constants.js.map +1 -1
- package/lib/logic/broadcast.d.ts.map +1 -1
- package/lib/logic/broadcast.js +2 -0
- package/lib/logic/broadcast.js.map +1 -1
- package/lib/logic/combine.d.ts +1 -1
- package/lib/logic/combine.d.ts.map +1 -1
- package/lib/logic/combine.js +2 -0
- package/lib/logic/combine.js.map +1 -1
- package/lib/logic/common.d.ts +1 -1
- package/lib/logic/common.d.ts.map +1 -1
- package/lib/logic/common.js +4 -2
- package/lib/logic/common.js.map +1 -1
- package/lib/logic/craftTransaction.d.ts +1 -1
- package/lib/logic/craftTransaction.d.ts.map +1 -1
- package/lib/logic/craftTransaction.js +10 -8
- package/lib/logic/craftTransaction.js.map +1 -1
- package/lib/logic/estimateFees.d.ts.map +1 -1
- package/lib/logic/estimateFees.js +2 -0
- package/lib/logic/estimateFees.js.map +1 -1
- package/lib/logic/getBalance.d.ts +1 -1
- package/lib/logic/getBalance.d.ts.map +1 -1
- package/lib/logic/getBalance.js +4 -2
- package/lib/logic/getBalance.js.map +1 -1
- package/lib/logic/getBlock.d.ts +1 -1
- package/lib/logic/getBlock.d.ts.map +1 -1
- package/lib/logic/getBlock.js +39 -34
- package/lib/logic/getBlock.js.map +1 -1
- package/lib/logic/getBlockInfo.d.ts +1 -1
- package/lib/logic/getBlockInfo.d.ts.map +1 -1
- package/lib/logic/getBlockInfo.js +2 -0
- package/lib/logic/getBlockInfo.js.map +1 -1
- package/lib/logic/index.d.ts +12 -12
- package/lib/logic/index.d.ts.map +1 -1
- package/lib/logic/index.js +2 -0
- package/lib/logic/index.js.map +1 -1
- package/lib/logic/lastBlock.d.ts +1 -1
- package/lib/logic/lastBlock.d.ts.map +1 -1
- package/lib/logic/lastBlock.js +2 -0
- package/lib/logic/lastBlock.js.map +1 -1
- package/lib/logic/listOperations.d.ts +1 -1
- package/lib/logic/listOperations.d.ts.map +1 -1
- package/lib/logic/listOperations.js +6 -4
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/logic/sdkWrapper.d.ts +1 -1
- package/lib/logic/sdkWrapper.d.ts.map +1 -1
- package/lib/logic/sdkWrapper.js +2 -0
- package/lib/logic/sdkWrapper.js.map +1 -1
- package/lib/logic/utils.d.ts.map +1 -1
- package/lib/logic/utils.js +4 -2
- package/lib/logic/utils.js.map +1 -1
- package/lib/logic/validateAddress.d.ts +1 -1
- package/lib/logic/validateAddress.d.ts.map +1 -1
- package/lib/logic/validateAddress.js +2 -0
- package/lib/logic/validateAddress.js.map +1 -1
- package/lib/logic/validateIntent.d.ts +2 -2
- package/lib/logic/validateIntent.d.ts.map +1 -1
- package/lib/logic/validateIntent.js +21 -19
- package/lib/logic/validateIntent.js.map +1 -1
- package/lib/logic/validateMemo.d.ts +1 -1
- package/lib/logic/validateMemo.d.ts.map +1 -1
- package/lib/logic/validateMemo.js +7 -5
- package/lib/logic/validateMemo.js.map +1 -1
- package/lib/network/horizon.d.ts +6 -7
- package/lib/network/horizon.d.ts.map +1 -1
- package/lib/network/horizon.js +48 -95
- package/lib/network/horizon.js.map +1 -1
- package/lib/network/horizonErrorBody.d.ts +29 -0
- package/lib/network/horizonErrorBody.d.ts.map +1 -0
- package/lib/network/horizonErrorBody.js +139 -0
- package/lib/network/horizonErrorBody.js.map +1 -0
- package/lib/network/horizonLedgerErrors.d.ts.map +1 -1
- package/lib/network/horizonLedgerErrors.js +28 -4
- package/lib/network/horizonLedgerErrors.js.map +1 -1
- package/lib/network/index.d.ts +1 -1
- package/lib/network/index.d.ts.map +1 -1
- package/lib/network/index.js +2 -0
- package/lib/network/index.js.map +1 -1
- package/lib/network/serialization.d.ts +6 -4
- package/lib/network/serialization.d.ts.map +1 -1
- package/lib/network/serialization.js +95 -91
- package/lib/network/serialization.js.map +1 -1
- package/lib/polyfill.d.ts.map +1 -1
- package/lib/polyfill.js +6 -4
- package/lib/polyfill.js.map +1 -1
- package/lib/supportedFeatures.d.ts +1 -1
- package/lib/supportedFeatures.d.ts.map +1 -1
- package/lib/supportedFeatures.js +3 -1
- package/lib/supportedFeatures.js.map +1 -1
- package/lib/types/errors.d.ts.map +1 -1
- package/lib/types/errors.js +14 -12
- package/lib/types/errors.js.map +1 -1
- package/lib/types/index.d.ts +2 -2
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +2 -0
- package/lib/types/index.js.map +1 -1
- package/lib/types/model.d.ts +6 -6
- package/lib/types/model.d.ts.map +1 -1
- package/lib/types/model.js +7 -5
- package/lib/types/model.js.map +1 -1
- package/lib-es/api/index.d.ts +5 -5
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +20 -18
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/config.d.ts +1 -1
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/config.js +3 -1
- package/lib-es/config.js.map +1 -1
- package/lib-es/constants.d.ts.map +1 -1
- package/lib-es/constants.js +3 -1
- package/lib-es/constants.js.map +1 -1
- package/lib-es/logic/broadcast.d.ts.map +1 -1
- package/lib-es/logic/broadcast.js +3 -1
- package/lib-es/logic/broadcast.js.map +1 -1
- package/lib-es/logic/combine.d.ts +1 -1
- package/lib-es/logic/combine.d.ts.map +1 -1
- package/lib-es/logic/combine.js +3 -1
- package/lib-es/logic/combine.js.map +1 -1
- package/lib-es/logic/common.d.ts +1 -1
- package/lib-es/logic/common.d.ts.map +1 -1
- package/lib-es/logic/common.js +5 -3
- package/lib-es/logic/common.js.map +1 -1
- package/lib-es/logic/craftTransaction.d.ts +1 -1
- package/lib-es/logic/craftTransaction.d.ts.map +1 -1
- package/lib-es/logic/craftTransaction.js +15 -13
- package/lib-es/logic/craftTransaction.js.map +1 -1
- package/lib-es/logic/estimateFees.d.ts.map +1 -1
- package/lib-es/logic/estimateFees.js +3 -1
- package/lib-es/logic/estimateFees.js.map +1 -1
- package/lib-es/logic/getBalance.d.ts +1 -1
- package/lib-es/logic/getBalance.d.ts.map +1 -1
- package/lib-es/logic/getBalance.js +5 -3
- package/lib-es/logic/getBalance.js.map +1 -1
- package/lib-es/logic/getBlock.d.ts +1 -1
- package/lib-es/logic/getBlock.d.ts.map +1 -1
- package/lib-es/logic/getBlock.js +42 -37
- package/lib-es/logic/getBlock.js.map +1 -1
- package/lib-es/logic/getBlockInfo.d.ts +1 -1
- package/lib-es/logic/getBlockInfo.d.ts.map +1 -1
- package/lib-es/logic/getBlockInfo.js +3 -1
- package/lib-es/logic/getBlockInfo.js.map +1 -1
- package/lib-es/logic/index.d.ts +12 -12
- package/lib-es/logic/index.d.ts.map +1 -1
- package/lib-es/logic/index.js +14 -12
- package/lib-es/logic/index.js.map +1 -1
- package/lib-es/logic/lastBlock.d.ts +1 -1
- package/lib-es/logic/lastBlock.d.ts.map +1 -1
- package/lib-es/logic/lastBlock.js +3 -1
- package/lib-es/logic/lastBlock.js.map +1 -1
- package/lib-es/logic/listOperations.d.ts +1 -1
- package/lib-es/logic/listOperations.d.ts.map +1 -1
- package/lib-es/logic/listOperations.js +7 -5
- package/lib-es/logic/listOperations.js.map +1 -1
- package/lib-es/logic/sdkWrapper.d.ts +1 -1
- package/lib-es/logic/sdkWrapper.d.ts.map +1 -1
- package/lib-es/logic/sdkWrapper.js +4 -2
- package/lib-es/logic/sdkWrapper.js.map +1 -1
- package/lib-es/logic/utils.d.ts.map +1 -1
- package/lib-es/logic/utils.js +6 -4
- package/lib-es/logic/utils.js.map +1 -1
- package/lib-es/logic/validateAddress.d.ts +1 -1
- package/lib-es/logic/validateAddress.d.ts.map +1 -1
- package/lib-es/logic/validateAddress.js +3 -1
- package/lib-es/logic/validateAddress.js.map +1 -1
- package/lib-es/logic/validateIntent.d.ts +2 -2
- package/lib-es/logic/validateIntent.d.ts.map +1 -1
- package/lib-es/logic/validateIntent.js +30 -28
- package/lib-es/logic/validateIntent.js.map +1 -1
- package/lib-es/logic/validateMemo.d.ts +1 -1
- package/lib-es/logic/validateMemo.d.ts.map +1 -1
- package/lib-es/logic/validateMemo.js +8 -6
- package/lib-es/logic/validateMemo.js.map +1 -1
- package/lib-es/network/horizon.d.ts +6 -7
- package/lib-es/network/horizon.d.ts.map +1 -1
- package/lib-es/network/horizon.js +57 -104
- package/lib-es/network/horizon.js.map +1 -1
- package/lib-es/network/horizonErrorBody.d.ts +29 -0
- package/lib-es/network/horizonErrorBody.d.ts.map +1 -0
- package/lib-es/network/horizonErrorBody.js +134 -0
- package/lib-es/network/horizonErrorBody.js.map +1 -0
- package/lib-es/network/horizonLedgerErrors.d.ts.map +1 -1
- package/lib-es/network/horizonLedgerErrors.js +30 -6
- package/lib-es/network/horizonLedgerErrors.js.map +1 -1
- package/lib-es/network/index.d.ts +1 -1
- package/lib-es/network/index.d.ts.map +1 -1
- package/lib-es/network/index.js +3 -1
- package/lib-es/network/index.js.map +1 -1
- package/lib-es/network/serialization.d.ts +6 -4
- package/lib-es/network/serialization.d.ts.map +1 -1
- package/lib-es/network/serialization.js +97 -95
- package/lib-es/network/serialization.js.map +1 -1
- package/lib-es/polyfill.d.ts.map +1 -1
- package/lib-es/polyfill.js +7 -5
- package/lib-es/polyfill.js.map +1 -1
- package/lib-es/supportedFeatures.d.ts +1 -1
- package/lib-es/supportedFeatures.d.ts.map +1 -1
- package/lib-es/supportedFeatures.js +3 -1
- package/lib-es/supportedFeatures.js.map +1 -1
- package/lib-es/types/errors.d.ts.map +1 -1
- package/lib-es/types/errors.js +15 -13
- package/lib-es/types/errors.js.map +1 -1
- package/lib-es/types/index.d.ts +2 -2
- package/lib-es/types/index.d.ts.map +1 -1
- package/lib-es/types/index.js +4 -2
- package/lib-es/types/index.js.map +1 -1
- package/lib-es/types/model.d.ts +6 -6
- package/lib-es/types/model.d.ts.map +1 -1
- package/lib-es/types/model.js +7 -5
- package/lib-es/types/model.js.map +1 -1
- package/package.json +13 -16
- package/src/api/index.integ.test.ts +168 -163
- package/src/api/index.test.ts +106 -103
- package/src/api/index.ts +49 -46
- package/src/api/index_error.test.ts +48 -25
- package/src/config.ts +15 -12
- package/src/constants.ts +4 -1
- package/src/globals.d.ts +7 -5
- package/src/logic/broadcast.integ.test.ts +22 -19
- package/src/logic/broadcast.ts +5 -2
- package/src/logic/combine.test.ts +18 -15
- package/src/logic/combine.ts +8 -5
- package/src/logic/common.ts +9 -6
- package/src/logic/craftTransaction.test.ts +76 -75
- package/src/logic/craftTransaction.ts +46 -43
- package/src/logic/estimateFees.ts +6 -3
- package/src/logic/getBalance.test.ts +31 -28
- package/src/logic/getBalance.ts +13 -10
- package/src/logic/getBlock.integ.test.ts +40 -39
- package/src/logic/getBlock.test.ts +462 -415
- package/src/logic/getBlock.ts +142 -127
- package/src/logic/getBlockInfo.test.ts +72 -69
- package/src/logic/getBlockInfo.ts +15 -12
- package/src/logic/index.ts +15 -12
- package/src/logic/lastBlock.ts +6 -3
- package/src/logic/listOperations.ts +14 -11
- package/src/logic/listOperations.unit.test.ts +212 -209
- package/src/logic/networkWrappers.test.ts +32 -29
- package/src/logic/sdkWrapper.ts +19 -16
- package/src/logic/utils.ts +13 -10
- package/src/logic/validateAddress.test.ts +21 -18
- package/src/logic/validateAddress.ts +7 -4
- package/src/logic/validateIntent.test.ts +62 -59
- package/src/logic/validateIntent.ts +87 -84
- package/src/logic/validateMemo.test.ts +50 -47
- package/src/logic/validateMemo.ts +16 -13
- package/src/network/broadcastTransaction.test.ts +83 -63
- package/src/network/fetchLedgerOperations.unit.test.ts +155 -0
- package/src/network/horizon.integ.test.ts +45 -42
- package/src/network/horizon.test.ts +17 -14
- package/src/network/horizon.ts +244 -314
- package/src/network/horizon.unit.test.ts +238 -237
- package/src/network/horizonErrorBody.test.ts +133 -0
- package/src/network/horizonErrorBody.ts +178 -0
- package/src/network/horizonLedgerErrors.test.ts +150 -78
- package/src/network/horizonLedgerErrors.ts +47 -20
- package/src/network/index.ts +4 -1
- package/src/network/registerHorizonInterceptors.test.ts +163 -160
- package/src/network/serialization.ts +232 -227
- package/src/network/serialization.unit.test.ts +801 -798
- package/src/polyfill.ts +18 -15
- package/src/supportedFeatures.ts +6 -3
- package/src/types/errors.ts +33 -32
- package/src/types/index.ts +5 -2
- package/src/types/model.ts +55 -52
- package/tsconfig.json +1 -1
- package/.unimportedrc.json +0 -17
- package/LICENSE.txt +0 -21
- package/src/network/fetchLedgerOperations.nock.unit.test.ts +0 -156
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { formatCurrencyUnit } from '@ledgerhq/coin-module-framework/currencies/index';
|
|
4
|
+
import { AmountRequired, InvalidAddress, InvalidAddressBecauseDestinationIsAlsoSource, NotEnoughBalance, NotEnoughBalanceBecauseDestinationNotCreated, NotEnoughSpendableBalance, RecipientRequired, } from '@ledgerhq/errors';
|
|
5
|
+
import BigNumber from 'bignumber.js';
|
|
6
|
+
import { fetchAccountNetworkInfo, getRecipientAccount } from '../network';
|
|
7
|
+
import { fetchAccount } from '../network/horizon';
|
|
8
|
+
import { BASE_RESERVE, MIN_BALANCE } from '../network/serialization';
|
|
9
|
+
import { StellarAssetNotAccepted, StellarAssetNotFound, StellarAssetRequired, StellarFeeSmallerThanBase, StellarFeeSmallerThanRecommended, StellarMuxedAccountNotExist, StellarNotEnoughNativeBalance, StellarNotEnoughNativeBalanceToAddTrustline, StellarSourceHasMultiSign, StellarWrongMemoFormat, } from '../types';
|
|
10
|
+
import { isAccountMultiSign, isAddressValid } from './utils';
|
|
11
|
+
import { validateMemo } from './validateMemo';
|
|
10
12
|
export const validateIntent = async (transactionIntent, balances, customFees) => {
|
|
11
13
|
const errors = {};
|
|
12
14
|
const warnings = {};
|
|
13
15
|
const useAllAmount = !!transactionIntent.useAllAmount;
|
|
14
|
-
const destinationNotExistMessage = new NotEnoughBalanceBecauseDestinationNotCreated(
|
|
16
|
+
const destinationNotExistMessage = new NotEnoughBalanceBecauseDestinationNotCreated('', {
|
|
15
17
|
minimalAmount: `${MIN_BALANCE} XLM`,
|
|
16
18
|
});
|
|
17
19
|
const { spendableBalance, balance } = await fetchAccount(transactionIntent.sender);
|
|
@@ -20,7 +22,7 @@ export const validateIntent = async (transactionIntent, balances, customFees) =>
|
|
|
20
22
|
const baseReserve = networkInfo.baseReserve
|
|
21
23
|
? BigInt(Math.round(networkInfo.baseReserve.toNumber() * 10)) / 10n
|
|
22
24
|
: 0n;
|
|
23
|
-
const isAssetPayment = transactionIntent.asset.type !==
|
|
25
|
+
const isAssetPayment = transactionIntent.asset.type !== 'native';
|
|
24
26
|
const nativeBalance = BigInt(balance.toString());
|
|
25
27
|
const nativeAmountAvailable = BigInt(spendableBalance.toString()) - estimatedFees;
|
|
26
28
|
let amount = 0n;
|
|
@@ -30,8 +32,8 @@ export const validateIntent = async (transactionIntent, balances, customFees) =>
|
|
|
30
32
|
if (!errors.amount && nativeAmountAvailable < 0) {
|
|
31
33
|
errors.amount = new StellarNotEnoughNativeBalance();
|
|
32
34
|
}
|
|
33
|
-
const networkInfoBaseFee = BigInt(networkInfo.baseFee.toString() ||
|
|
34
|
-
const networkFees = BigInt(networkInfo.fees.toString() ||
|
|
35
|
+
const networkInfoBaseFee = BigInt(networkInfo.baseFee.toString() || '0');
|
|
36
|
+
const networkFees = BigInt(networkInfo.fees.toString() || '0');
|
|
35
37
|
// Entered fee is smaller than base fee
|
|
36
38
|
if (estimatedFees < networkInfoBaseFee) {
|
|
37
39
|
errors.transaction = new StellarFeeSmallerThanBase();
|
|
@@ -41,13 +43,13 @@ export const validateIntent = async (transactionIntent, balances, customFees) =>
|
|
|
41
43
|
warnings.transaction = new StellarFeeSmallerThanRecommended();
|
|
42
44
|
}
|
|
43
45
|
// Operation specific checks
|
|
44
|
-
if (transactionIntent.type ===
|
|
46
|
+
if (transactionIntent.type === 'changeTrust') {
|
|
45
47
|
// Check asset provided
|
|
46
|
-
if (transactionIntent.asset.type !==
|
|
47
|
-
((
|
|
48
|
-
(
|
|
48
|
+
if (transactionIntent.asset.type !== 'native' &&
|
|
49
|
+
(('assetReference' in transactionIntent.asset && !transactionIntent.asset.assetReference) ||
|
|
50
|
+
('assetOwner' in transactionIntent.asset && !transactionIntent.asset.assetOwner))) {
|
|
49
51
|
// This is unlikely
|
|
50
|
-
errors.transaction = new StellarAssetRequired(
|
|
52
|
+
errors.transaction = new StellarAssetRequired('');
|
|
51
53
|
}
|
|
52
54
|
// Has enough native balance to add new trustline
|
|
53
55
|
// NOTE: need to do this as BASE_RESERVE is 0.5
|
|
@@ -62,11 +64,11 @@ export const validateIntent = async (transactionIntent, balances, customFees) =>
|
|
|
62
64
|
// Payment
|
|
63
65
|
// Check recipient address
|
|
64
66
|
if (!transactionIntent.recipient) {
|
|
65
|
-
errors.recipient = new RecipientRequired(
|
|
67
|
+
errors.recipient = new RecipientRequired('');
|
|
66
68
|
}
|
|
67
69
|
else if (!isAddressValid(transactionIntent.recipient)) {
|
|
68
|
-
errors.recipient = new InvalidAddress(
|
|
69
|
-
currencyName: transactionIntent.asset.name ??
|
|
70
|
+
errors.recipient = new InvalidAddress('', {
|
|
71
|
+
currencyName: transactionIntent.asset.name ?? '', // NOTE: before account.currencyName,
|
|
70
72
|
});
|
|
71
73
|
}
|
|
72
74
|
else if (transactionIntent.sender === transactionIntent.recipient) {
|
|
@@ -92,7 +94,7 @@ export const validateIntent = async (transactionIntent, balances, customFees) =>
|
|
|
92
94
|
// Asset payment
|
|
93
95
|
if (isAssetPayment) {
|
|
94
96
|
const asset = transactionIntent.asset;
|
|
95
|
-
if (asset.type ===
|
|
97
|
+
if (asset.type === 'native' || (!('assetReference' in asset) && !('assetOwner' in asset))) {
|
|
96
98
|
throw new StellarAssetNotFound();
|
|
97
99
|
}
|
|
98
100
|
// Check recipient account accepts asset
|
|
@@ -100,14 +102,14 @@ export const validateIntent = async (transactionIntent, balances, customFees) =>
|
|
|
100
102
|
!errors.recipient &&
|
|
101
103
|
!warnings.recipient &&
|
|
102
104
|
!recipientAccount.assetIds.includes(`${asset.assetReference}:${asset.assetOwner}`)) {
|
|
103
|
-
errors.recipient = new StellarAssetNotAccepted(
|
|
105
|
+
errors.recipient = new StellarAssetNotAccepted('', {
|
|
104
106
|
assetCode: asset.assetReference,
|
|
105
107
|
});
|
|
106
108
|
}
|
|
107
|
-
const assetBalance = balances.find(b => b.asset.type !==
|
|
108
|
-
|
|
109
|
+
const assetBalance = balances.find((b) => b.asset.type !== 'native' &&
|
|
110
|
+
'assetReference' in b.asset &&
|
|
109
111
|
b.asset.assetReference === asset.assetReference &&
|
|
110
|
-
|
|
112
|
+
'assetOwner' in b.asset &&
|
|
111
113
|
b.asset.assetOwner === asset.assetOwner);
|
|
112
114
|
if (!assetBalance) {
|
|
113
115
|
// This is unlikely
|
|
@@ -140,7 +142,7 @@ export const validateIntent = async (transactionIntent, balances, customFees) =>
|
|
|
140
142
|
disableRounding: true,
|
|
141
143
|
showCode: true,
|
|
142
144
|
})
|
|
143
|
-
:
|
|
145
|
+
: 'Unknown unit',
|
|
144
146
|
});
|
|
145
147
|
}
|
|
146
148
|
if (!errors.recipient && !errors.amount && (amount < 0n || totalSpent > nativeBalance)) {
|
|
@@ -156,7 +158,7 @@ export const validateIntent = async (transactionIntent, balances, customFees) =>
|
|
|
156
158
|
if (await isAccountMultiSign(transactionIntent.sender)) {
|
|
157
159
|
errors.recipient = new StellarSourceHasMultiSign();
|
|
158
160
|
}
|
|
159
|
-
if (transactionIntent?.memo?.type !==
|
|
161
|
+
if (transactionIntent?.memo?.type !== 'NO_MEMO' &&
|
|
160
162
|
!validateMemo(transactionIntent?.memo?.value, transactionIntent?.memo?.type)) {
|
|
161
163
|
errors.transaction = new StellarWrongMemoFormat();
|
|
162
164
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateIntent.js","sourceRoot":"","sources":["../../src/logic/validateIntent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validateIntent.js","sourceRoot":"","sources":["../../src/logic/validateIntent.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,sCAAsC;AAQtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kDAAkD,CAAA;AACrF,OAAO,EACL,cAAc,EACd,cAAc,EACd,4CAA4C,EAC5C,gBAAgB,EAChB,4CAA4C,EAC5C,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,kBAAkB,CAAA;AACzB,OAAO,SAAS,MAAM,cAAc,CAAA;AACpC,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACpE,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACpB,yBAAyB,EACzB,gCAAgC,EAEhC,2BAA2B,EAC3B,6BAA6B,EAC7B,2CAA2C,EAC3C,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,E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C,SAAS,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,MAAM,GAAG,EAAE,IAAI,UAAU,GAAG,aAAa,CAAC,EAAE,CAAC;gBACvF,MAAM,CAAC,MAAM,GAAG,IAAI,gBAAgB,EAAE,CAAA;gBACtC,UAAU,GAAG,EAAE,CAAA;gBACf,MAAM,GAAG,EAAE,CAAA;YACb,CAAC;QACH,CAAC;QAED,IAAI,MAAM,KAAK,EAAE,EAAE,CAAC;YAClB,MAAM,CAAC,MAAM,GAAG,IAAI,cAAc,EAAE,CAAA;QACtC,CAAC;IACH,CAAC;IAED,IAAI,MAAM,kBAAkB,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC;QACvD,MAAM,CAAC,SAAS,GAAG,IAAI,yBAAyB,EAAE,CAAA;IACpD,CAAC;IAED,IACE,iBAAiB,EAAE,IAAI,EAAE,IAAI,KAAK,SAAS;QAC3C,CAAC,YAAY,CAAC,iBAAiB,EAAE,IAAI,EAAE,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,IAAI,CAAC,EAC5E,CAAC;QACD,MAAM,CAAC,WAAW,GAAG,IAAI,sBAAsB,EAAE,CAAA;IACnD,CAAC;IAED,OAAO;QACL,MAAM;QACN,QAAQ;QACR,aAAa;QACb,MAAM;QACN,UAAU;KACX,CAAA;AACH,CAAC,CAAA;AAED,eAAe,cAAc,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StellarMemoKind } from
|
|
1
|
+
import { StellarMemoKind } from '../types/model';
|
|
2
2
|
export declare const MEMO_TEXT_MAXIMUM_SIZE = 28;
|
|
3
3
|
export declare const MEMO_HASH_FIXED_SIZE = 64;
|
|
4
4
|
export declare function validateMemo(memo: string, type: StellarMemoKind): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateMemo.d.ts","sourceRoot":"","sources":["../../src/logic/validateMemo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validateMemo.d.ts","sourceRoot":"","sources":["../../src/logic/validateMemo.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAEhD,eAAO,MAAM,sBAAsB,KAAK,CAAA;AACxC,eAAO,MAAM,oBAAoB,KAAK,CAAA;AAEtC,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,CAYzE"}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import BigNumber from 'bignumber.js';
|
|
2
4
|
export const MEMO_TEXT_MAXIMUM_SIZE = 28;
|
|
3
5
|
export const MEMO_HASH_FIXED_SIZE = 64;
|
|
4
6
|
export function validateMemo(memo, type) {
|
|
5
7
|
switch (type) {
|
|
6
|
-
case
|
|
8
|
+
case 'NO_MEMO':
|
|
7
9
|
return !memo || memo.length === 0;
|
|
8
|
-
case
|
|
10
|
+
case 'MEMO_TEXT':
|
|
9
11
|
return memo.length <= MEMO_TEXT_MAXIMUM_SIZE;
|
|
10
|
-
case
|
|
12
|
+
case 'MEMO_ID':
|
|
11
13
|
return !new BigNumber(memo.toString()).isNaN();
|
|
12
|
-
case
|
|
13
|
-
case
|
|
14
|
+
case 'MEMO_HASH':
|
|
15
|
+
case 'MEMO_RETURN':
|
|
14
16
|
return memo.length === 64;
|
|
15
17
|
}
|
|
16
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateMemo.js","sourceRoot":"","sources":["../../src/logic/validateMemo.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"validateMemo.js","sourceRoot":"","sources":["../../src/logic/validateMemo.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,sCAAsC;AAEtC,OAAO,SAAS,MAAM,cAAc,CAAA;AAGpC,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAA;AACxC,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAA;AAEtC,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,IAAqB;IAC9D,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,SAAS;YACZ,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,CAAA;QACnC,KAAK,WAAW;YACd,OAAO,IAAI,CAAC,MAAM,IAAI,sBAAsB,CAAA;QAC9C,KAAK,SAAS;YACZ,OAAO,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,CAAA;QAChD,KAAK,WAAW,CAAC;QACjB,KAAK,aAAa;YAChB,OAAO,IAAI,CAAC,MAAM,KAAK,EAAE,CAAA;IAC7B,CAAC;AACH,CAAC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { Operation, Page } from
|
|
2
|
-
import type { CacheRes } from
|
|
3
|
-
import { Horizon } from
|
|
4
|
-
import {
|
|
5
|
-
import { type BalanceAsset, type NetworkInfo, type RawOperation, type Signer, NetworkCongestionLevel } from "../types";
|
|
1
|
+
import type { Operation, Page } from '@ledgerhq/coin-module-framework/api/types';
|
|
2
|
+
import type { CacheRes } from '@ledgerhq/live-network/cache';
|
|
3
|
+
import { Horizon } from '@stellar/stellar-sdk';
|
|
4
|
+
import { type BalanceAsset, type NetworkInfo, type RawOperation, type Signer, NetworkCongestionLevel } from '../types';
|
|
6
5
|
/**
|
|
7
6
|
* Register logging and URL-fix interceptors on Horizon.AxiosClient.
|
|
8
7
|
* Must be called once after coinConfig is initialised (i.e. inside createApi).
|
|
@@ -42,12 +41,12 @@ export declare function fetchAccount(addr: string): Promise<{
|
|
|
42
41
|
*
|
|
43
42
|
* @return {Operation[]}
|
|
44
43
|
*/
|
|
45
|
-
export declare function fetchAllOperations(accountId: string, addr: string, order:
|
|
44
|
+
export declare function fetchAllOperations(accountId: string, addr: string, order: 'asc' | 'desc', cursor?: string, maxOperations?: number): Promise<Operation[]>;
|
|
46
45
|
export declare function fetchOperations({ accountId, addr, minHeight, order, cursor, limit, }: {
|
|
47
46
|
accountId: string;
|
|
48
47
|
addr: string;
|
|
49
48
|
minHeight: number;
|
|
50
|
-
order:
|
|
49
|
+
order: 'asc' | 'desc';
|
|
51
50
|
cursor: string | undefined;
|
|
52
51
|
limit?: number | undefined;
|
|
53
52
|
}): Promise<Page<Operation>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"horizon.d.ts","sourceRoot":"","sources":["../../src/network/horizon.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"horizon.d.ts","sourceRoot":"","sources":["../../src/network/horizon.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AAI5D,OAAO,EAEL,OAAO,EAQR,MAAM,sBAAsB,CAAA;AAK7B,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,MAAM,EACX,sBAAsB,EACvB,MAAM,UAAU,CAAA;AA4FjB;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,IAAI,IAAI,CAmDlD;AAGD,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK5D;AAMD,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,SAAS,EAClB,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,aAAa,GACvC,OAAO,CAAC,SAAS,CAAC,CAIpB;AAED,wBAAsB,YAAY,IAAI,OAAO,CAAC;IAC5C,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,EAAE,MAAM,CAAA;IACtB,sBAAsB,EAAE,sBAAsB,CAAA;CAC/C,CAAC,CAsCD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,OAAO,CAAC,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAUvF;AAED,wBAAsB,YAAY,IAAI,OAAO,CAAC;IAC5C,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,IAAI,CAAA;CACX,CAAC,CAOD;AAED;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,CAQjG;AAED;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CA2B9F;AAED,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CACxC,KAAK,CAAC;IACJ,SAAS,EAAE,MAAM,CAAA;CAClB,CAAC,EACF;IACE,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;IACjB,cAAc,EAAE,OAAO,CAAA;IACvB,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB,GAAG,IAAI,CAQT,CAAA"}
|
|
@@ -1,75 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
1
|
+
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { LedgerAPI4xx, LedgerAPI5xx, NetworkDown } from '@ledgerhq/errors';
|
|
4
|
+
import { makeLRUCache } from '@ledgerhq/live-network/cache';
|
|
5
|
+
import { log } from '@ledgerhq/logs';
|
|
6
|
+
import { BASE_FEE, Horizon, MuxedAccount, NetworkError, Networks, NotFoundError, Transaction as StellarSdkTransaction, StrKey, xdr, } from '@stellar/stellar-sdk';
|
|
7
|
+
import { BigNumber } from 'bignumber.js';
|
|
8
|
+
import coinConfig from '../config';
|
|
9
|
+
import { parseAPIValue } from '../logic/common';
|
|
10
|
+
import { patchHermesTypedArraysIfNeeded, unpatchHermesTypedArrays } from '../polyfill';
|
|
11
|
+
import { NetworkCongestionLevel, } from '../types';
|
|
12
|
+
import { StellarBroadcastFailedError } from '../types/errors';
|
|
13
|
+
import { documentationSummaryFromHorizonBody, getHorizonErrorBody, } from './horizonErrorBody';
|
|
14
|
+
import { throwHorizonLedgerOrOperationsError } from './horizonLedgerErrors';
|
|
15
|
+
import { getReservedBalance, rawOperationsToOperations } from './serialization';
|
|
13
16
|
const FALLBACK_BASE_FEE = 100;
|
|
14
17
|
const TRESHOLD_LOW = 0.5;
|
|
15
18
|
const TRESHOLD_MEDIUM = 0.75;
|
|
16
19
|
const FETCH_LIMIT = 100;
|
|
17
|
-
const STELLAR_TX_RESULT_CODES_DOC_URL =
|
|
18
|
-
/** Horizon `extras.result_codes.transaction` → one-line description (Stellar docs). */
|
|
19
|
-
const HORIZON_TRANSACTION_RESULT_CODE_DOCUMENTATION = {
|
|
20
|
-
tx_success: "The transaction succeeded.",
|
|
21
|
-
tx_failed: "One of the operations failed (none were applied).",
|
|
22
|
-
tx_too_early: "The ledger closeTime was before the minTime.",
|
|
23
|
-
tx_too_late: "The ledger closeTime was after the maxTime.",
|
|
24
|
-
tx_missing_operation: "No operation was specified.",
|
|
25
|
-
tx_bad_seq: "Sequence number does not match source account.",
|
|
26
|
-
tx_bad_auth: "Too few valid signatures / wrong network.",
|
|
27
|
-
tx_insufficient_balance: "Fee would bring account below reserve.",
|
|
28
|
-
tx_no_source_account: "Source account not found.",
|
|
29
|
-
tx_insufficient_fee: "Fee is too small.",
|
|
30
|
-
tx_bad_auth_extra: "Unused signatures attached to transaction.",
|
|
31
|
-
tx_internal_error: "An unknown error occurred.",
|
|
32
|
-
tx_fee_bump_inner_success: "Fee bump inner transaction succeeded.",
|
|
33
|
-
tx_fee_bump_inner_failed: "Fee bump inner transaction failed.",
|
|
34
|
-
tx_not_supported: "Transaction type not supported.",
|
|
35
|
-
tx_bad_sponsorship: "Sponsorship is invalid.",
|
|
36
|
-
tx_bad_min_seq_age_or_gap: "Minimum sequence age or gap precondition failed.",
|
|
37
|
-
tx_malformed: "Transaction is malformed.",
|
|
38
|
-
tx_soroban_invalid: "Soroban transaction is invalid.",
|
|
39
|
-
};
|
|
40
|
-
function isHorizonSubmitErrorBody(data) {
|
|
41
|
-
return !!(data &&
|
|
42
|
-
typeof data === "object" &&
|
|
43
|
-
"extras" in data &&
|
|
44
|
-
typeof data.extras === "object" &&
|
|
45
|
-
data.extras !== null &&
|
|
46
|
-
"result_codes" in data.extras &&
|
|
47
|
-
data.extras.result_codes !== undefined &&
|
|
48
|
-
typeof data.extras.result_codes === "object");
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Horizon submit failures are usually {@link BadResponseError} with `response` = problem+json body.
|
|
52
|
-
* In practice axios rejects with `AxiosError` first; the SDK's `.catch` forwards it unchanged (see js-stellar-sdk horizon/server.js),
|
|
53
|
-
* so the Horizon body lives on `error.response.data`.
|
|
54
|
-
*/
|
|
55
|
-
function getHorizonBodyFromSubmitFailure(error) {
|
|
56
|
-
if (error instanceof BadResponseError && isHorizonSubmitErrorBody(error.response)) {
|
|
57
|
-
return error.response;
|
|
58
|
-
}
|
|
59
|
-
if (error && typeof error === "object" && "response" in error) {
|
|
60
|
-
const data = error.response?.data;
|
|
61
|
-
if (isHorizonSubmitErrorBody(data)) {
|
|
62
|
-
return data;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
20
|
+
const STELLAR_TX_RESULT_CODES_DOC_URL = 'https://developers.stellar.org/docs/data/apis/horizon/api-reference/errors/result-codes/transactions';
|
|
67
21
|
function decodeTransactionResultFields(resultXdrBase64) {
|
|
68
22
|
if (!resultXdrBase64) {
|
|
69
23
|
return undefined;
|
|
70
24
|
}
|
|
71
25
|
try {
|
|
72
|
-
const tr = xdr.TransactionResult.fromXDR(resultXdrBase64,
|
|
26
|
+
const tr = xdr.TransactionResult.fromXDR(resultXdrBase64, 'base64');
|
|
73
27
|
const feeChargedStroops = tr.feeCharged().toString();
|
|
74
28
|
const resultXdrSwitchName = tr.result().switch().name;
|
|
75
29
|
const decodedResultXdr = {
|
|
@@ -86,17 +40,15 @@ function decodeTransactionResultFields(resultXdrBase64) {
|
|
|
86
40
|
}
|
|
87
41
|
function makeBroadcastFailedError(body, cause) {
|
|
88
42
|
const extras = body.extras;
|
|
89
|
-
const horizonTransactionCode = extras?.result_codes?.transaction ??
|
|
43
|
+
const horizonTransactionCode = extras?.result_codes?.transaction ?? '';
|
|
90
44
|
const horizonOperationCodes = extras?.result_codes?.operations;
|
|
91
|
-
const documentationSummary = (
|
|
92
|
-
HORIZON_TRANSACTION_RESULT_CODE_DOCUMENTATION[horizonTransactionCode]) ||
|
|
93
|
-
"Unknown transaction result code.";
|
|
45
|
+
const documentationSummary = documentationSummaryFromHorizonBody(body);
|
|
94
46
|
const decodedResult = decodeTransactionResultFields(extras?.result_xdr);
|
|
95
47
|
const feeChargedStroops = decodedResult?.feeChargedStroops;
|
|
96
48
|
const resultXdrSwitchName = decodedResult?.resultXdrSwitchName;
|
|
97
49
|
const decodedResultXdr = decodedResult?.decodedResultXdr;
|
|
98
|
-
const envelopeXdr = extras?.envelope_xdr ??
|
|
99
|
-
const message = body.detail || body.title || `Transaction submission failed (${body.status ??
|
|
50
|
+
const envelopeXdr = extras?.envelope_xdr ?? '';
|
|
51
|
+
const message = body.detail || body.title || `Transaction submission failed (${body.status ?? 'unknown'}).`;
|
|
100
52
|
return new StellarBroadcastFailedError(message, {
|
|
101
53
|
documentationSummary,
|
|
102
54
|
horizonTransactionCode,
|
|
@@ -136,7 +88,7 @@ export function registerHorizonInterceptors() {
|
|
|
136
88
|
if (interceptorsRegistered)
|
|
137
89
|
return;
|
|
138
90
|
interceptorsRegistered = true;
|
|
139
|
-
Horizon.AxiosClient.interceptors.request.use(config => {
|
|
91
|
+
Horizon.AxiosClient.interceptors.request.use((config) => {
|
|
140
92
|
let enableNetworkLogs = false;
|
|
141
93
|
try {
|
|
142
94
|
enableNetworkLogs = !!coinConfig.getCoinConfig().enableNetworkLogs;
|
|
@@ -145,13 +97,13 @@ export function registerHorizonInterceptors() {
|
|
|
145
97
|
return config;
|
|
146
98
|
}
|
|
147
99
|
if (enableNetworkLogs) {
|
|
148
|
-
const { baseURL, url, method =
|
|
149
|
-
log(
|
|
100
|
+
const { baseURL, url, method = '', data } = config;
|
|
101
|
+
log('network', `${method} ${baseURL ?? ''}${url}`, { data });
|
|
150
102
|
requestStartTimes.set(config, Date.now());
|
|
151
103
|
}
|
|
152
104
|
return config;
|
|
153
105
|
});
|
|
154
|
-
Horizon.AxiosClient.interceptors.response.use(response => {
|
|
106
|
+
Horizon.AxiosClient.interceptors.response.use((response) => {
|
|
155
107
|
let enableNetworkLogs = false;
|
|
156
108
|
try {
|
|
157
109
|
enableNetworkLogs = !!coinConfig.getCoinConfig().enableNetworkLogs;
|
|
@@ -163,7 +115,7 @@ export function registerHorizonInterceptors() {
|
|
|
163
115
|
// response.config is typed as `any` in stellar-sdk's HttpClientResponse
|
|
164
116
|
const startTime = requestStartTimes.get(response.config) ?? 0;
|
|
165
117
|
requestStartTimes.delete(response.config);
|
|
166
|
-
log(
|
|
118
|
+
log('network-success', `${response.status} ${response.config?.method ?? ''} ${response.config?.baseURL ?? ''}${response.config?.url ?? ''} (${(Date.now() - startTime).toFixed(0)}ms)`, { data: response.data });
|
|
167
119
|
}
|
|
168
120
|
// FIXME: workaround for the Stellar SDK not using the correct URL: the "next" URL
|
|
169
121
|
// included in server responses points to the node itself instead of our reverse proxy...
|
|
@@ -240,20 +192,20 @@ export async function fetchBaseFee() {
|
|
|
240
192
|
export async function fetchAccount(addr) {
|
|
241
193
|
let account = {};
|
|
242
194
|
let assets = [];
|
|
243
|
-
let balance =
|
|
195
|
+
let balance = '0';
|
|
244
196
|
try {
|
|
245
197
|
account = await getServer().accounts().accountId(addr).call();
|
|
246
198
|
balance =
|
|
247
|
-
account.balances?.find(balance => {
|
|
248
|
-
return balance.asset_type ===
|
|
249
|
-
})?.balance ||
|
|
199
|
+
account.balances?.find((balance) => {
|
|
200
|
+
return balance.asset_type === 'native';
|
|
201
|
+
})?.balance || '0';
|
|
250
202
|
// Getting all non-native (XLM) assets on the account
|
|
251
|
-
assets = account.balances?.filter(balance => {
|
|
252
|
-
return balance.asset_type !==
|
|
203
|
+
assets = account.balances?.filter((balance) => {
|
|
204
|
+
return balance.asset_type !== 'native';
|
|
253
205
|
});
|
|
254
206
|
}
|
|
255
207
|
catch {
|
|
256
|
-
balance =
|
|
208
|
+
balance = '0';
|
|
257
209
|
}
|
|
258
210
|
const formattedBalance = parseAPIValue(balance);
|
|
259
211
|
const spendableBalance = await getAccountSpendableBalance(formattedBalance, account);
|
|
@@ -275,7 +227,7 @@ export async function fetchAccount(addr) {
|
|
|
275
227
|
*
|
|
276
228
|
* @return {Operation[]}
|
|
277
229
|
*/
|
|
278
|
-
export async function fetchAllOperations(accountId, addr, order, cursor =
|
|
230
|
+
export async function fetchAllOperations(accountId, addr, order, cursor = '', maxOperations) {
|
|
279
231
|
if (!addr) {
|
|
280
232
|
return [];
|
|
281
233
|
}
|
|
@@ -290,7 +242,7 @@ export async function fetchAllOperations(accountId, addr, order, cursor = "", ma
|
|
|
290
242
|
.order(order)
|
|
291
243
|
.cursor(cursor)
|
|
292
244
|
.includeFailed(true)
|
|
293
|
-
.join(
|
|
245
|
+
.join('transactions')
|
|
294
246
|
.call();
|
|
295
247
|
if (!rawOperations || !rawOperations.records.length) {
|
|
296
248
|
return [];
|
|
@@ -309,7 +261,7 @@ export async function fetchAllOperations(accountId, addr, order, cursor = "", ma
|
|
|
309
261
|
catch (e) {
|
|
310
262
|
// FIXME: terrible hacks, because Stellar SDK fails to cast network failures to typed errors in react-native...
|
|
311
263
|
// (https://github.com/stellar/js-stellar-sdk/issues/638)
|
|
312
|
-
const errorMsg = e ? String(e) :
|
|
264
|
+
const errorMsg = e ? String(e) : '';
|
|
313
265
|
if (e instanceof NotFoundError || errorMsg.match(/status code 404/)) {
|
|
314
266
|
return [];
|
|
315
267
|
}
|
|
@@ -329,7 +281,7 @@ export async function fetchAllOperations(accountId, addr, order, cursor = "", ma
|
|
|
329
281
|
}
|
|
330
282
|
// https://developers.stellar.org/docs/data/horizon/api-reference/get-operations-by-account-id
|
|
331
283
|
export async function fetchOperations({ accountId, addr, minHeight, order, cursor, limit, }) {
|
|
332
|
-
const noResult = { items: [], next:
|
|
284
|
+
const noResult = { items: [], next: '' };
|
|
333
285
|
if (!addr) {
|
|
334
286
|
return noResult;
|
|
335
287
|
}
|
|
@@ -340,9 +292,9 @@ export async function fetchOperations({ accountId, addr, minHeight, order, curso
|
|
|
340
292
|
.forAccount(addr)
|
|
341
293
|
.limit(requestedLimit)
|
|
342
294
|
.order(order)
|
|
343
|
-
.cursor(cursor ??
|
|
295
|
+
.cursor(cursor ?? '')
|
|
344
296
|
.includeFailed(true)
|
|
345
|
-
.join(
|
|
297
|
+
.join('transactions')
|
|
346
298
|
.call();
|
|
347
299
|
if (!rawOperations || !rawOperations.records.length) {
|
|
348
300
|
return noResult;
|
|
@@ -351,7 +303,7 @@ export async function fetchOperations({ accountId, addr, minHeight, order, curso
|
|
|
351
303
|
const filteredOps = await rawOperationsToOperations(rawOps, addr, accountId, minHeight);
|
|
352
304
|
// Always return the cursor so the caller can continue pagination,
|
|
353
305
|
// even when filteredOps is empty (e.g. page of unsupported types).
|
|
354
|
-
const nextCursor = rawOps.length < requestedLimit ?
|
|
306
|
+
const nextCursor = rawOps.length < requestedLimit ? '' : rawOps[rawOps.length - 1].paging_token;
|
|
355
307
|
return { items: filteredOps, next: nextCursor };
|
|
356
308
|
}
|
|
357
309
|
catch (e) {
|
|
@@ -359,12 +311,12 @@ export async function fetchOperations({ accountId, addr, minHeight, order, curso
|
|
|
359
311
|
// (https://github.com/stellar/js-stellar-sdk/issues/638)
|
|
360
312
|
// update 2025-04-01: in case of NetworkError, the error.response fields are undefined. Hence we cannot rely on status code
|
|
361
313
|
// the only way to check is the errror message, which may break at some point
|
|
362
|
-
const errorMsg = e ? String(e) :
|
|
314
|
+
const errorMsg = e ? String(e) : '';
|
|
363
315
|
if (e instanceof NotFoundError || errorMsg.match(/status code 404/)) {
|
|
364
316
|
return noResult;
|
|
365
317
|
}
|
|
366
318
|
if (errorMsg.match(/too many requests/i)) {
|
|
367
|
-
throw new LedgerAPI4xx(
|
|
319
|
+
throw new LedgerAPI4xx('status code 4xx', { status: 429, url: undefined, method: 'GET' });
|
|
368
320
|
}
|
|
369
321
|
if (errorMsg.match(/status code 4[0-9]{2}/)) {
|
|
370
322
|
throw new LedgerAPI4xx();
|
|
@@ -386,7 +338,7 @@ export async function fetchAccountNetworkInfo(account) {
|
|
|
386
338
|
const baseReserve = getReservedBalance(extendedAccount);
|
|
387
339
|
const { recommendedFee, networkCongestionLevel, baseFee } = await fetchBaseFee();
|
|
388
340
|
return {
|
|
389
|
-
family:
|
|
341
|
+
family: 'stellar',
|
|
390
342
|
fees: new BigNumber(recommendedFee.toString()),
|
|
391
343
|
baseFee: new BigNumber(baseFee.toString()),
|
|
392
344
|
baseReserve,
|
|
@@ -395,7 +347,7 @@ export async function fetchAccountNetworkInfo(account) {
|
|
|
395
347
|
}
|
|
396
348
|
catch {
|
|
397
349
|
return {
|
|
398
|
-
family:
|
|
350
|
+
family: 'stellar',
|
|
399
351
|
fees: new BigNumber(0),
|
|
400
352
|
baseFee: new BigNumber(100),
|
|
401
353
|
baseReserve: new BigNumber(0),
|
|
@@ -416,7 +368,7 @@ export async function fetchSigners(account) {
|
|
|
416
368
|
}
|
|
417
369
|
}
|
|
418
370
|
function interpretedError(error) {
|
|
419
|
-
const body =
|
|
371
|
+
const body = getHorizonErrorBody(error);
|
|
420
372
|
if (body) {
|
|
421
373
|
const cause = error instanceof Error ? error : new Error(String(error));
|
|
422
374
|
return makeBroadcastFailedError(body, cause);
|
|
@@ -454,7 +406,7 @@ export async function loadAccount(addr) {
|
|
|
454
406
|
}
|
|
455
407
|
}
|
|
456
408
|
export async function getLastBlock() {
|
|
457
|
-
const ledger = await getServer().ledgers().order(
|
|
409
|
+
const ledger = await getServer().ledgers().order('desc').limit(1).call();
|
|
458
410
|
return {
|
|
459
411
|
height: ledger.records[0].sequence,
|
|
460
412
|
hash: ledger.records[0].hash,
|
|
@@ -492,8 +444,8 @@ export async function fetchAllLedgerOperations(ledgerSequence) {
|
|
|
492
444
|
.operations()
|
|
493
445
|
.forLedger(ledgerSequence)
|
|
494
446
|
.includeFailed(true)
|
|
495
|
-
.join(
|
|
496
|
-
.order(
|
|
447
|
+
.join('transactions')
|
|
448
|
+
.order('asc')
|
|
497
449
|
.limit(limit)
|
|
498
450
|
.call();
|
|
499
451
|
const records = [...response.records];
|
|
@@ -510,10 +462,11 @@ export async function fetchAllLedgerOperations(ledgerSequence) {
|
|
|
510
462
|
throwHorizonLedgerOrOperationsError(e, `Stellar ledger ${ledgerSequence} not found`);
|
|
511
463
|
}
|
|
512
464
|
}
|
|
513
|
-
export const getRecipientAccount = makeLRUCache(async ({ recipient }) => await recipientAccount(recipient), extract => extract.recipient, {
|
|
465
|
+
export const getRecipientAccount = makeLRUCache(async ({ recipient }) => await recipientAccount(recipient), (extract) => extract.recipient, {
|
|
514
466
|
max: 300,
|
|
515
467
|
ttl: 5 * 60,
|
|
516
|
-
}
|
|
468
|
+
} // 5 minutes
|
|
469
|
+
);
|
|
517
470
|
async function recipientAccount(address) {
|
|
518
471
|
if (!address) {
|
|
519
472
|
return null;
|
|
@@ -521,7 +474,7 @@ async function recipientAccount(address) {
|
|
|
521
474
|
let accountAddress = address;
|
|
522
475
|
const isMuxedAccount = StrKey.isValidMed25519PublicKey(address);
|
|
523
476
|
if (isMuxedAccount) {
|
|
524
|
-
const muxedAccount = MuxedAccount.fromAddress(address,
|
|
477
|
+
const muxedAccount = MuxedAccount.fromAddress(address, '0');
|
|
525
478
|
accountAddress = muxedAccount.baseAccount().accountId();
|
|
526
479
|
}
|
|
527
480
|
const account = await loadAccount(accountAddress);
|
|
@@ -538,12 +491,12 @@ async function recipientAccount(address) {
|
|
|
538
491
|
}
|
|
539
492
|
function getBalanceId(balance) {
|
|
540
493
|
switch (balance.asset_type) {
|
|
541
|
-
case
|
|
542
|
-
return
|
|
543
|
-
case
|
|
494
|
+
case 'native':
|
|
495
|
+
return 'native';
|
|
496
|
+
case 'liquidity_pool_shares':
|
|
544
497
|
return balance.liquidity_pool_id || null;
|
|
545
|
-
case
|
|
546
|
-
case
|
|
498
|
+
case 'credit_alphanum4':
|
|
499
|
+
case 'credit_alphanum12':
|
|
547
500
|
return `${balance.asset_code}:${balance.asset_issuer}`;
|
|
548
501
|
default:
|
|
549
502
|
return null;
|