@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,19 +1,22 @@
1
- import { Horizon } from "@stellar/stellar-sdk";
2
- import coinConfig from "../config";
3
- import { listOperations } from "./listOperations";
1
+ // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
+ // SPDX-License-Identifier: Apache-2.0
4
3
 
5
- jest.mock("@stellar/stellar-sdk");
4
+ import { Horizon } from '@stellar/stellar-sdk'
5
+ import coinConfig from '../config'
6
+ import { listOperations } from './listOperations'
6
7
 
7
- describe("listOperations", () => {
8
+ jest.mock('@stellar/stellar-sdk')
9
+
10
+ describe('listOperations', () => {
8
11
  coinConfig.setCoinConfig(() => ({
9
- status: { type: "active" },
10
- explorer: { url: "https://stellar.coin.ledger.com" },
11
- }));
12
+ status: { type: 'active' },
13
+ explorer: { url: 'https://stellar.coin.ledger.com' },
14
+ }))
12
15
 
13
- const mockCall = jest.fn();
16
+ const mockCall = jest.fn()
14
17
 
15
18
  beforeEach(() => {
16
- (Horizon.Server as jest.Mock).mockImplementation(() => ({
19
+ ;(Horizon.Server as jest.Mock).mockImplementation(() => ({
17
20
  operations: () => ({
18
21
  forAccount: () => ({
19
22
  limit: () => ({
@@ -29,373 +32,373 @@ describe("listOperations", () => {
29
32
  }),
30
33
  }),
31
34
  }),
32
- }));
33
- });
35
+ }))
36
+ })
34
37
 
35
38
  afterEach(() => {
36
- jest.clearAllMocks();
37
- });
39
+ jest.clearAllMocks()
40
+ })
38
41
 
