@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.
Files changed (271) hide show
  1. package/.oxlintrc.json +7 -0
  2. package/CHANGELOG.md +6 -0
  3. package/LICENSE +194 -0
  4. package/knip.json +12 -0
  5. package/lib/api/index.d.ts +5 -5
  6. package/lib/api/index.d.ts.map +1 -1
  7. package/lib/api/index.js +12 -10
  8. package/lib/api/index.js.map +1 -1
  9. package/lib/config.d.ts +1 -1
  10. package/lib/config.d.ts.map +1 -1
  11. package/lib/config.js +2 -0
  12. package/lib/config.js.map +1 -1
  13. package/lib/constants.d.ts.map +1 -1
  14. package/lib/constants.js +3 -1
  15. package/lib/constants.js.map +1 -1
  16. package/lib/logic/broadcast.d.ts.map +1 -1
  17. package/lib/logic/broadcast.js +2 -0
  18. package/lib/logic/broadcast.js.map +1 -1
  19. package/lib/logic/combine.d.ts +1 -1
  20. package/lib/logic/combine.d.ts.map +1 -1
  21. package/lib/logic/combine.js +2 -0
  22. package/lib/logic/combine.js.map +1 -1
  23. package/lib/logic/common.d.ts +1 -1
  24. package/lib/logic/common.d.ts.map +1 -1
  25. package/lib/logic/common.js +4 -2
  26. package/lib/logic/common.js.map +1 -1
  27. package/lib/logic/craftTransaction.d.ts +1 -1
  28. package/lib/logic/craftTransaction.d.ts.map +1 -1
  29. package/lib/logic/craftTransaction.js +10 -8
  30. package/lib/logic/craftTransaction.js.map +1 -1
  31. package/lib/logic/estimateFees.d.ts.map +1 -1
  32. package/lib/logic/estimateFees.js +2 -0
  33. package/lib/logic/estimateFees.js.map +1 -1
  34. package/lib/logic/getBalance.d.ts +1 -1
  35. package/lib/logic/getBalance.d.ts.map +1 -1
  36. package/lib/logic/getBalance.js +4 -2
  37. package/lib/logic/getBalance.js.map +1 -1
  38. package/lib/logic/getBlock.d.ts +1 -1
  39. package/lib/logic/getBlock.d.ts.map +1 -1
  40. package/lib/logic/getBlock.js +39 -34
  41. package/lib/logic/getBlock.js.map +1 -1
  42. package/lib/logic/getBlockInfo.d.ts +1 -1
  43. package/lib/logic/getBlockInfo.d.ts.map +1 -1
  44. package/lib/logic/getBlockInfo.js +2 -0
  45. package/lib/logic/getBlockInfo.js.map +1 -1
  46. package/lib/logic/index.d.ts +12 -12
  47. package/lib/logic/index.d.ts.map +1 -1
  48. package/lib/logic/index.js +2 -0
  49. package/lib/logic/index.js.map +1 -1
  50. package/lib/logic/lastBlock.d.ts +1 -1
  51. package/lib/logic/lastBlock.d.ts.map +1 -1
  52. package/lib/logic/lastBlock.js +2 -0
  53. package/lib/logic/lastBlock.js.map +1 -1
  54. package/lib/logic/listOperations.d.ts +1 -1
  55. package/lib/logic/listOperations.d.ts.map +1 -1
  56. package/lib/logic/listOperations.js +6 -4
  57. package/lib/logic/listOperations.js.map +1 -1
  58. package/lib/logic/sdkWrapper.d.ts +1 -1
  59. package/lib/logic/sdkWrapper.d.ts.map +1 -1
  60. package/lib/logic/sdkWrapper.js +2 -0
  61. package/lib/logic/sdkWrapper.js.map +1 -1
  62. package/lib/logic/utils.d.ts.map +1 -1
  63. package/lib/logic/utils.js +4 -2
  64. package/lib/logic/utils.js.map +1 -1
  65. package/lib/logic/validateAddress.d.ts +1 -1
  66. package/lib/logic/validateAddress.d.ts.map +1 -1
  67. package/lib/logic/validateAddress.js +2 -0
  68. package/lib/logic/validateAddress.js.map +1 -1
  69. package/lib/logic/validateIntent.d.ts +2 -2
  70. package/lib/logic/validateIntent.d.ts.map +1 -1
  71. package/lib/logic/validateIntent.js +21 -19
  72. package/lib/logic/validateIntent.js.map +1 -1
  73. package/lib/logic/validateMemo.d.ts +1 -1
  74. package/lib/logic/validateMemo.d.ts.map +1 -1
  75. package/lib/logic/validateMemo.js +7 -5
  76. package/lib/logic/validateMemo.js.map +1 -1
  77. package/lib/network/horizon.d.ts +6 -7
  78. package/lib/network/horizon.d.ts.map +1 -1
  79. package/lib/network/horizon.js +71 -68
  80. package/lib/network/horizon.js.map +1 -1
  81. package/lib/network/horizonLedgerErrors.d.ts.map +1 -1
  82. package/lib/network/horizonLedgerErrors.js +5 -3
  83. package/lib/network/horizonLedgerErrors.js.map +1 -1
  84. package/lib/network/index.d.ts +1 -1
  85. package/lib/network/index.d.ts.map +1 -1
  86. package/lib/network/index.js +2 -0
  87. package/lib/network/index.js.map +1 -1
  88. package/lib/network/serialization.d.ts +6 -4
  89. package/lib/network/serialization.d.ts.map +1 -1
  90. package/lib/network/serialization.js +95 -91
  91. package/lib/network/serialization.js.map +1 -1
  92. package/lib/polyfill.d.ts.map +1 -1
  93. package/lib/polyfill.js +6 -4
  94. package/lib/polyfill.js.map +1 -1
  95. package/lib/supportedFeatures.d.ts +1 -1
  96. package/lib/supportedFeatures.d.ts.map +1 -1
  97. package/lib/supportedFeatures.js +3 -1
  98. package/lib/supportedFeatures.js.map +1 -1
  99. package/lib/types/errors.d.ts.map +1 -1
  100. package/lib/types/errors.js +14 -12
  101. package/lib/types/errors.js.map +1 -1
  102. package/lib/types/index.d.ts +2 -2
  103. package/lib/types/index.d.ts.map +1 -1
  104. package/lib/types/index.js +2 -0
  105. package/lib/types/index.js.map +1 -1
  106. package/lib/types/model.d.ts +6 -6
  107. package/lib/types/model.d.ts.map +1 -1
  108. package/lib/types/model.js +7 -5
  109. package/lib/types/model.js.map +1 -1
  110. package/lib-es/api/index.d.ts +5 -5
  111. package/lib-es/api/index.d.ts.map +1 -1
  112. package/lib-es/api/index.js +20 -18
  113. package/lib-es/api/index.js.map +1 -1
  114. package/lib-es/config.d.ts +1 -1
  115. package/lib-es/config.d.ts.map +1 -1
  116. package/lib-es/config.js +3 -1
  117. package/lib-es/config.js.map +1 -1
  118. package/lib-es/constants.d.ts.map +1 -1
  119. package/lib-es/constants.js +3 -1
  120. package/lib-es/constants.js.map +1 -1
  121. package/lib-es/logic/broadcast.d.ts.map +1 -1
  122. package/lib-es/logic/broadcast.js +3 -1
  123. package/lib-es/logic/broadcast.js.map +1 -1
  124. package/lib-es/logic/combine.d.ts +1 -1
  125. package/lib-es/logic/combine.d.ts.map +1 -1
  126. package/lib-es/logic/combine.js +3 -1
  127. package/lib-es/logic/combine.js.map +1 -1
  128. package/lib-es/logic/common.d.ts +1 -1
  129. package/lib-es/logic/common.d.ts.map +1 -1
  130. package/lib-es/logic/common.js +5 -3
  131. package/lib-es/logic/common.js.map +1 -1
  132. package/lib-es/logic/craftTransaction.d.ts +1 -1
  133. package/lib-es/logic/craftTransaction.d.ts.map +1 -1
  134. package/lib-es/logic/craftTransaction.js +15 -13
  135. package/lib-es/logic/craftTransaction.js.map +1 -1
  136. package/lib-es/logic/estimateFees.d.ts.map +1 -1
  137. package/lib-es/logic/estimateFees.js +3 -1
  138. package/lib-es/logic/estimateFees.js.map +1 -1
  139. package/lib-es/logic/getBalance.d.ts +1 -1
  140. package/lib-es/logic/getBalance.d.ts.map +1 -1
  141. package/lib-es/logic/getBalance.js +5 -3
  142. package/lib-es/logic/getBalance.js.map +1 -1
  143. package/lib-es/logic/getBlock.d.ts +1 -1
  144. package/lib-es/logic/getBlock.d.ts.map +1 -1
  145. package/lib-es/logic/getBlock.js +42 -37
  146. package/lib-es/logic/getBlock.js.map +1 -1
  147. package/lib-es/logic/getBlockInfo.d.ts +1 -1
  148. package/lib-es/logic/getBlockInfo.d.ts.map +1 -1
  149. package/lib-es/logic/getBlockInfo.js +3 -1
  150. package/lib-es/logic/getBlockInfo.js.map +1 -1
  151. package/lib-es/logic/index.d.ts +12 -12
  152. package/lib-es/logic/index.d.ts.map +1 -1
  153. package/lib-es/logic/index.js +14 -12
  154. package/lib-es/logic/index.js.map +1 -1
  155. package/lib-es/logic/lastBlock.d.ts +1 -1
  156. package/lib-es/logic/lastBlock.d.ts.map +1 -1
  157. package/lib-es/logic/lastBlock.js +3 -1
  158. package/lib-es/logic/lastBlock.js.map +1 -1
  159. package/lib-es/logic/listOperations.d.ts +1 -1
  160. package/lib-es/logic/listOperations.d.ts.map +1 -1
  161. package/lib-es/logic/listOperations.js +7 -5
  162. package/lib-es/logic/listOperations.js.map +1 -1
  163. package/lib-es/logic/sdkWrapper.d.ts +1 -1
  164. package/lib-es/logic/sdkWrapper.d.ts.map +1 -1
  165. package/lib-es/logic/sdkWrapper.js +4 -2
  166. package/lib-es/logic/sdkWrapper.js.map +1 -1
  167. package/lib-es/logic/utils.d.ts.map +1 -1
  168. package/lib-es/logic/utils.js +6 -4
  169. package/lib-es/logic/utils.js.map +1 -1
  170. package/lib-es/logic/validateAddress.d.ts +1 -1
  171. package/lib-es/logic/validateAddress.d.ts.map +1 -1
  172. package/lib-es/logic/validateAddress.js +3 -1
  173. package/lib-es/logic/validateAddress.js.map +1 -1
  174. package/lib-es/logic/validateIntent.d.ts +2 -2
  175. package/lib-es/logic/validateIntent.d.ts.map +1 -1
  176. package/lib-es/logic/validateIntent.js +30 -28
  177. package/lib-es/logic/validateIntent.js.map +1 -1
  178. package/lib-es/logic/validateMemo.d.ts +1 -1
  179. package/lib-es/logic/validateMemo.d.ts.map +1 -1
  180. package/lib-es/logic/validateMemo.js +8 -6
  181. package/lib-es/logic/validateMemo.js.map +1 -1
  182. package/lib-es/network/horizon.d.ts +6 -7
  183. package/lib-es/network/horizon.d.ts.map +1 -1
  184. package/lib-es/network/horizon.js +80 -77
  185. package/lib-es/network/horizon.js.map +1 -1
  186. package/lib-es/network/horizonLedgerErrors.d.ts.map +1 -1
  187. package/lib-es/network/horizonLedgerErrors.js +7 -5
  188. package/lib-es/network/horizonLedgerErrors.js.map +1 -1
  189. package/lib-es/network/index.d.ts +1 -1
  190. package/lib-es/network/index.d.ts.map +1 -1
  191. package/lib-es/network/index.js +3 -1
  192. package/lib-es/network/index.js.map +1 -1
  193. package/lib-es/network/serialization.d.ts +6 -4
  194. package/lib-es/network/serialization.d.ts.map +1 -1
  195. package/lib-es/network/serialization.js +97 -95
  196. package/lib-es/network/serialization.js.map +1 -1
  197. package/lib-es/polyfill.d.ts.map +1 -1
  198. package/lib-es/polyfill.js +7 -5
  199. package/lib-es/polyfill.js.map +1 -1
  200. package/lib-es/supportedFeatures.d.ts +1 -1
  201. package/lib-es/supportedFeatures.d.ts.map +1 -1
  202. package/lib-es/supportedFeatures.js +3 -1
  203. package/lib-es/supportedFeatures.js.map +1 -1
  204. package/lib-es/types/errors.d.ts.map +1 -1
  205. package/lib-es/types/errors.js +15 -13
  206. package/lib-es/types/errors.js.map +1 -1
  207. package/lib-es/types/index.d.ts +2 -2
  208. package/lib-es/types/index.d.ts.map +1 -1
  209. package/lib-es/types/index.js +4 -2
  210. package/lib-es/types/index.js.map +1 -1
  211. package/lib-es/types/model.d.ts +6 -6
  212. package/lib-es/types/model.d.ts.map +1 -1
  213. package/lib-es/types/model.js +7 -5
  214. package/lib-es/types/model.js.map +1 -1
  215. package/package.json +13 -16
  216. package/src/api/index.integ.test.ts +165 -162
  217. package/src/api/index.test.ts +106 -103
  218. package/src/api/index.ts +49 -46
  219. package/src/api/index_error.test.ts +48 -25
  220. package/src/config.ts +15 -12
  221. package/src/constants.ts +4 -1
  222. package/src/globals.d.ts +7 -5
  223. package/src/logic/broadcast.integ.test.ts +22 -19
  224. package/src/logic/broadcast.ts +5 -2
  225. package/src/logic/combine.test.ts +18 -15
  226. package/src/logic/combine.ts +8 -5
  227. package/src/logic/common.ts +9 -6
  228. package/src/logic/craftTransaction.test.ts +76 -75
  229. package/src/logic/craftTransaction.ts +46 -43
  230. package/src/logic/estimateFees.ts +6 -3
  231. package/src/logic/getBalance.test.ts +31 -28
  232. package/src/logic/getBalance.ts +13 -10
  233. package/src/logic/getBlock.integ.test.ts +40 -39
  234. package/src/logic/getBlock.test.ts +462 -415
  235. package/src/logic/getBlock.ts +142 -127
  236. package/src/logic/getBlockInfo.test.ts +72 -69
  237. package/src/logic/getBlockInfo.ts +15 -12
  238. package/src/logic/index.ts +15 -12
  239. package/src/logic/lastBlock.ts +6 -3
  240. package/src/logic/listOperations.ts +14 -11
  241. package/src/logic/listOperations.unit.test.ts +212 -209
  242. package/src/logic/networkWrappers.test.ts +32 -29
  243. package/src/logic/sdkWrapper.ts +19 -16
  244. package/src/logic/utils.ts +13 -10
  245. package/src/logic/validateAddress.test.ts +21 -18
  246. package/src/logic/validateAddress.ts +7 -4
  247. package/src/logic/validateIntent.test.ts +62 -59
  248. package/src/logic/validateIntent.ts +87 -84
  249. package/src/logic/validateMemo.test.ts +50 -47
  250. package/src/logic/validateMemo.ts +16 -13
  251. package/src/network/broadcastTransaction.test.ts +60 -60
  252. package/src/network/fetchLedgerOperations.unit.test.ts +155 -0
  253. package/src/network/horizon.integ.test.ts +45 -42
  254. package/src/network/horizon.test.ts +17 -14
  255. package/src/network/horizon.ts +279 -281
  256. package/src/network/horizon.unit.test.ts +238 -237
  257. package/src/network/horizonLedgerErrors.test.ts +81 -78
  258. package/src/network/horizonLedgerErrors.ts +22 -19
  259. package/src/network/index.ts +4 -1
  260. package/src/network/registerHorizonInterceptors.test.ts +163 -160
  261. package/src/network/serialization.ts +232 -227
  262. package/src/network/serialization.unit.test.ts +801 -798
  263. package/src/polyfill.ts +18 -15
  264. package/src/supportedFeatures.ts +6 -3
  265. package/src/types/errors.ts +33 -32
  266. package/src/types/index.ts +5 -2
  267. package/src/types/model.ts +55 -52
  268. package/tsconfig.json +1 -1
  269. package/.unimportedrc.json +0 -17
  270. package/LICENSE.txt +0 -21
  271. package/src/network/fetchLedgerOperations.nock.unit.test.ts +0 -156
