@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
@@ -1,112 +1,115 @@
1
- import { LedgerAPI4xx, LedgerAPI5xx, NetworkDown } from "@ledgerhq/errors";
2
- import { NetworkError, NotFoundError } from "@stellar/stellar-sdk";
1
+ // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { LedgerAPI4xx, LedgerAPI5xx, NetworkDown } from '@ledgerhq/errors'
5
+ import { NetworkError, NotFoundError } from '@stellar/stellar-sdk'
3
6
  import {
4
7
  messageFromHorizonUnknown,
5
8
  throwHorizonLedgerOrOperationsError,
6
- } from "./horizonLedgerErrors";
9
+ } from './horizonLedgerErrors'
7
10
 
8
- describe("messageFromHorizonUnknown", () => {
9
- it("returns message for Error", () => {
10
- expect(messageFromHorizonUnknown(new Error("hello"))).toBe("hello");
11
- });
11
+ describe('messageFromHorizonUnknown', () => {
12
+ it('returns message for Error', () => {
13
+ expect(messageFromHorizonUnknown(new Error('hello'))).toBe('hello')
14
+ })
12
15
 
13
- it("returns string as-is", () => {
14
- expect(messageFromHorizonUnknown("plain")).toBe("plain");
15
- });
16
+ it('returns string as-is', () => {
17
+ expect(messageFromHorizonUnknown('plain')).toBe('plain')
18
+ })
16
19
 
17
- it("returns empty string for non-Error non-string", () => {
18
- expect(messageFromHorizonUnknown({ code: 1 })).toBe("");
19
- expect(messageFromHorizonUnknown(null)).toBe("");
20
- expect(messageFromHorizonUnknown(undefined)).toBe("");
21
- });
22
- });
20
+ it('returns empty string for non-Error non-string', () => {
21
+ expect(messageFromHorizonUnknown({ code: 1 })).toBe('')
22
+ expect(messageFromHorizonUnknown(null)).toBe('')
23
+ expect(messageFromHorizonUnknown(undefined)).toBe('')
24
+ })
25
+ })
23
26
 
24
- describe("throwHorizonLedgerOrOperationsError", () => {
25
- const notFound = "ledger not found";
27
+ describe('throwHorizonLedgerOrOperationsError', () => {
28
+ const notFound = 'ledger not found'
26
29
 
27
- it("throws notFoundMessage for NotFoundError", () => {
30
+ it('throws notFoundMessage for NotFoundError', () => {
28
31
  expect(() =>
29
- throwHorizonLedgerOrOperationsError(new NotFoundError("gone", {}), notFound),
30
- ).toThrow(notFound);
31
- });
32
+ throwHorizonLedgerOrOperationsError(new NotFoundError('gone', {}), notFound)
33
+ ).toThrow(notFound)
34
+ })
32
35
 
33
- it("throws notFoundMessage when message contains status code 404", () => {
36
+ it('throws notFoundMessage when message contains status code 404', () => {
34
37
  expect(() =>
35
- throwHorizonLedgerOrOperationsError(new Error("Request failed: status code 404"), notFound),
36
- ).toThrow(notFound);
37
- });
38
+ throwHorizonLedgerOrOperationsError(new Error('Request failed: status code 404'), notFound)
39
+ ).toThrow(notFound)
40
+ })
38
41
 
39
- it("throws LedgerAPI4xx 429 for too many requests in message", () => {
42
+ it('throws LedgerAPI4xx 429 for too many requests in message', () => {
40
43
  expect(() =>
41
- throwHorizonLedgerOrOperationsError(new Error("Too Many Requests"), notFound),
42
- ).toThrow(LedgerAPI4xx);
43
- });
44
+ throwHorizonLedgerOrOperationsError(new Error('Too Many Requests'), notFound)
45
+ ).toThrow(LedgerAPI4xx)
46
+ })
44
47
 
45
- it("throws LedgerAPI4xx for other 4xx status in message", () => {
48
+ it('throws LedgerAPI4xx for other 4xx status in message', () => {
46
49
  expect(() =>
47
- throwHorizonLedgerOrOperationsError(new Error("status code 400"), notFound),
48
- ).toThrow(LedgerAPI4xx);
49
- });
50
+ throwHorizonLedgerOrOperationsError(new Error('status code 400'), notFound)
51
+ ).toThrow(LedgerAPI4xx)
52
+ })
50
53
 