39
- it("lists operations associated with an address", async () => {
42
+ it('lists operations associated with an address', async () => {
40
43
  mockCall.mockResolvedValueOnce({
41
44
  records: [
42
45
  {
43
- id: "operation_id1",
44
- transaction_hash: "transaction_hash1",
45
- paging_token: "token1",
46
- source_account: "address",
47
- from: "address",
48
- to: "receiver1",
49
- amount: "46.0600000",
46
+ id: 'operation_id1',
47
+ transaction_hash: 'transaction_hash1',
48
+ paging_token: 'token1',
49
+ source_account: 'address',
50
+ from: 'address',
51
+ to: 'receiver1',
52
+ amount: '46.0600000',
50
53
  type: Horizon.HorizonApi.OperationResponseType.payment,
51
54
  transaction_successful: true,
52
- created_at: "2025-01-01",
55
+ created_at: '2025-01-01',
53
56
  transaction: () => ({
54
- fee_charged: "111900",
55
- fee_account: "address",
57
+ fee_charged: '111900',
58
+ fee_account: 'address',
56
59
  ledger_attr: 42,
57
60
  ledger: () => ({
58
- hash: "block_hash1",
59
- closed_at: "2025-01-01",
61
+ hash: 'block_hash1',
62
+ closed_at: '2025-01-01',
60
63
  }),
61
64
  }),
62
65
  },
63
66
  {
64
- id: "operation_id2",
65
- transaction_hash: "transaction_hash1",
66
- paging_token: "token2",
67
- source_account: "address",
68
- from: "address",
69
- to: "receiver2",
70
- amount: "666.0000000",
67
+ id: 'operation_id2',
68
+ transaction_hash: 'transaction_hash1',
69
+ paging_token: 'token2',
70
+ source_account: 'address',
71
+ from: 'address',
72
+ to: 'receiver2',
73
+ amount: '666.0000000',
71
74
  type: Horizon.HorizonApi.OperationResponseType.payment,
72
75
  transaction_successful: false,
73
- created_at: "2025-01-01",
76
+ created_at: '2025-01-01',
74
77
  transaction: () => ({
75
- fee_charged: "11100",
76
- fee_account: "address",
78
+ fee_charged: '11100',
79
+ fee_account: 'address',
77
80
  ledger_attr: 42,
78
81
  ledger: () => ({
79
- hash: "block_hash1",
80
- closed_at: "2025-01-01",
82
+ hash: 'block_hash1',
83
+ closed_at: '2025-01-01',
81
84
  }),
82
85
  }),
83
86
  },
84
87
  {
85
- id: "operation_id3",
86
- transaction_hash: "transaction_hash2",
87
- paging_token: "token3",
88
- source_account: "sender",
89
- from: "sender",
90
- to: "address",
91
- amount: "50.5000000",
88
+ id: 'operation_id3',
89
+ transaction_hash: 'transaction_hash2',
90
+ paging_token: 'token3',
91
+ source_account: 'sender',
92
+ from: 'sender',
93
+ to: 'address',
94
+ amount: '50.5000000',
92
95
  type: Horizon.HorizonApi.OperationResponseType.payment,
93
96
  transaction_successful: true,
94
- created_at: "2025-01-01",
97
+ created_at: '2025-01-01',
95
98
  transaction: () => ({
96
- fee_charged: "111",
97
- fee_account: "sender",
99
+ fee_charged: '111',
100
+ fee_account: 'sender',
98
101
  ledger_attr: 42,
99
102
  ledger: () => ({
100
- hash: "block_hash1",
101
- closed_at: "2025-01-01",
103
+ hash: 'block_hash1',
104
+ closed_at: '2025-01-01',
102
105
  }),
103
106
  }),
104
107
  },
105
108
  ],
106
- } as any);
109
+ } as any)
107
110
 
108
- expect(await listOperations("address", { order: "asc", minHeight: 0 })).toEqual({
111
+ expect(await listOperations('address', { order: 'asc', minHeight: 0 })).toEqual({
109
112
  items: [
110
113
  {
111
- id: "transaction_hash1-operation_id1",
112
- asset: { type: "native" },
114
+ id: 'transaction_hash1-operation_id1',
115
+ asset: { type: 'native' },
113
116
  details: {
114
- assetAmount: "460600000",
115
- ledgerOpType: "OUT",
117
+ assetAmount: '460600000',
118
+ ledgerOpType: 'OUT',
116
119
  sequence: undefined,
117
120
  memo: undefined,
118
121
  },
119
- senders: ["address"],
120
- recipients: ["receiver1"],
122
+ senders: ['address'],
123
+ recipients: ['receiver1'],
121
124
  tx: {
122
- block: { hash: "block_hash1", height: 42, time: new Date("2025-01-01") },
123
- date: new Date("2025-01-01"),
125
+ block: { hash: 'block_hash1', height: 42, time: new Date('2025-01-01') },
126
+ date: new Date('2025-01-01'),
124
127
  fees: 111900n,
125
- feesPayer: "address",
126
- hash: "transaction_hash1",
128
+ feesPayer: 'address',
129
+ hash: 'transaction_hash1',
127
130
  failed: false,
128
131
  },
129
- type: "OUT",
132
+ type: 'OUT',
130
133
  value: 460600000n,
131
134
  },
132
135
  {
133
- id: "transaction_hash1-operation_id2",
134
- asset: { type: "native" },
136
+ id: 'transaction_hash1-operation_id2',
137
+ asset: { type: 'native' },
135
138
  details: {
136
- assetAmount: "11100",
137
- ledgerOpType: "OUT",
139
+ assetAmount: '11100',
140
+ ledgerOpType: 'OUT',
138
141
  sequence: undefined,
139
142
  memo: undefined,
140
143
  },
141
- senders: ["address"],
142
- recipients: ["receiver2"],
144
+ senders: ['address'],
145
+ recipients: ['receiver2'],
143
146
  tx: {
144
- block: { hash: "block_hash1", height: 42, time: new Date("2025-01-01") },
145
- date: new Date("2025-01-01"),
147
+ block: { hash: 'block_hash1', height: 42, time: new Date('2025-01-01') },
148
+ date: new Date('2025-01-01'),
146
149
  fees: 11100n,
147
- feesPayer: "address",
148
- hash: "transaction_hash1",
150
+ feesPayer: 'address',
151
+ hash: 'transaction_hash1',
149
152
  failed: true,
150
153
  },
151
- type: "OUT",
154
+ type: 'OUT',
152
155
  value: 11100n,
153
156
  },
154
157
  {
155
- id: "transaction_hash2-operation_id3",
156
- asset: { type: "native" },
158
+ id: 'transaction_hash2-operation_id3',
159
+ asset: { type: 'native' },
157
160
  details: {
158
- assetAmount: "505000000",
159
- ledgerOpType: "IN",
161
+ assetAmount: '505000000',
162
+ ledgerOpType: 'IN',
160
163
  sequence: undefined,
161
164
  memo: undefined,
162
165
  },
163
- senders: ["sender"],
164
- recipients: ["address"],
166
+ senders: ['sender'],
167
+ recipients: ['address'],
165
168
  tx: {
166
- block: { hash: "block_hash1", height: 42, time: new Date("2025-01-01") },
167
- date: new Date("2025-01-01"),
169
+ block: { hash: 'block_hash1', height: 42, time: new Date('2025-01-01') },
170
+ date: new Date('2025-01-01'),
168
171
  fees: 111n,
169
- feesPayer: "sender",
170
- hash: "transaction_hash2",
172
+ feesPayer: 'sender',
173
+ hash: 'transaction_hash2',
171
174
  failed: false,
172
175
  },
173
- type: "IN",
176
+ type: 'IN',
174
177
  value: 505000000n,
175
178
  },
176
179
  ],
177
- next: "",
178
- });
179
- });
180
+ next: '',
181
+ })
182
+ })
180
183
 