package/src/polyfill.ts CHANGED
@@ -1,4 +1,7 @@
1
- import { log } from "@ledgerhq/logs";
1
+ // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { log } from '@ledgerhq/logs'
2
5
 
3
6
  /*
4
7
  * This whole patch thing is messy:
@@ -13,36 +16,36 @@ const OriginalTypedArrayMethods = {
13
16
  slice: Uint8Array.prototype.slice,
14
17
  map: Uint8Array.prototype.map,
15
18
  filter: Uint8Array.prototype.filter,
16
- };
19
+ }
17
20
 
18
21
  // Track whether we actually patched
19
- let hermesTypedArrayPatched = false;
22
+ let hermesTypedArrayPatched = false
20
23
 
21
24
  export function patchHermesTypedArraysIfNeeded() {
22
25
  if (global.HermesInternal && !hermesTypedArrayPatched) {
23
26
  try {
24
- log("coin:stellar", "🔵 Patching TypedArray because of Hermes bug");
27
+ log('coin:stellar', '🔵 Patching TypedArray because of Hermes bug')
25
28
  // Only require the module when we're actually running on Hermes
26
29
  // eslint-disable-next-line @typescript-eslint/no-var-requires
27
- const fixHermesTypedArrayBug = require("@exodus/patch-broken-hermes-typed-arrays");
28
- fixHermesTypedArrayBug();
29
- hermesTypedArrayPatched = true;
30
+ const fixHermesTypedArrayBug = require('@exodus/patch-broken-hermes-typed-arrays')
31
+ fixHermesTypedArrayBug()
32
+ hermesTypedArrayPatched = true
30
33
  } catch {
31
- log("coin:stellar", "Failed to patch typed arrays");
34
+ log('coin:stellar', 'Failed to patch typed arrays')
32
35
  }
33
36
  }
34
37
  }
35
38
 
36
39
  export function unpatchHermesTypedArrays() {
37
40
  if (hermesTypedArrayPatched) {
38
- const TypedArray = Object.getPrototypeOf(Uint8Array);
41
+ const TypedArray = Object.getPrototypeOf(Uint8Array)
39
42
 
40
- TypedArray.prototype.subarray = OriginalTypedArrayMethods.subarray;
41
- TypedArray.prototype.slice = OriginalTypedArrayMethods.slice;
42
- TypedArray.prototype.map = OriginalTypedArrayMethods.map;
43
- TypedArray.prototype.filter = OriginalTypedArrayMethods.filter;
43
+ TypedArray.prototype.subarray = OriginalTypedArrayMethods.subarray
44
+ TypedArray.prototype.slice = OriginalTypedArrayMethods.slice
45
+ TypedArray.prototype.map = OriginalTypedArrayMethods.map
46
+ TypedArray.prototype.filter = OriginalTypedArrayMethods.filter
44
47
 
45
- log("coin:stellar", "🟢 Reverted TypedArray methods to originals");
46
- hermesTypedArrayPatched = false; // reset
48
+ log('coin:stellar', '🟢 Reverted TypedArray methods to originals')
49
+ hermesTypedArrayPatched = false // reset
47
50
  }
48
51
  }
@@ -1,5 +1,8 @@
1
- import type { SupportedFeatures } from "@ledgerhq/coin-module-framework/features/types";
1
+ // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { SupportedFeatures } from '@ledgerhq/coin-module-framework/features/types'
2
5
 
3
6
  export const supportedFeatures: SupportedFeatures = {
4
- blockchain_txs: ["send"],
5
- };
7
+ blockchain_txs: ['send'],
8
+ }
@@ -1,45 +1,46 @@
1
- import { createCustomErrorClass } from "@ledgerhq/errors";
1
+ // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { createCustomErrorClass } from '@ledgerhq/errors'
2
5
 
3
6
  /** Decoded summary of `extras.result_xdr` (Horizon transaction result XDR). */
