@ledgerhq/coin-evm 5.2.1 → 5.3.2
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 +2 -12
- package/CHANGELOG.md +29 -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 +19 -13
- 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 +2 -2
- package/lib/logic/getStakes.d.ts.map +1 -1
- package/lib/logic/getStakes.js +6 -3
- package/lib/logic/getStakes.js.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/listOperations.d.ts.map +1 -1
- package/lib/logic/listOperations.js +3 -0
- package/lib/logic/listOperations.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 +8 -4
- 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/fetchers.d.ts.map +1 -1
- package/lib/staking/fetchers.js +1 -0
- package/lib/staking/fetchers.js.map +1 -1
- package/lib/staking/validators/monad.d.ts +5 -4
- package/lib/staking/validators/monad.d.ts.map +1 -1
- package/lib/staking/validators/monad.js +42 -3
- 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/staking.d.ts +3 -2
- package/lib/types/staking.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 +19 -13
- 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 +2 -2
- package/lib-es/logic/getStakes.d.ts.map +1 -1
- package/lib-es/logic/getStakes.js +6 -3
- package/lib-es/logic/getStakes.js.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/listOperations.d.ts.map +1 -1
- package/lib-es/logic/listOperations.js +3 -0
- package/lib-es/logic/listOperations.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 +8 -4
- 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/fetchers.d.ts.map +1 -1
- package/lib-es/staking/fetchers.js +2 -1
- package/lib-es/staking/fetchers.js.map +1 -1
- package/lib-es/staking/validators/monad.d.ts +5 -4
- package/lib-es/staking/validators/monad.d.ts.map +1 -1
- package/lib-es/staking/validators/monad.js +40 -2
- 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/staking.d.ts +3 -2
- package/lib-es/types/staking.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 +2 -2
- 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 +1 -1
- package/src/api/index.integ.test.ts +265 -153
- 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/ledger.fixtures.ts +1 -1
- package/src/internalTxSources.test.ts +3 -6
- package/src/logic/combine.test.ts +2 -2
- package/src/logic/combine.ts +2 -1
- package/src/logic/common.test.ts +3 -3
- package/src/logic/common.ts +2 -7
- package/src/logic/craftTransaction.test.ts +4 -3
- package/src/logic/craftTransaction.ts +3 -2
- package/src/logic/craftTransactionData.test.ts +1 -1
- package/src/logic/craftTransactionData.ts +1 -1
- package/src/logic/estimateFees.ts +6 -3
- package/src/logic/getBalance.test.ts +1 -1
- package/src/logic/getBalance.ts +30 -24
- package/src/logic/getBlock.test.ts +8 -7
- package/src/logic/getBlock.ts +3 -2
- package/src/logic/getBlockInfo.test.ts +1 -3
- package/src/logic/getStakes.test.ts +2 -2
- package/src/logic/getStakes.ts +15 -6
- package/src/logic/internalTransactionsFetcher.test.ts +4 -6
- package/src/logic/internalTransactionsFetcher.ts +1 -1
- package/src/logic/lastBlock.test.ts +2 -1
- package/src/logic/listOperations.test.ts +75 -2
- package/src/logic/listOperations.ts +3 -0
- package/src/logic/validateIntent.test.ts +2 -1
- package/src/logic/validateIntent.ts +4 -2
- package/src/logic.ts +1 -1
- package/src/network/explorer/etherscan.test.ts +36 -1
- package/src/network/explorer/etherscan.ts +20 -14
- package/src/network/explorer/index.test.ts +1 -1
- package/src/network/explorer/index.ts +2 -2
- package/src/network/explorer/ledger.test.ts +2 -1
- 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 +1 -1
- package/src/network/gasTracker/index.ts +2 -2
- package/src/network/gasTracker/ledger.test.ts +10 -17
- package/src/network/gasTracker/ledger.ts +5 -7
- package/src/network/gasTracker/types.ts +2 -2
- package/src/network/node/index.memoization.test.ts +1 -1
- package/src/network/node/ledger.ts +6 -5
- package/src/network/node/rpc.common.ts +14 -14
- package/src/network/node/rpc.test.ts +4 -10
- package/src/network/node/types.ts +3 -3
- package/src/staking/detectOperationType.test.ts +1 -1
- package/src/staking/encoder.test.ts +1 -1
- package/src/staking/fetchers.ts +2 -1
- package/src/staking/operations/index.test.ts +1 -1
- package/src/staking/redelegations.test.ts +23 -15
- package/src/staking/rewards.test.ts +6 -2
- package/src/staking/rewardsFromReceipt.test.ts +1 -1
- package/src/staking/transactionData.test.ts +2 -2
- package/src/staking/validators/monad.test.ts +102 -1
- package/src/staking/validators/monad.ts +58 -5
- package/src/staking/validators/monadResolver.ts +2 -1
- package/src/staking/validators/somnia.ts +2 -1
- package/src/staking/validators/zero_gravity.ts +2 -1
- package/src/staking/validators.test.ts +7 -2
- package/src/types/assets.ts +1 -1
- package/src/types/staking.ts +4 -2
- package/src/types/transaction.ts +1 -1
package/src/logic/common.test.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import type { EvmConfigInfo } from '../config'
|
|
5
|
-
import { FeeEstimation, MemoNotSupported } from '@ledgerhq/coin-module-framework/api/index'
|
|
6
|
-
import { TransactionIntent, BufferTxData } from '@ledgerhq/coin-module-framework/api/types'
|
|
5
|
+
import type { FeeEstimation, MemoNotSupported } from '@ledgerhq/coin-module-framework/api/index'
|
|
6
|
+
import type { TransactionIntent, BufferTxData } from '@ledgerhq/coin-module-framework/api/types'
|
|
7
7
|
import { BigNumber } from 'bignumber.js'
|
|
8
8
|
import { getNodeApi } from '../network/node'
|
|
9
9
|
import { mockNodeApi } from '../network/node/node.fixtures'
|
|
@@ -13,7 +13,7 @@ import { getCallData, prepareUnsignedTxParams } from './common'
|
|
|
13
13
|
import * as getErc20DataModule from './getErc20Data'
|
|
14
14
|
|
|
15
15
|
jest.mock('./getErc20Data', () => {
|
|
16
|
-
const actual = jest.requireActual<typeof
|
|
16
|
+
const actual = jest.requireActual<typeof getErc20DataModule>('./getErc20Data')
|
|
17
17
|
return {
|
|
18
18
|
getErc20Data: jest.fn((recipient: string, amount: bigint) =>
|
|
19
19
|
actual.getErc20Data(recipient, amount)
|
package/src/logic/common.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import type { EvmConfigInfo } from '../config'
|
|
5
|
+
import type { ApiFeeData, ApiGasOptions, TransactionLikeWithPreparedParams } from '../types'
|
|
5
6
|
import type {
|
|
6
7
|
BufferTxData,
|
|
7
8
|
FeeEstimation,
|
|
@@ -16,13 +17,7 @@ import BigNumber from 'bignumber.js'
|
|
|
16
17
|
import { ethers } from 'ethers'
|
|
17
18
|
import { getNodeApi } from '../network/node'
|
|
18
19
|
import { buildStakingTransactionParams, prepareStakingIntent, STAKING_CONTRACTS } from '../staking'
|
|
19
|
-
import {
|
|
20
|
-
ApiFeeData,
|
|
21
|
-
ApiGasOptions,
|
|
22
|
-
isNative,
|
|
23
|
-
TransactionLikeWithPreparedParams,
|
|
24
|
-
TransactionTypes,
|
|
25
|
-
} from '../types'
|
|
20
|
+
import { isNative, TransactionTypes } from '../types'
|
|
26
21
|
import { isEthAddress } from '../utils'
|
|
27
22
|
import { getErc20Data } from './getErc20Data'
|
|
28
23
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import type { EvmConfigInfo } from '../config'
|
|
5
|
-
import {
|
|
5
|
+
import type {
|
|
6
6
|
BufferTxData,
|
|
7
7
|
MemoNotSupported,
|
|
8
8
|
TransactionIntent,
|
|
@@ -542,7 +542,8 @@ describe('craftTransaction', () => {
|
|
|
542
542
|
await expect(
|
|
543
543
|
craftTransaction(context, 'sei_evm', {
|
|
544
544
|
transactionIntent: {
|
|
545
|
-
type: 'staking',
|
|
545
|
+
type: 'staking-legacy',
|
|
546
|
+
intentType: 'staking',
|
|
546
547
|
sender: '0x1234567890abcdef1234567890abcdef12345678',
|
|
547
548
|
recipient: '0x000000000000000000000000000000000001005',
|
|
548
549
|
valAddress: 'validator123',
|
|
@@ -551,7 +552,7 @@ describe('craftTransaction', () => {
|
|
|
551
552
|
mode: 'unsupported_operation',
|
|
552
553
|
} as any,
|
|
553
554
|
})
|
|
554
|
-
).rejects.toThrow()
|
|
555
|
+
).rejects.toThrow('Invalid staking operation: unsupported_operation')
|
|
555
556
|
})
|
|
556
557
|
})
|
|
557
558
|
})
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import type { EvmContext } from '../config'
|
|
5
|
-
import {
|
|
5
|
+
import type {
|
|
6
6
|
BufferTxData,
|
|
7
7
|
CraftedTransaction,
|
|
8
8
|
FeeEstimation,
|
|
@@ -10,7 +10,8 @@ import {
|
|
|
10
10
|
MemoNotSupported,
|
|
11
11
|
TransactionIntent,
|
|
12
12
|
} from '@ledgerhq/coin-module-framework/api/types'
|
|
13
|
-
import {
|
|
13
|
+
import type { TransactionLike } from 'ethers'
|
|
14
|
+
import { Transaction } from 'ethers'
|
|
14
15
|
import { GasEstimationError } from '../errors'
|
|
15
16
|
import { getNodeApi } from '../network/node'
|
|
16
17
|
import { TransactionTypes } from '../types'
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import type { EvmConfigInfo } from '../config'
|
|
5
|
+
import type { EvmContext } from '../config'
|
|
6
|
+
import type { ApiFeeData, ApiGasOptions, FeeData, GasOptions } from '../types'
|
|
4
7
|
import type {
|
|
5
8
|
BufferTxData,
|
|
6
9
|
FeeEstimation,
|
|
@@ -8,14 +11,14 @@ import type {
|
|
|
8
11
|
MemoNotSupported,
|
|
9
12
|
TransactionIntent,
|
|
10
13
|
} from '@ledgerhq/coin-module-framework/api/index'
|
|
14
|
+
import type { TransactionLike } from 'ethers'
|
|
11
15
|
import BigNumber from 'bignumber.js'
|
|
12
|
-
import { Transaction
|
|
13
|
-
import { EvmConfigInfo, type EvmContext } from '../config'
|
|
16
|
+
import { Transaction } from 'ethers'
|
|
14
17
|
import { getAdditionalLayer2Fees } from '../logic'
|
|
15
18
|
import { getGasTracker } from '../network/gasTracker'
|
|
16
19
|
import { getNodeApi } from '../network/node'
|
|
17
20
|
import { STAKING_CONTRACTS } from '../staking'
|
|
18
|
-
import {
|
|
21
|
+
import { TransactionTypes } from '../types'
|
|
19
22
|
import { isEthAddress, isStakingIntent } from '../utils'
|
|
20
23
|
import { getTransactionType, prepareUnsignedTxParams } from './common'
|
|
21
24
|
import { getNextSequence } from './getNextSequence'
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import type { EvmConfigInfo, EvmContext } from '../config'
|
|
5
|
-
import { AssetInfo } from '@ledgerhq/coin-module-framework/api/types'
|
|
5
|
+
import type { AssetInfo } from '@ledgerhq/coin-module-framework/api/types'
|
|
6
6
|
import BigNumber from 'bignumber.js'
|
|
7
7
|
import { createMockEvmContext } from '../fixtures/context.fixtures'
|
|
8
8
|
import { getExplorerApi } from '../network/explorer'
|
package/src/logic/getBalance.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import type { EvmConfigInfo } from '../config'
|
|
5
|
+
import type { EvmContext } from '../config'
|
|
6
|
+
import type { ExplorerApi } from '../network/explorer/types'
|
|
7
|
+
import type { NodeApi } from '../network/node/types'
|
|
4
8
|
import type {
|
|
5
9
|
Balance,
|
|
6
10
|
AssetInfo,
|
|
@@ -8,11 +12,9 @@ import type {
|
|
|
8
12
|
MemoNotSupported,
|
|
9
13
|
Operation,
|
|
10
14
|
} from '@ledgerhq/coin-module-framework/api/types'
|
|
11
|
-
import { EvmConfigInfo, type EvmContext } from '../config'
|
|
12
15
|
import { getExplorerApi } from '../network/explorer'
|
|
13
|
-
import { ExplorerApi } from '../network/explorer/types'
|
|
14
16
|
import { getNodeApi } from '../network/node'
|
|
15
|
-
import {
|
|
17
|
+
import { STAKING_CONFIG } from '../staking'
|
|
16
18
|
import { getStakes } from './getStakes'
|
|
17
19
|
|
|
18
20
|
export const TOKEN_BALANCE_BATCH_SIZE = 8
|
|
@@ -67,10 +69,27 @@ async function getTokenBalances(
|
|
|
67
69
|
): Promise<Balance[]> {
|
|
68
70
|
const balances: Balance[] = []
|
|
69
71
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
const opsResult = await explorerApi
|
|
73
|
+
.getOperations(config, currencyId, address, 0)
|
|
74
|
+
.catch(() => null)
|
|
75
|
+
const lastCoinOperations = opsResult?.lastCoinOperations ?? []
|
|
76
|
+
const lastTokenOperations = opsResult?.lastTokenOperations ?? []
|
|
77
|
+
|
|
78
|
+
const knownValidatorIds = STAKING_CONFIG[currencyId]?.extractKnownValIds?.(
|
|
79
|
+
currencyId,
|
|
80
|
+
lastCoinOperations
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
// Contracts whose ERC20 balance mirrors the native balance — skip them here to avoid
|
|
84
|
+
// counting the same value twice (the native balance is already returned upstream).
|
|
85
|
+
const { nativeContracts = [] } = config
|
|
86
|
+
const nativeContractsSet = new Set(nativeContracts.map((c) => c.toLowerCase()))
|
|
87
|
+
|
|
88
|
+
// Staking and token-asset collection run in parallel; both depend only on the
|
|
89
|
+
// operations result fetched above.
|
|
90
|
+
const [stakingResult, tokenAssetsResult] = await Promise.allSettled([
|
|
91
|
+
getStakes(context, currencyId, address, { knownValidatorIds }),
|
|
92
|
+
collectTokenAssets(lastTokenOperations, address, nativeContractsSet, options),
|
|
74
93
|
])
|
|
75
94
|
|
|
76
95
|
// Add staking positions to balances (with error handling)
|
|
@@ -84,23 +103,10 @@ async function getTokenBalances(
|
|
|
84
103
|
})
|
|
85
104
|
}
|
|
86
105
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
: []
|
|
92
|
-
|
|
93
|
-
// Contracts whose ERC20 balance mirrors the native balance — skip them here to avoid
|
|
94
|
-
// counting the same value twice (the native balance is already returned upstream).
|
|
95
|
-
const { nativeContracts = [] } = config
|
|
96
|
-
const nativeContractsSet = new Set(nativeContracts.map((c) => c.toLowerCase()))
|
|
97
|
-
|
|
98
|
-
const { contracts, assets } = await collectTokenAssets(
|
|
99
|
-
lastTokenOperations,
|
|
100
|
-
address,
|
|
101
|
-
nativeContractsSet,
|
|
102
|
-
options
|
|
103
|
-
)
|
|
106
|
+
const { contracts, assets } =
|
|
107
|
+
tokenAssetsResult.status === 'fulfilled'
|
|
108
|
+
? tokenAssetsResult.value
|
|
109
|
+
: { contracts: new Set<string>(), assets: new Map<string, AssetInfo>() }
|
|
104
110
|
|
|
105
111
|
// Fetch balances in parallel (by batches)
|
|
106
112
|
const contractsArray = Array.from(contracts)
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type {
|
|
5
|
-
import {
|
|
6
|
-
import { UnsupportedRpcMethodError } from '../errors'
|
|
7
|
-
import { getInternalTransactionsByBlock } from '../network/explorer/etherscan'
|
|
8
|
-
import { getNodeApi } from '../network/node'
|
|
9
|
-
import {
|
|
4
|
+
import type { EvmCoinConfig } from '../config'
|
|
5
|
+
import type {
|
|
10
6
|
BlockByHeightResult,
|
|
11
7
|
BlockReceiptInfo,
|
|
12
8
|
ERC20Transfer,
|
|
@@ -15,7 +11,12 @@ import {
|
|
|
15
11
|
TraceBlockItem,
|
|
16
12
|
TransactionInfo,
|
|
17
13
|
} from '../network/node/types'
|
|
18
|
-
import { EtherscanInternalTransaction } from '../types'
|
|
14
|
+
import type { EtherscanInternalTransaction } from '../types'
|
|
15
|
+
import type { BlockOperation } from '@ledgerhq/coin-module-framework/api/index'
|
|
16
|
+
import { createContext, internalTxSourcesFromList, setCoinConfig } from '../config'
|
|
17
|
+
import { UnsupportedRpcMethodError } from '../errors'
|
|
18
|
+
import { getInternalTransactionsByBlock } from '../network/explorer/etherscan'
|
|
19
|
+
import { getNodeApi } from '../network/node'
|
|
19
20
|
import { safeEncodeEIP55 } from '../utils'
|
|
20
21
|
import { getBlock } from './getBlock'
|
|
21
22
|
import { dropRootTraceDuplicates } from './rootTraceDedup'
|
package/src/logic/getBlock.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import type { EvmContext } from '../config'
|
|
5
|
+
import type { BlockReceiptInfo, PrefetchedBlockTransaction } from '../network/node/types'
|
|
4
6
|
import type {
|
|
5
7
|
Block,
|
|
6
8
|
BlockInfo,
|
|
@@ -11,10 +13,9 @@ import type {
|
|
|
11
13
|
import { promiseAllBatched } from '@ledgerhq/coin-module-framework/promises'
|
|
12
14
|
import { log } from '@ledgerhq/logs'
|
|
13
15
|
import { rpcTransactionToBlockOperations } from '../adapters/blockOperations'
|
|
14
|
-
import { DEFAULT_INTERNAL_TX_SOURCES
|
|
16
|
+
import { DEFAULT_INTERNAL_TX_SOURCES } from '../config'
|
|
15
17
|
import { UnsupportedRpcMethodError } from '../errors'
|
|
16
18
|
import { getNodeApi } from '../network/node'
|
|
17
|
-
import { BlockReceiptInfo, PrefetchedBlockTransaction } from '../network/node/types'
|
|
18
19
|
import { buildSmartContractDetails, safeEncodeEIP55 } from '../utils'
|
|
19
20
|
import { createInternalTransactionsFetcher } from './internalTransactionsFetcher'
|
|
20
21
|
import { dropRootTraceDuplicates } from './rootTraceDedup'
|
|
@@ -114,9 +114,7 @@ describe('getBlockInfo', () => {
|
|
|
114
114
|
const result = await getBlockInfo(context, '', 100)
|
|
115
115
|
|
|
116
116
|
expect(result.time).toBeInstanceOf(Date)
|
|
117
|
-
expect(result.parent).
|
|
118
|
-
expect(result.parent?.height).toBe(99)
|
|
119
|
-
expect(result.parent?.hash).toBe('0xparent')
|
|
117
|
+
expect(result.parent).toMatchObject({ height: 99, hash: '0xparent' })
|
|
120
118
|
})
|
|
121
119
|
})
|
|
122
120
|
})
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import type { EvmConfigInfo } from '../config'
|
|
5
|
-
import { JsonRpcProvider } from 'ethers'
|
|
5
|
+
import type { JsonRpcProvider } from 'ethers'
|
|
6
6
|
import { createMockEvmContext } from '../fixtures/context.fixtures'
|
|
7
7
|
import { withApi } from '../network/node/rpc.common'
|
|
8
8
|
import { encodeStakingData, decodeStakingResult } from '../staking/encoder'
|
|
@@ -44,7 +44,7 @@ describe('EVM Staking - getStakes', () => {
|
|
|
44
44
|
|
|
45
45
|
beforeEach(() => {
|
|
46
46
|
jest.clearAllMocks()
|
|
47
|
-
jest.spyOn(console, 'error').mockImplementation(() =>
|
|
47
|
+
jest.spyOn(console, 'error').mockImplementation(() => undefined)
|
|
48
48
|
})
|
|
49
49
|
|
|
50
50
|
it('should return stake objects with positive amounts for supported currencies', async () => {
|
package/src/logic/getStakes.ts
CHANGED
|
@@ -2,25 +2,34 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import type { EvmContext } from '../config'
|
|
5
|
-
import { Page, Stake } from '@ledgerhq/coin-module-framework/api/types'
|
|
5
|
+
import type { Page, Stake, StakesOptions } from '@ledgerhq/coin-module-framework/api/types'
|
|
6
6
|
import { STAKING_CONTRACTS, STAKING_CONFIG } from '../staking'
|
|
7
7
|
|
|
8
8
|
export const getStakes = async (
|
|
9
9
|
context: EvmContext,
|
|
10
10
|
currencyId: string,
|
|
11
|
-
address: string
|
|
11
|
+
address: string,
|
|
12
|
+
options?: StakesOptions
|
|
12
13
|
): Promise<Page<Stake>> => {
|
|
13
14
|
const contractConfig = STAKING_CONTRACTS[currencyId]
|
|
14
|
-
|
|
15
15
|
if (!contractConfig) {
|
|
16
16
|
return { items: [] }
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
const stakingStrategy = STAKING_CONFIG[currencyId]
|
|
20
|
+
if (!stakingStrategy) {
|
|
21
|
+
return { items: [] }
|
|
22
|
+
}
|
|
23
|
+
|
|
19
24
|
try {
|
|
20
25
|
const config = await context.config(currencyId)
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
const stakes = await stakingStrategy.fetcher(
|
|
27
|
+
config,
|
|
28
|
+
address,
|
|
29
|
+
contractConfig,
|
|
30
|
+
currencyId,
|
|
31
|
+
options?.knownValidatorIds
|
|
32
|
+
)
|
|
24
33
|
return { items: stakes }
|
|
25
34
|
} catch {
|
|
26
35
|
return { items: [] }
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import type { EvmConfigInfo } from '../config'
|
|
5
|
+
import type { SourceFetcher } from './internalTransactionsFetcher'
|
|
4
6
|
import type { BlockOperation } from '@ledgerhq/coin-module-framework/api/index'
|
|
5
|
-
import {
|
|
7
|
+
import { internalTxSourcesFromList } from '../config'
|
|
6
8
|
import { SourceUnavailableError } from '../errors'
|
|
7
9
|
import { getInternalTransactionsByBlock } from '../network/explorer/etherscan'
|
|
8
10
|
import { mockNodeApi } from '../network/node/node.fixtures'
|
|
9
|
-
import {
|
|
10
|
-
composeInternalTxsFetcher,
|
|
11
|
-
makeSourceFetchers,
|
|
12
|
-
type SourceFetcher,
|
|
13
|
-
} from './internalTransactionsFetcher'
|
|
11
|
+
import { composeInternalTxsFetcher, makeSourceFetchers } from './internalTransactionsFetcher'
|
|
14
12
|
|
|
15
13
|
jest.mock('../network/explorer/etherscan', () => ({
|
|
16
14
|
getInternalTransactionsByBlock: jest.fn().mockResolvedValue([]),
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import type { EvmConfigInfo } from '../config'
|
|
5
5
|
import type { InternalTxSource } from '../internalTxSources'
|
|
6
|
+
import type { NodeApi } from '../network/node/types'
|
|
6
7
|
import type { BlockOperation } from '@ledgerhq/coin-module-framework/api/index'
|
|
7
8
|
import { log } from '@ledgerhq/logs'
|
|
8
9
|
import { traceBlockItemsToOperationsByHash } from '../adapters/blockOperations'
|
|
@@ -10,7 +11,6 @@ import { internalTxsToOperationsByHash } from '../adapters/etherscan'
|
|
|
10
11
|
import { SourceUnavailableError } from '../errors'
|
|
11
12
|
import { getInternalTransactionsByBlock } from '../network/explorer/etherscan'
|
|
12
13
|
import { isEtherscanLikeExplorerConfig } from '../network/explorer/types'
|
|
13
|
-
import { NodeApi } from '../network/node/types'
|
|
14
14
|
|
|
15
15
|
export type InternalTxsByHash = Map<string, BlockOperation[]>
|
|
16
16
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { BlockFinalizationTag
|
|
4
|
+
import type { BlockFinalizationTag } from '../config'
|
|
5
|
+
import type { EvmConfigInfo } from '../config'
|
|
5
6
|
import { createMockEvmContext } from '../fixtures/context.fixtures'
|
|
6
7
|
import { getNodeApi } from '../network/node'
|
|
7
8
|
import { mockNodeApi } from '../network/node/node.fixtures'
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import type { EvmConfigInfo } from '../config'
|
|
5
|
+
import type { EvmContext } from '../config'
|
|
6
|
+
import type { ExplorerApi } from '../network/explorer/types'
|
|
4
7
|
import type { MemoNotSupported, Operation } from '@ledgerhq/coin-module-framework/api/types'
|
|
5
8
|
import BigNumber from 'bignumber.js'
|
|
6
|
-
import { EvmConfigInfo, type EvmContext } from '../config'
|
|
7
9
|
import { createMockEvmContext } from '../fixtures/context.fixtures'
|
|
8
10
|
import etherscanExplorer from '../network/explorer/etherscan'
|
|
9
11
|
import ledgerExplorer from '../network/explorer/ledger'
|
|
10
|
-
import { ExplorerApi } from '../network/explorer/types'
|
|
11
12
|
import { listOperations } from './listOperations'
|
|
12
13
|
|
|
13
14
|
describe('listOperations', () => {
|
|
@@ -892,6 +893,78 @@ describe('listOperations', () => {
|
|
|
892
893
|
expect(sameTxFees).toEqual([parentFee, parentFee])
|
|
893
894
|
})
|
|
894
895
|
|
|
896
|
+
/**
|
|
897
|
+
* Some explorers (chainscan.0g.ai tokentx) omit blockHash on ERC20 rows while txlist has it.
|
|
898
|
+
* A token op keeps its own block.hash when present, and only falls back to the parent's.
|
|
899
|
+
*/
|
|
900
|
+
it('falls back to the parent block.hash on token ops when the explorer token row omits it', async () => {
|
|
901
|
+
const testContext = ctxWithExplorer({ type: 'etherscan' })
|
|
902
|
+
const txHash = '0x6593efaefa1752c9ba92ba079fc9705daad1f67b3437b07139692e8e5b647021'
|
|
903
|
+
const parentBlockHash = '0x77fd02171913e7af2b4d76aeaca2bd70d36e112a66092790c4c2c8a57566a7e2'
|
|
904
|
+
const date = new Date('2026-02-16T09:25:37.000Z')
|
|
905
|
+
|
|
906
|
+
jest.spyOn(etherscanExplorer.explorerApi, 'getOperations').mockResolvedValue({
|
|
907
|
+
lastCoinOperations: [
|
|
908
|
+
{
|
|
909
|
+
id: 'native-fees',
|
|
910
|
+
type: 'FEES',
|
|
911
|
+
senders: [address],
|
|
912
|
+
recipients: ['0x8B598A7C136215A95ba0282b4d832B9f9801f2e2'],
|
|
913
|
+
value: 0n,
|
|
914
|
+
asset: { type: 'native' as const },
|
|
915
|
+
tx: {
|
|
916
|
+
hash: txHash,
|
|
917
|
+
block: { height: 24886171, hash: parentBlockHash, time: date },
|
|
918
|
+
fees: 997504000000000n,
|
|
919
|
+
feesPayer: address,
|
|
920
|
+
date,
|
|
921
|
+
failed: false,
|
|
922
|
+
},
|
|
923
|
+
details: { sequence: BigNumber(0) },
|
|
924
|
+
},
|
|
925
|
+
],
|
|
926
|
+
lastTokenOperations: [
|
|
927
|
+
{
|
|
928
|
+
id: `${txHash}-erc20-0-IN`,
|
|
929
|
+
type: 'IN',
|
|
930
|
+
senders: ['0x8B598A7C136215A95ba0282b4d832B9f9801f2e2'],
|
|
931
|
+
recipients: [address],
|
|
932
|
+
value: 1263257n,
|
|
933
|
+
asset: {
|
|
934
|
+
type: 'erc20' as const,
|
|
935
|
+
assetReference: '0x1f3AA82227281cA364bFb3d253B0f1af1Da6473E',
|
|
936
|
+
assetOwner: address,
|
|
937
|
+
},
|
|
938
|
+
tx: {
|
|
939
|
+
hash: txHash,
|
|
940
|
+
block: { height: 24886171, time: date },
|
|
941
|
+
fees: 0n,
|
|
942
|
+
date,
|
|
943
|
+
failed: false,
|
|
944
|
+
},
|
|
945
|
+
details: {
|
|
946
|
+
ledgerOpType: 'IN',
|
|
947
|
+
assetAmount: '1263257',
|
|
948
|
+
assetSenders: ['0x8B598A7C136215A95ba0282b4d832B9f9801f2e2'],
|
|
949
|
+
assetRecipients: [address],
|
|
950
|
+
sequence: BigNumber(0),
|
|
951
|
+
},
|
|
952
|
+
},
|
|
953
|
+
],
|
|
954
|
+
lastNftOperations: [],
|
|
955
|
+
lastInternalOperations: [],
|
|
956
|
+
nextPagingToken: '',
|
|
957
|
+
})
|
|
958
|
+
|
|
959
|
+
const { items } = await listOperations(testContext, '', address, {
|
|
960
|
+
minHeight: 0,
|
|
961
|
+
order: 'asc',
|
|
962
|
+
})
|
|
963
|
+
|
|
964
|
+
const tokenOp = items.find((op) => op.asset.type === 'erc20')
|
|
965
|
+
expect(tokenOp?.tx.block.hash).toBe(parentBlockHash)
|
|
966
|
+
})
|
|
967
|
+
|
|
895
968
|
it('inherits the parent nonce on token ops, whose fees-only native op is dropped', async () => {
|
|
896
969
|
// LIVE-35844: the Ledger explorer only reports the nonce on the native op
|
|
897
970
|
const testContext = ctxWithExplorer({ type: 'ledger' })
|
|
@@ -107,6 +107,8 @@ export async function listOperations(
|
|
|
107
107
|
// Gas is paid once per tx. Token/NFT sub-ops carry fees from their own explorer record (etherscan),
|
|
108
108
|
// or inherit the parent tx (ledger explorer). Override to always use the parent's fees so the fee
|
|
109
109
|
// is not double-counted and the fee payer is correct.
|
|
110
|
+
// block.hash falls back to the parent only when the token row has none: some explorers
|
|
111
|
+
// (chainscan.0g.ai tokentx) omit it while txlist carries it.
|
|
110
112
|
const enrichTokenWithParent = (op: Operation<MemoNotSupported>): Operation<MemoNotSupported> => {
|
|
111
113
|
const parent = parents[op.tx.hash]
|
|
112
114
|
if (!parent) return op
|
|
@@ -124,6 +126,7 @@ export async function listOperations(
|
|
|
124
126
|
...op,
|
|
125
127
|
tx: {
|
|
126
128
|
...op.tx,
|
|
129
|
+
block: { ...op.tx.block, hash: op.tx.block.hash || parent.tx.block.hash },
|
|
127
130
|
fees: parent.tx.fees,
|
|
128
131
|
failed: parent.tx.failed,
|
|
129
132
|
...(parent.tx.feesPayer ? { feesPayer: parent.tx.feesPayer } : {}),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import type { EvmCoinConfig } from '../config'
|
|
4
5
|
import type {
|
|
5
6
|
BufferTxData,
|
|
6
7
|
MemoNotSupported,
|
|
@@ -16,7 +17,7 @@ import {
|
|
|
16
17
|
RecipientRequired,
|
|
17
18
|
} from '@ledgerhq/coin-module-framework/errors'
|
|
18
19
|
import BigNumber from 'bignumber.js'
|
|
19
|
-
import { createContext,
|
|
20
|
+
import { createContext, setCoinConfig } from '../config'
|
|
20
21
|
import {
|
|
21
22
|
ClaimRewardsFeesWarning,
|
|
22
23
|
ETHAddressNonEIP,
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import type { EvmConfigInfo } from '../config'
|
|
5
|
+
import type { EvmContext } from '../config'
|
|
6
|
+
import type { StakingOperation } from '../types'
|
|
4
7
|
import type {
|
|
5
8
|
AssetInfo,
|
|
6
9
|
Balance,
|
|
@@ -20,7 +23,6 @@ import {
|
|
|
20
23
|
RecipientRequired,
|
|
21
24
|
} from '@ledgerhq/coin-module-framework/errors'
|
|
22
25
|
import BigNumber from 'bignumber.js'
|
|
23
|
-
import { EvmConfigInfo, type EvmContext } from '../config'
|
|
24
26
|
import {
|
|
25
27
|
ClaimRewardsFeesWarning,
|
|
26
28
|
ETHAddressNonEIP,
|
|
@@ -38,7 +40,7 @@ import {
|
|
|
38
40
|
import { getGasTracker } from '../network/gasTracker'
|
|
39
41
|
import { getNodeApi } from '../network/node'
|
|
40
42
|
import { STAKING_CONTRACTS } from '../staking'
|
|
41
|
-
import { isNative,
|
|
43
|
+
import { isNative, TransactionTypes } from '../types'
|
|
42
44
|
import { DEFAULT_GAS_LIMIT, isEthAddress, isStakingIntent } from '../utils'
|
|
43
45
|
import {
|
|
44
46
|
getTransactionType,
|
package/src/logic.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import type { PagingState } from '../../adapters'
|
|
4
5
|
import type { MemoNotSupported, Operation } from '@ledgerhq/coin-module-framework/api/types'
|
|
5
6
|
import { AssertionError, fail } from 'assert'
|
|
6
7
|
import { delay } from '@ledgerhq/coin-module-framework/promises'
|
|
@@ -13,7 +14,6 @@ import {
|
|
|
13
14
|
etherscanOperationToOperations,
|
|
14
15
|
deserializePagingToken,
|
|
15
16
|
serializePagingToken,
|
|
16
|
-
PagingState,
|
|
17
17
|
} from '../../adapters'
|
|
18
18
|
import { getCoinConfig } from '../../config'
|
|
19
19
|
import { EtherscanAPIError, EtherscanLikeExplorerUsedIncorrectly } from '../../errors'
|
|
@@ -147,6 +147,41 @@ describe('EVM Family', () => {
|
|
|
147
147
|
})
|
|
148
148
|
})
|
|
149
149
|
|
|
150
|
+
describe.each([
|
|
151
|
+
['coin', ETHERSCAN_API.getCoinOperations],
|
|
152
|
+
['ERC20', ETHERSCAN_API.getTokenOperations],
|
|
153
|
+
['ERC721', ETHERSCAN_API.getERC721Operations],
|
|
154
|
+
['ERC1155', ETHERSCAN_API.getERC1155Operations],
|
|
155
|
+
])('%s operations with non-array explorer results', (_, getOperations) => {
|
|
156
|
+
afterEach(() => {
|
|
157
|
+
jest.clearAllMocks()
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
it.each([null, 'No transactions found'])(
|
|
161
|
+
'returns an empty result when the explorer returns %p',
|
|
162
|
+
async (result) => {
|
|
163
|
+
jest.spyOn(axios, 'request').mockResolvedValueOnce({
|
|
164
|
+
data: { status: '0', message: 'No transactions found', result },
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
const response = await getOperations({
|
|
168
|
+
currencyId,
|
|
169
|
+
config: getCoinConfig(currencyId).info,
|
|
170
|
+
address,
|
|
171
|
+
fromBlock: 0,
|
|
172
|
+
sort: 'asc',
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
expect(response).toEqual({
|
|
176
|
+
operations: [],
|
|
177
|
+
isDone: true,
|
|
178
|
+
boundBlock: 0,
|
|
179
|
+
isPageFull: true,
|
|
180
|
+
})
|
|
181
|
+
}
|
|
182
|
+
)
|
|
183
|
+
})
|
|
184
|
+
|
|
150
185
|
describe('getCoinOperations', () => {
|
|
151
186
|
afterEach(() => {
|
|
152
187
|
jest.clearAllMocks()
|