181
- it("stops at minHeight", async () => {
184
+ it('stops at minHeight', async () => {
182
185
  mockCall.mockResolvedValueOnce({
183
186
  records: [
184
187
  {
185
- id: "operation_id1",
186
- transaction_hash: "transaction_hash1",
187
- paging_token: "token1",
188
- source_account: "address",
189
- from: "address",
190
- to: "receiver1",
191
- amount: "46.0600000",
188
+ id: 'operation_id1',
189
+ transaction_hash: 'transaction_hash1',
190
+ paging_token: 'token1',
191
+ source_account: 'address',
192
+ from: 'address',
193
+ to: 'receiver1',
194
+ amount: '46.0600000',
192
195
  type: Horizon.HorizonApi.OperationResponseType.payment,
193
196
  transaction_successful: true,
194
- created_at: "2025-01-01",
197
+ created_at: '2025-01-01',
195
198
  transaction: () => ({
196
- fee_charged: "111900",
197
- fee_account: "address",
199
+ fee_charged: '111900',
200
+ fee_account: 'address',
198
201
  ledger_attr: 42,
199
202
  ledger: () => ({
200
- hash: "block_hash1",
201
- closed_at: "2025-01-01",
203
+ hash: 'block_hash1',
204
+ closed_at: '2025-01-01',
202
205
  }),
203
206
  }),
204
207
  },
205
208
  {
206
- id: "operation_id2",
207
- transaction_hash: "transaction_hash1",
208
- paging_token: "token2",
209
- source_account: "address",
210
- from: "address",
211
- to: "receiver2",
212
- amount: "666.0000000",
209
+ id: 'operation_id2',
210
+ transaction_hash: 'transaction_hash1',
211
+ paging_token: 'token2',
212
+ source_account: 'address',
213
+ from: 'address',
214
+ to: 'receiver2',
215
+ amount: '666.0000000',
213
216
  type: Horizon.HorizonApi.OperationResponseType.payment,
214
217
  transaction_successful: false,
215
- created_at: "2025-01-01",
218
+ created_at: '2025-01-01',
216
219
  transaction: () => ({
217
- fee_charged: "11100",
218
- fee_account: "address",
220
+ fee_charged: '11100',
221
+ fee_account: 'address',
219
222
  ledger_attr: 41,
220
223
  ledger: () => ({
221
- hash: "block_hash1",
222
- closed_at: "2025-01-01",
224
+ hash: 'block_hash1',
225
+ closed_at: '2025-01-01',
223
226
  }),
224
227
  }),
225
228
  },
226
229
  {
227
- id: "operation_id3",
228
- transaction_hash: "transaction_hash2",
229
- paging_token: "token3",
230
- source_account: "sender",
231
- from: "sender",
232
- to: "address",
233
- amount: "50.5000000",
230
+ id: 'operation_id3',
231
+ transaction_hash: 'transaction_hash2',
232
+ paging_token: 'token3',
233
+ source_account: 'sender',
234
+ from: 'sender',
235
+ to: 'address',
236
+ amount: '50.5000000',
234
237
  type: Horizon.HorizonApi.OperationResponseType.payment,
235
238
  transaction_successful: true,
236
- created_at: "2025-01-01",
239
+ created_at: '2025-01-01',
237
240
  transaction: () => ({
238
- fee_charged: "111",
239
- fee_account: "sender",
241
+ fee_charged: '111',
242
+ fee_account: 'sender',
240
243
  ledger_attr: 40,
241
244
  ledger: () => ({
242
- hash: "block_hash1",
243
- closed_at: "2025-01-01",
245
+ hash: 'block_hash1',
246
+ closed_at: '2025-01-01',
244
247
  }),
245
248
  }),
246
249
  },
247
250
  ],
248
- } as any);
251
+ } as any)
249
252
 
250
- expect(await listOperations("address", { order: "asc", minHeight: 41 })).toEqual({
253
+ expect(await listOperations('address', { order: 'asc', minHeight: 41 })).toEqual({
251
254
  items: [
252
255
  {
253
- id: "transaction_hash1-operation_id1",
254
- asset: { type: "native" },
256
+ id: 'transaction_hash1-operation_id1',
257
+ asset: { type: 'native' },
255
258
  details: {
256
- assetAmount: "460600000",
257
- ledgerOpType: "OUT",
259
+ assetAmount: '460600000',
260
+ ledgerOpType: 'OUT',
258
261
  sequence: undefined,
259
262
  memo: undefined,
260
263
  },
261
- senders: ["address"],
262
- recipients: ["receiver1"],
264
+ senders: ['address'],
265
+ recipients: ['receiver1'],
263
266
  tx: {
264
- block: { hash: "block_hash1", height: 42, time: new Date("2025-01-01") },
265
- date: new Date("2025-01-01"),
267
+ block: { hash: 'block_hash1', height: 42, time: new Date('2025-01-01') },
268
+ date: new Date('2025-01-01'),
266
269
  fees: 111900n,
267
- feesPayer: "address",
268
- hash: "transaction_hash1",
270
+ feesPayer: 'address',
271
+ hash: 'transaction_hash1',
269
272
  failed: false,
270
273
  },
271
- type: "OUT",
274
+ type: 'OUT',
272
275
  value: 460600000n,
273
276
  },
274
277
  {
275
- id: "transaction_hash1-operation_id2",
276
- asset: { type: "native" },
278
+ id: 'transaction_hash1-operation_id2',
279
+ asset: { type: 'native' },
277
280
  details: {
278
- assetAmount: "11100",
279
- ledgerOpType: "OUT",
281
+ assetAmount: '11100',
282
+ ledgerOpType: 'OUT',
280
283
  sequence: undefined,
281
284
  memo: undefined,
282
285
  },
283
- senders: ["address"],
284
- recipients: ["receiver2"],
286
+ senders: ['address'],
287
+ recipients: ['receiver2'],
285
288
  tx: {
286
- block: { hash: "block_hash1", height: 41, time: new Date("2025-01-01") },
287
- date: new Date("2025-01-01"),
289
+ block: { hash: 'block_hash1', height: 41, time: new Date('2025-01-01') },
290
+ date: new Date('2025-01-01'),
288
291
  fees: 11100n,
289
- feesPayer: "address",
290
- hash: "transaction_hash1",
292
+ feesPayer: 'address',
293
+ hash: 'transaction_hash1',
291
294
  failed: true,
292
295
  },
293
- type: "OUT",
296
+ type: 'OUT',
294
297
  value: 11100n,
295
298
  },
296
299
  ],
297
- next: "",
298
- });
299
- });
300
+ next: '',
301
+ })
302
+ })
300
303
 