4
7
  export type StellarDecodedResultXdr =
5
8
  | {
6
- feeChargedStroops: string;
7
- resultSwitch: string;
9
+ feeChargedStroops: string
10
+ resultSwitch: string
8
11
  }
9
12
  | {
10
- decodeFailed: true;
11
- rawResultXdrBase64: string;
12
- };
13
+ decodeFailed: true
14
+ rawResultXdrBase64: string
15
+ }
13
16
 
14
17
  export type StellarBroadcastFailedFields = {
15
- documentationSummary: string;
16
- horizonTransactionCode: string;
17
- horizonOperationCodes: string[] | undefined;
18
- resultXdrSwitchName: string | undefined;
19
- feeChargedStroops: string | undefined;
20
- stellarDocUrl: string;
21
- decodedResultXdr: StellarDecodedResultXdr | undefined;
22
- envelopeXdr: string;
23
- };
18
+ documentationSummary: string
19
+ horizonTransactionCode: string
20
+ horizonOperationCodes: string[] | undefined
21
+ resultXdrSwitchName: string | undefined
22
+ feeChargedStroops: string | undefined
23
+ stellarDocUrl: string
24
+ decodedResultXdr: StellarDecodedResultXdr | undefined
25
+ envelopeXdr: string
26
+ }
24
27
 
