@ledgerhq/coin-stellar 6.26.0 → 6.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.oxlintrc.json +7 -0
- package/CHANGELOG.md +6 -0
- package/LICENSE +194 -0
- package/knip.json +12 -0
- package/lib/api/index.d.ts +5 -5
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +12 -10
- package/lib/api/index.js.map +1 -1
- package/lib/config.d.ts +1 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +2 -0
- package/lib/config.js.map +1 -1
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +3 -1
- package/lib/constants.js.map +1 -1
- package/lib/logic/broadcast.d.ts.map +1 -1
- package/lib/logic/broadcast.js +2 -0
- package/lib/logic/broadcast.js.map +1 -1
- package/lib/logic/combine.d.ts +1 -1
- package/lib/logic/combine.d.ts.map +1 -1
- package/lib/logic/combine.js +2 -0
- package/lib/logic/combine.js.map +1 -1
- package/lib/logic/common.d.ts +1 -1
- package/lib/logic/common.d.ts.map +1 -1
- package/lib/logic/common.js +4 -2
- package/lib/logic/common.js.map +1 -1
- package/lib/logic/craftTransaction.d.ts +1 -1
- package/lib/logic/craftTransaction.d.ts.map +1 -1
- package/lib/logic/craftTransaction.js +10 -8
- package/lib/logic/craftTransaction.js.map +1 -1
- package/lib/logic/estimateFees.d.ts.map +1 -1
- package/lib/logic/estimateFees.js +2 -0
- package/lib/logic/estimateFees.js.map +1 -1
- package/lib/logic/getBalance.d.ts +1 -1
- package/lib/logic/getBalance.d.ts.map +1 -1
- package/lib/logic/getBalance.js +4 -2
- package/lib/logic/getBalance.js.map +1 -1
- package/lib/logic/getBlock.d.ts +1 -1
- package/lib/logic/getBlock.d.ts.map +1 -1
- package/lib/logic/getBlock.js +39 -34
- package/lib/logic/getBlock.js.map +1 -1
- package/lib/logic/getBlockInfo.d.ts +1 -1
- package/lib/logic/getBlockInfo.d.ts.map +1 -1
- package/lib/logic/getBlockInfo.js +2 -0
- package/lib/logic/getBlockInfo.js.map +1 -1
- package/lib/logic/index.d.ts +12 -12
- package/lib/logic/index.d.ts.map +1 -1
- package/lib/logic/index.js +2 -0
- package/lib/logic/index.js.map +1 -1
- package/lib/logic/lastBlock.d.ts +1 -1
- package/lib/logic/lastBlock.d.ts.map +1 -1
- package/lib/logic/lastBlock.js +2 -0
- package/lib/logic/lastBlock.js.map +1 -1
- package/lib/logic/listOperations.d.ts +1 -1
- package/lib/logic/listOperations.d.ts.map +1 -1
- package/lib/logic/listOperations.js +6 -4
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/logic/sdkWrapper.d.ts +1 -1
- package/lib/logic/sdkWrapper.d.ts.map +1 -1
- package/lib/logic/sdkWrapper.js +2 -0
- package/lib/logic/sdkWrapper.js.map +1 -1
- package/lib/logic/utils.d.ts.map +1 -1
- package/lib/logic/utils.js +4 -2
- package/lib/logic/utils.js.map +1 -1
- package/lib/logic/validateAddress.d.ts +1 -1
- package/lib/logic/validateAddress.d.ts.map +1 -1
- package/lib/logic/validateAddress.js +2 -0
- package/lib/logic/validateAddress.js.map +1 -1
- package/lib/logic/validateIntent.d.ts +2 -2
- package/lib/logic/validateIntent.d.ts.map +1 -1
- package/lib/logic/validateIntent.js +21 -19
- package/lib/logic/validateIntent.js.map +1 -1
- package/lib/logic/validateMemo.d.ts +1 -1
- package/lib/logic/validateMemo.d.ts.map +1 -1
- package/lib/logic/validateMemo.js +7 -5
- package/lib/logic/validateMemo.js.map +1 -1
- package/lib/network/horizon.d.ts +6 -7
- package/lib/network/horizon.d.ts.map +1 -1
- package/lib/network/horizon.js +71 -68
- package/lib/network/horizon.js.map +1 -1
- package/lib/network/horizonLedgerErrors.d.ts.map +1 -1
- package/lib/network/horizonLedgerErrors.js +5 -3
- package/lib/network/horizonLedgerErrors.js.map +1 -1
- package/lib/network/index.d.ts +1 -1
- package/lib/network/index.d.ts.map +1 -1
- package/lib/network/index.js +2 -0
- package/lib/network/index.js.map +1 -1
- package/lib/network/serialization.d.ts +6 -4
- package/lib/network/serialization.d.ts.map +1 -1
- package/lib/network/serialization.js +95 -91
- package/lib/network/serialization.js.map +1 -1
- package/lib/polyfill.d.ts.map +1 -1
- package/lib/polyfill.js +6 -4
- package/lib/polyfill.js.map +1 -1
- package/lib/supportedFeatures.d.ts +1 -1
- package/lib/supportedFeatures.d.ts.map +1 -1
- package/lib/supportedFeatures.js +3 -1
- package/lib/supportedFeatures.js.map +1 -1
- package/lib/types/errors.d.ts.map +1 -1
- package/lib/types/errors.js +14 -12
- package/lib/types/errors.js.map +1 -1
- package/lib/types/index.d.ts +2 -2
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +2 -0
- package/lib/types/index.js.map +1 -1
- package/lib/types/model.d.ts +6 -6
- package/lib/types/model.d.ts.map +1 -1
- package/lib/types/model.js +7 -5
- package/lib/types/model.js.map +1 -1
- package/lib-es/api/index.d.ts +5 -5
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +20 -18
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/config.d.ts +1 -1
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/config.js +3 -1
- package/lib-es/config.js.map +1 -1
- package/lib-es/constants.d.ts.map +1 -1
- package/lib-es/constants.js +3 -1
- package/lib-es/constants.js.map +1 -1
- package/lib-es/logic/broadcast.d.ts.map +1 -1
- package/lib-es/logic/broadcast.js +3 -1
- package/lib-es/logic/broadcast.js.map +1 -1
- package/lib-es/logic/combine.d.ts +1 -1
- package/lib-es/logic/combine.d.ts.map +1 -1
- package/lib-es/logic/combine.js +3 -1
- package/lib-es/logic/combine.js.map +1 -1
- package/lib-es/logic/common.d.ts +1 -1
- package/lib-es/logic/common.d.ts.map +1 -1
- package/lib-es/logic/common.js +5 -3
- package/lib-es/logic/common.js.map +1 -1
- package/lib-es/logic/craftTransaction.d.ts +1 -1
- package/lib-es/logic/craftTransaction.d.ts.map +1 -1
- package/lib-es/logic/craftTransaction.js +15 -13
- package/lib-es/logic/craftTransaction.js.map +1 -1
- package/lib-es/logic/estimateFees.d.ts.map +1 -1
- package/lib-es/logic/estimateFees.js +3 -1
- package/lib-es/logic/estimateFees.js.map +1 -1
- package/lib-es/logic/getBalance.d.ts +1 -1
- package/lib-es/logic/getBalance.d.ts.map +1 -1
- package/lib-es/logic/getBalance.js +5 -3
- package/lib-es/logic/getBalance.js.map +1 -1
- package/lib-es/logic/getBlock.d.ts +1 -1
- package/lib-es/logic/getBlock.d.ts.map +1 -1
- package/lib-es/logic/getBlock.js +42 -37
- package/lib-es/logic/getBlock.js.map +1 -1
- package/lib-es/logic/getBlockInfo.d.ts +1 -1
- package/lib-es/logic/getBlockInfo.d.ts.map +1 -1
- package/lib-es/logic/getBlockInfo.js +3 -1
- package/lib-es/logic/getBlockInfo.js.map +1 -1
- package/lib-es/logic/index.d.ts +12 -12
- package/lib-es/logic/index.d.ts.map +1 -1
- package/lib-es/logic/index.js +14 -12
- package/lib-es/logic/index.js.map +1 -1
- package/lib-es/logic/lastBlock.d.ts +1 -1
- package/lib-es/logic/lastBlock.d.ts.map +1 -1
- package/lib-es/logic/lastBlock.js +3 -1
- package/lib-es/logic/lastBlock.js.map +1 -1
- package/lib-es/logic/listOperations.d.ts +1 -1
- package/lib-es/logic/listOperations.d.ts.map +1 -1
- package/lib-es/logic/listOperations.js +7 -5
- package/lib-es/logic/listOperations.js.map +1 -1
- package/lib-es/logic/sdkWrapper.d.ts +1 -1
- package/lib-es/logic/sdkWrapper.d.ts.map +1 -1
- package/lib-es/logic/sdkWrapper.js +4 -2
- package/lib-es/logic/sdkWrapper.js.map +1 -1
- package/lib-es/logic/utils.d.ts.map +1 -1
- package/lib-es/logic/utils.js +6 -4
- package/lib-es/logic/utils.js.map +1 -1
- package/lib-es/logic/validateAddress.d.ts +1 -1
- package/lib-es/logic/validateAddress.d.ts.map +1 -1
- package/lib-es/logic/validateAddress.js +3 -1
- package/lib-es/logic/validateAddress.js.map +1 -1
- package/lib-es/logic/validateIntent.d.ts +2 -2
- package/lib-es/logic/validateIntent.d.ts.map +1 -1
- package/lib-es/logic/validateIntent.js +30 -28
- package/lib-es/logic/validateIntent.js.map +1 -1
- package/lib-es/logic/validateMemo.d.ts +1 -1
- package/lib-es/logic/validateMemo.d.ts.map +1 -1
- package/lib-es/logic/validateMemo.js +8 -6
- package/lib-es/logic/validateMemo.js.map +1 -1
- package/lib-es/network/horizon.d.ts +6 -7
- package/lib-es/network/horizon.d.ts.map +1 -1
- package/lib-es/network/horizon.js +80 -77
- package/lib-es/network/horizon.js.map +1 -1
- package/lib-es/network/horizonLedgerErrors.d.ts.map +1 -1
- package/lib-es/network/horizonLedgerErrors.js +7 -5
- package/lib-es/network/horizonLedgerErrors.js.map +1 -1
- package/lib-es/network/index.d.ts +1 -1
- package/lib-es/network/index.d.ts.map +1 -1
- package/lib-es/network/index.js +3 -1
- package/lib-es/network/index.js.map +1 -1
- package/lib-es/network/serialization.d.ts +6 -4
- package/lib-es/network/serialization.d.ts.map +1 -1
- package/lib-es/network/serialization.js +97 -95
- package/lib-es/network/serialization.js.map +1 -1
- package/lib-es/polyfill.d.ts.map +1 -1
- package/lib-es/polyfill.js +7 -5
- package/lib-es/polyfill.js.map +1 -1
- package/lib-es/supportedFeatures.d.ts +1 -1
- package/lib-es/supportedFeatures.d.ts.map +1 -1
- package/lib-es/supportedFeatures.js +3 -1
- package/lib-es/supportedFeatures.js.map +1 -1
- package/lib-es/types/errors.d.ts.map +1 -1
- package/lib-es/types/errors.js +15 -13
- package/lib-es/types/errors.js.map +1 -1
- package/lib-es/types/index.d.ts +2 -2
- package/lib-es/types/index.d.ts.map +1 -1
- package/lib-es/types/index.js +4 -2
- package/lib-es/types/index.js.map +1 -1
- package/lib-es/types/model.d.ts +6 -6
- package/lib-es/types/model.d.ts.map +1 -1
- package/lib-es/types/model.js +7 -5
- package/lib-es/types/model.js.map +1 -1
- package/package.json +13 -16
- package/src/api/index.integ.test.ts +165 -162
- package/src/api/index.test.ts +106 -103
- package/src/api/index.ts +49 -46
- package/src/api/index_error.test.ts +48 -25
- package/src/config.ts +15 -12
- package/src/constants.ts +4 -1
- package/src/globals.d.ts +7 -5
- package/src/logic/broadcast.integ.test.ts +22 -19
- package/src/logic/broadcast.ts +5 -2
- package/src/logic/combine.test.ts +18 -15
- package/src/logic/combine.ts +8 -5
- package/src/logic/common.ts +9 -6
- package/src/logic/craftTransaction.test.ts +76 -75
- package/src/logic/craftTransaction.ts +46 -43
- package/src/logic/estimateFees.ts +6 -3
- package/src/logic/getBalance.test.ts +31 -28
- package/src/logic/getBalance.ts +13 -10
- package/src/logic/getBlock.integ.test.ts +40 -39
- package/src/logic/getBlock.test.ts +462 -415
- package/src/logic/getBlock.ts +142 -127
- package/src/logic/getBlockInfo.test.ts +72 -69
- package/src/logic/getBlockInfo.ts +15 -12
- package/src/logic/index.ts +15 -12
- package/src/logic/lastBlock.ts +6 -3
- package/src/logic/listOperations.ts +14 -11
- package/src/logic/listOperations.unit.test.ts +212 -209
- package/src/logic/networkWrappers.test.ts +32 -29
- package/src/logic/sdkWrapper.ts +19 -16
- package/src/logic/utils.ts +13 -10
- package/src/logic/validateAddress.test.ts +21 -18
- package/src/logic/validateAddress.ts +7 -4
- package/src/logic/validateIntent.test.ts +62 -59
- package/src/logic/validateIntent.ts +87 -84
- package/src/logic/validateMemo.test.ts +50 -47
- package/src/logic/validateMemo.ts +16 -13
- package/src/network/broadcastTransaction.test.ts +60 -60
- package/src/network/fetchLedgerOperations.unit.test.ts +155 -0
- package/src/network/horizon.integ.test.ts +45 -42
- package/src/network/horizon.test.ts +17 -14
- package/src/network/horizon.ts +279 -281
- package/src/network/horizon.unit.test.ts +238 -237
- package/src/network/horizonLedgerErrors.test.ts +81 -78
- package/src/network/horizonLedgerErrors.ts +22 -19
- package/src/network/index.ts +4 -1
- package/src/network/registerHorizonInterceptors.test.ts +163 -160
- package/src/network/serialization.ts +232 -227
- package/src/network/serialization.unit.test.ts +801 -798
- package/src/polyfill.ts +18 -15
- package/src/supportedFeatures.ts +6 -3
- package/src/types/errors.ts +33 -32
- package/src/types/index.ts +5 -2
- package/src/types/model.ts +55 -52
- package/tsconfig.json +1 -1
- package/.unimportedrc.json +0 -17
- package/LICENSE.txt +0 -21
- package/src/network/fetchLedgerOperations.nock.unit.test.ts +0 -156
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { listOperations } from "./listOperations";
|
|
1
|
+
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
import { Horizon } from '@stellar/stellar-sdk'
|
|
5
|
+
import coinConfig from '../config'
|
|
6
|
+
import { listOperations } from './listOperations'
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
jest.mock('@stellar/stellar-sdk')
|
|
9
|
+
|
|
10
|
+
describe('listOperations', () => {
|
|
8
11
|
coinConfig.setCoinConfig(() => ({
|
|
9
|
-
status: { type:
|
|
10
|
-
explorer: { url:
|
|
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(
|
|
42
|
+
it('lists operations associated with an address', async () => {
|
|
40
43
|
mockCall.mockResolvedValueOnce({
|
|
41
44
|
records: [
|
|
42
45
|
{
|
|
43
|
-
id:
|
|
44
|
-
transaction_hash:
|
|
45
|
-
paging_token:
|
|
46
|
-
source_account:
|
|
47
|
-
from:
|
|
48
|
-
to:
|
|
49
|
-
amount:
|
|
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:
|
|
55
|
+
created_at: '2025-01-01',
|
|
53
56
|
transaction: () => ({
|
|
54
|
-
fee_charged:
|
|
55
|
-
fee_account:
|
|
57
|
+
fee_charged: '111900',
|
|
58
|
+
fee_account: 'address',
|
|
56
59
|
ledger_attr: 42,
|
|
57
60
|
ledger: () => ({
|
|
58
|
-
hash:
|
|
59
|
-
closed_at:
|
|
61
|
+
hash: 'block_hash1',
|
|
62
|
+
closed_at: '2025-01-01',
|
|
60
63
|
}),
|
|
61
64
|
}),
|
|
62
65
|
},
|
|
63
66
|
{
|
|
64
|
-
id:
|
|
65
|
-
transaction_hash:
|
|
66
|
-
paging_token:
|
|
67
|
-
source_account:
|
|
68
|
-
from:
|
|
69
|
-
to:
|
|
70
|
-
amount:
|
|
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:
|
|
76
|
+
created_at: '2025-01-01',
|
|
74
77
|
transaction: () => ({
|
|
75
|
-
fee_charged:
|
|
76
|
-
fee_account:
|
|
78
|
+
fee_charged: '11100',
|
|
79
|
+
fee_account: 'address',
|
|
77
80
|
ledger_attr: 42,
|
|
78
81
|
ledger: () => ({
|
|
79
|
-
hash:
|
|
80
|
-
closed_at:
|
|
82
|
+
hash: 'block_hash1',
|
|
83
|
+
closed_at: '2025-01-01',
|
|
81
84
|
}),
|
|
82
85
|
}),
|
|
83
86
|
},
|
|
84
87
|
{
|
|
85
|
-
id:
|
|
86
|
-
transaction_hash:
|
|
87
|
-
paging_token:
|
|
88
|
-
source_account:
|
|
89
|
-
from:
|
|
90
|
-
to:
|
|
91
|
-
amount:
|
|
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:
|
|
97
|
+
created_at: '2025-01-01',
|
|
95
98
|
transaction: () => ({
|
|
96
|
-
fee_charged:
|
|
97
|
-
fee_account:
|
|
99
|
+
fee_charged: '111',
|
|
100
|
+
fee_account: 'sender',
|
|
98
101
|
ledger_attr: 42,
|
|
99
102
|
ledger: () => ({
|
|
100
|
-
hash:
|
|
101
|
-
closed_at:
|
|
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(
|
|
111
|
+
expect(await listOperations('address', { order: 'asc', minHeight: 0 })).toEqual({
|
|
109
112
|
items: [
|
|
110
113
|
{
|
|
111
|
-
id:
|
|
112
|
-
asset: { type:
|
|
114
|
+
id: 'transaction_hash1-operation_id1',
|
|
115
|
+
asset: { type: 'native' },
|
|
113
116
|
details: {
|
|
114
|
-
assetAmount:
|
|
115
|
-
ledgerOpType:
|
|
117
|
+
assetAmount: '460600000',
|
|
118
|
+
ledgerOpType: 'OUT',
|
|
116
119
|
sequence: undefined,
|
|
117
120
|
memo: undefined,
|
|
118
121
|
},
|
|
119
|
-
senders: [
|
|
120
|
-
recipients: [
|
|
122
|
+
senders: ['address'],
|
|
123
|
+
recipients: ['receiver1'],
|
|
121
124
|
tx: {
|
|
122
|
-
block: { hash:
|
|
123
|
-
date: new Date(
|
|
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:
|
|
126
|
-
hash:
|
|
128
|
+
feesPayer: 'address',
|
|
129
|
+
hash: 'transaction_hash1',
|
|
127
130
|
failed: false,
|
|
128
131
|
},
|
|
129
|
-
type:
|
|
132
|
+
type: 'OUT',
|
|
130
133
|
value: 460600000n,
|
|
131
134
|
},
|
|
132
135
|
{
|
|
133
|
-
id:
|
|
134
|
-
asset: { type:
|
|
136
|
+
id: 'transaction_hash1-operation_id2',
|
|
137
|
+
asset: { type: 'native' },
|
|
135
138
|
details: {
|
|
136
|
-
assetAmount:
|
|
137
|
-
ledgerOpType:
|
|
139
|
+
assetAmount: '11100',
|
|
140
|
+
ledgerOpType: 'OUT',
|
|
138
141
|
sequence: undefined,
|
|
139
142
|
memo: undefined,
|
|
140
143
|
},
|
|
141
|
-
senders: [
|
|
142
|
-
recipients: [
|
|
144
|
+
senders: ['address'],
|
|
145
|
+
recipients: ['receiver2'],
|
|
143
146
|
tx: {
|
|
144
|
-
block: { hash:
|
|
145
|
-
date: new Date(
|
|
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:
|
|
148
|
-
hash:
|
|
150
|
+
feesPayer: 'address',
|
|
151
|
+
hash: 'transaction_hash1',
|
|
149
152
|
failed: true,
|
|
150
153
|
},
|
|
151
|
-
type:
|
|
154
|
+
type: 'OUT',
|
|
152
155
|
value: 11100n,
|
|
153
156
|
},
|
|
154
157
|
{
|
|
155
|
-
id:
|
|
156
|
-
asset: { type:
|
|
158
|
+
id: 'transaction_hash2-operation_id3',
|
|
159
|
+
asset: { type: 'native' },
|
|
157
160
|
details: {
|
|
158
|
-
assetAmount:
|
|
159
|
-
ledgerOpType:
|
|
161
|
+
assetAmount: '505000000',
|
|
162
|
+
ledgerOpType: 'IN',
|
|
160
163
|
sequence: undefined,
|
|
161
164
|
memo: undefined,
|
|
162
165
|
},
|
|
163
|
-
senders: [
|
|
164
|
-
recipients: [
|
|
166
|
+
senders: ['sender'],
|
|
167
|
+
recipients: ['address'],
|
|
165
168
|
tx: {
|
|
166
|
-
block: { hash:
|
|
167
|
-
date: new Date(
|
|
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:
|
|
170
|
-
hash:
|
|
172
|
+
feesPayer: 'sender',
|
|
173
|
+
hash: 'transaction_hash2',
|
|
171
174
|
failed: false,
|
|
172
175
|
},
|
|
173
|
-
type:
|
|
176
|
+
type: 'IN',
|
|
174
177
|
value: 505000000n,
|
|
175
178
|
},
|
|
176
179
|
],
|
|
177
|
-
next:
|
|
178
|
-
})
|
|
179
|
-
})
|
|
180
|
+
next: '',
|
|
181
|
+
})
|
|
182
|
+
})
|
|
180
183
|
|
|
181
|
-
it(
|
|
184
|
+
it('stops at minHeight', async () => {
|
|
182
185
|
mockCall.mockResolvedValueOnce({
|
|
183
186
|
records: [
|
|
184
187
|
{
|
|
185
|
-
id:
|
|
186
|
-
transaction_hash:
|
|
187
|
-
paging_token:
|
|
188
|
-
source_account:
|
|
189
|
-
from:
|
|
190
|
-
to:
|
|
191
|
-
amount:
|
|
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:
|
|
197
|
+
created_at: '2025-01-01',
|
|
195
198
|
transaction: () => ({
|
|
196
|
-
fee_charged:
|
|
197
|
-
fee_account:
|
|
199
|
+
fee_charged: '111900',
|
|
200
|
+
fee_account: 'address',
|
|
198
201
|
ledger_attr: 42,
|
|
199
202
|
ledger: () => ({
|
|
200
|
-
hash:
|
|
201
|
-
closed_at:
|
|
203
|
+
hash: 'block_hash1',
|
|
204
|
+
closed_at: '2025-01-01',
|
|
202
205
|
}),
|
|
203
206
|
}),
|
|
204
207
|
},
|
|
205
208
|
{
|
|
206
|
-
id:
|
|
207
|
-
transaction_hash:
|
|
208
|
-
paging_token:
|
|
209
|
-
source_account:
|
|
210
|
-
from:
|
|
211
|
-
to:
|
|
212
|
-
amount:
|
|
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:
|
|
218
|
+
created_at: '2025-01-01',
|
|
216
219
|
transaction: () => ({
|
|
217
|
-
fee_charged:
|
|
218
|
-
fee_account:
|
|
220
|
+
fee_charged: '11100',
|
|
221
|
+
fee_account: 'address',
|
|
219
222
|
ledger_attr: 41,
|
|
220
223
|
ledger: () => ({
|
|
221
|
-
hash:
|
|
222
|
-
closed_at:
|
|
224
|
+
hash: 'block_hash1',
|
|
225
|
+
closed_at: '2025-01-01',
|
|
223
226
|
}),
|
|
224
227
|
}),
|
|
225
228
|
},
|
|
226
229
|
{
|
|
227
|
-
id:
|
|
228
|
-
transaction_hash:
|
|
229
|
-
paging_token:
|
|
230
|
-
source_account:
|
|
231
|
-
from:
|
|
232
|
-
to:
|
|
233
|
-
amount:
|
|
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:
|
|
239
|
+
created_at: '2025-01-01',
|
|
237
240
|
transaction: () => ({
|
|
238
|
-
fee_charged:
|
|
239
|
-
fee_account:
|
|
241
|
+
fee_charged: '111',
|
|
242
|
+
fee_account: 'sender',
|
|
240
243
|
ledger_attr: 40,
|
|
241
244
|
ledger: () => ({
|
|
242
|
-
hash:
|
|
243
|
-
closed_at:
|
|
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(
|
|
253
|
+
expect(await listOperations('address', { order: 'asc', minHeight: 41 })).toEqual({
|
|
251
254
|
items: [
|
|
252
255
|
{
|
|
253
|
-
id:
|
|
254
|
-
asset: { type:
|
|
256
|
+
id: 'transaction_hash1-operation_id1',
|
|
257
|
+
asset: { type: 'native' },
|
|
255
258
|
details: {
|
|
256
|
-
assetAmount:
|
|
257
|
-
ledgerOpType:
|
|
259
|
+
assetAmount: '460600000',
|
|
260
|
+
ledgerOpType: 'OUT',
|
|
258
261
|
sequence: undefined,
|
|
259
262
|
memo: undefined,
|
|
260
263
|
},
|
|
261
|
-
senders: [
|
|
262
|
-
recipients: [
|
|
264
|
+
senders: ['address'],
|
|
265
|
+
recipients: ['receiver1'],
|
|
263
266
|
tx: {
|
|
264
|
-
block: { hash:
|
|
265
|
-
date: new Date(
|
|
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:
|
|
268
|
-
hash:
|
|
270
|
+
feesPayer: 'address',
|
|
271
|
+
hash: 'transaction_hash1',
|
|
269
272
|
failed: false,
|
|
270
273
|
},
|
|
271
|
-
type:
|
|
274
|
+
type: 'OUT',
|
|
272
275
|
value: 460600000n,
|
|
273
276
|
},
|
|
274
277
|
{
|
|
275
|
-
id:
|
|
276
|
-
asset: { type:
|
|
278
|
+
id: 'transaction_hash1-operation_id2',
|
|
279
|
+
asset: { type: 'native' },
|
|
277
280
|
details: {
|
|
278
|
-
assetAmount:
|
|
279
|
-
ledgerOpType:
|
|
281
|
+
assetAmount: '11100',
|
|
282
|
+
ledgerOpType: 'OUT',
|
|
280
283
|
sequence: undefined,
|
|
281
284
|
memo: undefined,
|
|
282
285
|
},
|
|
283
|
-
senders: [
|
|
284
|
-
recipients: [
|
|
286
|
+
senders: ['address'],
|
|
287
|
+
recipients: ['receiver2'],
|
|
285
288
|
tx: {
|
|
286
|
-
block: { hash:
|
|
287
|
-
date: new Date(
|
|
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:
|
|
290
|
-
hash:
|
|
292
|
+
feesPayer: 'address',
|
|
293
|
+
hash: 'transaction_hash1',
|
|
291
294
|
failed: true,
|
|
292
295
|
},
|
|
293
|
-
type:
|
|
296
|
+
type: 'OUT',
|
|
294
297
|
value: 11100n,
|
|
295
298
|
},
|
|
296
299
|
],
|
|
297
|
-
next:
|
|
298
|
-
})
|
|
299
|
-
})
|
|
300
|
+
next: '',
|
|
301
|
+
})
|
|
302
|
+
})
|
|
300
303
|
|
|
301
|
-
it(
|
|
304
|
+
it('should return memo if set', async () => {
|
|
302
305
|
mockCall.mockResolvedValueOnce({
|
|
303
306
|
records: [
|
|
304
307
|
{
|
|
305
|
-
id:
|
|
306
|
-
transaction_hash:
|
|
307
|
-
paging_token:
|
|
308
|
-
source_account:
|
|
309
|
-
from:
|
|
310
|
-
to:
|
|
311
|
-
amount:
|
|
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:
|
|
317
|
+
created_at: '2025-01-01',
|
|
315
318
|
transaction: () => ({
|
|
316
|
-
fee_charged:
|
|
317
|
-
fee_account:
|
|
319
|
+
fee_charged: '111900',
|
|
320
|
+
fee_account: 'address',
|
|
318
321
|
ledger_attr: 42,
|
|
319
|
-
memo_type:
|
|
320
|
-
memo:
|
|
322
|
+
memo_type: 'text',
|
|
323
|
+
memo: 'momo',
|
|
321
324
|
ledger: () => ({
|
|
322
|
-
hash:
|
|
323
|
-
closed_at:
|
|
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(
|
|
333
|
+
expect(await listOperations('address', { order: 'asc', minHeight: 0 })).toEqual({
|
|
331
334
|
items: [
|
|
332
335
|
{
|
|
333
|
-
id:
|
|
334
|
-
asset: { type:
|
|
335
|
-
senders: [
|
|
336
|
-
recipients: [
|
|
336
|
+
id: 'transaction_hash1-operation_id1',
|
|
337
|
+
asset: { type: 'native' },
|
|
338
|
+
senders: ['address'],
|
|
339
|
+
recipients: ['receiver1'],
|
|
337
340
|
tx: {
|
|
338
|
-
block: { hash:
|
|
339
|
-
date: new Date(
|
|
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:
|
|
342
|
-
hash:
|
|
344
|
+
feesPayer: 'address',
|
|
345
|
+
hash: 'transaction_hash1',
|
|
343
346
|
failed: false,
|
|
344
347
|
},
|
|
345
|
-
type:
|
|
348
|
+
type: 'OUT',
|
|
346
349
|
value: 460600000n,
|
|
347
350
|
details: {
|
|
348
|
-
assetAmount:
|
|
349
|
-
ledgerOpType:
|
|
351
|
+
assetAmount: '460600000',
|
|
352
|
+
ledgerOpType: 'OUT',
|
|
350
353
|
sequence: undefined,
|
|
351
354
|
memo: {
|
|
352
|
-
type:
|
|
353
|
-
value:
|
|
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(
|
|
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:
|
|
367
|
-
transaction_hash:
|
|
368
|
-
paging_token:
|
|
369
|
-
source_account:
|
|
370
|
-
from:
|
|
371
|
-
to:
|
|
372
|
-
amount:
|
|
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:
|
|
378
|
+
created_at: '2025-01-01',
|
|
376
379
|
transaction: () => ({
|
|
377
|
-
fee_charged:
|
|
378
|
-
fee_account:
|
|
379
|
-
source_account:
|
|
380
|
+
fee_charged: '500',
|
|
381
|
+
fee_account: 'sponsor_address',
|
|
382
|
+
source_account: 'address',
|
|
380
383
|
ledger_attr: 42,
|
|
381
384
|
ledger: () => ({
|
|
382
|
-
hash:
|
|
383
|
-
closed_at:
|
|
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(
|
|
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:
|
|
398
|
+
feesPayer: 'sponsor_address',
|
|
396
399
|
},
|
|
397
|
-
senders: [
|
|
398
|
-
recipients: [
|
|
399
|
-
})
|
|
400
|
-
})
|
|
401
|
-
})
|
|
400
|
+
senders: ['address'],
|
|
401
|
+
recipients: ['receiver1'],
|
|
402
|
+
})
|
|
403
|
+
})
|
|
404
|
+
})
|