@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
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import type {
|
|
5
5
|
BufferTxData,
|
|
6
6
|
MemoNotSupported,
|
|
7
|
-
Operation,
|
|
8
7
|
TransactionIntent,
|
|
9
8
|
} from '@ledgerhq/coin-module-framework/api/types'
|
|
10
9
|
import {
|
|
@@ -15,8 +14,9 @@ import {
|
|
|
15
14
|
NotEnoughBalance,
|
|
16
15
|
RecipientRequired,
|
|
17
16
|
} from '@ledgerhq/coin-module-framework/errors'
|
|
17
|
+
import { createStakingTransactionIntentMockData } from '@ledgerhq/coin-module-framework/test-utils'
|
|
18
18
|
import BigNumber from 'bignumber.js'
|
|
19
|
-
import { createContext,
|
|
19
|
+
import { createContext, setCoinConfig } from '../config'
|
|
20
20
|
import {
|
|
21
21
|
ClaimRewardsFeesWarning,
|
|
22
22
|
ETHAddressNonEIP,
|
|
@@ -31,6 +31,12 @@ import {
|
|
|
31
31
|
RedelegateDstValAddressRequired,
|
|
32
32
|
ValAddressRequired,
|
|
33
33
|
} from '../errors'
|
|
34
|
+
import {
|
|
35
|
+
createMockEvmCoinConfig,
|
|
36
|
+
mkLedgerExplorer,
|
|
37
|
+
mkLedgerGasTracker,
|
|
38
|
+
mkLedgerNode,
|
|
39
|
+
} from '../fixtures/context.fixtures'
|
|
34
40
|
import ledgerExplorer from '../network/explorer/ledger'
|
|
35
41
|
import ledgerGasTracker from '../network/gasTracker/ledger'
|
|
36
42
|
import { getNodeApi } from '../network/node'
|
|
@@ -80,43 +86,18 @@ function eip1559Intent(
|
|
|
80
86
|
}
|
|
81
87
|
}
|
|
82
88
|
|
|
83
|
-
function stakingIntent(
|
|
84
|
-
intent: Partial<
|
|
85
|
-
TransactionIntent<MemoNotSupported, BufferTxData> & {
|
|
86
|
-
mode: 'delegate' | 'redelegate' | 'undelegate' | 'claimReward'
|
|
87
|
-
valAddress?: string
|
|
88
|
-
dstValAddress?: string
|
|
89
|
-
}
|
|
90
|
-
>
|
|
91
|
-
): TransactionIntent<MemoNotSupported, BufferTxData> {
|
|
92
|
-
return {
|
|
93
|
-
type: 'send-legacy',
|
|
94
|
-
intentType: 'staking',
|
|
95
|
-
sender: '0xsender',
|
|
96
|
-
recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29',
|
|
97
|
-
amount: 1n,
|
|
98
|
-
asset: { type: 'native' },
|
|
99
|
-
mode: 'delegate',
|
|
100
|
-
valAddress: 'seivaloper1y82m5y3wevjneamzg0pmx87dzanyxzht0kepvn',
|
|
101
|
-
data: { type: 'buffer', value: Buffer.from([]) },
|
|
102
|
-
...intent,
|
|
103
|
-
} as TransactionIntent<MemoNotSupported, BufferTxData>
|
|
104
|
-
}
|
|
105
|
-
|
|
106
89
|
describe('validateIntent', () => {
|
|
107
90
|
const nodeApiMock = mockNodeApi()
|
|
108
91
|
|
|
109
92
|
beforeEach(() => {
|
|
110
|
-
setCoinConfig(
|
|
111
|
-
(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
},
|
|
119
|
-
}) as unknown as EvmCoinConfig
|
|
93
|
+
setCoinConfig(() =>
|
|
94
|
+
createMockEvmCoinConfig({
|
|
95
|
+
chainId: 1,
|
|
96
|
+
node: mkLedgerNode({ explorerId: 'eth' }),
|
|
97
|
+
name: 'Ethereum',
|
|
98
|
+
explorer: mkLedgerExplorer({ explorerId: 'eth' }),
|
|
99
|
+
gasTracker: mkLedgerGasTracker({ explorerId: 'eth' }),
|
|
100
|
+
})
|
|
120
101
|
)
|
|
121
102
|
|
|
122
103
|
mockGetNodeApi.mockReturnValue(nodeApiMock)
|
|
@@ -439,11 +420,23 @@ describe('validateIntent', () => {
|
|
|
439
420
|
lastNftOperations: [],
|
|
440
421
|
lastTokenOperations: [
|
|
441
422
|
{
|
|
423
|
+
id: '',
|
|
424
|
+
type: '',
|
|
425
|
+
senders: [],
|
|
426
|
+
recipients: [],
|
|
427
|
+
value: 0n,
|
|
442
428
|
asset: {
|
|
443
429
|
type: 'erc20' as const,
|
|
444
430
|
assetReference: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
445
431
|
},
|
|
446
|
-
|
|
432
|
+
tx: {
|
|
433
|
+
hash: '',
|
|
434
|
+
block: { height: 0, hash: '', time: new Date(0) },
|
|
435
|
+
fees: 0n,
|
|
436
|
+
date: new Date(0),
|
|
437
|
+
failed: false,
|
|
438
|
+
},
|
|
439
|
+
},
|
|
447
440
|
],
|
|
448
441
|
nextPagingToken: '',
|
|
449
442
|
})
|
|
@@ -538,13 +531,15 @@ describe('validateIntent', () => {
|
|
|
538
531
|
|
|
539
532
|
describe('staking', () => {
|
|
540
533
|
it('detects missing validator address for delegate with an error', async () => {
|
|
541
|
-
const intent = stakingIntent({ mode: 'delegate' }) as Record<string, unknown>
|
|
542
|
-
delete intent.valAddress
|
|
543
|
-
|
|
544
534
|
const res = await validateIntent(
|
|
545
535
|
createContext(),
|
|
546
536
|
'sei_evm',
|
|
547
|
-
|
|
537
|
+
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
538
|
+
type: 'staking-legacy',
|
|
539
|
+
mode: 'delegate',
|
|
540
|
+
valAddress: '',
|
|
541
|
+
data: { type: 'buffer', value: Buffer.from([]) },
|
|
542
|
+
}),
|
|
548
543
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
549
544
|
{
|
|
550
545
|
value: 10n,
|
|
@@ -560,16 +555,15 @@ describe('validateIntent', () => {
|
|
|
560
555
|
})
|
|
561
556
|
|
|
562
557
|
it('detects missing destination validator address for redelegate with an error', async () => {
|
|
563
|
-
const intent = stakingIntent({
|
|
564
|
-
mode: 'redelegate',
|
|
565
|
-
valAddress: 'seivaloper1y82m5y3wevjneamzg0pmx87dzanyxzht0kepvn',
|
|
566
|
-
}) as Record<string, unknown>
|
|
567
|
-
delete intent.dstValAddress
|
|
568
|
-
|
|
569
558
|
const res = await validateIntent(
|
|
570
559
|
createContext(),
|
|
571
560
|
'sei_evm',
|
|
572
|
-
|
|
561
|
+
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
562
|
+
type: 'staking-legacy',
|
|
563
|
+
mode: 'redelegate',
|
|
564
|
+
valAddress: 'seivaloper1y82m5y3wevjneamzg0pmx87dzanyxzht0kepvn',
|
|
565
|
+
data: { type: 'buffer', value: Buffer.from([]) },
|
|
566
|
+
}),
|
|
573
567
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
574
568
|
{
|
|
575
569
|
value: 10n,
|
|
@@ -588,10 +582,12 @@ describe('validateIntent', () => {
|
|
|
588
582
|
const res = await validateIntent(
|
|
589
583
|
createContext(),
|
|
590
584
|
'sei_evm',
|
|
591
|
-
|
|
585
|
+
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
586
|
+
type: 'staking-legacy',
|
|
592
587
|
mode: 'delegate',
|
|
593
588
|
amount: 45n,
|
|
594
589
|
valAddress: 'seivaloper1y82m5y3wevjneamzg0pmx87dzanyxzht0kepvn',
|
|
590
|
+
data: { type: 'buffer', value: Buffer.from([]) },
|
|
595
591
|
}),
|
|
596
592
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
597
593
|
{
|
|
@@ -611,10 +607,12 @@ describe('validateIntent', () => {
|
|
|
611
607
|
const res = await validateIntent(
|
|
612
608
|
createContext(),
|
|
613
609
|
'sei_evm',
|
|
614
|
-
|
|
610
|
+
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
611
|
+
type: 'staking-legacy',
|
|
615
612
|
mode: 'undelegate',
|
|
616
613
|
amount: 100n,
|
|
617
614
|
valAddress: 'seivaloper1y82m5y3wevjneamzg0pmx87dzanyxzht0kepvn',
|
|
615
|
+
data: { type: 'buffer', value: Buffer.from([]) },
|
|
618
616
|
}),
|
|
619
617
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
620
618
|
{
|
|
@@ -631,11 +629,13 @@ describe('validateIntent', () => {
|
|
|
631
629
|
const res = await validateIntent(
|
|
632
630
|
createContext(),
|
|
633
631
|
'sei_evm',
|
|
634
|
-
|
|
632
|
+
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
633
|
+
type: 'staking-legacy',
|
|
635
634
|
mode: 'redelegate',
|
|
636
635
|
amount: 100n,
|
|
637
636
|
valAddress: 'seivaloper1y82m5y3wevjneamzg0pmx87dzanyxzht0kepvn',
|
|
638
637
|
dstValAddress: 'seivaloper1f4cqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq',
|
|
638
|
+
data: { type: 'buffer', value: Buffer.from([]) },
|
|
639
639
|
}),
|
|
640
640
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
641
641
|
{
|
|
@@ -652,10 +652,12 @@ describe('validateIntent', () => {
|
|
|
652
652
|
const res = await validateIntent(
|
|
653
653
|
createContext(),
|
|
654
654
|
'sei_evm',
|
|
655
|
-
|
|
655
|
+
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
656
|
+
type: 'staking-legacy',
|
|
656
657
|
mode: 'delegate',
|
|
657
658
|
amount: 1n,
|
|
658
659
|
valAddress: 'seivaloper1y82m5y3wevjneamzg0pmx87dzanyxzht0kepvn',
|
|
660
|
+
data: { type: 'buffer', value: Buffer.from([]) },
|
|
659
661
|
}),
|
|
660
662
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
661
663
|
{
|
|
@@ -675,10 +677,12 @@ describe('validateIntent', () => {
|
|
|
675
677
|
const res = await validateIntent(
|
|
676
678
|
createContext(),
|
|
677
679
|
'sei_evm',
|
|
678
|
-
|
|
679
|
-
|
|
680
|
+
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
681
|
+
type: 'staking-legacy',
|
|
680
682
|
mode: 'claimReward',
|
|
683
|
+
amount: 0n,
|
|
681
684
|
valAddress: 'seivaloper1y82m5y3wevjneamzg0pmx87dzanyxzht0kepvn',
|
|
685
|
+
data: { type: 'buffer', value: Buffer.from([]) },
|
|
682
686
|
}),
|
|
683
687
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
684
688
|
{
|
|
@@ -696,10 +700,12 @@ describe('validateIntent', () => {
|
|
|
696
700
|
const res = await validateIntent(
|
|
697
701
|
createContext(),
|
|
698
702
|
'sei_evm',
|
|
699
|
-
|
|
700
|
-
|
|
703
|
+
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
704
|
+
type: 'staking-legacy',
|
|
701
705
|
mode: 'claimReward',
|
|
706
|
+
amount: 0n,
|
|
702
707
|
valAddress: '',
|
|
708
|
+
data: { type: 'buffer', value: Buffer.from([]) },
|
|
703
709
|
}),
|
|
704
710
|
[{ value: 500n, asset: { type: 'native' } }],
|
|
705
711
|
{
|
|
@@ -717,10 +723,12 @@ describe('validateIntent', () => {
|
|
|
717
723
|
const res = await validateIntent(
|
|
718
724
|
createContext(),
|
|
719
725
|
'sei_evm',
|
|
720
|
-
|
|
721
|
-
|
|
726
|
+
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
727
|
+
type: 'staking-legacy',
|
|
722
728
|
mode: 'claimReward',
|
|
729
|
+
amount: 0n,
|
|
723
730
|
valAddress: 'seivaloper1y82m5y3wevjneamzg0pmx87dzanyxzht0kepvn',
|
|
731
|
+
data: { type: 'buffer', value: Buffer.from([]) },
|
|
724
732
|
}),
|
|
725
733
|
[{ value: 500n, asset: { type: 'native' } }],
|
|
726
734
|
{
|
|
@@ -744,7 +752,12 @@ describe('validateIntent', () => {
|
|
|
744
752
|
const res = await validateIntent(
|
|
745
753
|
createContext(),
|
|
746
754
|
'unknown_chain',
|
|
747
|
-
|
|
755
|
+
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
756
|
+
type: 'staking-legacy',
|
|
757
|
+
mode: 'delegate',
|
|
758
|
+
useAllAmount: true,
|
|
759
|
+
data: { type: 'buffer', value: Buffer.from([]) },
|
|
760
|
+
}),
|
|
748
761
|
[{ value: balance, asset: { type: 'native' } }],
|
|
749
762
|
{ value: totalFees, parameters: { gasLimit: 100_000n, gasPrice: 1n } }
|
|
750
763
|
)
|
|
@@ -762,7 +775,12 @@ describe('validateIntent', () => {
|
|
|
762
775
|
const res = await validateIntent(
|
|
763
776
|
createContext(),
|
|
764
777
|
'sei_evm',
|
|
765
|
-
|
|
778
|
+
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
779
|
+
type: 'staking-legacy',
|
|
780
|
+
mode: 'delegate',
|
|
781
|
+
useAllAmount: true,
|
|
782
|
+
data: { type: 'buffer', value: Buffer.from([]) },
|
|
783
|
+
}),
|
|
766
784
|
[{ value: balance, asset: { type: 'native' } }],
|
|
767
785
|
{
|
|
768
786
|
value: fees,
|
|
@@ -785,7 +803,12 @@ describe('validateIntent', () => {
|
|
|
785
803
|
const res = await validateIntent(
|
|
786
804
|
createContext(),
|
|
787
805
|
'sei_evm',
|
|
788
|
-
|
|
806
|
+
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
807
|
+
type: 'staking-legacy',
|
|
808
|
+
mode: 'delegate',
|
|
809
|
+
useAllAmount: true,
|
|
810
|
+
data: { type: 'buffer', value: Buffer.from([]) },
|
|
811
|
+
}),
|
|
789
812
|
[{ value: balance, asset: { type: 'native' } }],
|
|
790
813
|
{
|
|
791
814
|
value: fees,
|
|
@@ -806,10 +829,12 @@ describe('validateIntent', () => {
|
|
|
806
829
|
assetReference: '0x0000000000000000000000000000000000000001',
|
|
807
830
|
}
|
|
808
831
|
const claimRewardIntent = (overrides: { amount: bigint; native: boolean }) =>
|
|
809
|
-
|
|
832
|
+
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
833
|
+
type: 'staking-legacy',
|
|
810
834
|
mode: 'claimReward',
|
|
811
835
|
amount: overrides.amount,
|
|
812
836
|
valAddress: 'seivaloper1y82m5y3wevjneamzg0pmx87dzanyxzht0kepvn',
|
|
837
|
+
data: { type: 'buffer', value: Buffer.from([]) },
|
|
813
838
|
...(overrides.native ? {} : { asset: tokenAsset }),
|
|
814
839
|
})
|
|
815
840
|
const claimRewardBalances = (native: boolean) => [
|
|
@@ -1081,9 +1106,7 @@ describe('validateIntent', () => {
|
|
|
1081
1106
|
|
|
1082
1107
|
it('detects gas limit being too low in a tx with an error', async () => {
|
|
1083
1108
|
const eip7623GasLimit = 21000n
|
|
1084
|
-
|
|
1085
|
-
eip7623GasLimit
|
|
1086
|
-
)
|
|
1109
|
+
jest.mocked(computeGasLimitModule.computeEIP7623GasLimit).mockReturnValue(eip7623GasLimit)
|
|
1087
1110
|
|
|
1088
1111
|
const res = await validateIntent(
|
|
1089
1112
|
createContext(),
|
|
@@ -1107,9 +1130,7 @@ describe('validateIntent', () => {
|
|
|
1107
1130
|
|
|
1108
1131
|
it('detects custom gas limit being too low in a tx with an error', async () => {
|
|
1109
1132
|
const eip7623GasLimit = 21000n
|
|
1110
|
-
|
|
1111
|
-
eip7623GasLimit
|
|
1112
|
-
)
|
|
1133
|
+
jest.mocked(computeGasLimitModule.computeEIP7623GasLimit).mockReturnValue(eip7623GasLimit)
|
|
1113
1134
|
|
|
1114
1135
|
const res = await validateIntent(
|
|
1115
1136
|
createContext(),
|
|
@@ -1133,17 +1154,15 @@ describe('validateIntent', () => {
|
|
|
1133
1154
|
|
|
1134
1155
|
describe('calldata floor coin config', () => {
|
|
1135
1156
|
it('forwards the configured floor parameters to computeEIP7623GasLimit', async () => {
|
|
1136
|
-
setCoinConfig(
|
|
1137
|
-
(
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
},
|
|
1146
|
-
}) as unknown as EvmCoinConfig
|
|
1157
|
+
setCoinConfig(() =>
|
|
1158
|
+
createMockEvmCoinConfig({
|
|
1159
|
+
chainId: 1,
|
|
1160
|
+
node: mkLedgerNode({ explorerId: 'eth' }),
|
|
1161
|
+
explorer: mkLedgerExplorer({ explorerId: 'eth' }),
|
|
1162
|
+
gasTracker: mkLedgerGasTracker({ explorerId: 'eth' }),
|
|
1163
|
+
calldataFloorGasPerToken: 16,
|
|
1164
|
+
calldataFloorZeroByteTokens: 4,
|
|
1165
|
+
})
|
|
1147
1166
|
)
|
|
1148
1167
|
|
|
1149
1168
|
await validateIntent(
|
|
@@ -1363,16 +1382,14 @@ describe('validateIntent', () => {
|
|
|
1363
1382
|
|
|
1364
1383
|
describe('minGasPrice', () => {
|
|
1365
1384
|
beforeEach(() => {
|
|
1366
|
-
setCoinConfig(
|
|
1367
|
-
(
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
},
|
|
1375
|
-
}) as unknown as EvmCoinConfig
|
|
1385
|
+
setCoinConfig(() =>
|
|
1386
|
+
createMockEvmCoinConfig({
|
|
1387
|
+
chainId: 1,
|
|
1388
|
+
node: mkLedgerNode({ explorerId: 'eth' }),
|
|
1389
|
+
explorer: mkLedgerExplorer({ explorerId: 'eth' }),
|
|
1390
|
+
gasTracker: mkLedgerGasTracker({ explorerId: 'eth' }),
|
|
1391
|
+
minGasPrice: '25000000000',
|
|
1392
|
+
})
|
|
1376
1393
|
)
|
|
1377
1394
|
})
|
|
1378
1395
|
|
|
@@ -1419,16 +1436,14 @@ describe('validateIntent', () => {
|
|
|
1419
1436
|
describe('legacy specific', () => {
|
|
1420
1437
|
describe('minGasPrice', () => {
|
|
1421
1438
|
beforeEach(() => {
|
|
1422
|
-
setCoinConfig(
|
|
1423
|
-
(
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
},
|
|
1431
|
-
}) as unknown as EvmCoinConfig
|
|
1439
|
+
setCoinConfig(() =>
|
|
1440
|
+
createMockEvmCoinConfig({
|
|
1441
|
+
chainId: 1,
|
|
1442
|
+
node: mkLedgerNode({ explorerId: 'eth' }),
|
|
1443
|
+
explorer: mkLedgerExplorer({ explorerId: 'eth' }),
|
|
1444
|
+
gasTracker: mkLedgerGasTracker({ explorerId: 'eth' }),
|
|
1445
|
+
minGasPrice: '25000000000',
|
|
1446
|
+
})
|
|
1432
1447
|
)
|
|
1433
1448
|
})
|
|
1434
1449
|
|
|
@@ -1578,8 +1593,20 @@ describe('validateIntent', () => {
|
|
|
1578
1593
|
lastNftOperations: [],
|
|
1579
1594
|
lastTokenOperations: [
|
|
1580
1595
|
{
|
|
1596
|
+
id: '',
|
|
1597
|
+
type: '',
|
|
1598
|
+
senders: [],
|
|
1599
|
+
recipients: [],
|
|
1600
|
+
value: 0n,
|
|
1581
1601
|
asset: { type: 'erc20' as const, assetReference: 'contract-address' },
|
|
1582
|
-
|
|
1602
|
+
tx: {
|
|
1603
|
+
hash: '',
|
|
1604
|
+
block: { height: 0, hash: '', time: new Date(0) },
|
|
1605
|
+
fees: 0n,
|
|
1606
|
+
date: new Date(0),
|
|
1607
|
+
failed: false,
|
|
1608
|
+
},
|
|
1609
|
+
},
|
|
1583
1610
|
],
|
|
1584
1611
|
nextPagingToken: '',
|
|
1585
1612
|
})
|
|
@@ -1622,8 +1649,20 @@ describe('validateIntent', () => {
|
|
|
1622
1649
|
lastNftOperations: [],
|
|
1623
1650
|
lastTokenOperations: [
|
|
1624
1651
|
{
|
|
1652
|
+
id: '',
|
|
1653
|
+
type: '',
|
|
1654
|
+
senders: [],
|
|
1655
|
+
recipients: [],
|
|
1656
|
+
value: 0n,
|
|
1625
1657
|
asset: { type: 'erc20' as const, assetReference: 'contract-address' },
|
|
1626
|
-
|
|
1658
|
+
tx: {
|
|
1659
|
+
hash: '',
|
|
1660
|
+
block: { height: 0, hash: '', time: new Date(0) },
|
|
1661
|
+
fees: 0n,
|
|
1662
|
+
date: new Date(0),
|
|
1663
|
+
failed: false,
|
|
1664
|
+
},
|
|
1665
|
+
},
|
|
1627
1666
|
],
|
|
1628
1667
|
nextPagingToken: '',
|
|
1629
1668
|
})
|
|
@@ -1691,8 +1730,20 @@ describe('validateIntent', () => {
|
|
|
1691
1730
|
lastNftOperations: [],
|
|
1692
1731
|
lastTokenOperations: [
|
|
1693
1732
|
{
|
|
1733
|
+
id: '',
|
|
1734
|
+
type: '',
|
|
1735
|
+
senders: [],
|
|
1736
|
+
recipients: [],
|
|
1737
|
+
value: 0n,
|
|
1694
1738
|
asset: { type: 'erc20' as const, assetReference: 'contract-address' },
|
|
1695
|
-
|
|
1739
|
+
tx: {
|
|
1740
|
+
hash: '',
|
|
1741
|
+
block: { height: 0, hash: '', time: new Date(0) },
|
|
1742
|
+
fees: 0n,
|
|
1743
|
+
date: new Date(0),
|
|
1744
|
+
failed: false,
|
|
1745
|
+
},
|
|
1746
|
+
},
|
|
1696
1747
|
],
|
|
1697
1748
|
nextPagingToken: '',
|
|
1698
1749
|
})
|
|
@@ -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.test.ts
CHANGED
|
@@ -9,13 +9,18 @@ jest.mock('./network/node/index', () => ({
|
|
|
9
9
|
}))
|
|
10
10
|
|
|
11
11
|
import { getCoinConfig } from './config'
|
|
12
|
+
import { createMockEvmConfigInfo, mkExternalNode } from './fixtures/context.fixtures'
|
|
12
13
|
import { getAdditionalLayer2Fees } from './logic'
|
|
13
14
|
import { getNodeApi } from './network/node/index'
|
|
15
|
+
import { mockNodeApi } from './network/node/node.fixtures'
|
|
14
16
|
import { padHexString, safeEncodeEIP55 } from './utils'
|
|
15
17
|
|
|
16
18
|
const mockGetNodeApi = jest.mocked(getNodeApi)
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
+
const nodeApiMock = mockNodeApi()
|
|
20
|
+
const {
|
|
21
|
+
getOptimismAdditionalFees: mockGetOptimismAdditionalFees,
|
|
22
|
+
getScrollAdditionalFees: mockGetScrollAdditionalFees,
|
|
23
|
+
} = nodeApiMock
|
|
19
24
|
|
|
20
25
|
jest.mock('./config')
|
|
21
26
|
const mockGetConfig = jest.mocked(getCoinConfig)
|
|
@@ -90,30 +95,20 @@ describe('EVM Family', () => {
|
|
|
90
95
|
describe('getAdditionalLayer2Fees', () => {
|
|
91
96
|
beforeEach(() => {
|
|
92
97
|
jest.clearAllMocks()
|
|
93
|
-
mockGetNodeApi.
|
|
94
|
-
() =>
|
|
95
|
-
({
|
|
96
|
-
getOptimismAdditionalFees: mockGetOptimismAdditionalFees,
|
|
97
|
-
getScrollAdditionalFees: mockGetScrollAdditionalFees,
|
|
98
|
-
}) as any
|
|
99
|
-
)
|
|
98
|
+
mockGetNodeApi.mockReturnValue(nodeApiMock)
|
|
100
99
|
})
|
|
101
100
|
|
|
102
101
|
it('should try to get additionalFees for a valid layer 2', async () => {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
await getAdditionalLayer2Fees({} as any, 'optimism', {} as any)
|
|
102
|
+
const cfg = createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
|
|
103
|
+
await getAdditionalLayer2Fees(cfg, 'optimism', '')
|
|
107
104
|
expect(mockGetOptimismAdditionalFees).toHaveBeenCalled()
|
|
108
|
-
await getAdditionalLayer2Fees(
|
|
105
|
+
await getAdditionalLayer2Fees(cfg, 'scroll', '')
|
|
109
106
|
expect(mockGetScrollAdditionalFees).toHaveBeenCalled()
|
|
110
107
|
})
|
|
111
108
|
|
|
112
109
|
it('should not try to get additionalFees for an invalid layer 2', async () => {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
await getAdditionalLayer2Fees({} as any, 'ethereum', {} as any)
|
|
110
|
+
const cfg = createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
|
|
111
|
+
await getAdditionalLayer2Fees(cfg, 'ethereum', '')
|
|
117
112
|
expect(mockGetOptimismAdditionalFees).not.toHaveBeenCalled()
|
|
118
113
|
expect(mockGetScrollAdditionalFees).not.toHaveBeenCalled()
|
|
119
114
|
})
|
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'
|
|
@@ -28,7 +28,7 @@ import * as ETHERSCAN_API from './etherscan'
|
|
|
28
28
|
|
|
29
29
|
jest.mock('axios')
|
|
30
30
|
jest.mock('@ledgerhq/coin-module-framework/promises')
|
|
31
|
-
|
|
31
|
+
jest.mocked(delay).mockImplementation(
|
|
32
32
|
() => new Promise((resolve) => setTimeout(resolve, 1)) // mocking the delay supposed to happen after each try
|
|
33
33
|
)
|
|
34
34
|
|
|
@@ -1859,7 +1859,7 @@ describe('EVM Family', () => {
|
|
|
1859
1859
|
})
|
|
1860
1860
|
|
|
1861
1861
|
describe('getNftOperations supportedTokens atomicity', () => {
|
|
1862
|
-
const withSupportedTokens = (supportedTokens:
|
|
1862
|
+
const withSupportedTokens = (supportedTokens: string[]) => {
|
|
1863
1863
|
mockGetConfig.mockImplementation((): any => ({
|
|
1864
1864
|
info: {
|
|
1865
1865
|
explorer: { type: 'etherscan', uri: 'mock' },
|
|
@@ -1931,7 +1931,7 @@ describe('EVM Family', () => {
|
|
|
1931
1931
|
// only non-NFT standards (e.g. a future "erc20") must NOT activate NFT fetching. Activation is
|
|
1932
1932
|
// driven by explicit NFT-standard membership, not by the array being non-empty.
|
|
1933
1933
|
it('does not activate NFTs for a non-NFT standard such as erc20', async () => {
|
|
1934
|
-
withSupportedTokens(['erc20']
|
|
1934
|
+
withSupportedTokens(['erc20'])
|
|
1935
1935
|
const { assetTypes, fetchedErc721, fetchedErc1155 } = await fetchNfts()
|
|
1936
1936
|
expect(assetTypes).toEqual(new Set())
|
|
1937
1937
|
expect(fetchedErc721).toBe(false)
|
|
@@ -2005,7 +2005,7 @@ describe('EVM Family', () => {
|
|
|
2005
2005
|
const pageCounts: Record<string, number> = {}
|
|
2006
2006
|
|
|
2007
2007
|
return async (config: any) => {
|
|
2008
|
-
const url = config.url
|
|
2008
|
+
const url: string = config.url
|
|
2009
2009
|
const params = config.params
|
|
2010
2010
|
const startBlock = params.startblock ?? 0
|
|
2011
2011
|
const endBlock = params.endblock ?? Infinity
|
|
@@ -2088,7 +2088,7 @@ describe('EVM Family', () => {
|
|
|
2088
2088
|
...result.lastTokenOperations.map((op) => ({ type: 'T', block: op.tx.block.height })),
|
|
2089
2089
|
]
|
|
2090
2090
|
// Secondary sort order: C < I < T (coin first at same block)
|
|
2091
|
-
const typeOrder = { C: 0, I: 1, T: 2 }
|
|
2091
|
+
const typeOrder: Record<string, number> = { C: 0, I: 1, T: 2 }
|
|
2092
2092
|
const ops = tagged
|
|
2093
2093
|
.filter((op): op is { type: string; block: number } => op.block !== undefined)
|
|
2094
2094
|
.sort((a, b) => b.block - a.block || typeOrder[a.type] - typeOrder[b.type])
|
|
@@ -1,11 +1,21 @@
|
|
|
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 {
|
|
6
|
+
EtherscanERC1155Event,
|
|
7
|
+
EtherscanERC20Event,
|
|
8
|
+
EtherscanERC721Event,
|
|
9
|
+
EtherscanInternalTransaction,
|
|
10
|
+
EtherscanOperation,
|
|
11
|
+
} from '../../types'
|
|
12
|
+
import type { ExplorerApi } from './types'
|
|
4
13
|
import type { MemoNotSupported, Operation } from '@ledgerhq/coin-module-framework/api/types'
|
|
14
|
+
import type { AxiosRequestConfig } from 'axios'
|
|
5
15
|
import { delay } from '@ledgerhq/coin-module-framework/promises'
|
|
6
16
|
import { makeLRUCache } from '@ledgerhq/live-network/cache'
|
|
7
17
|
import { log } from '@ledgerhq/logs'
|
|
8
|
-
import axios
|
|
18
|
+
import axios from 'axios'
|
|
9
19
|
import {
|
|
10
20
|
etherscanOperationToOperations,
|
|
11
21
|
etherscanERC20EventToOperations,
|
|
@@ -15,24 +25,16 @@ import {
|
|
|
15
25
|
deserializePagingToken,
|
|
16
26
|
serializePagingToken,
|
|
17
27
|
} from '../../adapters'
|
|
18
|
-
import { EvmConfigInfo } from '../../config'
|
|
19
28
|
import {
|
|
20
29
|
EtherscanAPIError,
|
|
21
30
|
EtherscanLikeExplorerUsedIncorrectly,
|
|
22
31
|
InvalidExplorerResponse,
|
|
23
32
|
} from '../../errors'
|
|
24
33
|
import { enrichRewardOperationsValue } from '../../staking/rewardsFromReceipt'
|
|
25
|
-
import {
|
|
26
|
-
EtherscanERC1155Event,
|
|
27
|
-
EtherscanERC20Event,
|
|
28
|
-
EtherscanERC721Event,
|
|
29
|
-
EtherscanInternalTransaction,
|
|
30
|
-
EtherscanOperation,
|
|
31
|
-
} from '../../types'
|
|
32
34
|
import { nftDisabled } from '../../utils'
|
|
33
35
|
import { withApi } from '../node/rpc.common'
|
|
34
36
|
import { isExternalNodeConfig } from '../node/types'
|
|
35
|
-
import {
|
|
37
|
+
import { isEtherscanLikeExplorerConfig } from './types'
|
|
36
38
|
|
|
37
39
|
export const ETHERSCAN_TIMEOUT = 5000 // 5 seconds between 2 calls
|
|
38
40
|
export const DEFAULT_RETRIES_API = 8
|