25
28
  export const StellarBroadcastFailedError = createCustomErrorClass<StellarBroadcastFailedFields>(
26
- "StellarBroadcastFailedError",
27
- );
29
+ 'StellarBroadcastFailedError'
30
+ )
28
31
 
29
- export const StellarBurnAddressError = createCustomErrorClass("StellarBurnAddressError");
30
- export const StellarAssetRequired = createCustomErrorClass("StellarAssetRequired");
31
- export const StellarMuxedAccountNotExist = createCustomErrorClass("StellarMuxedAccountNotExist");
32
- export const StellarWrongMemoFormat = createCustomErrorClass("StellarWrongMemoFormat");
33
- export const StellarAssetNotAccepted = createCustomErrorClass("StellarAssetNotAccepted");
34
- export const StellarAssetNotFound = createCustomErrorClass("StellarAssetNotFound");
35
- export const StellarNotEnoughNativeBalance = createCustomErrorClass(
36
- "StellarNotEnoughNativeBalance",
37
- );
32
+ export const StellarBurnAddressError = createCustomErrorClass('StellarBurnAddressError')
33
+ export const StellarAssetRequired = createCustomErrorClass('StellarAssetRequired')
34
+ export const StellarMuxedAccountNotExist = createCustomErrorClass('StellarMuxedAccountNotExist')
35
+ export const StellarWrongMemoFormat = createCustomErrorClass('StellarWrongMemoFormat')
36
+ export const StellarAssetNotAccepted = createCustomErrorClass('StellarAssetNotAccepted')
37
+ export const StellarAssetNotFound = createCustomErrorClass('StellarAssetNotFound')
38
+ export const StellarNotEnoughNativeBalance = createCustomErrorClass('StellarNotEnoughNativeBalance')
38
39
  export const StellarFeeSmallerThanRecommended = createCustomErrorClass(
39
- "StellarFeeSmallerThanRecommended",
40
- );
41
- export const StellarFeeSmallerThanBase = createCustomErrorClass("StellarFeeSmallerThanBase");
40
+ 'StellarFeeSmallerThanRecommended'
41
+ )
42
+ export const StellarFeeSmallerThanBase = createCustomErrorClass('StellarFeeSmallerThanBase')
42
43
  export const StellarNotEnoughNativeBalanceToAddTrustline = createCustomErrorClass(
43
- "StellarNotEnoughNativeBalanceToAddTrustline",
44
- );
45
- export const StellarSourceHasMultiSign = createCustomErrorClass("StellarSourceHasMultiSign");
44
+ 'StellarNotEnoughNativeBalanceToAddTrustline'
45
+ )
46
+ export const StellarSourceHasMultiSign = createCustomErrorClass('StellarSourceHasMultiSign')
@@ -1,2 +1,5 @@
1
- export * from "./errors";
2
- export * from "./model";
1
+ // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './errors'
5
+ export * from './model'
@@ -1,71 +1,74 @@
1
- import { Horizon } from "@stellar/stellar-sdk";
2
- import type { BigNumber } from "bignumber.js";
1
+ // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { Horizon } from '@stellar/stellar-sdk'
5
+ import BigNumber from 'bignumber.js'
3
6
 