301
- it("should return memo if set", async () => {
304
+ it('should return memo if set', async () => {
302
305
  mockCall.mockResolvedValueOnce({
303
306
  records: [
304
307
  {
305
- id: "operation_id1",
306
- transaction_hash: "transaction_hash1",
307
- paging_token: "token1",
308
- source_account: "address",
309
- from: "address",
310
- to: "receiver1",
311
- amount: "46.0600000",
308
+ id: 'operation_id1',
309
+ transaction_hash: 'transaction_hash1',
310
+ paging_token: 'token1',
311
+ source_account: 'address',
312
+ from: 'address',
313
+ to: 'receiver1',
314
+ amount: '46.0600000',
312
315
  type: Horizon.HorizonApi.OperationResponseType.payment,
313
316
  transaction_successful: true,
314
- created_at: "2025-01-01",
317
+ created_at: '2025-01-01',
315
318
  transaction: () => ({
316
- fee_charged: "111900",
317
- fee_account: "address",
319
+ fee_charged: '111900',
320
+ fee_account: 'address',
318
321
  ledger_attr: 42,
319
- memo_type: "text",
320
- memo: "momo",
322
+ memo_type: 'text',
323
+ memo: 'momo',
321
324
  ledger: () => ({
322
- hash: "block_hash1",
323
- closed_at: "2025-01-01",
325
+ hash: 'block_hash1',
326
+ closed_at: '2025-01-01',
324
327
  }),
325
328
  }),
326
329
  },
327
330
  ],
328
- } as any);
331
+ } as any)
329
332
 
330
- expect(await listOperations("address", { order: "asc", minHeight: 0 })).toEqual({
333
+ expect(await listOperations('address', { order: 'asc', minHeight: 0 })).toEqual({
331
334
  items: [
332
335
  {
333
- id: "transaction_hash1-operation_id1",
334
- asset: { type: "native" },
335
- senders: ["address"],
336
- recipients: ["receiver1"],
336
+ id: 'transaction_hash1-operation_id1',
337
+ asset: { type: 'native' },
338
+ senders: ['address'],
339
+ recipients: ['receiver1'],
337
340
  tx: {
338
- block: { hash: "block_hash1", height: 42, time: new Date("2025-01-01") },
339
- date: new Date("2025-01-01"),
341
+ block: { hash: 'block_hash1', height: 42, time: new Date('2025-01-01') },
342
+ date: new Date('2025-01-01'),
340
343
  fees: 111900n,
341
- feesPayer: "address",
342
- hash: "transaction_hash1",
344
+ feesPayer: 'address',
345
+ hash: 'transaction_hash1',
343
346
  failed: false,
344
347
  },
345
- type: "OUT",
348
+ type: 'OUT',
346
349
  value: 460600000n,
347
350
  details: {
348
- assetAmount: "460600000",
349
- ledgerOpType: "OUT",
351
+ assetAmount: '460600000',
352
+ ledgerOpType: 'OUT',
350
353
  sequence: undefined,
351
354
  memo: {
352
- type: "MEMO_TEXT",
353
- value: "momo",
355
+ type: 'MEMO_TEXT',
356
+ value: 'momo',
354
357
  },
355
358
  },
356
359
  },
357
360
  ],
358
- next: "",
359
- });
360
- });
361
+ next: '',
362
+ })
363
+ })
361
364
 
