@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,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
4
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
5
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
6
|
};
|
|
@@ -17,7 +19,7 @@ const validateIntent = async (transactionIntent, balances, customFees) => {
|
|
|
17
19
|
const errors = {};
|
|
18
20
|
const warnings = {};
|
|
19
21
|
const useAllAmount = !!transactionIntent.useAllAmount;
|
|
20
|
-
const destinationNotExistMessage = new errors_1.NotEnoughBalanceBecauseDestinationNotCreated(
|
|
22
|
+
const destinationNotExistMessage = new errors_1.NotEnoughBalanceBecauseDestinationNotCreated('', {
|
|
21
23
|
minimalAmount: `${serialization_1.MIN_BALANCE} XLM`,
|
|
22
24
|
});
|
|
23
25
|
const { spendableBalance, balance } = await (0, horizon_1.fetchAccount)(transactionIntent.sender);
|
|
@@ -26,7 +28,7 @@ const validateIntent = async (transactionIntent, balances, customFees) => {
|
|
|
26
28
|
const baseReserve = networkInfo.baseReserve
|
|
27
29
|
? BigInt(Math.round(networkInfo.baseReserve.toNumber() * 10)) / 10n
|
|
28
30
|
: 0n;
|
|
29
|
-
const isAssetPayment = transactionIntent.asset.type !==
|
|
31
|
+
const isAssetPayment = transactionIntent.asset.type !== 'native';
|
|
30
32
|
const nativeBalance = BigInt(balance.toString());
|
|
31
33
|
const nativeAmountAvailable = BigInt(spendableBalance.toString()) - estimatedFees;
|
|
32
34
|
let amount = 0n;
|
|
@@ -36,8 +38,8 @@ const validateIntent = async (transactionIntent, balances, customFees) => {
|
|
|
36
38
|
if (!errors.amount && nativeAmountAvailable < 0) {
|
|
37
39
|
errors.amount = new types_1.StellarNotEnoughNativeBalance();
|
|
38
40
|
}
|
|
39
|
-
const networkInfoBaseFee = BigInt(networkInfo.baseFee.toString() ||
|
|
40
|
-
const networkFees = BigInt(networkInfo.fees.toString() ||
|
|
41
|
+
const networkInfoBaseFee = BigInt(networkInfo.baseFee.toString() || '0');
|
|
42
|
+
const networkFees = BigInt(networkInfo.fees.toString() || '0');
|
|
41
43
|
// Entered fee is smaller than base fee
|
|
42
44
|
if (estimatedFees < networkInfoBaseFee) {
|
|
43
45
|
errors.transaction = new types_1.StellarFeeSmallerThanBase();
|
|
@@ -47,13 +49,13 @@ const validateIntent = async (transactionIntent, balances, customFees) => {
|
|
|
47
49
|
warnings.transaction = new types_1.StellarFeeSmallerThanRecommended();
|
|
48
50
|
}
|
|
49
51
|
// Operation specific checks
|
|
50
|
-
if (transactionIntent.type ===
|
|
52
|
+
if (transactionIntent.type === 'changeTrust') {
|
|
51
53
|
// Check asset provided
|
|
52
|
-
if (transactionIntent.asset.type !==
|
|
53
|
-
((
|
|
54
|
-
(
|
|
54
|
+
if (transactionIntent.asset.type !== 'native' &&
|
|
55
|
+
(('assetReference' in transactionIntent.asset && !transactionIntent.asset.assetReference) ||
|
|
56
|
+
('assetOwner' in transactionIntent.asset && !transactionIntent.asset.assetOwner))) {
|
|
55
57
|
// This is unlikely
|
|
56
|
-
errors.transaction = new types_1.StellarAssetRequired(
|
|
58
|
+
errors.transaction = new types_1.StellarAssetRequired('');
|
|
57
59
|
}
|
|
58
60
|
// Has enough native balance to add new trustline
|
|
59
61
|
// NOTE: need to do this as BASE_RESERVE is 0.5
|
|
@@ -68,11 +70,11 @@ const validateIntent = async (transactionIntent, balances, customFees) => {
|
|
|
68
70
|
// Payment
|
|
69
71
|
// Check recipient address
|
|
70
72
|
if (!transactionIntent.recipient) {
|
|
71
|
-
errors.recipient = new errors_1.RecipientRequired(
|
|
73
|
+
errors.recipient = new errors_1.RecipientRequired('');
|
|
72
74
|
}
|
|
73
75
|
else if (!(0, utils_1.isAddressValid)(transactionIntent.recipient)) {
|
|
74
|
-
errors.recipient = new errors_1.InvalidAddress(
|
|
75
|
-
currencyName: transactionIntent.asset.name ??
|
|
76
|
+
errors.recipient = new errors_1.InvalidAddress('', {
|
|
77
|
+
currencyName: transactionIntent.asset.name ?? '', // NOTE: before account.currencyName,
|
|
76
78
|
});
|
|
77
79
|
}
|
|
78
80
|
else if (transactionIntent.sender === transactionIntent.recipient) {
|
|
@@ -98,7 +100,7 @@ const validateIntent = async (transactionIntent, balances, customFees) => {
|
|
|
98
100
|
// Asset payment
|
|
99
101
|
if (isAssetPayment) {
|
|
100
102
|
const asset = transactionIntent.asset;
|
|
101
|
-
if (asset.type ===
|
|
103
|
+
if (asset.type === 'native' || (!('assetReference' in asset) && !('assetOwner' in asset))) {
|
|
102
104
|
throw new types_1.StellarAssetNotFound();
|
|
103
105
|
}
|
|
104
106
|
// Check recipient account accepts asset
|
|
@@ -106,14 +108,14 @@ const validateIntent = async (transactionIntent, balances, customFees) => {
|
|
|
106
108
|
!errors.recipient &&
|
|
107
109
|
!warnings.recipient &&
|
|
108
110
|
!recipientAccount.assetIds.includes(`${asset.assetReference}:${asset.assetOwner}`)) {
|
|
109
|
-
errors.recipient = new types_1.StellarAssetNotAccepted(
|
|
111
|
+
errors.recipient = new types_1.StellarAssetNotAccepted('', {
|
|
110
112
|
assetCode: asset.assetReference,
|
|
111
113
|
});
|
|
112
114
|
}
|
|
113
|
-
const assetBalance = balances.find(b => b.asset.type !==
|
|
114
|
-
|
|
115
|
+
const assetBalance = balances.find((b) => b.asset.type !== 'native' &&
|
|
116
|
+
'assetReference' in b.asset &&
|
|
115
117
|
b.asset.assetReference === asset.assetReference &&
|
|
116
|
-
|
|
118
|
+
'assetOwner' in b.asset &&
|
|
117
119
|
b.asset.assetOwner === asset.assetOwner);
|
|
118
120
|
if (!assetBalance) {
|
|
119
121
|
// This is unlikely
|
|
@@ -146,7 +148,7 @@ const validateIntent = async (transactionIntent, balances, customFees) => {
|
|
|
146
148
|
disableRounding: true,
|
|
147
149
|
showCode: true,
|
|
148
150
|
})
|
|
149
|
-
:
|
|
151
|
+
: 'Unknown unit',
|
|
150
152
|
});
|
|
151
153
|
}
|
|
152
154
|
if (!errors.recipient && !errors.amount && (amount < 0n || totalSpent > nativeBalance)) {
|
|
@@ -162,7 +164,7 @@ const validateIntent = async (transactionIntent, balances, customFees) => {
|
|
|
162
164
|
if (await (0, utils_1.isAccountMultiSign)(transactionIntent.sender)) {
|
|
163
165
|
errors.recipient = new types_1.StellarSourceHasMultiSign();
|
|
164
166
|
}
|
|
165
|
-
if (transactionIntent?.memo?.type !==
|
|
167
|
+
if (transactionIntent?.memo?.type !== 'NO_MEMO' &&
|
|
166
168
|
!(0, validateMemo_1.validateMemo)(transactionIntent?.memo?.value, transactionIntent?.memo?.type)) {
|
|
167
169
|
errors.transaction = new types_1.StellarWrongMemoFormat();
|
|
168
170
|
}
|
|
@@ -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,4EAAqF;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;
|
|
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,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
4
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
5
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
6
|
};
|
|
@@ -10,14 +12,14 @@ exports.MEMO_TEXT_MAXIMUM_SIZE = 28;
|
|
|
10
12
|
exports.MEMO_HASH_FIXED_SIZE = 64;
|
|
11
13
|
function validateMemo(memo, type) {
|
|
12
14
|
switch (type) {
|
|
13
|
-
case
|
|
15
|
+
case 'NO_MEMO':
|
|
14
16
|
return !memo || memo.length === 0;
|
|
15
|
-
case
|
|
17
|
+
case 'MEMO_TEXT':
|
|
16
18
|
return memo.length <= exports.MEMO_TEXT_MAXIMUM_SIZE;
|
|
17
|
-
case
|
|
19
|
+
case 'MEMO_ID':
|
|
18
20
|
return !new bignumber_js_1.default(memo.toString()).isNaN();
|
|
19
|
-
case
|
|
20
|
-
case
|
|
21
|
+
case 'MEMO_HASH':
|
|
22
|
+
case 'MEMO_RETURN':
|
|
21
23
|
return memo.length === 64;
|
|
22
24
|
}
|
|
23
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateMemo.js","sourceRoot":"","sources":["../../src/logic/validateMemo.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"validateMemo.js","sourceRoot":"","sources":["../../src/logic/validateMemo.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,sCAAsC;;;;;;AAQtC,oCAYC;AAlBD,gEAAoC;AAGvB,QAAA,sBAAsB,GAAG,EAAE,CAAA;AAC3B,QAAA,oBAAoB,GAAG,EAAE,CAAA;AAEtC,SAAgB,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,8BAAsB,CAAA;QAC9C,KAAK,SAAS;YACZ,OAAO,CAAC,IAAI,sBAAS,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"}
|
package/lib/network/horizon.d.ts
CHANGED
|
@@ -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,MA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BnF;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAGvE;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAOrE;AAWD,wBAAsB,oBAAoB,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAiBrF;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,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"}
|
package/lib/network/horizon.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
4
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
5
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
6
|
};
|
|
@@ -25,72 +27,24 @@ const logs_1 = require("@ledgerhq/logs");
|
|
|
25
27
|
const stellar_sdk_1 = require("@stellar/stellar-sdk");
|
|
26
28
|
const bignumber_js_1 = require("bignumber.js");
|
|
27
29
|
const config_1 = __importDefault(require("../config"));
|
|
30
|
+
const common_1 = require("../logic/common");
|
|
28
31
|
const polyfill_1 = require("../polyfill");
|
|
29
|
-
const errors_2 = require("../types/errors");
|
|
30
32
|
const types_1 = require("../types");
|
|
31
|
-
const
|
|
33
|
+
const errors_2 = require("../types/errors");
|
|
34
|
+
const horizonErrorBody_1 = require("./horizonErrorBody");
|
|
32
35
|
const horizonLedgerErrors_1 = require("./horizonLedgerErrors");
|
|
33
|
-
const
|
|
36
|
+
const serialization_1 = require("./serialization");
|
|
34
37
|
const FALLBACK_BASE_FEE = 100;
|
|
35
38
|
const TRESHOLD_LOW = 0.5;
|
|
36
39
|
const TRESHOLD_MEDIUM = 0.75;
|
|
37
40
|
const FETCH_LIMIT = 100;
|
|
38
|
-
const STELLAR_TX_RESULT_CODES_DOC_URL =
|
|
39
|
-
/** Horizon `extras.result_codes.transaction` → one-line description (Stellar docs). */
|
|
40
|
-
const HORIZON_TRANSACTION_RESULT_CODE_DOCUMENTATION = {
|
|
41
|
-
tx_success: "The transaction succeeded.",
|
|
42
|
-
tx_failed: "One of the operations failed (none were applied).",
|
|
43
|
-
tx_too_early: "The ledger closeTime was before the minTime.",
|
|
44
|
-
tx_too_late: "The ledger closeTime was after the maxTime.",
|
|
45
|
-
tx_missing_operation: "No operation was specified.",
|
|
46
|
-
tx_bad_seq: "Sequence number does not match source account.",
|
|
47
|
-
tx_bad_auth: "Too few valid signatures / wrong network.",
|
|
48
|
-
tx_insufficient_balance: "Fee would bring account below reserve.",
|
|
49
|
-
tx_no_source_account: "Source account not found.",
|
|
50
|
-
tx_insufficient_fee: "Fee is too small.",
|
|
51
|
-
tx_bad_auth_extra: "Unused signatures attached to transaction.",
|
|
52
|
-
tx_internal_error: "An unknown error occurred.",
|
|
53
|
-
tx_fee_bump_inner_success: "Fee bump inner transaction succeeded.",
|
|
54
|
-
tx_fee_bump_inner_failed: "Fee bump inner transaction failed.",
|
|
55
|
-
tx_not_supported: "Transaction type not supported.",
|
|
56
|
-
tx_bad_sponsorship: "Sponsorship is invalid.",
|
|
57
|
-
tx_bad_min_seq_age_or_gap: "Minimum sequence age or gap precondition failed.",
|
|
58
|
-
tx_malformed: "Transaction is malformed.",
|
|
59
|
-
tx_soroban_invalid: "Soroban transaction is invalid.",
|
|
60
|
-
};
|
|
61
|
-
function isHorizonSubmitErrorBody(data) {
|
|
62
|
-
return !!(data &&
|
|
63
|
-
typeof data === "object" &&
|
|
64
|
-
"extras" in data &&
|
|
65
|
-
typeof data.extras === "object" &&
|
|
66
|
-
data.extras !== null &&
|
|
67
|
-
"result_codes" in data.extras &&
|
|
68
|
-
data.extras.result_codes !== undefined &&
|
|
69
|
-
typeof data.extras.result_codes === "object");
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Horizon submit failures are usually {@link BadResponseError} with `response` = problem+json body.
|
|
73
|
-
* In practice axios rejects with `AxiosError` first; the SDK's `.catch` forwards it unchanged (see js-stellar-sdk horizon/server.js),
|
|
74
|
-
* so the Horizon body lives on `error.response.data`.
|
|
75
|
-
*/
|
|
76
|
-
function getHorizonBodyFromSubmitFailure(error) {
|
|
77
|
-
if (error instanceof stellar_sdk_1.BadResponseError && isHorizonSubmitErrorBody(error.response)) {
|
|
78
|
-
return error.response;
|
|
79
|
-
}
|
|
80
|
-
if (error && typeof error === "object" && "response" in error) {
|
|
81
|
-
const data = error.response?.data;
|
|
82
|
-
if (isHorizonSubmitErrorBody(data)) {
|
|
83
|
-
return data;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
41
|
+
const STELLAR_TX_RESULT_CODES_DOC_URL = 'https://developers.stellar.org/docs/data/apis/horizon/api-reference/errors/result-codes/transactions';
|
|
88
42
|
function decodeTransactionResultFields(resultXdrBase64) {
|
|
89
43
|
if (!resultXdrBase64) {
|
|
90
44
|
return undefined;
|
|
91
45
|
}
|
|
92
46
|
try {
|
|
93
|
-
const tr = stellar_sdk_1.xdr.TransactionResult.fromXDR(resultXdrBase64,
|
|
47
|
+
const tr = stellar_sdk_1.xdr.TransactionResult.fromXDR(resultXdrBase64, 'base64');
|
|
94
48
|
const feeChargedStroops = tr.feeCharged().toString();
|
|
95
49
|
const resultXdrSwitchName = tr.result().switch().name;
|
|
96
50
|
const decodedResultXdr = {
|
|
@@ -107,17 +61,15 @@ function decodeTransactionResultFields(resultXdrBase64) {
|
|
|
107
61
|
}
|
|
108
62
|
function makeBroadcastFailedError(body, cause) {
|
|
109
63
|
const extras = body.extras;
|
|
110
|
-
const horizonTransactionCode = extras?.result_codes?.transaction ??
|
|
64
|
+
const horizonTransactionCode = extras?.result_codes?.transaction ?? '';
|
|
111
65
|
const horizonOperationCodes = extras?.result_codes?.operations;
|
|
112
|
-
const documentationSummary = (
|
|
113
|
-
HORIZON_TRANSACTION_RESULT_CODE_DOCUMENTATION[horizonTransactionCode]) ||
|
|
114
|
-
"Unknown transaction result code.";
|
|
66
|
+
const documentationSummary = (0, horizonErrorBody_1.documentationSummaryFromHorizonBody)(body);
|
|
115
67
|
const decodedResult = decodeTransactionResultFields(extras?.result_xdr);
|
|
116
68
|
const feeChargedStroops = decodedResult?.feeChargedStroops;
|
|
117
69
|
const resultXdrSwitchName = decodedResult?.resultXdrSwitchName;
|
|
118
70
|
const decodedResultXdr = decodedResult?.decodedResultXdr;
|
|
119
|
-
const envelopeXdr = extras?.envelope_xdr ??
|
|
120
|
-
const message = body.detail || body.title || `Transaction submission failed (${body.status ??
|
|
71
|
+
const envelopeXdr = extras?.envelope_xdr ?? '';
|
|
72
|
+
const message = body.detail || body.title || `Transaction submission failed (${body.status ?? 'unknown'}).`;
|
|
121
73
|
return new errors_2.StellarBroadcastFailedError(message, {
|
|
122
74
|
documentationSummary,
|
|
123
75
|
horizonTransactionCode,
|
|
@@ -157,7 +109,7 @@ function registerHorizonInterceptors() {
|
|
|
157
109
|
if (interceptorsRegistered)
|
|
158
110
|
return;
|
|
159
111
|
interceptorsRegistered = true;
|
|
160
|
-
stellar_sdk_1.Horizon.AxiosClient.interceptors.request.use(config => {
|
|
112
|
+
stellar_sdk_1.Horizon.AxiosClient.interceptors.request.use((config) => {
|
|
161
113
|
let enableNetworkLogs = false;
|
|
162
114
|
try {
|
|
163
115
|
enableNetworkLogs = !!config_1.default.getCoinConfig().enableNetworkLogs;
|
|
@@ -166,13 +118,13 @@ function registerHorizonInterceptors() {
|
|
|
166
118
|
return config;
|
|
167
119
|
}
|
|
168
120
|
if (enableNetworkLogs) {
|
|
169
|
-
const { baseURL, url, method =
|
|
170
|
-
(0, logs_1.log)(
|
|
121
|
+
const { baseURL, url, method = '', data } = config;
|
|
122
|
+
(0, logs_1.log)('network', `${method} ${baseURL ?? ''}${url}`, { data });
|
|
171
123
|
requestStartTimes.set(config, Date.now());
|
|
172
124
|
}
|
|
173
125
|
return config;
|
|
174
126
|
});
|
|
175
|
-
stellar_sdk_1.Horizon.AxiosClient.interceptors.response.use(response => {
|
|
127
|
+
stellar_sdk_1.Horizon.AxiosClient.interceptors.response.use((response) => {
|
|
176
128
|
let enableNetworkLogs = false;
|
|
177
129
|
try {
|
|
178
130
|
enableNetworkLogs = !!config_1.default.getCoinConfig().enableNetworkLogs;
|
|
@@ -184,7 +136,7 @@ function registerHorizonInterceptors() {
|
|
|
184
136
|
// response.config is typed as `any` in stellar-sdk's HttpClientResponse
|
|
185
137
|
const startTime = requestStartTimes.get(response.config) ?? 0;
|
|
186
138
|
requestStartTimes.delete(response.config);
|
|
187
|
-
(0, logs_1.log)(
|
|
139
|
+
(0, logs_1.log)('network-success', `${response.status} ${response.config?.method ?? ''} ${response.config?.baseURL ?? ''}${response.config?.url ?? ''} (${(Date.now() - startTime).toFixed(0)}ms)`, { data: response.data });
|
|
188
140
|
}
|
|
189
141
|
// FIXME: workaround for the Stellar SDK not using the correct URL: the "next" URL
|
|
190
142
|
// included in server responses points to the node itself instead of our reverse proxy...
|
|
@@ -261,20 +213,20 @@ async function fetchBaseFee() {
|
|
|
261
213
|
async function fetchAccount(addr) {
|
|
262
214
|
let account = {};
|
|
263
215
|
let assets = [];
|
|
264
|
-
let balance =
|
|
216
|
+
let balance = '0';
|
|
265
217
|
try {
|
|
266
218
|
account = await getServer().accounts().accountId(addr).call();
|
|
267
219
|
balance =
|
|
268
|
-
account.balances?.find(balance => {
|
|
269
|
-
return balance.asset_type ===
|
|
270
|
-
})?.balance ||
|
|
220
|
+
account.balances?.find((balance) => {
|
|
221
|
+
return balance.asset_type === 'native';
|
|
222
|
+
})?.balance || '0';
|
|
271
223
|
// Getting all non-native (XLM) assets on the account
|
|
272
|
-
assets = account.balances?.filter(balance => {
|
|
273
|
-
return balance.asset_type !==
|
|
224
|
+
assets = account.balances?.filter((balance) => {
|
|
225
|
+
return balance.asset_type !== 'native';
|
|
274
226
|
});
|
|
275
227
|
}
|
|
276
228
|
catch {
|
|
277
|
-
balance =
|
|
229
|
+
balance = '0';
|
|
278
230
|
}
|
|
279
231
|
const formattedBalance = (0, common_1.parseAPIValue)(balance);
|
|
280
232
|
const spendableBalance = await getAccountSpendableBalance(formattedBalance, account);
|
|
@@ -296,7 +248,7 @@ async function fetchAccount(addr) {
|
|
|
296
248
|
*
|
|
297
249
|
* @return {Operation[]}
|
|
298
250
|
*/
|
|
299
|
-
async function fetchAllOperations(accountId, addr, order, cursor =
|
|
251
|
+
async function fetchAllOperations(accountId, addr, order, cursor = '', maxOperations) {
|
|
300
252
|
if (!addr) {
|
|
301
253
|
return [];
|
|
302
254
|
}
|
|
@@ -311,7 +263,7 @@ async function fetchAllOperations(accountId, addr, order, cursor = "", maxOperat
|
|
|
311
263
|
.order(order)
|
|
312
264
|
.cursor(cursor)
|
|
313
265
|
.includeFailed(true)
|
|
314
|
-
.join(
|
|
266
|
+
.join('transactions')
|
|
315
267
|
.call();
|
|
316
268
|
if (!rawOperations || !rawOperations.records.length) {
|
|
317
269
|
return [];
|
|
@@ -330,7 +282,7 @@ async function fetchAllOperations(accountId, addr, order, cursor = "", maxOperat
|
|
|
330
282
|
catch (e) {
|
|
331
283
|
// FIXME: terrible hacks, because Stellar SDK fails to cast network failures to typed errors in react-native...
|
|
332
284
|
// (https://github.com/stellar/js-stellar-sdk/issues/638)
|
|
333
|
-
const errorMsg = e ? String(e) :
|
|
285
|
+
const errorMsg = e ? String(e) : '';
|
|
334
286
|
if (e instanceof stellar_sdk_1.NotFoundError || errorMsg.match(/status code 404/)) {
|
|
335
287
|
return [];
|
|
336
288
|
}
|
|
@@ -350,7 +302,7 @@ async function fetchAllOperations(accountId, addr, order, cursor = "", maxOperat
|
|
|
350
302
|
}
|
|
351
303
|
// https://developers.stellar.org/docs/data/horizon/api-reference/get-operations-by-account-id
|
|
352
304
|
async function fetchOperations({ accountId, addr, minHeight, order, cursor, limit, }) {
|
|
353
|
-
const noResult = { items: [], next:
|
|
305
|
+
const noResult = { items: [], next: '' };
|
|
354
306
|
if (!addr) {
|
|
355
307
|
return noResult;
|
|
356
308
|
}
|
|
@@ -361,9 +313,9 @@ async function fetchOperations({ accountId, addr, minHeight, order, cursor, limi
|
|
|
361
313
|
.forAccount(addr)
|
|
362
314
|
.limit(requestedLimit)
|
|
363
315
|
.order(order)
|
|
364
|
-
.cursor(cursor ??
|
|
316
|
+
.cursor(cursor ?? '')
|
|
365
317
|
.includeFailed(true)
|
|
366
|
-
.join(
|
|
318
|
+
.join('transactions')
|
|
367
319
|
.call();
|
|
368
320
|
if (!rawOperations || !rawOperations.records.length) {
|
|
369
321
|
return noResult;
|
|
@@ -372,7 +324,7 @@ async function fetchOperations({ accountId, addr, minHeight, order, cursor, limi
|
|
|
372
324
|
const filteredOps = await (0, serialization_1.rawOperationsToOperations)(rawOps, addr, accountId, minHeight);
|
|
373
325
|
// Always return the cursor so the caller can continue pagination,
|
|
374
326
|
// even when filteredOps is empty (e.g. page of unsupported types).
|
|
375
|
-
const nextCursor = rawOps.length < requestedLimit ?
|
|
327
|
+
const nextCursor = rawOps.length < requestedLimit ? '' : rawOps[rawOps.length - 1].paging_token;
|
|
376
328
|
return { items: filteredOps, next: nextCursor };
|
|
377
329
|
}
|
|
378
330
|
catch (e) {
|
|
@@ -380,12 +332,12 @@ async function fetchOperations({ accountId, addr, minHeight, order, cursor, limi
|
|
|
380
332
|
// (https://github.com/stellar/js-stellar-sdk/issues/638)
|
|
381
333
|
// update 2025-04-01: in case of NetworkError, the error.response fields are undefined. Hence we cannot rely on status code
|
|
382
334
|
// the only way to check is the errror message, which may break at some point
|
|
383
|
-
const errorMsg = e ? String(e) :
|
|
335
|
+
const errorMsg = e ? String(e) : '';
|
|
384
336
|
if (e instanceof stellar_sdk_1.NotFoundError || errorMsg.match(/status code 404/)) {
|
|
385
337
|
return noResult;
|
|
386
338
|
}
|
|
387
339
|
if (errorMsg.match(/too many requests/i)) {
|
|
388
|
-
throw new errors_1.LedgerAPI4xx(
|
|
340
|
+
throw new errors_1.LedgerAPI4xx('status code 4xx', { status: 429, url: undefined, method: 'GET' });
|
|
389
341
|
}
|
|
390
342
|
if (errorMsg.match(/status code 4[0-9]{2}/)) {
|
|
391
343
|
throw new errors_1.LedgerAPI4xx();
|
|
@@ -407,7 +359,7 @@ async function fetchAccountNetworkInfo(account) {
|
|
|
407
359
|
const baseReserve = (0, serialization_1.getReservedBalance)(extendedAccount);
|
|
408
360
|
const { recommendedFee, networkCongestionLevel, baseFee } = await fetchBaseFee();
|
|
409
361
|
return {
|
|
410
|
-
family:
|
|
362
|
+
family: 'stellar',
|
|
411
363
|
fees: new bignumber_js_1.BigNumber(recommendedFee.toString()),
|
|
412
364
|
baseFee: new bignumber_js_1.BigNumber(baseFee.toString()),
|
|
413
365
|
baseReserve,
|
|
@@ -416,7 +368,7 @@ async function fetchAccountNetworkInfo(account) {
|
|
|
416
368
|
}
|
|
417
369
|
catch {
|
|
418
370
|
return {
|
|
419
|
-
family:
|
|
371
|
+
family: 'stellar',
|
|
420
372
|
fees: new bignumber_js_1.BigNumber(0),
|
|
421
373
|
baseFee: new bignumber_js_1.BigNumber(100),
|
|
422
374
|
baseReserve: new bignumber_js_1.BigNumber(0),
|
|
@@ -437,7 +389,7 @@ async function fetchSigners(account) {
|
|
|
437
389
|
}
|
|
438
390
|
}
|
|
439
391
|
function interpretedError(error) {
|
|
440
|
-
const body =
|
|
392
|
+
const body = (0, horizonErrorBody_1.getHorizonErrorBody)(error);
|
|
441
393
|
if (body) {
|
|
442
394
|
const cause = error instanceof Error ? error : new Error(String(error));
|
|
443
395
|
return makeBroadcastFailedError(body, cause);
|
|
@@ -475,7 +427,7 @@ async function loadAccount(addr) {
|
|
|
475
427
|
}
|
|
476
428
|
}
|
|
477
429
|
async function getLastBlock() {
|
|
478
|
-
const ledger = await getServer().ledgers().order(
|
|
430
|
+
const ledger = await getServer().ledgers().order('desc').limit(1).call();
|
|
479
431
|
return {
|
|
480
432
|
height: ledger.records[0].sequence,
|
|
481
433
|
hash: ledger.records[0].hash,
|
|
@@ -513,8 +465,8 @@ async function fetchAllLedgerOperations(ledgerSequence) {
|
|
|
513
465
|
.operations()
|
|
514
466
|
.forLedger(ledgerSequence)
|
|
515
467
|
.includeFailed(true)
|
|
516
|
-
.join(
|
|
517
|
-
.order(
|
|
468
|
+
.join('transactions')
|
|
469
|
+
.order('asc')
|
|
518
470
|
.limit(limit)
|
|
519
471
|
.call();
|
|
520
472
|
const records = [...response.records];
|
|
@@ -531,10 +483,11 @@ async function fetchAllLedgerOperations(ledgerSequence) {
|
|
|
531
483
|
(0, horizonLedgerErrors_1.throwHorizonLedgerOrOperationsError)(e, `Stellar ledger ${ledgerSequence} not found`);
|
|
532
484
|
}
|
|
533
485
|
}
|
|
534
|
-
exports.getRecipientAccount = (0, cache_1.makeLRUCache)(async ({ recipient }) => await recipientAccount(recipient), extract => extract.recipient, {
|
|
486
|
+
exports.getRecipientAccount = (0, cache_1.makeLRUCache)(async ({ recipient }) => await recipientAccount(recipient), (extract) => extract.recipient, {
|
|
535
487
|
max: 300,
|
|
536
488
|
ttl: 5 * 60,
|
|
537
|
-
}
|
|
489
|
+
} // 5 minutes
|
|
490
|
+
);
|
|
538
491
|
async function recipientAccount(address) {
|
|
539
492
|
if (!address) {
|
|
540
493
|
return null;
|
|
@@ -542,7 +495,7 @@ async function recipientAccount(address) {
|
|
|
542
495
|
let accountAddress = address;
|
|
543
496
|
const isMuxedAccount = stellar_sdk_1.StrKey.isValidMed25519PublicKey(address);
|
|
544
497
|
if (isMuxedAccount) {
|
|
545
|
-
const muxedAccount = stellar_sdk_1.MuxedAccount.fromAddress(address,
|
|
498
|
+
const muxedAccount = stellar_sdk_1.MuxedAccount.fromAddress(address, '0');
|
|
546
499
|
accountAddress = muxedAccount.baseAccount().accountId();
|
|
547
500
|
}
|
|
548
501
|
const account = await loadAccount(accountAddress);
|
|
@@ -559,12 +512,12 @@ async function recipientAccount(address) {
|
|
|
559
512
|
}
|
|
560
513
|
function getBalanceId(balance) {
|
|
561
514
|
switch (balance.asset_type) {
|
|
562
|
-
case
|
|
563
|
-
return
|
|
564
|
-
case
|
|
515
|
+
case 'native':
|
|
516
|
+
return 'native';
|
|
517
|
+
case 'liquidity_pool_shares':
|
|
565
518
|
return balance.liquidity_pool_id || null;
|
|
566
|
-
case
|
|
567
|
-
case
|
|
519
|
+
case 'credit_alphanum4':
|
|
520
|
+
case 'credit_alphanum12':
|
|
568
521
|
return `${balance.asset_code}:${balance.asset_issuer}`;
|
|
569
522
|
default:
|
|
570
523
|
return null;
|