4
7
  export type NetworkInfo = {
5
- family: "stellar";
6
- fees: BigNumber;
7
- baseFee: BigNumber;
8
- baseReserve: BigNumber;
9
- networkCongestionLevel?: NetworkCongestionLevel | undefined;
10
- };
8
+ family: 'stellar'
9
+ fees: BigNumber
10
+ baseFee: BigNumber
11
+ baseReserve: BigNumber
12
+ networkCongestionLevel?: NetworkCongestionLevel | undefined
13
+ }
11
14
 
12
15
  export type NetworkInfoRaw = {
13
- family: "stellar";
14
- fees: string;
15
- baseFee: string;
16
- baseReserve: string;
17
- networkCongestionLevel?: NetworkCongestionLevel | undefined;
18
- };
16
+ family: 'stellar'
17
+ fees: string
18
+ baseFee: string
19
+ baseReserve: string
20
+ networkCongestionLevel?: NetworkCongestionLevel | undefined
21
+ }
19
22
 
20
23
  export enum NetworkCongestionLevel {
21
- LOW = "LOW",
22
- MEDIUM = "MEDIUM",
23
- HIGH = "HIGH",
24
+ LOW = 'LOW',
25
+ MEDIUM = 'MEDIUM',
26
+ HIGH = 'HIGH',
24
27
  }