51
- test.each([["401"], ["403"]])(
52
- "throws LedgerAPI4xx when message contains status code %s",
53
- code => {
54
+ test.each([['401'], ['403']])(
55
+ 'throws LedgerAPI4xx when message contains status code %s',
56
+ (code) => {
54
57
  expect(() =>
55
58
  throwHorizonLedgerOrOperationsError(
56
59
  new Error(`Request failed: status code ${code}`),
57
- notFound,
58
- ),
59
- ).toThrow(LedgerAPI4xx);
60
- },
61
- );
60
+ notFound
61
+ )
62
+ ).toThrow(LedgerAPI4xx)
63
+ }
64
+ )
62
65
 
63
- it("throws LedgerAPI5xx for 5xx status in message", () => {
66
+ it('throws LedgerAPI5xx for 5xx status in message', () => {
64
67
  expect(() =>
65
- throwHorizonLedgerOrOperationsError(new Error("status code 503"), notFound),
66
- ).toThrow(LedgerAPI5xx);
67
- });
68
+ throwHorizonLedgerOrOperationsError(new Error('status code 503'), notFound)
69
+ ).toThrow(LedgerAPI5xx)
70
+ })
68
71
 
69
- test.each([["502"], ["500"]])(
70
- "throws LedgerAPI5xx when message contains status code %s",
71
- code => {
72
+ test.each([['502'], ['500']])(
73
+ 'throws LedgerAPI5xx when message contains status code %s',
74
+ (code) => {
72
75
  expect(() =>
73
- throwHorizonLedgerOrOperationsError(new Error(`upstream status code ${code}`), notFound),
74
- ).toThrow(LedgerAPI5xx);
75
- },
76
- );
76
+ throwHorizonLedgerOrOperationsError(new Error(`upstream status code ${code}`), notFound)
77
+ ).toThrow(LedgerAPI5xx)
78
+ }
79
+ )
77
80
 
78
- it("throws NetworkDown for NetworkError", () => {
81
+ it('throws NetworkDown for NetworkError', () => {
79
82
  expect(() =>
80
- throwHorizonLedgerOrOperationsError(new NetworkError("net", {}), notFound),
81
- ).toThrow(NetworkDown);
82
- });
83
+ throwHorizonLedgerOrOperationsError(new NetworkError('net', {}), notFound)
84
+ ).toThrow(NetworkDown)
85
+ })
83
86
 
84
87
  test.each([
85
- ["ECONNRESET", "ECONNRESET on read"],
86
- ["ECONNREFUSED", "connect ECONNREFUSED 127.0.0.1:443"],
87
- ["ENOTFOUND", "getaddrinfo ENOTFOUND horizon.example"],
88
- ["EPIPE", "write EPIPE broken pipe"],
89
- ["ETIMEDOUT", "connect ETIMEDOUT 10.0.0.1:443"],
90
- ])("throws NetworkDown when message contains %s", (_label, message) => {
88
+ ['ECONNRESET', 'ECONNRESET on read'],
89
+ ['ECONNREFUSED', 'connect ECONNREFUSED 127.0.0.1:443'],
90
+ ['ENOTFOUND', 'getaddrinfo ENOTFOUND horizon.example'],
91
+ ['EPIPE', 'write EPIPE broken pipe'],
92
+ ['ETIMEDOUT', 'connect ETIMEDOUT 10.0.0.1:443'],
93
+ ])('throws NetworkDown when message contains %s', (_label, message) => {
91
94
  expect(() => throwHorizonLedgerOrOperationsError(new Error(message), notFound)).toThrow(
92
- NetworkDown,
93
- );
94
- });
95
+ NetworkDown
96
+ )
97
+ })
95
98
 
96
- it("throws NetworkDown for undefined is not an object in message", () => {
99
+ it('throws NetworkDown for undefined is not an object in message', () => {
97
100
  expect(() =>
98
- throwHorizonLedgerOrOperationsError(new Error("undefined is not an object"), notFound),
99
- ).toThrow(NetworkDown);
100
- });
101
+ throwHorizonLedgerOrOperationsError(new Error('undefined is not an object'), notFound)
102
+ ).toThrow(NetworkDown)
103
+ })
101
104
 
