@ledgerhq/coin-evm 5.3.1 → 5.3.3
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 +3 -13
- package/CHANGELOG.md +13 -0
- package/lib/adapters/blockOperations.d.ts +2 -2
- package/lib/adapters/blockOperations.d.ts.map +1 -1
- package/lib/adapters/blockOperations.js.map +1 -1
- package/lib/api/index.d.ts +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/config.d.ts +1 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/logic/combine.d.ts +2 -1
- package/lib/logic/combine.d.ts.map +1 -1
- package/lib/logic/combine.js.map +1 -1
- package/lib/logic/common.d.ts +2 -1
- package/lib/logic/common.d.ts.map +1 -1
- 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.map +1 -1
- package/lib/logic/craftTransactionData.d.ts +1 -1
- package/lib/logic/craftTransactionData.d.ts.map +1 -1
- package/lib/logic/estimateFees.d.ts +1 -1
- package/lib/logic/estimateFees.d.ts.map +1 -1
- 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.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.map +1 -1
- package/lib/logic/getStakes.d.ts +1 -1
- package/lib/logic/getStakes.d.ts.map +1 -1
- package/lib/logic/internalTransactionsFetcher.d.ts +1 -1
- package/lib/logic/internalTransactionsFetcher.d.ts.map +1 -1
- package/lib/logic/internalTransactionsFetcher.js.map +1 -1
- package/lib/logic/validateIntent.d.ts +1 -1
- package/lib/logic/validateIntent.d.ts.map +1 -1
- package/lib/logic/validateIntent.js.map +1 -1
- package/lib/logic.d.ts +1 -1
- package/lib/logic.d.ts.map +1 -1
- package/lib/network/explorer/etherscan.d.ts +4 -4
- package/lib/network/explorer/etherscan.d.ts.map +1 -1
- package/lib/network/explorer/etherscan.js.map +1 -1
- package/lib/network/explorer/index.d.ts +2 -2
- package/lib/network/explorer/index.d.ts.map +1 -1
- package/lib/network/explorer/index.js.map +1 -1
- package/lib/network/explorer/ledger.d.ts +2 -2
- package/lib/network/explorer/ledger.d.ts.map +1 -1
- package/lib/network/explorer/ledger.js.map +1 -1
- package/lib/network/explorer/none.d.ts +1 -1
- package/lib/network/explorer/none.d.ts.map +1 -1
- package/lib/network/explorer/none.js.map +1 -1
- package/lib/network/explorer/types.d.ts +1 -1
- package/lib/network/explorer/types.d.ts.map +1 -1
- package/lib/network/gasTracker/index.d.ts +2 -2
- package/lib/network/gasTracker/index.d.ts.map +1 -1
- package/lib/network/gasTracker/index.js.map +1 -1
- package/lib/network/gasTracker/ledger.d.ts +3 -3
- package/lib/network/gasTracker/ledger.d.ts.map +1 -1
- package/lib/network/gasTracker/ledger.js.map +1 -1
- package/lib/network/gasTracker/types.d.ts +2 -2
- package/lib/network/gasTracker/types.d.ts.map +1 -1
- package/lib/network/node/ledger.d.ts +2 -2
- package/lib/network/node/ledger.d.ts.map +1 -1
- package/lib/network/node/ledger.js.map +1 -1
- package/lib/network/node/rpc.common.d.ts +1 -1
- package/lib/network/node/rpc.common.d.ts.map +1 -1
- package/lib/network/node/rpc.common.js.map +1 -1
- package/lib/network/node/types.d.ts +3 -3
- package/lib/network/node/types.d.ts.map +1 -1
- package/lib/staking/validators/monad.d.ts +2 -1
- package/lib/staking/validators/monad.d.ts.map +1 -1
- package/lib/staking/validators/monad.js.map +1 -1
- package/lib/staking/validators/monadResolver.d.ts +2 -1
- package/lib/staking/validators/monadResolver.d.ts.map +1 -1
- package/lib/staking/validators/monadResolver.js.map +1 -1
- package/lib/staking/validators/somnia.d.ts.map +1 -1
- package/lib/staking/validators/somnia.js.map +1 -1
- package/lib/staking/validators/zero_gravity.d.ts.map +1 -1
- package/lib/staking/validators/zero_gravity.js.map +1 -1
- package/lib/types/assets.d.ts +1 -1
- package/lib/types/assets.d.ts.map +1 -1
- package/lib/types/transaction.d.ts +1 -1
- package/lib/types/transaction.d.ts.map +1 -1
- package/lib-es/adapters/blockOperations.d.ts +2 -2
- package/lib-es/adapters/blockOperations.d.ts.map +1 -1
- package/lib-es/adapters/blockOperations.js.map +1 -1
- package/lib-es/api/index.d.ts +1 -1
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/config.d.ts +1 -1
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/logic/combine.d.ts +2 -1
- package/lib-es/logic/combine.d.ts.map +1 -1
- package/lib-es/logic/combine.js.map +1 -1
- package/lib-es/logic/common.d.ts +2 -1
- package/lib-es/logic/common.d.ts.map +1 -1
- package/lib-es/logic/common.js +1 -1
- 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.map +1 -1
- package/lib-es/logic/craftTransactionData.d.ts +1 -1
- package/lib-es/logic/craftTransactionData.d.ts.map +1 -1
- package/lib-es/logic/estimateFees.d.ts +1 -1
- package/lib-es/logic/estimateFees.d.ts.map +1 -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.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.map +1 -1
- package/lib-es/logic/getStakes.d.ts +1 -1
- package/lib-es/logic/getStakes.d.ts.map +1 -1
- package/lib-es/logic/internalTransactionsFetcher.d.ts +1 -1
- package/lib-es/logic/internalTransactionsFetcher.d.ts.map +1 -1
- package/lib-es/logic/internalTransactionsFetcher.js.map +1 -1
- package/lib-es/logic/validateIntent.d.ts +1 -1
- package/lib-es/logic/validateIntent.d.ts.map +1 -1
- package/lib-es/logic/validateIntent.js.map +1 -1
- package/lib-es/logic.d.ts +1 -1
- package/lib-es/logic.d.ts.map +1 -1
- package/lib-es/network/explorer/etherscan.d.ts +4 -4
- package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
- package/lib-es/network/explorer/etherscan.js.map +1 -1
- package/lib-es/network/explorer/index.d.ts +2 -2
- package/lib-es/network/explorer/index.d.ts.map +1 -1
- package/lib-es/network/explorer/index.js.map +1 -1
- package/lib-es/network/explorer/ledger.d.ts +2 -2
- package/lib-es/network/explorer/ledger.d.ts.map +1 -1
- package/lib-es/network/explorer/ledger.js.map +1 -1
- package/lib-es/network/explorer/none.d.ts +1 -1
- package/lib-es/network/explorer/none.d.ts.map +1 -1
- package/lib-es/network/explorer/none.js.map +1 -1
- package/lib-es/network/explorer/types.d.ts +1 -1
- package/lib-es/network/explorer/types.d.ts.map +1 -1
- package/lib-es/network/gasTracker/index.d.ts +2 -2
- package/lib-es/network/gasTracker/index.d.ts.map +1 -1
- package/lib-es/network/gasTracker/index.js.map +1 -1
- package/lib-es/network/gasTracker/ledger.d.ts +3 -3
- package/lib-es/network/gasTracker/ledger.d.ts.map +1 -1
- package/lib-es/network/gasTracker/ledger.js +1 -1
- package/lib-es/network/gasTracker/ledger.js.map +1 -1
- package/lib-es/network/gasTracker/types.d.ts +2 -2
- package/lib-es/network/gasTracker/types.d.ts.map +1 -1
- package/lib-es/network/node/ledger.d.ts +2 -2
- package/lib-es/network/node/ledger.d.ts.map +1 -1
- package/lib-es/network/node/ledger.js.map +1 -1
- package/lib-es/network/node/rpc.common.d.ts +1 -1
- package/lib-es/network/node/rpc.common.d.ts.map +1 -1
- package/lib-es/network/node/rpc.common.js +1 -1
- package/lib-es/network/node/rpc.common.js.map +1 -1
- package/lib-es/network/node/types.d.ts +3 -3
- package/lib-es/network/node/types.d.ts.map +1 -1
- package/lib-es/staking/validators/monad.d.ts +2 -1
- package/lib-es/staking/validators/monad.d.ts.map +1 -1
- package/lib-es/staking/validators/monad.js.map +1 -1
- package/lib-es/staking/validators/monadResolver.d.ts +2 -1
- package/lib-es/staking/validators/monadResolver.d.ts.map +1 -1
- package/lib-es/staking/validators/monadResolver.js.map +1 -1
- package/lib-es/staking/validators/somnia.d.ts.map +1 -1
- package/lib-es/staking/validators/somnia.js.map +1 -1
- package/lib-es/staking/validators/zero_gravity.d.ts.map +1 -1
- package/lib-es/staking/validators/zero_gravity.js.map +1 -1
- package/lib-es/types/assets.d.ts +1 -1
- package/lib-es/types/assets.d.ts.map +1 -1
- package/lib-es/types/transaction.d.ts +1 -1
- package/lib-es/types/transaction.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/adapters/blockOperations.test.ts +29 -31
- package/src/adapters/blockOperations.ts +3 -2
- package/src/adapters/etherscan.test.ts +7 -7
- package/src/adapters/ledger.test.ts +2 -2
- package/src/api/getBlock.integ.test.ts +1 -1
- package/src/api/index.fantom.integ.test.ts +1 -1
- package/src/api/index.flare.integ.test.ts +2 -14
- package/src/api/index.integ.test.ts +330 -246
- package/src/api/index.linea.integ.test.ts +1 -1
- package/src/api/index.optimism.integ.test.ts +1 -1
- package/src/api/index.shape.integ.test.ts +1 -1
- package/src/api/index.ts +1 -1
- package/src/config.ts +1 -1
- package/src/fixtures/context.fixtures.ts +79 -1
- package/src/fixtures/ethers.fixtures.ts +26 -0
- package/src/fixtures/ledger.fixtures.ts +1 -1
- package/src/internalTxSources.test.ts +3 -6
- package/src/logic/broadcast.integ.test.ts +6 -18
- package/src/logic/broadcast.test.ts +19 -31
- package/src/logic/broadcastSource.test.ts +6 -7
- package/src/logic/combine.test.ts +2 -2
- package/src/logic/combine.ts +2 -1
- package/src/logic/common.test.ts +120 -112
- package/src/logic/common.ts +2 -7
- package/src/logic/craftTransaction.test.ts +163 -200
- package/src/logic/craftTransaction.ts +3 -2
- package/src/logic/craftTransactionData.test.ts +6 -6
- package/src/logic/craftTransactionData.ts +1 -1
- package/src/logic/estimateFees.test.ts +19 -15
- package/src/logic/estimateFees.ts +6 -3
- package/src/logic/getBalance.test.ts +16 -15
- package/src/logic/getBalance.ts +4 -3
- package/src/logic/getBlock.test.ts +379 -388
- package/src/logic/getBlock.ts +3 -2
- package/src/logic/getBlockInfo.test.ts +7 -9
- package/src/logic/getNextSequence.test.ts +5 -5
- package/src/logic/getStakes.test.ts +35 -35
- package/src/logic/getStakes.ts +1 -1
- package/src/logic/internalTransactionsFetcher.test.ts +26 -24
- package/src/logic/internalTransactionsFetcher.ts +1 -1
- package/src/logic/lastBlock.test.ts +29 -20
- package/src/logic/listOperations.test.ts +44 -40
- package/src/logic/validateIntent.test.ts +152 -101
- package/src/logic/validateIntent.ts +4 -2
- package/src/logic.test.ts +13 -18
- package/src/logic.ts +1 -1
- package/src/network/explorer/etherscan.test.ts +6 -6
- package/src/network/explorer/etherscan.ts +12 -10
- package/src/network/explorer/index.test.ts +52 -22
- package/src/network/explorer/index.ts +2 -2
- package/src/network/explorer/ledger.test.ts +17 -5
- package/src/network/explorer/ledger.ts +3 -2
- package/src/network/explorer/none.ts +2 -1
- package/src/network/explorer/types.ts +1 -1
- package/src/network/gasTracker/index.test.ts +14 -8
- package/src/network/gasTracker/index.ts +2 -2
- package/src/network/gasTracker/ledger.test.ts +34 -29
- package/src/network/gasTracker/ledger.ts +5 -7
- package/src/network/gasTracker/types.ts +2 -2
- package/src/network/node/index.memoization.test.ts +25 -31
- package/src/network/node/index.test.ts +14 -25
- package/src/network/node/ledger.test.ts +45 -60
- package/src/network/node/ledger.ts +6 -5
- package/src/network/node/node.fixtures.ts +0 -2
- package/src/network/node/rpc.common.ts +14 -14
- package/src/network/node/rpc.test.ts +153 -184
- package/src/network/node/types.ts +3 -3
- package/src/staking/detectOperationType.test.ts +1 -1
- package/src/staking/encoder.test.ts +14 -22
- package/src/staking/logic.test.ts +20 -14
- package/src/staking/operations/index.test.ts +29 -29
- package/src/staking/prepareIntents.test.ts +26 -20
- package/src/staking/redelegations.test.ts +50 -33
- package/src/staking/rewards.test.ts +29 -17
- package/src/staking/rewardsFromReceipt.test.ts +20 -21
- package/src/staking/transactionData.test.ts +23 -23
- package/src/staking/validators/monad.test.ts +65 -24
- package/src/staking/validators/monad.ts +2 -1
- package/src/staking/validators/monadResolver.ts +2 -1
- package/src/staking/validators/somnia.test.ts +21 -13
- package/src/staking/validators/somnia.ts +2 -1
- package/src/staking/validators/zero_gravity.test.ts +118 -48
- package/src/staking/validators/zero_gravity.ts +2 -1
- package/src/staking/validators.integ.test.ts +13 -25
- package/src/staking/validators.test.ts +7 -2
- package/src/types/assets.ts +1 -1
- package/src/types/transaction.ts +1 -1
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import type { EvmConfig, EvmContext } from '../config'
|
|
5
|
+
import type { ExplorerApi } from '../network/explorer/types'
|
|
4
6
|
import type { MemoNotSupported, Operation } from '@ledgerhq/coin-module-framework/api/types'
|
|
5
7
|
import BigNumber from 'bignumber.js'
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
+
import {
|
|
9
|
+
createMockEvmContext,
|
|
10
|
+
mkEtherscanExplorer,
|
|
11
|
+
mkLedgerExplorer,
|
|
12
|
+
} from '../fixtures/context.fixtures'
|
|
8
13
|
import etherscanExplorer from '../network/explorer/etherscan'
|
|
9
14
|
import ledgerExplorer from '../network/explorer/ledger'
|
|
10
|
-
import { ExplorerApi } from '../network/explorer/types'
|
|
11
15
|
import { listOperations } from './listOperations'
|
|
12
16
|
|
|
13
17
|
describe('listOperations', () => {
|
|
@@ -16,8 +20,8 @@ describe('listOperations', () => {
|
|
|
16
20
|
|
|
17
21
|
// The logic layer resolves config from the threaded context, so tests carry their explorer
|
|
18
22
|
// config on the context instead of seeding the module-level singleton.
|
|
19
|
-
const ctxWithExplorer = (explorer:
|
|
20
|
-
createMockEvmContext({ explorer }
|
|
23
|
+
const ctxWithExplorer = (explorer: EvmConfig['explorer']): EvmContext =>
|
|
24
|
+
createMockEvmContext({ explorer })
|
|
21
25
|
|
|
22
26
|
afterEach(() => {
|
|
23
27
|
jest.clearAllMocks()
|
|
@@ -272,13 +276,13 @@ describe('listOperations', () => {
|
|
|
272
276
|
})
|
|
273
277
|
|
|
274
278
|
it.each([
|
|
275
|
-
['an etherscan explorer',
|
|
279
|
+
['an etherscan explorer', mkEtherscanExplorer(), etherscanExplorer.explorerApi],
|
|
276
280
|
[
|
|
277
281
|
'a no cache etherscan explorer',
|
|
278
|
-
{
|
|
282
|
+
mkEtherscanExplorer({ noCache: true }),
|
|
279
283
|
etherscanExplorer.explorerApiNoCache,
|
|
280
284
|
],
|
|
281
|
-
['a ledger explorer',
|
|
285
|
+
['a ledger explorer', mkLedgerExplorer(), ledgerExplorer],
|
|
282
286
|
])('lists latest operations using %s', async (_, config, explorer) => {
|
|
283
287
|
const testContext = ctxWithExplorer(config)
|
|
284
288
|
const getOperationsSpy = buildOperationsSpy(explorer)
|
|
@@ -547,7 +551,7 @@ describe('listOperations', () => {
|
|
|
547
551
|
})
|
|
548
552
|
|
|
549
553
|
it('filters out operations where the requested address is not involved (case insensitive)', async () => {
|
|
550
|
-
const testContext = ctxWithExplorer(
|
|
554
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
551
555
|
const address = 'address'
|
|
552
556
|
// Explorer returns: one native op for "address", and one internal op (same tx) where
|
|
553
557
|
// senders/recipients and parent senders/recipients do NOT include "address"
|
|
@@ -645,7 +649,7 @@ describe('listOperations', () => {
|
|
|
645
649
|
})
|
|
646
650
|
|
|
647
651
|
it('should use token transfer value for ERC20 operations, not parent native value', async () => {
|
|
648
|
-
const testContext = ctxWithExplorer(
|
|
652
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
649
653
|
|
|
650
654
|
const txHash = '0x4235dc16c74aecb248ad1005f3a0c82582a25afe797e62ecc8f4eed86ca628a1'
|
|
651
655
|
const txFee = 21000000000000n
|
|
@@ -749,7 +753,7 @@ describe('listOperations', () => {
|
|
|
749
753
|
})
|
|
750
754
|
|
|
751
755
|
it('leaves feesPayer undefined when token op has no parent coin op (no reference operation)', async () => {
|
|
752
|
-
const testContext = ctxWithExplorer(
|
|
756
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
753
757
|
|
|
754
758
|
const recipient = '0xrecipient'
|
|
755
759
|
const sender = '0xsender'
|
|
@@ -817,7 +821,7 @@ describe('listOperations', () => {
|
|
|
817
821
|
* @see https://ledgerhq.atlassian.net/browse/BACK-10954
|
|
818
822
|
*/
|
|
819
823
|
it('uses parent coin operation fee for token ops when explorer fee on token row differs', async () => {
|
|
820
|
-
const testContext = ctxWithExplorer(
|
|
824
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
821
825
|
|
|
822
826
|
const address = '0x63f5c1b5a54a2423a0284b55ad6e48485e048e6a'
|
|
823
827
|
const txHash = '0xdd046a625b9b4b1ec9c9eaabfa61869f74d9d744433dae3c7686432301713bb3'
|
|
@@ -897,7 +901,7 @@ describe('listOperations', () => {
|
|
|
897
901
|
* A token op keeps its own block.hash when present, and only falls back to the parent's.
|
|
898
902
|
*/
|
|
899
903
|
it('falls back to the parent block.hash on token ops when the explorer token row omits it', async () => {
|
|
900
|
-
const testContext = ctxWithExplorer(
|
|
904
|
+
const testContext = ctxWithExplorer(mkEtherscanExplorer())
|
|
901
905
|
const txHash = '0x6593efaefa1752c9ba92ba079fc9705daad1f67b3437b07139692e8e5b647021'
|
|
902
906
|
const parentBlockHash = '0x77fd02171913e7af2b4d76aeaca2bd70d36e112a66092790c4c2c8a57566a7e2'
|
|
903
907
|
const date = new Date('2026-02-16T09:25:37.000Z')
|
|
@@ -936,7 +940,7 @@ describe('listOperations', () => {
|
|
|
936
940
|
},
|
|
937
941
|
tx: {
|
|
938
942
|
hash: txHash,
|
|
939
|
-
block: { height: 24886171, time: date },
|
|
943
|
+
block: { height: 24886171, hash: '', time: date },
|
|
940
944
|
fees: 0n,
|
|
941
945
|
date,
|
|
942
946
|
failed: false,
|
|
@@ -966,7 +970,7 @@ describe('listOperations', () => {
|
|
|
966
970
|
|
|
967
971
|
it('inherits the parent nonce on token ops, whose fees-only native op is dropped', async () => {
|
|
968
972
|
// LIVE-35844: the Ledger explorer only reports the nonce on the native op
|
|
969
|
-
const testContext = ctxWithExplorer(
|
|
973
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
970
974
|
|
|
971
975
|
const address = '0xb69b37a4fb4a18b3258f974ff6e9f529ad2647b1'
|
|
972
976
|
const txHash = '0xf034ecf17ad61bc29bab12fc303296428d6c7c8a285bd92b2e30a92b1dd5f3bc'
|
|
@@ -1017,7 +1021,7 @@ describe('listOperations', () => {
|
|
|
1017
1021
|
})
|
|
1018
1022
|
|
|
1019
1023
|
it('should emit both native and token operations when tx has native value > 0 and token transfers', async () => {
|
|
1020
|
-
const testContext = ctxWithExplorer(
|
|
1024
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
1021
1025
|
|
|
1022
1026
|
jest.spyOn(ledgerExplorer, 'getOperations').mockResolvedValue({
|
|
1023
1027
|
lastCoinOperations: [
|
|
@@ -1163,7 +1167,7 @@ describe('listOperations', () => {
|
|
|
1163
1167
|
it.each(paginationBehaviors)(
|
|
1164
1168
|
'etherscan explorer sort parameter is respected %s',
|
|
1165
1169
|
async ({ limit, order, expectedExplorerOrder, expectedResultOrder }) => {
|
|
1166
|
-
const testContext = ctxWithExplorer(
|
|
1170
|
+
const testContext = ctxWithExplorer(mkEtherscanExplorer())
|
|
1167
1171
|
const getOperationsSpy = buildOperationsSpy(etherscanExplorer.explorerApi)
|
|
1168
1172
|
const { items: result } = await listOperations(testContext, currency, address, {
|
|
1169
1173
|
minHeight: 0,
|
|
@@ -1235,7 +1239,7 @@ describe('listOperations', () => {
|
|
|
1235
1239
|
details: { internal: true, sequence: BigNumber(1) },
|
|
1236
1240
|
}
|
|
1237
1241
|
|
|
1238
|
-
const testContext = ctxWithExplorer(
|
|
1242
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
1239
1243
|
jest.spyOn(ledgerExplorer, 'getOperations').mockResolvedValue({
|
|
1240
1244
|
lastCoinOperations: [ambiguousParentSenders],
|
|
1241
1245
|
lastTokenOperations: [relatedTokenOp],
|
|
@@ -1258,7 +1262,7 @@ describe('listOperations', () => {
|
|
|
1258
1262
|
it('preserves semantic operation types (DELEGATE, NFT_*, etc.) instead of mapping to IN/OUT', async () => {
|
|
1259
1263
|
const address = '0xdelegator'
|
|
1260
1264
|
const stakingContract = '0xstaking'
|
|
1261
|
-
const testContext = ctxWithExplorer(
|
|
1265
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
1262
1266
|
jest.spyOn(ledgerExplorer, 'getOperations').mockResolvedValue({
|
|
1263
1267
|
lastCoinOperations: [
|
|
1264
1268
|
{
|
|
@@ -1298,7 +1302,7 @@ describe('listOperations', () => {
|
|
|
1298
1302
|
it('preserves REWARD type for outbound claim-reward tx (not downgraded to OUT/FEES)', async () => {
|
|
1299
1303
|
const address = '0xdelegator'
|
|
1300
1304
|
const distributionPrecompile = '0x0000000000000000000000000000000000001007'
|
|
1301
|
-
const testContext = ctxWithExplorer(
|
|
1305
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
1302
1306
|
jest.spyOn(ledgerExplorer, 'getOperations').mockResolvedValue({
|
|
1303
1307
|
lastCoinOperations: [
|
|
1304
1308
|
{
|
|
@@ -1334,7 +1338,7 @@ describe('listOperations', () => {
|
|
|
1334
1338
|
})
|
|
1335
1339
|
|
|
1336
1340
|
it('copies smart contract fields from explorer extra into operation details', async () => {
|
|
1337
|
-
const testContext = ctxWithExplorer(
|
|
1341
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
1338
1342
|
const contractAddr = '0x1111111111111111111111111111111111111111'
|
|
1339
1343
|
const payload = '0xabcd'
|
|
1340
1344
|
jest.spyOn(ledgerExplorer, 'getOperations').mockResolvedValue({
|
|
@@ -1516,7 +1520,7 @@ describe('listOperations', () => {
|
|
|
1516
1520
|
}
|
|
1517
1521
|
|
|
1518
1522
|
it('Case 1: simple native transfer between EOAs', async () => {
|
|
1519
|
-
const testContext = ctxWithExplorer(
|
|
1523
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
1520
1524
|
mockGetOperations({
|
|
1521
1525
|
lastCoinOperations: [
|
|
1522
1526
|
{
|
|
@@ -1562,7 +1566,7 @@ describe('listOperations', () => {
|
|
|
1562
1566
|
})
|
|
1563
1567
|
|
|
1564
1568
|
it('Case 2: native self send from EOA', async () => {
|
|
1565
|
-
const testContext = ctxWithExplorer(
|
|
1569
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
1566
1570
|
mockGetOperations({
|
|
1567
1571
|
lastCoinOperations: [
|
|
1568
1572
|
{
|
|
@@ -1601,7 +1605,7 @@ describe('listOperations', () => {
|
|
|
1601
1605
|
})
|
|
1602
1606
|
|
|
1603
1607
|
it('Case 2: when explorer returns IN+OUT for self-send, still 2 ops', async () => {
|
|
1604
|
-
const testContext = ctxWithExplorer(
|
|
1608
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
1605
1609
|
mockGetOperations(
|
|
1606
1610
|
{
|
|
1607
1611
|
lastCoinOperations: [
|
|
@@ -1633,7 +1637,7 @@ describe('listOperations', () => {
|
|
|
1633
1637
|
})
|
|
1634
1638
|
|
|
1635
1639
|
it('Case 3: simple ERC20 transfer between EOAs', async () => {
|
|
1636
|
-
const testContext = ctxWithExplorer(
|
|
1640
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
1637
1641
|
const sharedTxHash = '0xcase3'
|
|
1638
1642
|
mockGetOperations(
|
|
1639
1643
|
{
|
|
@@ -1693,7 +1697,7 @@ describe('listOperations', () => {
|
|
|
1693
1697
|
})
|
|
1694
1698
|
|
|
1695
1699
|
it('Case 4: ERC20 self send from EOA', async () => {
|
|
1696
|
-
const testContext = ctxWithExplorer(
|
|
1700
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
1697
1701
|
mockGetOperations(
|
|
1698
1702
|
{
|
|
1699
1703
|
lastCoinOperations: [
|
|
@@ -1745,7 +1749,7 @@ describe('listOperations', () => {
|
|
|
1745
1749
|
})
|
|
1746
1750
|
|
|
1747
1751
|
it('Case 5: ETH transfer from smart contract', async () => {
|
|
1748
|
-
const testContext = ctxWithExplorer(
|
|
1752
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
1749
1753
|
const sharedTxHash = '0xcase5'
|
|
1750
1754
|
mockGetOperations(
|
|
1751
1755
|
{
|
|
@@ -1804,7 +1808,7 @@ describe('listOperations', () => {
|
|
|
1804
1808
|
})
|
|
1805
1809
|
|
|
1806
1810
|
it('Case 6: ERC20 transfer from smart contract', async () => {
|
|
1807
|
-
const testContext = ctxWithExplorer(
|
|
1811
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
1808
1812
|
const sharedTxHash = '0xcase6'
|
|
1809
1813
|
mockGetOperations(
|
|
1810
1814
|
{
|
|
@@ -1879,7 +1883,7 @@ describe('listOperations', () => {
|
|
|
1879
1883
|
})
|
|
1880
1884
|
|
|
1881
1885
|
it('Case 7: ETH transfer to smart contract', async () => {
|
|
1882
|
-
const testContext = ctxWithExplorer(
|
|
1886
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
1883
1887
|
mockGetOperations({
|
|
1884
1888
|
lastCoinOperations: [
|
|
1885
1889
|
{
|
|
@@ -1910,7 +1914,7 @@ describe('listOperations', () => {
|
|
|
1910
1914
|
})
|
|
1911
1915
|
|
|
1912
1916
|
it('Case 8: ERC20 transfer to smart contract', async () => {
|
|
1913
|
-
const testContext = ctxWithExplorer(
|
|
1917
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
1914
1918
|
mockGetOperations(
|
|
1915
1919
|
{
|
|
1916
1920
|
lastCoinOperations: [
|
|
@@ -1954,7 +1958,7 @@ describe('listOperations', () => {
|
|
|
1954
1958
|
})
|
|
1955
1959
|
|
|
1956
1960
|
it('Case 9: ETH transfer through smart contract', async () => {
|
|
1957
|
-
const testContext = ctxWithExplorer(
|
|
1961
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
1958
1962
|
const sharedTxHash = '0xcase9'
|
|
1959
1963
|
mockGetOperations(
|
|
1960
1964
|
{
|
|
@@ -2013,7 +2017,7 @@ describe('listOperations', () => {
|
|
|
2013
2017
|
})
|
|
2014
2018
|
|
|
2015
2019
|
it('Case 10: mixed assets smart contract interaction', async () => {
|
|
2016
|
-
const testContext = ctxWithExplorer(
|
|
2020
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
2017
2021
|
const sharedTxHash = '0xcase10'
|
|
2018
2022
|
mockGetOperations(
|
|
2019
2023
|
{
|
|
@@ -2083,7 +2087,7 @@ describe('listOperations', () => {
|
|
|
2083
2087
|
})
|
|
2084
2088
|
|
|
2085
2089
|
it('Case 11: Spoofed token transfer through smart contract', async () => {
|
|
2086
|
-
const testContext = ctxWithExplorer(
|
|
2090
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
2087
2091
|
const sharedTxHash = '0xcase11'
|
|
2088
2092
|
mockGetOperations(
|
|
2089
2093
|
{
|
|
@@ -2162,7 +2166,7 @@ describe('listOperations', () => {
|
|
|
2162
2166
|
})
|
|
2163
2167
|
|
|
2164
2168
|
it('Case: root trace internal tx is deduplicated against parent coin op (Blockscout bug)', async () => {
|
|
2165
|
-
const testContext = ctxWithExplorer(
|
|
2169
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
2166
2170
|
const sharedTxHash = '0xRootTraceBug'
|
|
2167
2171
|
// Blockscout returns the top-level call as an internal tx with from=EOA.
|
|
2168
2172
|
// Regular tx: user → router, value=6 (in txlist)
|
|
@@ -2212,7 +2216,7 @@ describe('listOperations', () => {
|
|
|
2212
2216
|
})
|
|
2213
2217
|
|
|
2214
2218
|
it('Case: root trace dedup is sender-based, filters even when internal value differs', async () => {
|
|
2215
|
-
const testContext = ctxWithExplorer(
|
|
2219
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
2216
2220
|
const sharedTxHash = '0xRootTraceDiffValue'
|
|
2217
2221
|
// Variant where the internal root trace has a different value than the coin op.
|
|
2218
2222
|
// The filter is purely sender-based (not value-based), so it still deduplicates.
|
|
@@ -2257,7 +2261,7 @@ describe('listOperations', () => {
|
|
|
2257
2261
|
})
|
|
2258
2262
|
|
|
2259
2263
|
it('Case: incoming root trace internal tx is deduplicated against parent operation', async () => {
|
|
2260
|
-
const testContext = ctxWithExplorer(
|
|
2264
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
2261
2265
|
const sharedTxHash = '0xIncomingRootTrace'
|
|
2262
2266
|
mockGetOperations(
|
|
2263
2267
|
{
|
|
@@ -2289,7 +2293,7 @@ describe('listOperations', () => {
|
|
|
2289
2293
|
})
|
|
2290
2294
|
|
|
2291
2295
|
it('Case: incoming internal tx with different value is NOT filtered', async () => {
|
|
2292
|
-
const testContext = ctxWithExplorer(
|
|
2296
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
2293
2297
|
const sharedTxHash = '0xIncomingDiffValue'
|
|
2294
2298
|
mockGetOperations(
|
|
2295
2299
|
{
|
|
@@ -2323,7 +2327,7 @@ describe('listOperations', () => {
|
|
|
2323
2327
|
})
|
|
2324
2328
|
|
|
2325
2329
|
it('Case: incoming internal tx with same value but different sender is NOT filtered', async () => {
|
|
2326
|
-
const testContext = ctxWithExplorer(
|
|
2330
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
2327
2331
|
const sharedTxHash = '0xIncomingSameValueDiffSender'
|
|
2328
2332
|
mockGetOperations(
|
|
2329
2333
|
{
|
|
@@ -2357,7 +2361,7 @@ describe('listOperations', () => {
|
|
|
2357
2361
|
})
|
|
2358
2362
|
|
|
2359
2363
|
it('Case: legitimate internal tx is NOT filtered when parent sender differs (smart contract wallet)', async () => {
|
|
2360
|
-
const testContext = ctxWithExplorer(
|
|
2364
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
2361
2365
|
const sharedTxHash = '0xSCWCase'
|
|
2362
2366
|
// A relayer sends a tx to the wallet (coin op), then the wallet makes a sub-call (internal tx).
|
|
2363
2367
|
// The internal tx sender (wallet) matches the queried address, but the parent sender (relayer) differs.
|
|
@@ -2402,7 +2406,7 @@ describe('listOperations', () => {
|
|
|
2402
2406
|
})
|
|
2403
2407
|
|
|
2404
2408
|
it('Case 12: Smart contract token minting', async () => {
|
|
2405
|
-
const testContext = ctxWithExplorer(
|
|
2409
|
+
const testContext = ctxWithExplorer(mkLedgerExplorer())
|
|
2406
2410
|
const sharedTxHash = '0xcase12'
|
|
2407
2411
|
const zeroAddress = '0x0000000000000000000000000000000000000000'
|
|
2408
2412
|
mockGetOperations(
|