@ledgerhq/coin-stellar 6.26.0 → 6.26.1
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 +6 -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 +71 -68
- package/lib/network/horizon.js.map +1 -1
- package/lib/network/horizonLedgerErrors.d.ts.map +1 -1
- package/lib/network/horizonLedgerErrors.js +5 -3
- 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 +80 -77
- package/lib-es/network/horizon.js.map +1 -1
- package/lib-es/network/horizonLedgerErrors.d.ts.map +1 -1
- package/lib-es/network/horizonLedgerErrors.js +7 -5
- 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 +165 -162
- 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 +60 -60
- 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 +279 -281
- package/src/network/horizon.unit.test.ts +238 -237
- package/src/network/horizonLedgerErrors.test.ts +81 -78
- package/src/network/horizonLedgerErrors.ts +22 -19
- 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;AACrF,6CAQyB;AACzB,gEAAoC;AACpC,wCAAyE;AACzE,gDAAiD;AACjD,4DAAoE;AACpE,oCAYiB;AACjB,mCAA4D;AAC5D,iDAA6C;AAEtC,MAAM,cAAc,GAAG,KAAK,EACjC,iBAAiD,EACjD,QAAmB,EACnB,UAA0B,EACM,EAAE;IAClC,MAAM,MAAM,GAA0B,EAAE,CAAA;IACxC,MAAM,QAAQ,GAA0B,EAAE,CAAA;IAC1C,MAAM,YAAY,GAAG,CAAC,CAAC,iBAAiB,CAA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AG,IAAI,yBAAgB,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,uBAAc,EAAE,CAAA;QACtC,CAAC;IACH,CAAC;IAED,IAAI,MAAM,IAAA,0BAAkB,EAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC;QACvD,MAAM,CAAC,SAAS,GAAG,IAAI,iCAAyB,EAAE,CAAA;IACpD,CAAC;IAED,IACE,iBAAiB,EAAE,IAAI,EAAE,IAAI,KAAK,SAAS;QAC3C,CAAC,IAAA,2BAAY,EAAC,iBAAiB,EAAE,IAAI,EAAE,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,IAAI,CAAC,EAC5E,CAAC;QACD,MAAM,CAAC,WAAW,GAAG,IAAI,8BAAsB,EAAE,CAAA;IACnD,CAAC;IAED,OAAO;QACL,MAAM;QACN,QAAQ;QACR,aAAa;QACb,MAAM;QACN,UAAU;KACX,CAAA;AACH,CAAC,CAAA;AAlMY,QAAA,cAAc,kBAkM1B;AAED,kBAAe,sBAAc,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,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,EAGL,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;AA+JjB;;;;;;;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;AAED;;;;;GAKG;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O,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,48 +27,48 @@ 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");
|
|
32
34
|
const horizonLedgerErrors_1 = require("./horizonLedgerErrors");
|
|
33
|
-
const
|
|
35
|
+
const serialization_1 = require("./serialization");
|
|
34
36
|
const FALLBACK_BASE_FEE = 100;
|
|
35
37
|
const TRESHOLD_LOW = 0.5;
|
|
36
38
|
const TRESHOLD_MEDIUM = 0.75;
|
|
37
39
|
const FETCH_LIMIT = 100;
|
|
38
|
-
const STELLAR_TX_RESULT_CODES_DOC_URL =
|
|
40
|
+
const STELLAR_TX_RESULT_CODES_DOC_URL = 'https://developers.stellar.org/docs/data/apis/horizon/api-reference/errors/result-codes/transactions';
|
|
39
41
|
/** Horizon `extras.result_codes.transaction` → one-line description (Stellar docs). */
|
|
40
42
|
const HORIZON_TRANSACTION_RESULT_CODE_DOCUMENTATION = {
|
|
41
|
-
tx_success:
|
|
42
|
-
tx_failed:
|
|
43
|
-
tx_too_early:
|
|
44
|
-
tx_too_late:
|
|
45
|
-
tx_missing_operation:
|
|
46
|
-
tx_bad_seq:
|
|
47
|
-
tx_bad_auth:
|
|
48
|
-
tx_insufficient_balance:
|
|
49
|
-
tx_no_source_account:
|
|
50
|
-
tx_insufficient_fee:
|
|
51
|
-
tx_bad_auth_extra:
|
|
52
|
-
tx_internal_error:
|
|
53
|
-
tx_fee_bump_inner_success:
|
|
54
|
-
tx_fee_bump_inner_failed:
|
|
55
|
-
tx_not_supported:
|
|
56
|
-
tx_bad_sponsorship:
|
|
57
|
-
tx_bad_min_seq_age_or_gap:
|
|
58
|
-
tx_malformed:
|
|
59
|
-
tx_soroban_invalid:
|
|
43
|
+
tx_success: 'The transaction succeeded.',
|
|
44
|
+
tx_failed: 'One of the operations failed (none were applied).',
|
|
45
|
+
tx_too_early: 'The ledger closeTime was before the minTime.',
|
|
46
|
+
tx_too_late: 'The ledger closeTime was after the maxTime.',
|
|
47
|
+
tx_missing_operation: 'No operation was specified.',
|
|
48
|
+
tx_bad_seq: 'Sequence number does not match source account.',
|
|
49
|
+
tx_bad_auth: 'Too few valid signatures / wrong network.',
|
|
50
|
+
tx_insufficient_balance: 'Fee would bring account below reserve.',
|
|
51
|
+
tx_no_source_account: 'Source account not found.',
|
|
52
|
+
tx_insufficient_fee: 'Fee is too small.',
|
|
53
|
+
tx_bad_auth_extra: 'Unused signatures attached to transaction.',
|
|
54
|
+
tx_internal_error: 'An unknown error occurred.',
|
|
55
|
+
tx_fee_bump_inner_success: 'Fee bump inner transaction succeeded.',
|
|
56
|
+
tx_fee_bump_inner_failed: 'Fee bump inner transaction failed.',
|
|
57
|
+
tx_not_supported: 'Transaction type not supported.',
|
|
58
|
+
tx_bad_sponsorship: 'Sponsorship is invalid.',
|
|
59
|
+
tx_bad_min_seq_age_or_gap: 'Minimum sequence age or gap precondition failed.',
|
|
60
|
+
tx_malformed: 'Transaction is malformed.',
|
|
61
|
+
tx_soroban_invalid: 'Soroban transaction is invalid.',
|
|
60
62
|
};
|
|
61
63
|
function isHorizonSubmitErrorBody(data) {
|
|
62
64
|
return !!(data &&
|
|
63
|
-
typeof data ===
|
|
64
|
-
|
|
65
|
-
typeof data.extras ===
|
|
65
|
+
typeof data === 'object' &&
|
|
66
|
+
'extras' in data &&
|
|
67
|
+
typeof data.extras === 'object' &&
|
|
66
68
|
data.extras !== null &&
|
|
67
|
-
|
|
69
|
+
'result_codes' in data.extras &&
|
|
68
70
|
data.extras.result_codes !== undefined &&
|
|
69
|
-
typeof data.extras.result_codes ===
|
|
71
|
+
typeof data.extras.result_codes === 'object');
|
|
70
72
|
}
|
|
71
73
|
/**
|
|
72
74
|
* Horizon submit failures are usually {@link BadResponseError} with `response` = problem+json body.
|
|
@@ -77,7 +79,7 @@ function getHorizonBodyFromSubmitFailure(error) {
|
|
|
77
79
|
if (error instanceof stellar_sdk_1.BadResponseError && isHorizonSubmitErrorBody(error.response)) {
|
|
78
80
|
return error.response;
|
|
79
81
|
}
|
|
80
|
-
if (error && typeof error ===
|
|
82
|
+
if (error && typeof error === 'object' && 'response' in error) {
|
|
81
83
|
const data = error.response?.data;
|
|
82
84
|
if (isHorizonSubmitErrorBody(data)) {
|
|
83
85
|
return data;
|
|
@@ -90,7 +92,7 @@ function decodeTransactionResultFields(resultXdrBase64) {
|
|
|
90
92
|
return undefined;
|
|
91
93
|
}
|
|
92
94
|
try {
|
|
93
|
-
const tr = stellar_sdk_1.xdr.TransactionResult.fromXDR(resultXdrBase64,
|
|
95
|
+
const tr = stellar_sdk_1.xdr.TransactionResult.fromXDR(resultXdrBase64, 'base64');
|
|
94
96
|
const feeChargedStroops = tr.feeCharged().toString();
|
|
95
97
|
const resultXdrSwitchName = tr.result().switch().name;
|
|
96
98
|
const decodedResultXdr = {
|
|
@@ -107,17 +109,17 @@ function decodeTransactionResultFields(resultXdrBase64) {
|
|
|
107
109
|
}
|
|
108
110
|
function makeBroadcastFailedError(body, cause) {
|
|
109
111
|
const extras = body.extras;
|
|
110
|
-
const horizonTransactionCode = extras?.result_codes?.transaction ??
|
|
112
|
+
const horizonTransactionCode = extras?.result_codes?.transaction ?? '';
|
|
111
113
|
const horizonOperationCodes = extras?.result_codes?.operations;
|
|
112
114
|
const documentationSummary = (horizonTransactionCode &&
|
|
113
115
|
HORIZON_TRANSACTION_RESULT_CODE_DOCUMENTATION[horizonTransactionCode]) ||
|
|
114
|
-
|
|
116
|
+
'Unknown transaction result code.';
|
|
115
117
|
const decodedResult = decodeTransactionResultFields(extras?.result_xdr);
|
|
116
118
|
const feeChargedStroops = decodedResult?.feeChargedStroops;
|
|
117
119
|
const resultXdrSwitchName = decodedResult?.resultXdrSwitchName;
|
|
118
120
|
const decodedResultXdr = decodedResult?.decodedResultXdr;
|
|
119
|
-
const envelopeXdr = extras?.envelope_xdr ??
|
|
120
|
-
const message = body.detail || body.title || `Transaction submission failed (${body.status ??
|
|
121
|
+
const envelopeXdr = extras?.envelope_xdr ?? '';
|
|
122
|
+
const message = body.detail || body.title || `Transaction submission failed (${body.status ?? 'unknown'}).`;
|
|
121
123
|
return new errors_2.StellarBroadcastFailedError(message, {
|
|
122
124
|
documentationSummary,
|
|
123
125
|
horizonTransactionCode,
|
|
@@ -157,7 +159,7 @@ function registerHorizonInterceptors() {
|
|
|
157
159
|
if (interceptorsRegistered)
|
|
158
160
|
return;
|
|
159
161
|
interceptorsRegistered = true;
|
|
160
|
-
stellar_sdk_1.Horizon.AxiosClient.interceptors.request.use(config => {
|
|
162
|
+
stellar_sdk_1.Horizon.AxiosClient.interceptors.request.use((config) => {
|
|
161
163
|
let enableNetworkLogs = false;
|
|
162
164
|
try {
|
|
163
165
|
enableNetworkLogs = !!config_1.default.getCoinConfig().enableNetworkLogs;
|
|
@@ -166,13 +168,13 @@ function registerHorizonInterceptors() {
|
|
|
166
168
|
return config;
|
|
167
169
|
}
|
|
168
170
|
if (enableNetworkLogs) {
|
|
169
|
-
const { baseURL, url, method =
|
|
170
|
-
(0, logs_1.log)(
|
|
171
|
+
const { baseURL, url, method = '', data } = config;
|
|
172
|
+
(0, logs_1.log)('network', `${method} ${baseURL ?? ''}${url}`, { data });
|
|
171
173
|
requestStartTimes.set(config, Date.now());
|
|
172
174
|
}
|
|
173
175
|
return config;
|
|
174
176
|
});
|
|
175
|
-
stellar_sdk_1.Horizon.AxiosClient.interceptors.response.use(response => {
|
|
177
|
+
stellar_sdk_1.Horizon.AxiosClient.interceptors.response.use((response) => {
|
|
176
178
|
let enableNetworkLogs = false;
|
|
177
179
|
try {
|
|
178
180
|
enableNetworkLogs = !!config_1.default.getCoinConfig().enableNetworkLogs;
|
|
@@ -184,7 +186,7 @@ function registerHorizonInterceptors() {
|
|
|
184
186
|
// response.config is typed as `any` in stellar-sdk's HttpClientResponse
|
|
185
187
|
const startTime = requestStartTimes.get(response.config) ?? 0;
|
|
186
188
|
requestStartTimes.delete(response.config);
|
|
187
|
-
(0, logs_1.log)(
|
|
189
|
+
(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
190
|
}
|
|
189
191
|
// FIXME: workaround for the Stellar SDK not using the correct URL: the "next" URL
|
|
190
192
|
// included in server responses points to the node itself instead of our reverse proxy...
|
|
@@ -261,20 +263,20 @@ async function fetchBaseFee() {
|
|
|
261
263
|
async function fetchAccount(addr) {
|
|
262
264
|
let account = {};
|
|
263
265
|
let assets = [];
|
|
264
|
-
let balance =
|
|
266
|
+
let balance = '0';
|
|
265
267
|
try {
|
|
266
268
|
account = await getServer().accounts().accountId(addr).call();
|
|
267
269
|
balance =
|
|
268
|
-
account.balances?.find(balance => {
|
|
269
|
-
return balance.asset_type ===
|
|
270
|
-
})?.balance ||
|
|
270
|
+
account.balances?.find((balance) => {
|
|
271
|
+
return balance.asset_type === 'native';
|
|
272
|
+
})?.balance || '0';
|
|
271
273
|
// Getting all non-native (XLM) assets on the account
|
|
272
|
-
assets = account.balances?.filter(balance => {
|
|
273
|
-
return balance.asset_type !==
|
|
274
|
+
assets = account.balances?.filter((balance) => {
|
|
275
|
+
return balance.asset_type !== 'native';
|
|
274
276
|
});
|
|
275
277
|
}
|
|
276
278
|
catch {
|
|
277
|
-
balance =
|
|
279
|
+
balance = '0';
|
|
278
280
|
}
|
|
279
281
|
const formattedBalance = (0, common_1.parseAPIValue)(balance);
|
|
280
282
|
const spendableBalance = await getAccountSpendableBalance(formattedBalance, account);
|
|
@@ -296,7 +298,7 @@ async function fetchAccount(addr) {
|
|
|
296
298
|
*
|
|
297
299
|
* @return {Operation[]}
|
|
298
300
|
*/
|
|
299
|
-
async function fetchAllOperations(accountId, addr, order, cursor =
|
|
301
|
+
async function fetchAllOperations(accountId, addr, order, cursor = '', maxOperations) {
|
|
300
302
|
if (!addr) {
|
|
301
303
|
return [];
|
|
302
304
|
}
|
|
@@ -311,7 +313,7 @@ async function fetchAllOperations(accountId, addr, order, cursor = "", maxOperat
|
|
|
311
313
|
.order(order)
|
|
312
314
|
.cursor(cursor)
|
|
313
315
|
.includeFailed(true)
|
|
314
|
-
.join(
|
|
316
|
+
.join('transactions')
|
|
315
317
|
.call();
|
|
316
318
|
if (!rawOperations || !rawOperations.records.length) {
|
|
317
319
|
return [];
|
|
@@ -330,7 +332,7 @@ async function fetchAllOperations(accountId, addr, order, cursor = "", maxOperat
|
|
|
330
332
|
catch (e) {
|
|
331
333
|
// FIXME: terrible hacks, because Stellar SDK fails to cast network failures to typed errors in react-native...
|
|
332
334
|
// (https://github.com/stellar/js-stellar-sdk/issues/638)
|
|
333
|
-
const errorMsg = e ? String(e) :
|
|
335
|
+
const errorMsg = e ? String(e) : '';
|
|
334
336
|
if (e instanceof stellar_sdk_1.NotFoundError || errorMsg.match(/status code 404/)) {
|
|
335
337
|
return [];
|
|
336
338
|
}
|
|
@@ -350,7 +352,7 @@ async function fetchAllOperations(accountId, addr, order, cursor = "", maxOperat
|
|
|
350
352
|
}
|
|
351
353
|
// https://developers.stellar.org/docs/data/horizon/api-reference/get-operations-by-account-id
|
|
352
354
|
async function fetchOperations({ accountId, addr, minHeight, order, cursor, limit, }) {
|
|
353
|
-
const noResult = { items: [], next:
|
|
355
|
+
const noResult = { items: [], next: '' };
|
|
354
356
|
if (!addr) {
|
|
355
357
|
return noResult;
|
|
356
358
|
}
|
|
@@ -361,9 +363,9 @@ async function fetchOperations({ accountId, addr, minHeight, order, cursor, limi
|
|
|
361
363
|
.forAccount(addr)
|
|
362
364
|
.limit(requestedLimit)
|
|
363
365
|
.order(order)
|
|
364
|
-
.cursor(cursor ??
|
|
366
|
+
.cursor(cursor ?? '')
|
|
365
367
|
.includeFailed(true)
|
|
366
|
-
.join(
|
|
368
|
+
.join('transactions')
|
|
367
369
|
.call();
|
|
368
370
|
if (!rawOperations || !rawOperations.records.length) {
|
|
369
371
|
return noResult;
|
|
@@ -372,7 +374,7 @@ async function fetchOperations({ accountId, addr, minHeight, order, cursor, limi
|
|
|
372
374
|
const filteredOps = await (0, serialization_1.rawOperationsToOperations)(rawOps, addr, accountId, minHeight);
|
|
373
375
|
// Always return the cursor so the caller can continue pagination,
|
|
374
376
|
// even when filteredOps is empty (e.g. page of unsupported types).
|
|
375
|
-
const nextCursor = rawOps.length < requestedLimit ?
|
|
377
|
+
const nextCursor = rawOps.length < requestedLimit ? '' : rawOps[rawOps.length - 1].paging_token;
|
|
376
378
|
return { items: filteredOps, next: nextCursor };
|
|
377
379
|
}
|
|
378
380
|
catch (e) {
|
|
@@ -380,12 +382,12 @@ async function fetchOperations({ accountId, addr, minHeight, order, cursor, limi
|
|
|
380
382
|
// (https://github.com/stellar/js-stellar-sdk/issues/638)
|
|
381
383
|
// update 2025-04-01: in case of NetworkError, the error.response fields are undefined. Hence we cannot rely on status code
|
|
382
384
|
// the only way to check is the errror message, which may break at some point
|
|
383
|
-
const errorMsg = e ? String(e) :
|
|
385
|
+
const errorMsg = e ? String(e) : '';
|
|
384
386
|
if (e instanceof stellar_sdk_1.NotFoundError || errorMsg.match(/status code 404/)) {
|
|
385
387
|
return noResult;
|
|
386
388
|
}
|
|
387
389
|
if (errorMsg.match(/too many requests/i)) {
|
|
388
|
-
throw new errors_1.LedgerAPI4xx(
|
|
390
|
+
throw new errors_1.LedgerAPI4xx('status code 4xx', { status: 429, url: undefined, method: 'GET' });
|
|
389
391
|
}
|
|
390
392
|
if (errorMsg.match(/status code 4[0-9]{2}/)) {
|
|
391
393
|
throw new errors_1.LedgerAPI4xx();
|
|
@@ -407,7 +409,7 @@ async function fetchAccountNetworkInfo(account) {
|
|
|
407
409
|
const baseReserve = (0, serialization_1.getReservedBalance)(extendedAccount);
|
|
408
410
|
const { recommendedFee, networkCongestionLevel, baseFee } = await fetchBaseFee();
|
|
409
411
|
return {
|
|
410
|
-
family:
|
|
412
|
+
family: 'stellar',
|
|
411
413
|
fees: new bignumber_js_1.BigNumber(recommendedFee.toString()),
|
|
412
414
|
baseFee: new bignumber_js_1.BigNumber(baseFee.toString()),
|
|
413
415
|
baseReserve,
|
|
@@ -416,7 +418,7 @@ async function fetchAccountNetworkInfo(account) {
|
|
|
416
418
|
}
|
|
417
419
|
catch {
|
|
418
420
|
return {
|
|
419
|
-
family:
|
|
421
|
+
family: 'stellar',
|
|
420
422
|
fees: new bignumber_js_1.BigNumber(0),
|
|
421
423
|
baseFee: new bignumber_js_1.BigNumber(100),
|
|
422
424
|
baseReserve: new bignumber_js_1.BigNumber(0),
|
|
@@ -475,7 +477,7 @@ async function loadAccount(addr) {
|
|
|
475
477
|
}
|
|
476
478
|
}
|
|
477
479
|
async function getLastBlock() {
|
|
478
|
-
const ledger = await getServer().ledgers().order(
|
|
480
|
+
const ledger = await getServer().ledgers().order('desc').limit(1).call();
|
|
479
481
|
return {
|
|
480
482
|
height: ledger.records[0].sequence,
|
|
481
483
|
hash: ledger.records[0].hash,
|
|
@@ -513,8 +515,8 @@ async function fetchAllLedgerOperations(ledgerSequence) {
|
|
|
513
515
|
.operations()
|
|
514
516
|
.forLedger(ledgerSequence)
|
|
515
517
|
.includeFailed(true)
|
|
516
|
-
.join(
|
|
517
|
-
.order(
|
|
518
|
+
.join('transactions')
|
|
519
|
+
.order('asc')
|
|
518
520
|
.limit(limit)
|
|
519
521
|
.call();
|
|
520
522
|
const records = [...response.records];
|
|
@@ -531,10 +533,11 @@ async function fetchAllLedgerOperations(ledgerSequence) {
|
|
|
531
533
|
(0, horizonLedgerErrors_1.throwHorizonLedgerOrOperationsError)(e, `Stellar ledger ${ledgerSequence} not found`);
|
|
532
534
|
}
|
|
533
535
|
}
|
|
534
|
-
exports.getRecipientAccount = (0, cache_1.makeLRUCache)(async ({ recipient }) => await recipientAccount(recipient), extract => extract.recipient, {
|
|
536
|
+
exports.getRecipientAccount = (0, cache_1.makeLRUCache)(async ({ recipient }) => await recipientAccount(recipient), (extract) => extract.recipient, {
|
|
535
537
|
max: 300,
|
|
536
538
|
ttl: 5 * 60,
|
|
537
|
-
}
|
|
539
|
+
} // 5 minutes
|
|
540
|
+
);
|
|
538
541
|
async function recipientAccount(address) {
|
|
539
542
|
if (!address) {
|
|
540
543
|
return null;
|
|
@@ -542,7 +545,7 @@ async function recipientAccount(address) {
|
|
|
542
545
|
let accountAddress = address;
|
|
543
546
|
const isMuxedAccount = stellar_sdk_1.StrKey.isValidMed25519PublicKey(address);
|
|
544
547
|
if (isMuxedAccount) {
|
|
545
|
-
const muxedAccount = stellar_sdk_1.MuxedAccount.fromAddress(address,
|
|
548
|
+
const muxedAccount = stellar_sdk_1.MuxedAccount.fromAddress(address, '0');
|
|
546
549
|
accountAddress = muxedAccount.baseAccount().accountId();
|
|
547
550
|
}
|
|
548
551
|
const account = await loadAccount(accountAddress);
|
|
@@ -559,12 +562,12 @@ async function recipientAccount(address) {
|
|
|
559
562
|
}
|
|
560
563
|
function getBalanceId(balance) {
|
|
561
564
|
switch (balance.asset_type) {
|
|
562
|
-
case
|
|
563
|
-
return
|
|
564
|
-
case
|
|
565
|
+
case 'native':
|
|
566
|
+
return 'native';
|
|
567
|
+
case 'liquidity_pool_shares':
|
|
565
568
|
return balance.liquidity_pool_id || null;
|
|
566
|
-
case
|
|
567
|
-
case
|
|
569
|
+
case 'credit_alphanum4':
|
|
570
|
+
case 'credit_alphanum12':
|
|
568
571
|
return `${balance.asset_code}:${balance.asset_issuer}`;
|
|
569
572
|
default:
|
|
570
573
|
return null;
|