@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAGA,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
|
package/lib-es/types/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,sCAAsC;AAEtC,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
|
package/lib-es/types/model.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Horizon } from
|
|
2
|
-
import
|
|
1
|
+
import { Horizon } from '@stellar/stellar-sdk';
|
|
2
|
+
import BigNumber from 'bignumber.js';
|
|
3
3
|
export type NetworkInfo = {
|
|
4
|
-
family:
|
|
4
|
+
family: 'stellar';
|
|
5
5
|
fees: BigNumber;
|
|
6
6
|
baseFee: BigNumber;
|
|
7
7
|
baseReserve: BigNumber;
|
|
8
8
|
networkCongestionLevel?: NetworkCongestionLevel | undefined;
|
|
9
9
|
};
|
|
10
10
|
export type NetworkInfoRaw = {
|
|
11
|
-
family:
|
|
11
|
+
family: 'stellar';
|
|
12
12
|
fees: string;
|
|
13
13
|
baseFee: string;
|
|
14
14
|
baseReserve: string;
|
|
@@ -22,9 +22,9 @@ export declare enum NetworkCongestionLevel {
|
|
|
22
22
|
export declare const StellarMemoType: readonly ["NO_MEMO", "MEMO_TEXT", "MEMO_ID", "MEMO_HASH", "MEMO_RETURN"];
|
|
23
23
|
export type StellarMemoKind = (typeof StellarMemoType)[number];
|
|
24
24
|
export type StellarMemo = {
|
|
25
|
-
type:
|
|
25
|
+
type: 'NO_MEMO';
|
|
26
26
|
} | {
|
|
27
|
-
type: Exclude<StellarMemoKind,
|
|
27
|
+
type: Exclude<StellarMemoKind, 'NO_MEMO'>;
|
|
28
28
|
value: string;
|
|
29
29
|
};
|
|
30
30
|
export type RawOperation = Horizon.ServerApi.OperationRecord & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/types/model.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/types/model.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,OAAO,SAAS,MAAM,cAAc,CAAA;AAEpC,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,SAAS,CAAA;IACjB,IAAI,EAAE,SAAS,CAAA;IACf,OAAO,EAAE,SAAS,CAAA;IAClB,WAAW,EAAE,SAAS,CAAA;IACtB,sBAAsB,CAAC,EAAE,sBAAsB,GAAG,SAAS,CAAA;CAC5D,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,SAAS,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,sBAAsB,CAAC,EAAE,sBAAsB,GAAG,SAAS,CAAA;CAC5D,CAAA;AAED,oBAAY,sBAAsB;IAChC,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,IAAI,SAAS;CACd;AAED,eAAO,MAAM,eAAe,0EAMlB,CAAA;AAGV,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAA;AAE9D,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,OAAO,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAEhE,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,eAAe,GAAG;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,sBAAsB,EAAE,OAAO,CAAA;CAChC,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,kBAAkB,EAAE,MAAM,CAAA;IAC1B,mBAAmB,EAAE,MAAM,CAAA;IAC3B,oBAAoB,EAAE,MAAM,CAAA;IAC5B,aAAa,EAAE,OAAO,CAAA;IACtB,qCAAqC,EAAE,OAAO,CAAA;IAC9C,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,MAAM,GAAG;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;CACb,CAAA"}
|
package/lib-es/types/model.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
1
3
|
export var NetworkCongestionLevel;
|
|
2
4
|
(function (NetworkCongestionLevel) {
|
|
3
5
|
NetworkCongestionLevel["LOW"] = "LOW";
|
|
@@ -5,10 +7,10 @@ export var NetworkCongestionLevel;
|
|
|
5
7
|
NetworkCongestionLevel["HIGH"] = "HIGH";
|
|
6
8
|
})(NetworkCongestionLevel || (NetworkCongestionLevel = {}));
|
|
7
9
|
export const StellarMemoType = [
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
'NO_MEMO',
|
|
11
|
+
'MEMO_TEXT',
|
|
12
|
+
'MEMO_ID',
|
|
13
|
+
'MEMO_HASH',
|
|
14
|
+
'MEMO_RETURN',
|
|
13
15
|
];
|
|
14
16
|
//# sourceMappingURL=model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/types/model.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/types/model.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,sCAAsC;AAqBtC,MAAM,CAAN,IAAY,sBAIX;AAJD,WAAY,sBAAsB;IAChC,qCAAW,CAAA;IACX,2CAAiB,CAAA;IACjB,uCAAa,CAAA;AACf,CAAC,EAJW,sBAAsB,KAAtB,sBAAsB,QAIjC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,SAAS;IACT,WAAW;IACX,SAAS;IACT,WAAW;IACX,aAAa;CACL,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-stellar",
|
|
3
|
-
"version": "6.26.
|
|
3
|
+
"version": "6.26.2",
|
|
4
4
|
"description": "Ledger Stellar Coin integration",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
],
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "https://github.com/LedgerHQ/
|
|
14
|
+
"url": "https://github.com/LedgerHQ/coin-modules.git"
|
|
15
15
|
},
|
|
16
16
|
"bugs": {
|
|
17
|
-
"url": "https://github.com/LedgerHQ/
|
|
17
|
+
"url": "https://github.com/LedgerHQ/coin-modules/issues"
|
|
18
18
|
},
|
|
19
|
-
"homepage": "https://github.com/LedgerHQ/
|
|
19
|
+
"homepage": "https://github.com/LedgerHQ/coin-modules/tree/main/libs/coin-modules/coin-stellar",
|
|
20
20
|
"publishConfig": {
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
@@ -79,27 +79,24 @@
|
|
|
79
79
|
"./package.json": "./package.json"
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@ledgerhq/coin-module-framework": "3.5.1",
|
|
83
82
|
"@stellar/stellar-sdk": "^14.0.0",
|
|
84
83
|
"bignumber.js": "^9.1.2",
|
|
85
|
-
"invariant": "^2.2.2",
|
|
86
84
|
"@exodus/patch-broken-hermes-typed-arrays": "1.0.0-alpha.1",
|
|
87
|
-
"@ledgerhq/
|
|
88
|
-
|
|
85
|
+
"@ledgerhq/coin-module-framework": "^3.6.0"
|
|
86
|
+
},
|
|
87
|
+
"peerDependencies": {
|
|
88
|
+
"@ledgerhq/errors": "^6.33.0",
|
|
89
|
+
"@ledgerhq/live-network": "^2.4.0",
|
|
89
90
|
"@ledgerhq/logs": "^6.17.0"
|
|
90
91
|
},
|
|
91
92
|
"devDependencies": {
|
|
92
93
|
"@swc/core": "1.15.11",
|
|
93
94
|
"@swc/jest": "0.2.39",
|
|
94
|
-
"@types/
|
|
95
|
-
"@types/
|
|
96
|
-
"@types/node": "24.12.0",
|
|
95
|
+
"@types/jest": "^30.0.0",
|
|
96
|
+
"@types/node": "^24.0.0",
|
|
97
97
|
"jest": "30.2.0",
|
|
98
|
-
"msw": "^2.7.3",
|
|
99
|
-
"nock": "14.0.2",
|
|
100
98
|
"oxfmt": "0.36.0",
|
|
101
|
-
"oxlint": "1.51.0"
|
|
102
|
-
"@ledgerhq/disable-network-setup": "^0.3.0"
|
|
99
|
+
"oxlint": "1.51.0"
|
|
103
100
|
},
|
|
104
101
|
"scripts": {
|
|
105
102
|
"clean": "rimraf lib lib-es",
|
|
@@ -116,7 +113,7 @@
|
|
|
116
113
|
"test-integ": "jest --config=jest.integ.config.js",
|
|
117
114
|
"test-integ:debug": "node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand --config=jest.integ.config.js",
|
|
118
115
|
"typecheck": "tsc --noEmit --customConditions node",
|
|
119
|
-
"unimported": "
|
|
116
|
+
"unimported": "knip --include=files,dependencies",
|
|
120
117
|
"format": "oxfmt src",
|
|
121
118
|
"format:check": "oxfmt src --check"
|
|
122
119
|
}
|
|
@@ -1,263 +1,268 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
1
|
+
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { CoinModuleApi, Operation } from '@ledgerhq/coin-module-framework/api/index'
|
|
5
|
+
import { xdr } from '@stellar/stellar-sdk'
|
|
6
|
+
import { StellarMemo } from '../types'
|
|
7
|
+
import { createApi, envelopeFromAnyXDR } from '.'
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
* Mainnet explorer: https://stellar.expert/explorer/public
|
|
8
11
|
*/
|
|
9
|
-
describe(
|
|
10
|
-
let module: CoinModuleApi<StellarMemo
|
|
11
|
-
const ADDRESS =
|
|
12
|
+
describe('Stellar Api', () => {
|
|
13
|
+
let module: CoinModuleApi<StellarMemo>
|
|
14
|
+
const ADDRESS = 'GBAMU3EJX6KLW2JEIAIEAYNLPKHFPJR6OYQYX5HPYB3CVQ6QD4XUJ23J'
|
|
12
15
|
|
|
13
16
|
beforeAll(() => {
|
|
14
17
|
module = createApi({
|
|
15
18
|
explorer: {
|
|
16
|
-
url:
|
|
19
|
+
url: 'https://stellar.coin.ledger.com',
|
|
17
20
|
},
|
|
18
|
-
})
|
|
19
|
-
})
|
|
21
|
+
})
|
|
22
|
+
})
|
|
20
23
|
|
|
21
|
-
describe(
|
|
22
|
-
it(
|
|
24
|
+
describe('estimateFees', () => {
|
|
25
|
+
it('returns a default value', async () => {
|
|
23
26
|
// Given
|
|
24
|
-
const amount = BigInt(100_000)
|
|
27
|
+
const amount = BigInt(100_000)
|
|
25
28
|
|
|
26
29
|
// When
|
|
27
30
|
const result = await module.estimateFees({
|
|
28
|
-
intentType:
|
|
29
|
-
asset: { type:
|
|
30
|
-
type:
|
|
31
|
+
intentType: 'transaction',
|
|
32
|
+
asset: { type: 'native' },
|
|
33
|
+
type: 'send',
|
|
31
34
|
sender: ADDRESS,
|
|
32
|
-
recipient:
|
|
35
|
+
recipient: 'address',
|
|
33
36
|
amount: amount,
|
|
34
|
-
memo: { type:
|
|
35
|
-
})
|
|
37
|
+
memo: { type: 'NO_MEMO' },
|
|
38
|
+
})
|
|
36
39
|
|
|
37
|
-
expect(result.value).toBeGreaterThanOrEqual(100n)
|
|
38
|
-
})
|
|
39
|
-
})
|
|
40
|
+
expect(result.value).toBeGreaterThanOrEqual(100n)
|
|
41
|
+
})
|
|
42
|
+
})
|
|
40
43
|
|
|
41
|
-
describe(
|
|
42
|
-
let txs: Operation[]
|
|
43
|
-
let nextCursor: string | undefined
|
|
44
|
+
describe('listOperations', () => {
|
|
45
|
+
let txs: Operation[]
|
|
46
|
+
let nextCursor: string | undefined
|
|
44
47
|
|
|
45
48
|
beforeAll(async () => {
|
|
46
49
|
const result = await module.listOperations(ADDRESS, {
|
|
47
50
|
minHeight: 0,
|
|
48
|
-
order:
|
|
49
|
-
})
|
|
50
|
-
txs = result.items
|
|
51
|
-
nextCursor = result.next
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
it(
|
|
55
|
-
expect(txs.length).toBeGreaterThanOrEqual(1)
|
|
56
|
-
txs.forEach(operation => {
|
|
51
|
+
order: 'asc',
|
|
52
|
+
})
|
|
53
|
+
txs = result.items
|
|
54
|
+
nextCursor = result.next
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('returns a page of operations for the address', async () => {
|
|
58
|
+
expect(txs.length).toBeGreaterThanOrEqual(1)
|
|
59
|
+
txs.forEach((operation) => {
|
|
57
60
|
const isSenderOrReceipt =
|
|
58
|
-
operation.senders.includes(ADDRESS) || operation.recipients.includes(ADDRESS)
|
|
59
|
-
expect(isSenderOrReceipt).toBe(true)
|
|
60
|
-
expect(operation.value).toBeGreaterThanOrEqual(0)
|
|
61
|
-
expect(operation.tx.hash).toMatch(/^[A-Fa-f0-9]{64}$/)
|
|
62
|
-
expect(operation.tx.block.hash).toMatch(/^[A-Fa-f0-9]{64}$/)
|
|
63
|
-
expect(operation.tx.block.height).toBeGreaterThanOrEqual(0)
|
|
64
|
-
expect(operation.tx.fees).toBeGreaterThan(0)
|
|
65
|
-
expect(operation.tx.date).toBeInstanceOf(Date)
|
|
66
|
-
expect(operation.tx.feesPayer).toMatch(/^G[A-Z2-7]{55}$/)
|
|
67
|
-
})
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
it(
|
|
71
|
-
expect(txs.length).toBeGreaterThanOrEqual(1)
|
|
72
|
-
const checkSet = new Set(txs.map(elt => elt.id))
|
|
73
|
-
expect(checkSet.size).toEqual(txs.length)
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
it(
|
|
61
|
+
operation.senders.includes(ADDRESS) || operation.recipients.includes(ADDRESS)
|
|
62
|
+
expect(isSenderOrReceipt).toBe(true)
|
|
63
|
+
expect(operation.value).toBeGreaterThanOrEqual(0)
|
|
64
|
+
expect(operation.tx.hash).toMatch(/^[A-Fa-f0-9]{64}$/)
|
|
65
|
+
expect(operation.tx.block.hash).toMatch(/^[A-Fa-f0-9]{64}$/)
|
|
66
|
+
expect(operation.tx.block.height).toBeGreaterThanOrEqual(0)
|
|
67
|
+
expect(operation.tx.fees).toBeGreaterThan(0)
|
|
68
|
+
expect(operation.tx.date).toBeInstanceOf(Date)
|
|
69
|
+
expect(operation.tx.feesPayer).toMatch(/^G[A-Z2-7]{55}$/)
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it('returns unique operations within the page', async () => {
|
|
74
|
+
expect(txs.length).toBeGreaterThanOrEqual(1)
|
|
75
|
+
const checkSet = new Set(txs.map((elt) => elt.id))
|
|
76
|
+
expect(checkSet.size).toEqual(txs.length)
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
it('returns a cursor for pagination when more pages exist', async () => {
|
|
77
80
|
// The test account has enough operations to fill at least one page
|
|
78
|
-
expect(typeof nextCursor).toBe(
|
|
79
|
-
})
|
|
81
|
+
expect(typeof nextCursor).toBe('string')
|
|
82
|
+
})
|
|
80
83
|
|
|
81
|
-
it(
|
|
82
|
-
if (!nextCursor) return
|
|
84
|
+
it('supports cursor-based pagination', async () => {
|
|
85
|
+
if (!nextCursor) return // skip if account has fewer ops than page size
|
|
83
86
|
const page2 = await module.listOperations(ADDRESS, {
|
|
84
87
|
minHeight: 0,
|
|
85
|
-
order:
|
|
88
|
+
order: 'asc',
|
|
86
89
|
cursor: nextCursor,
|
|
87
|
-
})
|
|
88
|
-
expect(page2.items.length).toBeGreaterThanOrEqual(1)
|
|
90
|
+
})
|
|
91
|
+
expect(page2.items.length).toBeGreaterThanOrEqual(1)
|
|
89
92
|
// No overlap between pages
|
|
90
|
-
const page1Ids = new Set(txs.map(op => op.id))
|
|
91
|
-
page2.items.forEach(op => {
|
|
92
|
-
expect(page1Ids.has(op.id)).toBe(false)
|
|
93
|
-
})
|
|
94
|
-
})
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
describe(
|
|
98
|
-
it(
|
|
93
|
+
const page1Ids = new Set(txs.map((op) => op.id))
|
|
94
|
+
page2.items.forEach((op) => {
|
|
95
|
+
expect(page1Ids.has(op.id)).toBe(false)
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
describe('lastBlock', () => {
|
|
101
|
+
it('returns last block info', async () => {
|
|
99
102
|
// When
|
|
100
|
-
const result = await module.lastBlock()
|
|
103
|
+
const result = await module.lastBlock()
|
|
101
104
|
|
|
102
105
|
// Then
|
|
103
|
-
expect(result.hash).toMatch(/^[A-Fa-f0-9]{64}$/)
|
|
104
|
-
expect(result.height).toBeGreaterThan(0)
|
|
105
|
-
expect(result.time).toBeInstanceOf(Date)
|
|
106
|
-
})
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
describe(
|
|
110
|
-
it(
|
|
106
|
+
expect(result.hash).toMatch(/^[A-Fa-f0-9]{64}$/)
|
|
107
|
+
expect(result.height).toBeGreaterThan(0)
|
|
108
|
+
expect(result.time).toBeInstanceOf(Date)
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
describe('getBalance', () => {
|
|
113
|
+
it('returns a list regarding address parameter', async () => {
|
|
111
114
|
// When
|
|
112
|
-
const result = await module.getBalance(ADDRESS)
|
|
115
|
+
const result = await module.getBalance(ADDRESS)
|
|
113
116
|
|
|
114
117
|
// Then
|
|
115
|
-
expect(result).toBeInstanceOf(Array)
|
|
118
|
+
expect(result).toBeInstanceOf(Array)
|
|
116
119
|
expect(result[0]).toMatchObject({
|
|
117
120
|
value: expect.any(BigInt),
|
|
118
|
-
asset: { type:
|
|
119
|
-
})
|
|
120
|
-
expect(result[0].value).toBeGreaterThan(0)
|
|
121
|
-
result.slice(1).forEach(balance => {
|
|
122
|
-
expect(balance.asset.type).not.toEqual(
|
|
123
|
-
expect(balance.value).toBeGreaterThanOrEqual(0)
|
|
124
|
-
})
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
it(
|
|
121
|
+
asset: { type: 'native' },
|
|
122
|
+
})
|
|
123
|
+
expect(result[0].value).toBeGreaterThan(0)
|
|
124
|
+
result.slice(1).forEach((balance) => {
|
|
125
|
+
expect(balance.asset.type).not.toEqual('native')
|
|
126
|
+
expect(balance.value).toBeGreaterThanOrEqual(0)
|
|
127
|
+
})
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
it('returns 0 when address is not found', async () => {
|
|
128
131
|
const result = await module.getBalance(
|
|
129
|
-
|
|
130
|
-
)
|
|
132
|
+
'GAJSV2O545Z6ZK7FTPW2GOYNKMYJMP2REUJV4AW6DSYTYUHVI3000000'
|
|
133
|
+
)
|
|
131
134
|
|
|
132
|
-
expect(result).toEqual([{ value: BigInt(0), asset: { type:
|
|
133
|
-
})
|
|
134
|
-
})
|
|
135
|
+
expect(result).toEqual([{ value: BigInt(0), asset: { type: 'native' }, locked: 0n }])
|
|
136
|
+
})
|
|
137
|
+
})
|
|
135
138
|
|
|
136
|
-
describe(
|
|
137
|
-
const TYPE =
|
|
138
|
-
const RECIPIENT =
|
|
139
|
-
const AMOUNT = BigInt(1_000_000)
|
|
139
|
+
describe('craftTransaction', () => {
|
|
140
|
+
const TYPE = 'send'
|
|
141
|
+
const RECIPIENT = 'GD6QELUZPSKPRWVXOQ3F6GBF4OBRMCHO5PHREXH4ZRTPJAG7V5MD7JGX'
|
|
142
|
+
const AMOUNT = BigInt(1_000_000)
|
|
140
143
|
|
|
141
144
|
function readFees(transactionXdr: string) {
|
|
142
|
-
const transactionEnvelope = envelopeFromAnyXDR(transactionXdr,
|
|
143
|
-
return transactionEnvelope.value().tx().fee()
|
|
145
|
+
const transactionEnvelope = envelopeFromAnyXDR(transactionXdr, 'base64')
|
|
146
|
+
return transactionEnvelope.value().tx().fee()
|
|
144
147
|
}
|
|
145
148
|
|
|
146
149
|
function readMemo(transactionXdr: string) {
|
|
147
|
-
const transactionEnvelope = envelopeFromAnyXDR(transactionXdr,
|
|
148
|
-
return (transactionEnvelope.value().tx() as xdr.TransactionV0).memo()
|
|
150
|
+
const transactionEnvelope = envelopeFromAnyXDR(transactionXdr, 'base64')
|
|
151
|
+
return (transactionEnvelope.value().tx() as xdr.TransactionV0).memo()
|
|
149
152
|
}
|
|
150
153
|
|
|
151
|
-
it(
|
|
154
|
+
it('returns a raw transaction', async () => {
|
|
152
155
|
const { transaction: result } = await module.craftTransaction({
|
|
153
|
-
intentType:
|
|
154
|
-
asset: { type:
|
|
156
|
+
intentType: 'transaction',
|
|
157
|
+
asset: { type: 'native' },
|
|
155
158
|
type: TYPE,
|
|
156
159
|
sender: ADDRESS,
|
|
157
160
|
recipient: RECIPIENT,
|
|
158
161
|
amount: AMOUNT,
|
|
159
|
-
memo: { type:
|
|
160
|
-
})
|
|
162
|
+
memo: { type: 'NO_MEMO' },
|
|
163
|
+
})
|
|
161
164
|
|
|
162
|
-
const envelope = envelopeFromAnyXDR(result,
|
|
165
|
+
const envelope = envelopeFromAnyXDR(result, 'base64')
|
|
163
166
|
|
|
164
|
-
expect(envelope.toXDR(
|
|
165
|
-
})
|
|
167
|
+
expect(envelope.toXDR('base64').length).toEqual(188)
|
|
168
|
+
})
|
|
166
169
|
|
|
167
|
-
it(
|
|
170
|
+
it('should use estimated fees when user does not provide them for crafting a transaction', async () => {
|
|
168
171
|
const { transaction: transactionXdr } = await module.craftTransaction({
|
|
169
|
-
intentType:
|
|
170
|
-
asset: { type:
|
|
172
|
+
intentType: 'transaction',
|
|
173
|
+
asset: { type: 'native' },
|
|
171
174
|
type: TYPE,
|
|
172
175
|
sender: ADDRESS,
|
|
173
176
|
recipient: RECIPIENT,
|
|
174
177
|
amount: AMOUNT,
|
|
175
|
-
memo: { type:
|
|
176
|
-
})
|
|
178
|
+
memo: { type: 'NO_MEMO' },
|
|
179
|
+
})
|
|
177
180
|
|
|
178
|
-
const fees = readFees(transactionXdr)
|
|
179
|
-
expect(fees).toBeGreaterThan(0)
|
|
180
|
-
})
|
|
181
|
+
const fees = readFees(transactionXdr)
|
|
182
|
+
expect(fees).toBeGreaterThan(0)
|
|
183
|
+
})
|
|
181
184
|
|
|
182
|
-
it(
|
|
183
|
-
const customFees = 99n
|
|
185
|
+
it('should use custom user fees when user provides it for crafting a transaction', async () => {
|
|
186
|
+
const customFees = 99n
|
|
184
187
|
const { transaction: transactionXdr } = await module.craftTransaction(
|
|
185
188
|
{
|
|
186
|
-
intentType:
|
|
187
|
-
asset: { type:
|
|
189
|
+
intentType: 'transaction',
|
|
190
|
+
asset: { type: 'native' },
|
|
188
191
|
type: TYPE,
|
|
189
192
|
sender: ADDRESS,
|
|
190
193
|
recipient: RECIPIENT,
|
|
191
194
|
amount: AMOUNT,
|
|
192
|
-
memo: { type:
|
|
195
|
+
memo: { type: 'NO_MEMO' },
|
|
193
196
|
},
|
|
194
|
-
{ value: customFees }
|
|
195
|
-
)
|
|
197
|
+
{ value: customFees }
|
|
198
|
+
)
|
|
196
199
|
|
|
197
|
-
const fees = readFees(transactionXdr)
|
|
198
|
-
expect(fees).toEqual(Number(customFees))
|
|
199
|
-
})
|
|
200
|
+
const fees = readFees(transactionXdr)
|
|
201
|
+
expect(fees).toEqual(Number(customFees))
|
|
202
|
+
})
|
|
200
203
|
|
|
201
|
-
it(
|
|
204
|
+
it('should have no memo when not provided by user', async () => {
|
|
202
205
|
const { transaction: transactionXdr } = await module.craftTransaction({
|
|
203
|
-
intentType:
|
|
204
|
-
asset: { type:
|
|
206
|
+
intentType: 'transaction',
|
|
207
|
+
asset: { type: 'native' },
|
|
205
208
|
type: TYPE,
|
|
206
209
|
sender: ADDRESS,
|
|
207
210
|
recipient: RECIPIENT,
|
|
208
211
|
amount: AMOUNT,
|
|
209
|
-
memo: { type:
|
|
210
|
-
})
|
|
211
|
-
expect(readMemo(transactionXdr)).toEqual(xdr.Memo.memoNone())
|
|
212
|
-
})
|
|
212
|
+
memo: { type: 'NO_MEMO' },
|
|
213
|
+
})
|
|
214
|
+
expect(readMemo(transactionXdr)).toEqual(xdr.Memo.memoNone())
|
|
215
|
+
})
|
|
213
216
|
|
|
214
|
-
it(
|
|
217
|
+
it('should have a memo when provided by user', async () => {
|
|
215
218
|
const { transaction: transactionXdr } = await module.craftTransaction({
|
|
216
|
-
intentType:
|
|
217
|
-
asset: { type:
|
|
219
|
+
intentType: 'transaction',
|
|
220
|
+
asset: { type: 'native' },
|
|
218
221
|
type: TYPE,
|
|
219
222
|
sender: ADDRESS,
|
|
220
223
|
recipient: RECIPIENT,
|
|
221
224
|
amount: AMOUNT,
|
|
222
225
|
memo: {
|
|
223
|
-
type:
|
|
224
|
-
value:
|
|
226
|
+
type: 'MEMO_TEXT',
|
|
227
|
+
value: 'test',
|
|
225
228
|
},
|
|
226
|
-
})
|
|
227
|
-
expect(readMemo(transactionXdr)).toEqual(xdr.Memo.memoText(Buffer.from(
|
|
228
|
-
})
|
|
229
|
-
})
|
|
229
|
+
})
|
|
230
|
+
expect(readMemo(transactionXdr)).toEqual(xdr.Memo.memoText(Buffer.from('test', 'ascii')))
|
|
231
|
+
})
|
|
232
|
+
})
|
|
230
233
|
|
|
231
234
|
/**
|
|
232
235
|
* Signed transaction envelope from BACK-10960 / Jira (mainnet).
|
|
233
|
-
* Live Horizon
|
|
236
|
+
* Live Horizon reports `tx_failed` with operation-level `op_underfunded`.
|
|
234
237
|
*/
|
|
235
|
-
describe(
|
|
236
|
-
let broadcastModule: CoinModuleApi<StellarMemo
|
|
238
|
+
describe('broadcast', () => {
|
|
239
|
+
let broadcastModule: CoinModuleApi<StellarMemo>
|
|
237
240
|
const tx =
|
|
238
|
-
|
|
241
|
+
'AAAAAgAAAABRUCgFba+DTbei2ifpyYt5w2Hh0VyZ+X9fayjIDne7YAAAAGQCkDOGAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAACEIuPfWXgM8WhyqjrpFdIcGV1SUVhMzPUm4YspNHF60QAAAAAAAAAAALkd2QAAAAAAAAABDne7YAAAAEAASzsT/yDIfCfEDstkfnznXjiN7rNd7PkKQEn+rRIFm9EHoirGfHipWoBdYMrc6ixQD/0y0of1piSid8TLiFAB'
|
|
239
242
|
beforeAll(() => {
|
|
240
243
|
broadcastModule = createApi({
|
|
241
244
|
explorer: {
|
|
242
|
-
url:
|
|
245
|
+
url: 'https://horizon.stellar.org/',
|
|
243
246
|
},
|
|
244
|
-
})
|
|
245
|
-
})
|
|
247
|
+
})
|
|
248
|
+
})
|
|
246
249
|
|
|
247
|
-
it(
|
|
250
|
+
it('maps Horizon transaction failure to StellarBroadcastFailedError with XDR context', async () => {
|
|
248
251
|
await expect(broadcastModule.broadcast(tx)).rejects.toMatchObject({
|
|
249
|
-
name:
|
|
250
|
-
documentationSummary:
|
|
251
|
-
|
|
252
|
+
name: 'StellarBroadcastFailedError',
|
|
253
|
+
documentationSummary:
|
|
254
|
+
'The source account does not have enough balance to send the payment amount while maintaining its minimum reserve.',
|
|
255
|
+
horizonTransactionCode: 'tx_failed',
|
|
256
|
+
horizonOperationCodes: ['op_underfunded'],
|
|
252
257
|
stellarDocUrl:
|
|
253
|
-
|
|
258
|
+
'https://developers.stellar.org/docs/data/apis/horizon/api-reference/errors/result-codes/transactions',
|
|
254
259
|
decodedResultXdr: {
|
|
255
260
|
feeChargedStroops: expect.stringMatching(/^\d+$/),
|
|
256
|
-
resultSwitch:
|
|
261
|
+
resultSwitch: 'txFailed',
|
|
257
262
|
},
|
|
258
263
|
envelopeXdr: tx,
|
|
259
|
-
cause: expect.objectContaining({ name:
|
|
260
|
-
})
|
|
261
|
-
})
|
|
262
|
-
})
|
|
263
|
-
})
|
|
264
|
+
cause: expect.objectContaining({ name: 'AxiosError' }),
|
|
265
|
+
})
|
|
266
|
+
})
|
|
267
|
+
})
|
|
268
|
+
})
|