@ledgerhq/coin-evm 5.3.2 → 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 +1 -1
- package/CHANGELOG.md +7 -0
- package/package.json +2 -2
- package/src/adapters/blockOperations.test.ts +27 -29
- package/src/api/index.flare.integ.test.ts +1 -13
- package/src/api/index.integ.test.ts +86 -97
- package/src/fixtures/context.fixtures.ts +79 -1
- package/src/fixtures/ethers.fixtures.ts +26 -0
- 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/common.test.ts +120 -112
- package/src/logic/craftTransaction.test.ts +161 -199
- package/src/logic/craftTransactionData.test.ts +6 -6
- package/src/logic/estimateFees.test.ts +19 -15
- package/src/logic/getBalance.test.ts +15 -14
- package/src/logic/getBlock.test.ts +372 -382
- package/src/logic/getBlockInfo.test.ts +6 -6
- package/src/logic/getNextSequence.test.ts +5 -5
- package/src/logic/getStakes.test.ts +34 -34
- package/src/logic/internalTransactionsFetcher.test.ts +23 -19
- package/src/logic/lastBlock.test.ts +29 -21
- package/src/logic/listOperations.test.ts +43 -40
- package/src/logic/validateIntent.test.ts +151 -101
- package/src/logic.test.ts +13 -18
- package/src/network/explorer/etherscan.test.ts +5 -5
- package/src/network/explorer/index.test.ts +51 -21
- package/src/network/explorer/ledger.test.ts +15 -4
- package/src/network/gasTracker/index.test.ts +14 -8
- package/src/network/gasTracker/ledger.test.ts +25 -13
- 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/node.fixtures.ts +0 -2
- package/src/network/node/rpc.test.ts +152 -177
- package/src/staking/encoder.test.ts +13 -21
- package/src/staking/logic.test.ts +20 -14
- package/src/staking/operations/index.test.ts +28 -28
- package/src/staking/prepareIntents.test.ts +26 -20
- package/src/staking/redelegations.test.ts +27 -18
- package/src/staking/rewards.test.ts +23 -15
- package/src/staking/rewardsFromReceipt.test.ts +19 -20
- package/src/staking/transactionData.test.ts +22 -22
- package/src/staking/validators/monad.test.ts +65 -24
- package/src/staking/validators/somnia.test.ts +21 -13
- package/src/staking/validators/zero_gravity.test.ts +118 -48
- package/src/staking/validators.integ.test.ts +13 -25
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { EvmContext } from '../config'
|
|
5
5
|
import type {
|
|
6
6
|
AssetInfo,
|
|
7
7
|
BufferTxData,
|
|
8
8
|
MemoNotSupported,
|
|
9
|
-
SendTransactionIntent,
|
|
10
9
|
TransactionIntent,
|
|
11
10
|
} from '@ledgerhq/coin-module-framework/api/index'
|
|
11
|
+
import { createSendTransactionIntentMockData } from '@ledgerhq/coin-module-framework/test-utils'
|
|
12
12
|
import BigNumber from 'bignumber.js'
|
|
13
13
|
import { GasEstimationError } from '../errors'
|
|
14
14
|
import { createMockEvmContext } from '../fixtures/context.fixtures'
|
|
@@ -51,7 +51,7 @@ describe('estimateFees', () => {
|
|
|
51
51
|
const nodeApiMock = mockNodeApi()
|
|
52
52
|
const context: EvmContext = createMockEvmContext({
|
|
53
53
|
gasTracker: { type: 'ledger', explorerId: 'eth' },
|
|
54
|
-
}
|
|
54
|
+
})
|
|
55
55
|
|
|
56
56
|
beforeEach(() => {
|
|
57
57
|
jest.clearAllMocks()
|
|
@@ -61,10 +61,14 @@ describe('estimateFees', () => {
|
|
|
61
61
|
|
|
62
62
|
it('does not try to estimate with an invalid address and returns 0 as fallback', async () => {
|
|
63
63
|
expect(
|
|
64
|
-
await estimateFees(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
await estimateFees(
|
|
65
|
+
context,
|
|
66
|
+
'ethereum',
|
|
67
|
+
createSendTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
68
|
+
type: 'send-legacy',
|
|
69
|
+
recipient: 'not-an-address',
|
|
70
|
+
})
|
|
71
|
+
)
|
|
68
72
|
).toEqual({ value: 0n })
|
|
69
73
|
expect(nodeApiMock.getGasEstimation).not.toHaveBeenCalled()
|
|
70
74
|
})
|
|
@@ -84,7 +88,7 @@ describe('estimateFees', () => {
|
|
|
84
88
|
recipient: '0x7b2C7232f9E38F30E2868f0E5Bf311Cd83554b5A',
|
|
85
89
|
sender: '0xsender',
|
|
86
90
|
data: { type: 'buffer', value: Buffer.from([]) },
|
|
87
|
-
}
|
|
91
|
+
},
|
|
88
92
|
{
|
|
89
93
|
feesStrategy: 'fast',
|
|
90
94
|
gasOptions: {
|
|
@@ -184,7 +188,7 @@ describe('estimateFees', () => {
|
|
|
184
188
|
type: 'erc20',
|
|
185
189
|
assetReference: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
186
190
|
},
|
|
187
|
-
}
|
|
191
|
+
},
|
|
188
192
|
{ feesStrategy: 'fast' }
|
|
189
193
|
)
|
|
190
194
|
|
|
@@ -244,7 +248,7 @@ describe('estimateFees', () => {
|
|
|
244
248
|
sender: '0xsender',
|
|
245
249
|
data: { type: 'buffer', value: Buffer.from([]) },
|
|
246
250
|
asset: { type: 'native' },
|
|
247
|
-
}
|
|
251
|
+
},
|
|
248
252
|
{ feesStrategy: 'medium' }
|
|
249
253
|
)
|
|
250
254
|
|
|
@@ -275,7 +279,7 @@ describe('estimateFees', () => {
|
|
|
275
279
|
recipient: '0x7b2C7232f9E38F30E2868f0E5Bf311Cd83554b5A',
|
|
276
280
|
sender: '0xsender',
|
|
277
281
|
data: { type: 'buffer', value: Buffer.from([]) },
|
|
278
|
-
}
|
|
282
|
+
},
|
|
279
283
|
{
|
|
280
284
|
feesStrategy: 'custom',
|
|
281
285
|
gasPrice: 60000n,
|
|
@@ -317,7 +321,7 @@ describe('estimateFees', () => {
|
|
|
317
321
|
recipient: '0x7b2C7232f9E38F30E2868f0E5Bf311Cd83554b5A',
|
|
318
322
|
sender: '0xsender',
|
|
319
323
|
data: { type: 'buffer', value: Buffer.from([]) },
|
|
320
|
-
}
|
|
324
|
+
},
|
|
321
325
|
{ feesStrategy: 'slow' }
|
|
322
326
|
)
|
|
323
327
|
|
|
@@ -356,7 +360,7 @@ describe('estimateFees', () => {
|
|
|
356
360
|
recipient: '0x7b2C7232f9E38F30E2868f0E5Bf311Cd83554b5A',
|
|
357
361
|
sender: '0xsender',
|
|
358
362
|
data: { type: 'buffer', value: Buffer.from([]) },
|
|
359
|
-
}
|
|
363
|
+
},
|
|
360
364
|
{ feesStrategy: 'slow' }
|
|
361
365
|
)
|
|
362
366
|
|
|
@@ -601,7 +605,7 @@ describe('estimateFees', () => {
|
|
|
601
605
|
recipient: '0x7b2C7232f9E38F30E2868f0E5Bf311Cd83554b5A',
|
|
602
606
|
sender: '0xsender',
|
|
603
607
|
data: { type: 'buffer', value: Buffer.from([]) },
|
|
604
|
-
}
|
|
608
|
+
},
|
|
605
609
|
{
|
|
606
610
|
feesStrategy: 'custom',
|
|
607
611
|
gasPrice: 1_000_000_000n,
|
|
@@ -642,7 +646,7 @@ describe('estimateFees', () => {
|
|
|
642
646
|
recipient: '0x7b2C7232f9E38F30E2868f0E5Bf311Cd83554b5A',
|
|
643
647
|
sender: '0xsender',
|
|
644
648
|
data: { type: 'buffer', value: Buffer.from([]) },
|
|
645
|
-
}
|
|
649
|
+
},
|
|
646
650
|
{
|
|
647
651
|
feesStrategy: 'custom',
|
|
648
652
|
gasLimit: 50000n,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { EvmContext } from '../config'
|
|
5
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'
|
|
@@ -32,7 +32,7 @@ describe('getBalance', () => {
|
|
|
32
32
|
const nodeApiMock = mockNodeApi()
|
|
33
33
|
let context: EvmContext
|
|
34
34
|
const setNativeContracts = (nativeContracts?: string[]) => {
|
|
35
|
-
context = createMockEvmContext({ nativeContracts }
|
|
35
|
+
context = createMockEvmContext(Array.isArray(nativeContracts) ? { nativeContracts } : {})
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
beforeEach(() => {
|
|
@@ -103,13 +103,11 @@ describe('getBalance', () => {
|
|
|
103
103
|
},
|
|
104
104
|
], // expected
|
|
105
105
|
],
|
|
106
|
-
])('returns %s', async (_, operations, tokenBalances, expected) => {
|
|
106
|
+
])('returns %s', async (_, operations, tokenBalances: Record<string, string>, expected) => {
|
|
107
107
|
nodeApiMock.getCoinBalance.mockResolvedValue(new BigNumber('10000000000000000000000'))
|
|
108
108
|
nodeApiMock.getTokenBalance.mockImplementation(
|
|
109
109
|
(_currency: unknown, _address: string, contractAddress: string) =>
|
|
110
|
-
Promise.resolve(
|
|
111
|
-
new BigNumber((tokenBalances as Record<string, string>)[contractAddress] || '0')
|
|
112
|
-
)
|
|
110
|
+
Promise.resolve(new BigNumber(tokenBalances[contractAddress] || '0'))
|
|
113
111
|
)
|
|
114
112
|
|
|
115
113
|
mockGetExplorerApi.mockReturnValue({
|
|
@@ -232,14 +230,17 @@ describe('getBalance', () => {
|
|
|
232
230
|
}
|
|
233
231
|
)
|
|
234
232
|
mockGetExplorerApi.mockReturnValue({
|
|
235
|
-
getOperations: ()
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
233
|
+
getOperations: jest.fn().mockResolvedValue({
|
|
234
|
+
lastCoinOperations: [],
|
|
235
|
+
lastTokenOperations: [
|
|
236
|
+
{ asset: { type: 'erc20', assetReference: 'contract1' } },
|
|
237
|
+
{ asset: { type: 'erc20', assetReference: 'contract1' } },
|
|
238
|
+
{ asset: { type: 'erc20', assetReference: 'contract2' } },
|
|
239
|
+
],
|
|
240
|
+
lastNftOperations: [],
|
|
241
|
+
lastInternalOperations: [],
|
|
242
|
+
nextPagingToken: '',
|
|
243
|
+
}),
|
|
243
244
|
})
|
|
244
245
|
mockGetStakes.mockResolvedValue({
|
|
245
246
|
items: [],
|