25
28
 
26
29
  export const StellarMemoType = [
27
- "NO_MEMO",
28
- "MEMO_TEXT",
29
- "MEMO_ID",
30
- "MEMO_HASH",
31
- "MEMO_RETURN",
32
- ] as const;
30
+ 'NO_MEMO',
31
+ 'MEMO_TEXT',
32
+ 'MEMO_ID',
33
+ 'MEMO_HASH',
34
+ 'MEMO_RETURN',
35
+ ] as const
33
36
 
34
37
  // typesafe enum
35
- export type StellarMemoKind = (typeof StellarMemoType)[number];
38
+ export type StellarMemoKind = (typeof StellarMemoType)[number]
36
39
 
37
40
  export type StellarMemo =
38
- | { type: "NO_MEMO" }
39
- | { type: Exclude<StellarMemoKind, "NO_MEMO">; value: string };
41
+ | { type: 'NO_MEMO' }
42
+ | { type: Exclude<StellarMemoKind, 'NO_MEMO'>; value: string }
40
43
 
41
44
  export type RawOperation = Horizon.ServerApi.OperationRecord & {
42
- asset_code?: string;
43
- asset_issuer?: string;
44
- from?: string;
45
- to?: string;
46
- to_muxed?: string;
47
- funder?: string;
48
- trustor?: string;
49
- account?: string;
50
- transaction_successful: boolean;
51
- };
45
+ asset_code?: string
46
+ asset_issuer?: string
47
+ from?: string
48
+ to?: string
49
+ to_muxed?: string
50
+ funder?: string
51
+ trustor?: string
52
+ account?: string
53
+ transaction_successful: boolean
54
+ }
52
55
 