362
- it("uses fee_account as feesPayer for fee bump transactions when fee_account differs from source_account", async () => {
365
+ it('uses fee_account as feesPayer for fee bump transactions when fee_account differs from source_account', async () => {
363
366
  mockCall.mockResolvedValueOnce({
364
367
  records: [
365
368
  {
366
- id: "operation_id1",
367
- transaction_hash: "transaction_hash1",
368
- paging_token: "token1",
369
- source_account: "address",
370
- from: "address",
371
- to: "receiver1",
372
- amount: "10.0000000",
369
+ id: 'operation_id1',
370
+ transaction_hash: 'transaction_hash1',
371
+ paging_token: 'token1',
372
+ source_account: 'address',
373
+ from: 'address',
374
+ to: 'receiver1',
375
+ amount: '10.0000000',
373
376
  type: Horizon.HorizonApi.OperationResponseType.payment,
374
377
  transaction_successful: true,
375
- created_at: "2025-01-01",
378
+ created_at: '2025-01-01',
376
379
  transaction: () => ({
377
- fee_charged: "500",
378
- fee_account: "sponsor_address",
379
- source_account: "address",
380
+ fee_charged: '500',
381
+ fee_account: 'sponsor_address',
382
+ source_account: 'address',
380
383
  ledger_attr: 42,
381
384
  ledger: () => ({
382
- hash: "block_hash1",
383
- closed_at: "2025-01-01",
385
+ hash: 'block_hash1',
386
+ closed_at: '2025-01-01',
384
387
  }),
385
388
  }),
386
389
  },
387
390
  ],
388
- } as any);
391
+ } as any)
389
392
 
390
- const { items: operations } = await listOperations("address", { order: "asc", minHeight: 0 });
391
- expect(operations).toHaveLength(1);
393
+ const { items: operations } = await listOperations('address', { order: 'asc', minHeight: 0 })
394
+ expect(operations).toHaveLength(1)
392
395
  expect(operations[0]).toMatchObject({
393
396
  tx: {
394
397
  fees: 500n,
395
- feesPayer: "sponsor_address",
398
+ feesPayer: 'sponsor_address',
396
399
  },
397
- senders: ["address"],
398
- recipients: ["receiver1"],
399
- });
400
- });
401
- });
400
+ senders: ['address'],
401
+ recipients: ['receiver1'],
402
+ })
403
+ })
404
+ })