102
- it("rethrows unknown errors", () => {
103
- const o = { custom: true };
105
+ it('rethrows unknown errors', () => {
106
+ const o = { custom: true }
104
107
  try {
105
- throwHorizonLedgerOrOperationsError(o, notFound);
108
+ throwHorizonLedgerOrOperationsError(o, notFound)
106
109
  } catch (e) {
107
- expect(e).toBe(o);
108
- return;
110
+ expect(e).toBe(o)
111
+ return
109
112
  }
110
- throw new Error("expected throw");
111
- });
112
- });
113
+ throw new Error('expected throw')
114
+ })
115
+ })
@@ -1,45 +1,48 @@
1
- import { LedgerAPI4xx, LedgerAPI5xx, NetworkDown } from "@ledgerhq/errors";
2
- import { NetworkError, NotFoundError } from "@stellar/stellar-sdk";
1
+ // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { LedgerAPI4xx, LedgerAPI5xx, NetworkDown } from '@ledgerhq/errors'
5
+ import { NetworkError, NotFoundError } from '@stellar/stellar-sdk'
3
6
 
4
7
  export function messageFromHorizonUnknown(e: unknown): string {
5
8
  if (e instanceof Error) {
6
- return e.message;
9
+ return e.message
7
10
  }
8
- if (typeof e === "string") {
9
- return e;
11
+ if (typeof e === 'string') {
12
+ return e
10
13
  }
11
- return "";
14
+ return ''
12
15
  }
13
16
 
14
- const HORIZON_STATUS_404 = /status code 404/;
15
- const HORIZON_TOO_MANY_REQUESTS = /too many requests/i;
16
- const HORIZON_STATUS_4XX = /status code 4\d{2}/;
17
- const HORIZON_STATUS_5XX = /status code 5\d{2}/;
18
- const HORIZON_NETWORK_DOWN = /ECONNRESET|ECONNREFUSED|ENOTFOUND|EPIPE|ETIMEDOUT/;
19
- const HORIZON_UNDEFINED_OBJECT = /undefined is not an object/;
17
+ const HORIZON_STATUS_404 = /status code 404/
18
+ const HORIZON_TOO_MANY_REQUESTS = /too many requests/i
19
+ const HORIZON_STATUS_4XX = /status code 4\d{2}/
20
+ const HORIZON_STATUS_5XX = /status code 5\d{2}/
21
+ const HORIZON_NETWORK_DOWN = /ECONNRESET|ECONNREFUSED|ENOTFOUND|EPIPE|ETIMEDOUT/
22
+ const HORIZON_UNDEFINED_OBJECT = /undefined is not an object/
20
23
 
21
24
  export function throwHorizonLedgerOrOperationsError(e: unknown, notFoundMessage: string): never {
22
- const errorMsg = messageFromHorizonUnknown(e);
25
+ const errorMsg = messageFromHorizonUnknown(e)
23
26
 
24
27
  if (e instanceof NotFoundError || HORIZON_STATUS_404.exec(errorMsg)) {
25
- throw new Error(notFoundMessage);
28
+ throw new Error(notFoundMessage)
26
29
  }
27
30
  if (HORIZON_TOO_MANY_REQUESTS.exec(errorMsg)) {
28
- throw new LedgerAPI4xx("status code 4xx", { status: 429, url: undefined, method: "GET" });
31
+ throw new LedgerAPI4xx('status code 4xx', { status: 429, url: undefined, method: 'GET' })
29
32
  }
30
33
  if (HORIZON_STATUS_4XX.exec(errorMsg)) {
31
- throw new LedgerAPI4xx();
34
+ throw new LedgerAPI4xx()
32
35
  }
33
36
  if (HORIZON_STATUS_5XX.exec(errorMsg)) {
34
- throw new LedgerAPI5xx();
37
+ throw new LedgerAPI5xx()
35
38
  }
36
39
  if (
37
40
  e instanceof NetworkError ||
38
41
  HORIZON_NETWORK_DOWN.exec(errorMsg) ||
39
42
  HORIZON_UNDEFINED_OBJECT.exec(errorMsg)
40
43
  ) {
41
- throw new NetworkDown();
44
+ throw new NetworkDown()
42
45
  }
43
46
 
44
- throw e;
47
+ throw e
45
48
  }
@@ -1,3 +1,6 @@
1
+ // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
1
4
  export {
2
5
  broadcastTransaction,
3
6
  fetchAccount,
@@ -13,4 +16,4 @@ export {
13
16
  getRecipientAccount,
14
17
  loadAccount,
15
18
  registerHorizonInterceptors,
16
- } from "./horizon";
19
+ } from './horizon'