@ledgerhq/coin-evm 16.8.0 → 17.0.0
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/CHANGELOG.md +26 -0
- package/lib/adapters/etherscan.d.ts.map +1 -1
- package/lib/adapters/etherscan.js +5 -0
- package/lib/adapters/etherscan.js.map +1 -1
- package/lib/adapters/ledger.d.ts.map +1 -1
- package/lib/adapters/ledger.js +1 -0
- package/lib/adapters/ledger.js.map +1 -1
- package/lib/api/index.d.ts +2 -5
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +1 -2
- package/lib/api/index.js.map +1 -1
- package/lib/logic/feeCollectorOperations.d.ts +3 -3
- package/lib/logic/feeCollectorOperations.js +3 -3
- package/lib/logic/getBlock.d.ts +2 -2
- package/lib/logic/getBlock.d.ts.map +1 -1
- package/lib/logic/getBlock.js +5 -11
- package/lib/logic/getBlock.js.map +1 -1
- package/lib-es/adapters/etherscan.d.ts.map +1 -1
- package/lib-es/adapters/etherscan.js +5 -0
- package/lib-es/adapters/etherscan.js.map +1 -1
- package/lib-es/adapters/ledger.d.ts.map +1 -1
- package/lib-es/adapters/ledger.js +1 -0
- package/lib-es/adapters/ledger.js.map +1 -1
- package/lib-es/api/index.d.ts +2 -5
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +1 -2
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/logic/feeCollectorOperations.d.ts +3 -3
- package/lib-es/logic/feeCollectorOperations.js +3 -3
- package/lib-es/logic/getBlock.d.ts +2 -2
- package/lib-es/logic/getBlock.d.ts.map +1 -1
- package/lib-es/logic/getBlock.js +5 -11
- package/lib-es/logic/getBlock.js.map +1 -1
- package/package.json +2 -2
- package/src/adapters/blockscoutV2.test.ts +2 -0
- package/src/adapters/etherscan.test.ts +21 -0
- package/src/adapters/etherscan.ts +5 -0
- package/src/adapters/ledger.test.ts +8 -0
- package/src/adapters/ledger.ts +1 -0
- package/src/api/index.ts +1 -4
- package/src/api/tests/index.celo.integ.test.ts +1 -3
- package/src/api/tests/index.optimism.integ.test.ts +1 -0
- package/src/api/tests/index.test.ts +0 -9
- package/src/logic/feeCollectorOperations.ts +3 -3
- package/src/logic/getBlock.ts +6 -17
- package/src/logic/tests/getBlock.test.ts +10 -23
- package/src/logic/tests/listOperations.test.ts +53 -1
- package/src/logic/tests/validateIntent.test.ts +4 -0
- package/src/network/tests/explorer/etherscan.test.ts +1 -0
- package/src/network/tests/explorer/ledger.test.ts +4 -0
- package/src/staking/rewardsFromReceipt.test.ts +1 -0
- package/src/staking/validators/monad.test.ts +1 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { withDefaults } from '@ledgerhq/coin-module-framework/api/index'
|
|
5
4
|
import { mockEvmContext } from '../../fixtures/context.fixtures'
|
|
6
5
|
import { getValidatorsPage } from '../../staking/validators'
|
|
7
6
|
import { createApi, parseCallParams } from '../index'
|
|
@@ -30,7 +29,6 @@ describe.each([
|
|
|
30
29
|
validateAddress: expect.any(Function),
|
|
31
30
|
validateIntent: expect.any(Function),
|
|
32
31
|
craftTransactionData: expect.any(Function),
|
|
33
|
-
readOptions: { getBlock: ['feesAsset'] },
|
|
34
32
|
},
|
|
35
33
|
],
|
|
36
34
|
[
|
|
@@ -52,7 +50,6 @@ describe.each([
|
|
|
52
50
|
validateAddress: expect.any(Function),
|
|
53
51
|
validateIntent: expect.any(Function),
|
|
54
52
|
craftTransactionData: expect.any(Function),
|
|
55
|
-
readOptions: { getBlock: ['feesAsset'] },
|
|
56
53
|
},
|
|
57
54
|
],
|
|
58
55
|
])('coin-framework methods %s', (_s, _config, methods) => {
|
|
@@ -66,12 +63,6 @@ describe.each([
|
|
|
66
63
|
expect(impl).not.toHaveProperty(method)
|
|
67
64
|
}
|
|
68
65
|
})
|
|
69
|
-
|
|
70
|
-
it('honours the fee asset read option on getBlock only', () => {
|
|
71
|
-
const api = withDefaults(createApi())
|
|
72
|
-
expect(api.supportsReadOption('getBlock', 'feesAsset')).toBe(true)
|
|
73
|
-
expect(api.supportsReadOption('listOperations', 'feesAsset')).toBe(false)
|
|
74
|
-
})
|
|
75
66
|
})
|
|
76
67
|
|
|
77
68
|
describe('parseCallParams', () => {
|
|
@@ -192,9 +192,9 @@ export async function findTransactionsPaidByOthers(
|
|
|
192
192
|
* operation of the transaction for the account, a value-0 `FEES` operation carries the fee
|
|
193
193
|
* instead, as ADR-016 allows.
|
|
194
194
|
*
|
|
195
|
-
* The fee also moves as base-token transfers (zkSync `0x800A`), which stay as token operations
|
|
196
|
-
*
|
|
197
|
-
*
|
|
195
|
+
* The fee also moves as base-token transfers (zkSync `0x800A`), which stay as token operations
|
|
196
|
+
* (BACK-11036). ADR-068 removes fee movements in every asset, as `getBlock` does; this function
|
|
197
|
+
* does not follow it yet.
|
|
198
198
|
*
|
|
199
199
|
* @param operations operations of the account, as listOperations returns them
|
|
200
200
|
* @param address the account
|
package/src/logic/getBlock.ts
CHANGED
|
@@ -11,7 +11,6 @@ import type {
|
|
|
11
11
|
BlockInfo,
|
|
12
12
|
BlockOperation,
|
|
13
13
|
BlockTransaction,
|
|
14
|
-
GetBlockOptions,
|
|
15
14
|
TransferBlockOperation,
|
|
16
15
|
} from '@ledgerhq/coin-module-framework/api/index'
|
|
17
16
|
import type { Logger } from '@ledgerhq/coin-module-framework/config'
|
|
@@ -30,11 +29,7 @@ import {
|
|
|
30
29
|
} from './internalTransactionsFetcher'
|
|
31
30
|
import { dropRootTraceDuplicates } from './rootTraceDedup'
|
|
32
31
|
|
|
33
|
-
export async function getBlock(
|
|
34
|
-
context: EvmContext,
|
|
35
|
-
height: number,
|
|
36
|
-
options?: GetBlockOptions
|
|
37
|
-
): Promise<Block> {
|
|
32
|
+
export async function getBlock(context: EvmContext, height: number): Promise<Block> {
|
|
38
33
|
// Note: to use RPC calls efficiently, the strategy here is:
|
|
39
34
|
// - fetch the block + transactions in one call (using prefetchTxs=true)
|
|
40
35
|
// - fetch transaction receipts in one call using eth_getBlockReceipts
|
|
@@ -72,9 +67,7 @@ export async function getBlock(
|
|
|
72
67
|
result.transactionHashes || result.transactions?.map((tx) => tx.hash) || []
|
|
73
68
|
|
|
74
69
|
const readTokenFee =
|
|
75
|
-
|
|
76
|
-
? createCeloTokenFeeReader(nodeApi, result.height)
|
|
77
|
-
: undefined
|
|
70
|
+
config.chainId === CHAIN_ID.CELO ? createCeloTokenFeeReader(nodeApi, result.height) : undefined
|
|
78
71
|
|
|
79
72
|
// Internal transactions only exist inside transactions, so a block with none has nothing to
|
|
80
73
|
// merge. Skipping the fetch avoids a request for a guaranteed-empty answer — on the `explorer`
|
|
@@ -110,17 +103,13 @@ export async function getBlock(
|
|
|
110
103
|
const feeCollectorContracts = config.feeCollectorContracts ?? []
|
|
111
104
|
const feeCollectorTokens = config.feeCollectorTokens ?? []
|
|
112
105
|
const [paidTransactions, unpaidInternalTxs] = attributeFeeCollectorTransfers(
|
|
113
|
-
|
|
114
|
-
? attributeFeeCollectorTokenPayers(transactions, feeCollectorContracts, feeCollectorTokens)
|
|
115
|
-
: transactions,
|
|
106
|
+
attributeFeeCollectorTokenPayers(transactions, feeCollectorContracts, feeCollectorTokens),
|
|
116
107
|
internalTxs,
|
|
117
108
|
feeCollectorContracts,
|
|
118
109
|
context.logger
|
|
119
110
|
)
|
|
120
111
|
const mergedTransactions = mergeInternalTransactions(
|
|
121
|
-
|
|
122
|
-
? dropFeeCollectorTokenTransfers(paidTransactions, feeCollectorContracts, feeCollectorTokens)
|
|
123
|
-
: paidTransactions,
|
|
112
|
+
dropFeeCollectorTokenTransfers(paidTransactions, feeCollectorContracts, feeCollectorTokens),
|
|
124
113
|
unpaidInternalTxs
|
|
125
114
|
)
|
|
126
115
|
|
|
@@ -478,9 +467,9 @@ function prefetchedTransactionToBlockTransaction(
|
|
|
478
467
|
function withTokenFee(
|
|
479
468
|
nativeFees: bigint,
|
|
480
469
|
tokenFee: TokenFee | undefined
|
|
481
|
-
): Pick<BlockTransaction, 'fees' | 'feesAsset'
|
|
470
|
+
): Required<Pick<BlockTransaction, 'fees' | 'feesAsset'>> {
|
|
482
471
|
return tokenFee === undefined
|
|
483
|
-
? { fees: nativeFees }
|
|
472
|
+
? { fees: nativeFees, feesAsset: { type: 'native' } }
|
|
484
473
|
: { fees: tokenFee.fees, feesAsset: tokenFee.feesAsset }
|
|
485
474
|
}
|
|
486
475
|
|
|
@@ -1336,7 +1336,7 @@ describe('getBlock', () => {
|
|
|
1336
1336
|
expect(userNativeDelta(tx.operations)).toBe(-PREPAYMENT)
|
|
1337
1337
|
})
|
|
1338
1338
|
|
|
1339
|
-
it('drops the base-token fee legs
|
|
1339
|
+
it('drops the base-token fee legs when the network lists the base token', async () => {
|
|
1340
1340
|
const otherTransfer = makeNodeErc20Transfer({
|
|
1341
1341
|
asset: { type: 'erc20', assetReference: L2_BASE_TOKEN },
|
|
1342
1342
|
from: USER,
|
|
@@ -1359,7 +1359,7 @@ describe('getBlock', () => {
|
|
|
1359
1359
|
}),
|
|
1360
1360
|
])
|
|
1361
1361
|
|
|
1362
|
-
const [tx] = (await getBlock(context, 12345
|
|
1362
|
+
const [tx] = (await getBlock(context, 12345)).transactions
|
|
1363
1363
|
|
|
1364
1364
|
expect(tx.operations).toEqual([
|
|
1365
1365
|
{
|
|
@@ -1379,7 +1379,7 @@ describe('getBlock', () => {
|
|
|
1379
1379
|
])
|
|
1380
1380
|
expect(tx.fees).toBe(FEE)
|
|
1381
1381
|
expect(tx.feesPayer).toBe(USER)
|
|
1382
|
-
expect(tx).
|
|
1382
|
+
expect(tx.feesAsset).toEqual({ type: 'native' })
|
|
1383
1383
|
})
|
|
1384
1384
|
|
|
1385
1385
|
it.each([
|
|
@@ -1433,7 +1433,7 @@ describe('getBlock', () => {
|
|
|
1433
1433
|
})
|
|
1434
1434
|
)
|
|
1435
1435
|
|
|
1436
|
-
const [tx] = (await getBlock(context, 12345
|
|
1436
|
+
const [tx] = (await getBlock(context, 12345)).transactions
|
|
1437
1437
|
|
|
1438
1438
|
expect(tx.feesPayer).toBe(PAYMASTER)
|
|
1439
1439
|
expect(tx.operations).toEqual([])
|
|
@@ -2393,7 +2393,7 @@ describe('getBlock', () => {
|
|
|
2393
2393
|
async (_, prefetched, receiptType) => {
|
|
2394
2394
|
const { context, nodeApi } = mockCeloBlock({ prefetched, receiptType })
|
|
2395
2395
|
|
|
2396
|
-
const [tx] = (await getBlock(context, 12345
|
|
2396
|
+
const [tx] = (await getBlock(context, 12345)).transactions
|
|
2397
2397
|
|
|
2398
2398
|
expect(tx.fees).toBe(3176n)
|
|
2399
2399
|
expect(tx.feesAsset).toEqual({ type: 'erc20', assetReference: USDT })
|
|
@@ -2403,43 +2403,30 @@ describe('getBlock', () => {
|
|
|
2403
2403
|
}
|
|
2404
2404
|
)
|
|
2405
2405
|
|
|
2406
|
-
it('keeps the native fee and the fee logs when the caller does not ask for the fee asset', async () => {
|
|
2407
|
-
const { context, nodeApi } = mockCeloBlock()
|
|
2408
|
-
|
|
2409
|
-
const [tx] = (await getBlock(context, 12345)).transactions
|
|
2410
|
-
|
|
2411
|
-
expect(tx.fees).toBe(NATIVE_FEES)
|
|
2412
|
-
expect(tx).not.toHaveProperty('feesAsset')
|
|
2413
|
-
expect(tx.operations).toHaveLength(transfers.length * 2)
|
|
2414
|
-
expect(nodeApi.getFeeCurrencies).not.toHaveBeenCalled()
|
|
2415
|
-
})
|
|
2416
|
-
|
|
2417
2406
|
it('keeps the native fee of a CIP-64 transaction that pays in the native coin', async () => {
|
|
2418
2407
|
const { context } = mockCeloBlock({ feeCurrency: null })
|
|
2419
2408
|
|
|
2420
|
-
const [tx] = (await getBlock(context, 12345
|
|
2409
|
+
const [tx] = (await getBlock(context, 12345)).transactions
|
|
2421
2410
|
|
|
2422
2411
|
expect(tx.fees).toBe(NATIVE_FEES)
|
|
2423
|
-
expect(tx).
|
|
2412
|
+
expect(tx.feesAsset).toEqual({ type: 'native' })
|
|
2424
2413
|
expect(tx.operations).toHaveLength(transfers.length * 2)
|
|
2425
2414
|
})
|
|
2426
2415
|
|
|
2427
2416
|
it('does not read fee currencies on another chain', async () => {
|
|
2428
2417
|
const { context, nodeApi } = mockCeloBlock({ chainId: CHAIN_ID.ETHEREUM })
|
|
2429
2418
|
|
|
2430
|
-
const [tx] = (await getBlock(context, 12345
|
|
2419
|
+
const [tx] = (await getBlock(context, 12345)).transactions
|
|
2431
2420
|
|
|
2432
2421
|
expect(tx.fees).toBe(NATIVE_FEES)
|
|
2433
|
-
expect(tx).
|
|
2422
|
+
expect(tx.feesAsset).toEqual({ type: 'native' })
|
|
2434
2423
|
expect(nodeApi.getFeeCurrencies).not.toHaveBeenCalled()
|
|
2435
2424
|
})
|
|
2436
2425
|
|
|
2437
2426
|
it('rejects a block with a transaction paid in an unsupported fee currency', async () => {
|
|
2438
2427
|
const { context } = mockCeloBlock({ feeCurrency: address2 })
|
|
2439
2428
|
|
|
2440
|
-
await expect(getBlock(context, 12345
|
|
2441
|
-
UnsupportedFeeCurrencyError
|
|
2442
|
-
)
|
|
2429
|
+
await expect(getBlock(context, 12345)).rejects.toThrow(UnsupportedFeeCurrencyError)
|
|
2443
2430
|
})
|
|
2444
2431
|
})
|
|
2445
2432
|
})
|
|
@@ -70,6 +70,7 @@ describe('listOperations', () => {
|
|
|
70
70
|
hash: 'coin-op-1-tx-hash',
|
|
71
71
|
block: { height: 10, hash: 'coin-op-1-block-hash', time: new Date('2025-02-12') },
|
|
72
72
|
fees: 20n,
|
|
73
|
+
feesAsset: { type: 'native' },
|
|
73
74
|
feesPayer: 'address1',
|
|
74
75
|
date: new Date('2025-02-12'),
|
|
75
76
|
failed: false,
|
|
@@ -87,6 +88,7 @@ describe('listOperations', () => {
|
|
|
87
88
|
hash: 'coin-op-2-tx-hash',
|
|
88
89
|
block: { height: 20, hash: 'coin-op-2-block-hash', time: new Date('2025-02-20') },
|
|
89
90
|
fees: 20n,
|
|
91
|
+
feesAsset: { type: 'native' },
|
|
90
92
|
feesPayer: 'address',
|
|
91
93
|
date: new Date('2025-02-20'),
|
|
92
94
|
failed: true,
|
|
@@ -104,6 +106,7 @@ describe('listOperations', () => {
|
|
|
104
106
|
hash: 'token-op-1-tx-hash',
|
|
105
107
|
block: { height: 20, hash: 'coin-op-2-block-hash', time: new Date('2025-02-20') },
|
|
106
108
|
fees: 20n,
|
|
109
|
+
feesAsset: { type: 'native' },
|
|
107
110
|
feesPayer: 'address',
|
|
108
111
|
date: new Date('2025-02-20'),
|
|
109
112
|
failed: false,
|
|
@@ -121,6 +124,7 @@ describe('listOperations', () => {
|
|
|
121
124
|
hash: 'token-op-2-tx-hash',
|
|
122
125
|
block: { height: 20, hash: 'coin-op-2-block-hash', time: new Date('2025-02-20') },
|
|
123
126
|
fees: 20n,
|
|
127
|
+
feesAsset: { type: 'native' },
|
|
124
128
|
feesPayer: 'address1',
|
|
125
129
|
date: new Date('2025-02-20'),
|
|
126
130
|
failed: false,
|
|
@@ -138,6 +142,7 @@ describe('listOperations', () => {
|
|
|
138
142
|
hash: 'token-op-3-tx-hash',
|
|
139
143
|
block: { height: 20, hash: 'coin-op-3-block-hash', time: new Date('2025-02-20') },
|
|
140
144
|
fees: 20n,
|
|
145
|
+
feesAsset: { type: 'native' },
|
|
141
146
|
feesPayer: 'address',
|
|
142
147
|
date: new Date('2025-02-20'),
|
|
143
148
|
failed: true,
|
|
@@ -155,6 +160,7 @@ describe('listOperations', () => {
|
|
|
155
160
|
hash: 'coin-op-6-tx-hash',
|
|
156
161
|
block: { height: 20, hash: 'coin-op-6-block-hash', time: new Date('2025-02-20') },
|
|
157
162
|
fees: 15n,
|
|
163
|
+
feesAsset: { type: 'native' },
|
|
158
164
|
feesPayer: 'contract-address',
|
|
159
165
|
date: new Date('2025-02-20'),
|
|
160
166
|
failed: false,
|
|
@@ -178,6 +184,7 @@ describe('listOperations', () => {
|
|
|
178
184
|
hash: 'token-op-1-tx-hash',
|
|
179
185
|
block: { height: 20, hash: 'token-op-1-block-hash', time: new Date('2025-02-20') },
|
|
180
186
|
fees: 20n,
|
|
187
|
+
feesAsset: { type: 'native' },
|
|
181
188
|
date: new Date('2025-02-20'),
|
|
182
189
|
failed: false,
|
|
183
190
|
},
|
|
@@ -204,6 +211,7 @@ describe('listOperations', () => {
|
|
|
204
211
|
hash: 'token-op-2-tx-hash',
|
|
205
212
|
block: { height: 20, hash: 'token-op-2-block-hash', time: new Date('2025-02-20') },
|
|
206
213
|
fees: 20n,
|
|
214
|
+
feesAsset: { type: 'native' },
|
|
207
215
|
date: new Date('2025-02-20'),
|
|
208
216
|
failed: false,
|
|
209
217
|
},
|
|
@@ -230,6 +238,7 @@ describe('listOperations', () => {
|
|
|
230
238
|
hash: 'token-op-3-tx-hash',
|
|
231
239
|
block: { height: 20, hash: 'token-op-3-block-hash', time: new Date('2025-02-20') },
|
|
232
240
|
fees: 20n,
|
|
241
|
+
feesAsset: { type: 'native' },
|
|
233
242
|
date: new Date('2025-02-20'),
|
|
234
243
|
failed: false,
|
|
235
244
|
},
|
|
@@ -257,6 +266,7 @@ describe('listOperations', () => {
|
|
|
257
266
|
hash: 'token-op-3-tx-hash',
|
|
258
267
|
block: { height: 20, hash: 'token-op-3-block-hash', time: new Date('2025-02-20') },
|
|
259
268
|
fees: 0n,
|
|
269
|
+
feesAsset: { type: 'native' },
|
|
260
270
|
date: new Date('2025-02-20'),
|
|
261
271
|
failed: false,
|
|
262
272
|
},
|
|
@@ -275,6 +285,7 @@ describe('listOperations', () => {
|
|
|
275
285
|
hash: 'coin-op-6-tx-hash',
|
|
276
286
|
block: { height: 20, hash: 'token-op-3-block-hash', time: new Date('2025-02-20') },
|
|
277
287
|
fees: 0n,
|
|
288
|
+
feesAsset: { type: 'native' },
|
|
278
289
|
date: new Date('2025-02-20'),
|
|
279
290
|
failed: false,
|
|
280
291
|
},
|
|
@@ -295,6 +306,7 @@ describe('listOperations', () => {
|
|
|
295
306
|
hash: 'orphan-internal-tx-hash',
|
|
296
307
|
block: { height: 25, hash: '', time: new Date('2025-02-25') },
|
|
297
308
|
fees: 0n,
|
|
309
|
+
feesAsset: { type: 'native' },
|
|
298
310
|
date: new Date('2025-02-25'),
|
|
299
311
|
failed: false,
|
|
300
312
|
},
|
|
@@ -345,6 +357,7 @@ describe('listOperations', () => {
|
|
|
345
357
|
time: new Date('2025-02-12'),
|
|
346
358
|
},
|
|
347
359
|
fees: 20n,
|
|
360
|
+
feesAsset: { type: 'native' },
|
|
348
361
|
feesPayer: 'address1', // feesPayer is always the sender of the native operation
|
|
349
362
|
date: new Date('2025-02-12'),
|
|
350
363
|
failed: false,
|
|
@@ -366,6 +379,7 @@ describe('listOperations', () => {
|
|
|
366
379
|
time: new Date('2025-02-20'),
|
|
367
380
|
},
|
|
368
381
|
fees: 20n,
|
|
382
|
+
feesAsset: { type: 'native' },
|
|
369
383
|
feesPayer: 'address', // feesPayer is always the sender of the native operation
|
|
370
384
|
date: new Date('2025-02-20'),
|
|
371
385
|
failed: true,
|
|
@@ -387,6 +401,7 @@ describe('listOperations', () => {
|
|
|
387
401
|
time: new Date('2025-02-20'),
|
|
388
402
|
},
|
|
389
403
|
fees: 15n,
|
|
404
|
+
feesAsset: { type: 'native' },
|
|
390
405
|
feesPayer: 'contract-address', // feesPayer is always the sender of the native operation
|
|
391
406
|
date: new Date('2025-02-20'),
|
|
392
407
|
failed: false,
|
|
@@ -408,6 +423,7 @@ describe('listOperations', () => {
|
|
|
408
423
|
time: new Date('2025-02-20'),
|
|
409
424
|
},
|
|
410
425
|
fees: 20n,
|
|
426
|
+
feesAsset: { type: 'native' },
|
|
411
427
|
feesPayer: 'address', // feesPayer is the parent sender of the token operation
|
|
412
428
|
date: new Date('2025-02-20'),
|
|
413
429
|
failed: false,
|
|
@@ -442,6 +458,7 @@ describe('listOperations', () => {
|
|
|
442
458
|
},
|
|
443
459
|
date: new Date('2025-02-20'),
|
|
444
460
|
fees: 20n,
|
|
461
|
+
feesAsset: { type: 'native' },
|
|
445
462
|
feesPayer: 'address1', // feesPayer is the parent sender of the token operation
|
|
446
463
|
failed: false,
|
|
447
464
|
},
|
|
@@ -470,6 +487,7 @@ describe('listOperations', () => {
|
|
|
470
487
|
time: new Date('2025-02-20'),
|
|
471
488
|
},
|
|
472
489
|
fees: 20n,
|
|
490
|
+
feesAsset: { type: 'native' },
|
|
473
491
|
feesPayer: 'address', // feesPayer is the parent sender of the token operation
|
|
474
492
|
date: new Date('2025-02-20'),
|
|
475
493
|
failed: true,
|
|
@@ -501,6 +519,7 @@ describe('listOperations', () => {
|
|
|
501
519
|
date: new Date('2025-02-20'),
|
|
502
520
|
failed: false,
|
|
503
521
|
fees: 20n, // from parent coin-op-5
|
|
522
|
+
feesAsset: { type: 'native' },
|
|
504
523
|
feesPayer: 'address', // feesPayer is the parent sender of the internal operation
|
|
505
524
|
hash: 'token-op-3-tx-hash',
|
|
506
525
|
},
|
|
@@ -526,6 +545,7 @@ describe('listOperations', () => {
|
|
|
526
545
|
date: new Date('2025-02-20'),
|
|
527
546
|
failed: false,
|
|
528
547
|
fees: 15n, // from parent coin-op-6 (internal-op-2 has fee=0)
|
|
548
|
+
feesAsset: { type: 'native' },
|
|
529
549
|
feesPayer: 'contract-address', // feesPayer is the parent sender of the internal operation
|
|
530
550
|
hash: 'coin-op-6-tx-hash',
|
|
531
551
|
},
|
|
@@ -552,6 +572,7 @@ describe('listOperations', () => {
|
|
|
552
572
|
date: new Date('2025-02-25'),
|
|
553
573
|
failed: false,
|
|
554
574
|
fees: 0n,
|
|
575
|
+
feesAsset: { type: 'native' },
|
|
555
576
|
// no feesPayer for orphan internal operation
|
|
556
577
|
hash: 'orphan-internal-tx-hash',
|
|
557
578
|
},
|
|
@@ -597,6 +618,7 @@ describe('listOperations', () => {
|
|
|
597
618
|
hash: '0xTxForAddress',
|
|
598
619
|
block: { height: 100, hash: '0xBlockHash', time: new Date('2025-02-20') },
|
|
599
620
|
fees: 10n,
|
|
621
|
+
feesAsset: { type: 'native' },
|
|
600
622
|
feesPayer: address.toUpperCase(),
|
|
601
623
|
date: new Date('2025-02-20'),
|
|
602
624
|
failed: false,
|
|
@@ -614,6 +636,7 @@ describe('listOperations', () => {
|
|
|
614
636
|
hash: '0xTxUnrelated',
|
|
615
637
|
block: { height: 101, hash: '0xBlockHash2', time: new Date('2025-02-20') },
|
|
616
638
|
fees: 10n,
|
|
639
|
+
feesAsset: { type: 'native' },
|
|
617
640
|
feesPayer: '0xOtherA',
|
|
618
641
|
date: new Date('2025-02-20'),
|
|
619
642
|
failed: false,
|
|
@@ -635,6 +658,7 @@ describe('listOperations', () => {
|
|
|
635
658
|
hash: '0xTxUnrelated',
|
|
636
659
|
block: { height: 101, hash: '0xBlockHash2', time: new Date('2025-02-20') },
|
|
637
660
|
fees: 0n,
|
|
661
|
+
feesAsset: { type: 'native' },
|
|
638
662
|
date: new Date('2025-02-20'),
|
|
639
663
|
failed: false,
|
|
640
664
|
},
|
|
@@ -666,6 +690,7 @@ describe('listOperations', () => {
|
|
|
666
690
|
time: new Date('2025-02-20'),
|
|
667
691
|
},
|
|
668
692
|
fees: 10n,
|
|
693
|
+
feesAsset: { type: 'native' },
|
|
669
694
|
feesPayer: 'ADDRESS',
|
|
670
695
|
date: new Date('2025-02-20'),
|
|
671
696
|
failed: false,
|
|
@@ -700,6 +725,7 @@ describe('listOperations', () => {
|
|
|
700
725
|
time: new Date('2025-02-20'),
|
|
701
726
|
},
|
|
702
727
|
fees: txFee,
|
|
728
|
+
feesAsset: { type: 'native' },
|
|
703
729
|
feesPayer: 'address1',
|
|
704
730
|
date: new Date('2025-02-20'),
|
|
705
731
|
failed: false,
|
|
@@ -723,6 +749,7 @@ describe('listOperations', () => {
|
|
|
723
749
|
time: new Date('2025-02-20'),
|
|
724
750
|
},
|
|
725
751
|
fees: txFee,
|
|
752
|
+
feesAsset: { type: 'native' },
|
|
726
753
|
date: new Date('2025-02-20'),
|
|
727
754
|
failed: false,
|
|
728
755
|
},
|
|
@@ -762,6 +789,7 @@ describe('listOperations', () => {
|
|
|
762
789
|
time: new Date('2025-02-20'),
|
|
763
790
|
},
|
|
764
791
|
fees: 21000000000000n,
|
|
792
|
+
feesAsset: { type: 'native' },
|
|
765
793
|
feesPayer: 'address1',
|
|
766
794
|
date: new Date('2025-02-20'),
|
|
767
795
|
failed: false,
|
|
@@ -800,6 +828,7 @@ describe('listOperations', () => {
|
|
|
800
828
|
hash: '0xOtherTxHash',
|
|
801
829
|
block: { height: 100, hash: '0xBlockHash', time: new Date('2025-02-20') },
|
|
802
830
|
fees: 1n,
|
|
831
|
+
feesAsset: { type: 'native' },
|
|
803
832
|
feesPayer: recipient,
|
|
804
833
|
date: new Date('2025-02-20'),
|
|
805
834
|
failed: false,
|
|
@@ -819,6 +848,7 @@ describe('listOperations', () => {
|
|
|
819
848
|
hash: txHash,
|
|
820
849
|
block: { height: 101, hash: '0xBlockHash2', time: new Date('2025-02-20') },
|
|
821
850
|
fees: 0n,
|
|
851
|
+
feesAsset: { type: 'native' },
|
|
822
852
|
date: new Date('2025-02-20'),
|
|
823
853
|
failed: false,
|
|
824
854
|
},
|
|
@@ -872,6 +902,7 @@ describe('listOperations', () => {
|
|
|
872
902
|
hash: txHash,
|
|
873
903
|
block,
|
|
874
904
|
fees: parentFee,
|
|
905
|
+
feesAsset: { type: 'native' },
|
|
875
906
|
feesPayer: address,
|
|
876
907
|
date: new Date('2023-06-10T08:56:43.000Z'),
|
|
877
908
|
failed: false,
|
|
@@ -893,6 +924,7 @@ describe('listOperations', () => {
|
|
|
893
924
|
hash: txHash,
|
|
894
925
|
block,
|
|
895
926
|
fees: wrongTokenFee,
|
|
927
|
+
feesAsset: { type: 'native' },
|
|
896
928
|
date: new Date('2023-06-10T08:56:43.000Z'),
|
|
897
929
|
failed: false,
|
|
898
930
|
},
|
|
@@ -948,6 +980,7 @@ describe('listOperations', () => {
|
|
|
948
980
|
hash: txHash,
|
|
949
981
|
block: { height: 24886171, hash: parentBlockHash, time: date },
|
|
950
982
|
fees: 997504000000000n,
|
|
983
|
+
feesAsset: { type: 'native' },
|
|
951
984
|
feesPayer: address,
|
|
952
985
|
date,
|
|
953
986
|
failed: false,
|
|
@@ -971,6 +1004,7 @@ describe('listOperations', () => {
|
|
|
971
1004
|
hash: txHash,
|
|
972
1005
|
block: { height: 24886171, hash: '', time: date },
|
|
973
1006
|
fees: 0n,
|
|
1007
|
+
feesAsset: { type: 'native' },
|
|
974
1008
|
date,
|
|
975
1009
|
failed: false,
|
|
976
1010
|
},
|
|
@@ -1004,7 +1038,14 @@ describe('listOperations', () => {
|
|
|
1004
1038
|
const address = '0xb69b37a4fb4a18b3258f974ff6e9f529ad2647b1'
|
|
1005
1039
|
const txHash = '0xf034ecf17ad61bc29bab12fc303296428d6c7c8a285bd92b2e30a92b1dd5f3bc'
|
|
1006
1040
|
const block = { height: 25745506, hash: '0xblock', time: new Date('2026-08-13T10:29:00.000Z') }
|
|
1007
|
-
const tx = {
|
|
1041
|
+
const tx = {
|
|
1042
|
+
hash: txHash,
|
|
1043
|
+
block,
|
|
1044
|
+
fees: 41826029222736n,
|
|
1045
|
+
feesAsset: { type: 'native' as const },
|
|
1046
|
+
date: block.time,
|
|
1047
|
+
failed: false,
|
|
1048
|
+
}
|
|
1008
1049
|
|
|
1009
1050
|
jest.spyOn(ledgerExplorer, 'getOperations').mockResolvedValue({
|
|
1010
1051
|
lastCoinOperations: [
|
|
@@ -1067,6 +1108,7 @@ describe('listOperations', () => {
|
|
|
1067
1108
|
hash: '0xMixedTransactionHash',
|
|
1068
1109
|
block: { height: 100, hash: '0xBlockHash', time: new Date('2025-02-20') },
|
|
1069
1110
|
fees: 21000000000000n,
|
|
1111
|
+
feesAsset: { type: 'native' },
|
|
1070
1112
|
feesPayer: 'address1',
|
|
1071
1113
|
date: new Date('2025-02-20'),
|
|
1072
1114
|
failed: false,
|
|
@@ -1090,6 +1132,7 @@ describe('listOperations', () => {
|
|
|
1090
1132
|
hash: '0xMixedTransactionHash',
|
|
1091
1133
|
block: { height: 100, hash: '0xBlockHash', time: new Date('2025-02-20') },
|
|
1092
1134
|
fees: 21000000000000n,
|
|
1135
|
+
feesAsset: { type: 'native' },
|
|
1093
1136
|
date: new Date('2025-02-20'),
|
|
1094
1137
|
failed: false,
|
|
1095
1138
|
},
|
|
@@ -1129,6 +1172,7 @@ describe('listOperations', () => {
|
|
|
1129
1172
|
time: new Date('2025-02-20'),
|
|
1130
1173
|
},
|
|
1131
1174
|
fees: 21000000000000n,
|
|
1175
|
+
feesAsset: { type: 'native' },
|
|
1132
1176
|
feesPayer: 'address1',
|
|
1133
1177
|
date: new Date('2025-02-20'),
|
|
1134
1178
|
failed: false,
|
|
@@ -1154,6 +1198,7 @@ describe('listOperations', () => {
|
|
|
1154
1198
|
time: new Date('2025-02-20'),
|
|
1155
1199
|
},
|
|
1156
1200
|
fees: 21000000000000n,
|
|
1201
|
+
feesAsset: { type: 'native' },
|
|
1157
1202
|
feesPayer: 'address1',
|
|
1158
1203
|
date: new Date('2025-02-20'),
|
|
1159
1204
|
failed: false,
|
|
@@ -1318,6 +1363,7 @@ describe('listOperations', () => {
|
|
|
1318
1363
|
hash: 'coin-op-1-tx-hash',
|
|
1319
1364
|
block: { height: 10, hash: 'coin-op-1-block-hash', time: new Date('2025-02-12') },
|
|
1320
1365
|
fees: 20n,
|
|
1366
|
+
feesAsset: { type: 'native' as const },
|
|
1321
1367
|
date: new Date('2025-02-12'),
|
|
1322
1368
|
failed: false,
|
|
1323
1369
|
}
|
|
@@ -1395,6 +1441,7 @@ describe('listOperations', () => {
|
|
|
1395
1441
|
hash: '0xdelegate-tx',
|
|
1396
1442
|
block: { height: 100, hash: '0xblock', time: new Date('2025-02-20') },
|
|
1397
1443
|
fees: 1n,
|
|
1444
|
+
feesAsset: { type: 'native' },
|
|
1398
1445
|
feesPayer: address,
|
|
1399
1446
|
date: new Date('2025-02-20'),
|
|
1400
1447
|
failed: false,
|
|
@@ -1435,6 +1482,7 @@ describe('listOperations', () => {
|
|
|
1435
1482
|
hash: '0xreward-tx',
|
|
1436
1483
|
block: { height: 100, hash: '0xblock', time: new Date('2025-02-20') },
|
|
1437
1484
|
fees: 1n,
|
|
1485
|
+
feesAsset: { type: 'native' },
|
|
1438
1486
|
feesPayer: address,
|
|
1439
1487
|
date: new Date('2025-02-20'),
|
|
1440
1488
|
failed: false,
|
|
@@ -1473,6 +1521,7 @@ describe('listOperations', () => {
|
|
|
1473
1521
|
hash: '0xsci-hash',
|
|
1474
1522
|
block: { height: 10, hash: '0xblock', time: new Date('2025-02-20') },
|
|
1475
1523
|
fees: 1n,
|
|
1524
|
+
feesAsset: { type: 'native' },
|
|
1476
1525
|
feesPayer: 'address',
|
|
1477
1526
|
date: new Date('2025-02-20'),
|
|
1478
1527
|
failed: false,
|
|
@@ -1576,6 +1625,7 @@ describe('listOperations', () => {
|
|
|
1576
1625
|
hash: op.hash ?? operationTxHash,
|
|
1577
1626
|
block: { height: blockHeight, hash: blockHash, time: date },
|
|
1578
1627
|
fees: toBigInt(op.fee),
|
|
1628
|
+
feesAsset: { type: 'native' },
|
|
1579
1629
|
...(op.senders.length === 1 ? { feesPayer: op.senders[0] } : {}),
|
|
1580
1630
|
date,
|
|
1581
1631
|
failed: false,
|
|
@@ -1599,6 +1649,7 @@ describe('listOperations', () => {
|
|
|
1599
1649
|
hash: op.hash ?? operationTxHash,
|
|
1600
1650
|
block: { height: blockHeight, hash: blockHash, time: date },
|
|
1601
1651
|
fees: toBigInt(op.fee),
|
|
1652
|
+
feesAsset: { type: 'native' },
|
|
1602
1653
|
date,
|
|
1603
1654
|
failed: false,
|
|
1604
1655
|
},
|
|
@@ -1623,6 +1674,7 @@ describe('listOperations', () => {
|
|
|
1623
1674
|
hash: op.hash ?? operationTxHash,
|
|
1624
1675
|
block: { height: blockHeight, hash: blockHash, time: date },
|
|
1625
1676
|
fees: toBigInt(op.fee),
|
|
1677
|
+
feesAsset: { type: 'native' },
|
|
1626
1678
|
date,
|
|
1627
1679
|
failed: false,
|
|
1628
1680
|
},
|
|
@@ -427,6 +427,7 @@ describe('validateIntent', () => {
|
|
|
427
427
|
hash: '',
|
|
428
428
|
block: { height: 0, hash: '', time: new Date(0) },
|
|
429
429
|
fees: 0n,
|
|
430
|
+
feesAsset: { type: 'native' },
|
|
430
431
|
date: new Date(0),
|
|
431
432
|
failed: false,
|
|
432
433
|
},
|
|
@@ -1600,6 +1601,7 @@ describe('validateIntent', () => {
|
|
|
1600
1601
|
hash: '',
|
|
1601
1602
|
block: { height: 0, hash: '', time: new Date(0) },
|
|
1602
1603
|
fees: 0n,
|
|
1604
|
+
feesAsset: { type: 'native' },
|
|
1603
1605
|
date: new Date(0),
|
|
1604
1606
|
failed: false,
|
|
1605
1607
|
},
|
|
@@ -1655,6 +1657,7 @@ describe('validateIntent', () => {
|
|
|
1655
1657
|
hash: '',
|
|
1656
1658
|
block: { height: 0, hash: '', time: new Date(0) },
|
|
1657
1659
|
fees: 0n,
|
|
1660
|
+
feesAsset: { type: 'native' },
|
|
1658
1661
|
date: new Date(0),
|
|
1659
1662
|
failed: false,
|
|
1660
1663
|
},
|
|
@@ -1735,6 +1738,7 @@ describe('validateIntent', () => {
|
|
|
1735
1738
|
hash: '',
|
|
1736
1739
|
block: { height: 0, hash: '', time: new Date(0) },
|
|
1737
1740
|
fees: 0n,
|
|
1741
|
+
feesAsset: { type: 'native' },
|
|
1738
1742
|
date: new Date(0),
|
|
1739
1743
|
failed: false,
|
|
1740
1744
|
},
|
|
@@ -3022,6 +3022,7 @@ describe('EVM Family', () => {
|
|
|
3022
3022
|
hash: `0x${blockHeight}${i}`,
|
|
3023
3023
|
block: { height: blockHeight, hash: `0xblock${blockHeight}`, time: new Date() },
|
|
3024
3024
|
fees: 10n,
|
|
3025
|
+
feesAsset: { type: 'native' },
|
|
3025
3026
|
feesPayer: '0x456',
|
|
3026
3027
|
date: new Date(),
|
|
3027
3028
|
failed: false,
|
|
@@ -334,6 +334,7 @@ describe('EVM Family', () => {
|
|
|
334
334
|
time: new Date(coinOperation1.block.time),
|
|
335
335
|
},
|
|
336
336
|
fees,
|
|
337
|
+
feesAsset: { type: 'native' },
|
|
337
338
|
date: new Date(coinOperation1.block.time),
|
|
338
339
|
failed: false,
|
|
339
340
|
feesPayer: addr,
|
|
@@ -346,6 +347,7 @@ describe('EVM Family', () => {
|
|
|
346
347
|
time: new Date(coinOperation2.block.time),
|
|
347
348
|
},
|
|
348
349
|
fees,
|
|
350
|
+
feesAsset: { type: 'native' },
|
|
349
351
|
date: new Date(coinOperation2.block.time),
|
|
350
352
|
failed: false,
|
|
351
353
|
feesPayer: addr,
|
|
@@ -358,6 +360,7 @@ describe('EVM Family', () => {
|
|
|
358
360
|
time: new Date(coinOperation3.block.time),
|
|
359
361
|
},
|
|
360
362
|
fees,
|
|
363
|
+
feesAsset: { type: 'native' },
|
|
361
364
|
date: new Date(coinOperation3.block.time),
|
|
362
365
|
failed: false,
|
|
363
366
|
feesPayer: eip55.encode(coinOperation3.from),
|
|
@@ -370,6 +373,7 @@ describe('EVM Family', () => {
|
|
|
370
373
|
time: new Date(coinOperation4.block.time),
|
|
371
374
|
},
|
|
372
375
|
fees,
|
|
376
|
+
feesAsset: { type: 'native' },
|
|
373
377
|
date: new Date(coinOperation4.block.time),
|
|
374
378
|
failed: false,
|
|
375
379
|
feesPayer: eip55.encode(coinOperation4.from),
|