53
56
  export type BalanceAsset = {
54
- balance: string;
55
- limit: string;
56
- buying_liabilities: string;
57
- selling_liabilities: string;
58
- last_modified_ledger: number;
59
- is_authorized: boolean;
60
- is_authorized_to_maintain_liabilities: boolean;
61
- asset_type: string;
62
- asset_code: string;
63
- asset_issuer: string;
64
- liquidity_pool_id?: string;
65
- };
57
+ balance: string
58
+ limit: string
59
+ buying_liabilities: string
60
+ selling_liabilities: string
61
+ last_modified_ledger: number
62
+ is_authorized: boolean
63
+ is_authorized_to_maintain_liabilities: boolean
64
+ asset_type: string
65
+ asset_code: string
66
+ asset_issuer: string
67
+ liquidity_pool_id?: string
68
+ }
66
69
 
67
70
  export type Signer = {
68
- weight: number;
69
- key: string;
70
- type: string;
71
- };
71
+ weight: number
72
+ key: string
73
+ type: string
74
+ }
package/tsconfig.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "extends": "../../../tsconfig.base",
2
+ "extends": "../../tsconfig.base",
3
3
  "compilerOptions": {
4
4
  "noUnusedLocals": true,
5
5
  "noUnusedParameters": true,
@@ -1,17 +0,0 @@
1
- {
2
- "entry": ["src/api/index.ts", "src/index.ts", "src/logic/validateAddress.ts"],
3
- "ignorePatterns": [
4
- "**/node_modules/**",
5
- "**/*.fixture.ts",
6
- "**/*.mock.ts",
7
- "**/*.test.{js,jsx,ts,tsx}"
8
- ],
9
- "ignoreUnused": ["@ledgerhq/live-env", "expect", "invariant", "rxjs"],
10
- "ignoreUnresolved": ["@jest/expect-utils", "@jest/get-type", "jest-util"],
11
- "ignoreUnimported": [
12
- "src/globals.d.ts",
13
- "src/network/index.ts",
14
- "src/constants.ts",
15
- "src/supportedFeatures.ts"
16
- ]
17
- }
package/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License
2
-
3
- Copyright (c) 2017-present Ledger https://www.ledger.com/
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
@@ -1,156 +0,0 @@
1
- import nock from "nock";
2
- import coinConfig, { type StellarCoinConfig } from "../config";
3
- import type { CoinConfig } from "@ledgerhq/coin-module-framework/config";
4
- import { fetchAllLedgerOperations, fetchLedgerRecord } from "./horizon";
5
-
6
- const HORIZON = "https://horizon-testnet.stellar.org";
7
-
8
- let originalGetCoinConfig: CoinConfig<StellarCoinConfig>;
9
-
10
- /** Minimal Horizon payment op shape for nock fixtures (embedded.records). */
11
- const MINIMAL_HORIZON_PAYMENT_OP = {
12
- _links: {
13
- self: { href: "" },
14
- transaction: { href: "" },
15
- effects: { href: "" },
16
- succeeds: { href: "" },
17
- precedes: { href: "" },
18
- },
19
- id: "1",
20
- paging_token: "1",
21
- transaction_successful: true,
22
- source_account: "GB7FW6GRFEH63Q3BVRT65VMB26OKHQRG74QRFUMTL6D553UKDZCDM7U",
23
- type: "payment",
24
- type_i: 1,
25
- created_at: "2015-07-20T20:27:50Z",
26
- transaction_hash: "txh",
27
- asset_type: "native",
28
- from: "GB7FW6GRFEH63Q3BVRT65VMB26OKHQRG74QRFUMTL6D553UKDZCDM7U",
29
- to: "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
30
- amount: "1.0000000",
31
- };
32
-
33
- function setExplorer(fetchLimit = 100) {
34
- coinConfig.setCoinConfig(
35
- (): StellarCoinConfig =>
36
- ({
37
- status: { type: "active" },
38
- explorer: { url: `${HORIZON}/`, fetchLimit },
39
- }) as StellarCoinConfig,
40
- );
41
- }
42
-
43
- describe("fetchLedgerRecord / fetchAllLedgerOperations (nock)", () => {
44
- beforeAll(() => {
45
- originalGetCoinConfig = coinConfig.getCoinConfig;
46
- });
47
-
48
- afterAll(() => {
49
- if (originalGetCoinConfig) {
50
- coinConfig.setCoinConfig(originalGetCoinConfig);
51
- }
52
- });
53
-
54
- beforeEach(() => {
55
- nock.cleanAll();
56
- nock.disableNetConnect();
57
- setExplorer(100);
58
- });
59
-
60
- afterEach(() => {
61
- nock.cleanAll();
62
- nock.enableNetConnect();
63
- });
64
-
65
- it("fetchLedgerRecord maps 404 to not found error", async () => {
66
- nock(HORIZON).get("/ledgers/424242").reply(404, {
67
- status: 404,
68
- type: "https://stellar.org/horizon-errors/not_found",
69
- });
70
-
71
- await expect(fetchLedgerRecord(424242)).rejects.toThrow("Stellar ledger 424242 not found");
72
- });
73
-
74
- it("fetchAllLedgerOperations maps 404 to not found error", async () => {
75
- nock(HORIZON)
76
- .get(uri => uri.startsWith("/ledgers/424243/operations"))
77
- .reply(404, { status: 404, type: "https://stellar.org/horizon-errors/not_found" });
78
-
79
- await expect(fetchAllLedgerOperations(424243)).rejects.toThrow(
80
- "Stellar ledger 424243 not found",
81
- );
82
- });
83
-
84
- it("fetchLedgerRecord returns ledger on 200", async () => {
85
- const ledgerBody = {
86
- _links: { self: { href: "" }, transactions: { href: "" }, operations: { href: "" } },
87
- id: "abc",
88
- paging_token: "abc",
89
- hash: "0000000000000000000000000000000000000000000000000000000000000000",
90
- prev_hash: "",
91
- sequence: 3,
92
- successful_transaction_count: 0,
93
- failed_transaction_count: 0,
94
- operation_count: 0,
95
- tx_set_operation_count: 0,
96
- closed_at: "2015-07-20T20:27:50Z",
97
- total_coins: "100000000000.0000000",
98
- fee_pool: "0.0000000",
99
- base_fee_in_stroops: 100,
100
- base_reserve_in_stroops: 100000000,
101
- max_tx_set_size: 50,
102
- protocol_version: 1,
103
- header_xdr: "",
104
- };
105
- nock(HORIZON).get("/ledgers/3").reply(200, ledgerBody);
106
-
107
- const rec = await fetchLedgerRecord(3);
108
- expect(rec.sequence).toBe(3);
109
- expect(rec.hash).toBe(ledgerBody.hash);
110
- });
111
-
112
- it("fetchAllLedgerOperations returns embedded records on 200", async () => {
113
- const page = {
114
- _links: {
115
- self: { href: `${HORIZON}/ledgers/10/operations` },
116
- next: { href: "" },
117
- prev: { href: "" },
118
- },
119
- _embedded: { records: [MINIMAL_HORIZON_PAYMENT_OP] },
120
- };
121
-
122
- nock(HORIZON)
123
- .get(uri => uri.includes("/ledgers/10/operations"))
124
- .reply(200, page);
125
-
126
- const records = await fetchAllLedgerOperations(10);
127
- expect(records).toHaveLength(1);
128
- expect(records[0].type).toBe("payment");
129
- });
130
-
131
- it("fetchAllLedgerOperations paginates when page is full then stops on empty page", async () => {
132
- setExplorer(1);
133
-
134
- const nextHref = `${HORIZON}/ledgers/11/operations?cursor=after&limit=1&order=asc&include_failed=true&join=transactions`;
135
-
136
- const page1 = {
137
- _links: {
138
- self: { href: `${HORIZON}/ledgers/11/operations` },
139
- next: { href: nextHref },
140
- prev: { href: "" },
141
- },
142
- _embedded: { records: [MINIMAL_HORIZON_PAYMENT_OP] },
143
- };
144
-
145
- const page2 = {
146
- _links: { self: { href: "" }, next: { href: "" }, prev: { href: "" } },
147
- _embedded: { records: [] },
148
- };
149
-
150
- nock(HORIZON).get("/ledgers/11/operations").query(true).reply(200, page1);
151
- nock(HORIZON).get("/ledgers/11/operations").query(true).reply(200, page2);
152
-
153
- const records = await fetchAllLedgerOperations(11);
154
- expect(records.length).toBe(1);
155
- });
156
- });