@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,13 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { AssertionError, fail } from 'assert'
|
|
5
4
|
import { delay } from '@ledgerhq/coin-module-framework/promises'
|
|
6
5
|
import axios from 'axios'
|
|
7
6
|
import BigNumber from 'bignumber.js'
|
|
8
7
|
import { Transaction } from 'ethers'
|
|
9
8
|
import { DEFAULT_LEDGER_EXPLORER_URI } from '../../config'
|
|
10
9
|
import { GasEstimationError } from '../../errors'
|
|
10
|
+
import { createMockEvmConfigInfo } from '../../fixtures/context.fixtures'
|
|
11
11
|
import { getGasOptions } from '../gasTracker/ledger'
|
|
12
12
|
import { createLedgerNodeApi } from './ledger'
|
|
13
13
|
|
|
@@ -19,9 +19,9 @@ jest.mock('../gasTracker/ledger', () => ({
|
|
|
19
19
|
getGasOptions: jest.fn(),
|
|
20
20
|
}))
|
|
21
21
|
|
|
22
|
-
const mockGetGasOptions =
|
|
22
|
+
const mockGetGasOptions = jest.mocked(getGasOptions)
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
jest.mocked(delay).mockImplementation(
|
|
25
25
|
() => new Promise((resolve) => setTimeout(resolve, 1)) // mocking the delay supposed to happen after each try
|
|
26
26
|
)
|
|
27
27
|
|
|
@@ -149,15 +149,7 @@ describe('EVM Family', () => {
|
|
|
149
149
|
}
|
|
150
150
|
return { data: {} }
|
|
151
151
|
})
|
|
152
|
-
|
|
153
|
-
await api.getTransaction(currencyId, '0xHash')
|
|
154
|
-
fail('Promise should have been rejected')
|
|
155
|
-
} catch (e) {
|
|
156
|
-
if (e instanceof AssertionError) {
|
|
157
|
-
throw e
|
|
158
|
-
}
|
|
159
|
-
expect(e).toBeInstanceOf(SpyError)
|
|
160
|
-
}
|
|
152
|
+
await expect(api.getTransaction(currencyId, '0xHash')).rejects.toBeInstanceOf(SpyError)
|
|
161
153
|
})
|
|
162
154
|
})
|
|
163
155
|
|
|
@@ -290,15 +282,9 @@ describe('EVM Family', () => {
|
|
|
290
282
|
throw new Error()
|
|
291
283
|
})
|
|
292
284
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
} catch (e) {
|
|
297
|
-
if (e instanceof AssertionError) {
|
|
298
|
-
throw e
|
|
299
|
-
}
|
|
300
|
-
expect(e).toBeInstanceOf(GasEstimationError)
|
|
301
|
-
}
|
|
285
|
+
await expect(
|
|
286
|
+
api.getGasEstimation(currencyId, address, { amount: new BigNumber(0), recipient: '0x0' })
|
|
287
|
+
).rejects.toBeInstanceOf(GasEstimationError)
|
|
302
288
|
})
|
|
303
289
|
|
|
304
290
|
it('should throw GasEstimationError if request throws ECONNABORTED', async () => {
|
|
@@ -307,34 +293,17 @@ describe('EVM Family', () => {
|
|
|
307
293
|
.spyOn(axios, 'request')
|
|
308
294
|
.mockImplementation(() => Promise.reject({ code: 'ECONNABORTED' }))
|
|
309
295
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
} catch (e) {
|
|
314
|
-
if (e instanceof AssertionError) {
|
|
315
|
-
throw e
|
|
316
|
-
}
|
|
317
|
-
expect(e).toBeInstanceOf(GasEstimationError)
|
|
318
|
-
}
|
|
296
|
+
await expect(
|
|
297
|
+
api.getGasEstimation(currencyId, address, { amount: new BigNumber(0), recipient: '0x0' })
|
|
298
|
+
).rejects.toBeInstanceOf(GasEstimationError)
|
|
319
299
|
})
|
|
320
300
|
|
|
321
301
|
it('should return the expected payload', async () => {
|
|
322
302
|
const api = createLedgerNodeApi(ledgerConfig)
|
|
323
|
-
jest
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
to: '0xBob',
|
|
328
|
-
estimated_gas_limit: '1000000',
|
|
329
|
-
},
|
|
330
|
-
}
|
|
331
|
-
: {
|
|
332
|
-
data: {
|
|
333
|
-
to: '0xBob',
|
|
334
|
-
estimated_gas_limit: '789',
|
|
335
|
-
},
|
|
336
|
-
}
|
|
337
|
-
})
|
|
303
|
+
jest
|
|
304
|
+
.spyOn(axios, 'request')
|
|
305
|
+
.mockResolvedValueOnce({ data: { to: '0xBob', estimated_gas_limit: '789' } })
|
|
306
|
+
.mockResolvedValueOnce({ data: { to: '0xBob', estimated_gas_limit: '1000000' } })
|
|
338
307
|
|
|
339
308
|
const transaction = {
|
|
340
309
|
family: 'evm',
|
|
@@ -385,18 +354,30 @@ describe('EVM Family', () => {
|
|
|
385
354
|
},
|
|
386
355
|
}))
|
|
387
356
|
|
|
388
|
-
const slowFeeData = await api.getFeeData(
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
const
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
357
|
+
const slowFeeData = await api.getFeeData(
|
|
358
|
+
createMockEvmConfigInfo({ chainId: 1, node: ledgerConfig }),
|
|
359
|
+
currencyId,
|
|
360
|
+
{
|
|
361
|
+
type: 2,
|
|
362
|
+
feesStrategy: 'slow',
|
|
363
|
+
}
|
|
364
|
+
)
|
|
365
|
+
const mediumFeeData = await api.getFeeData(
|
|
366
|
+
createMockEvmConfigInfo({ chainId: 1, node: ledgerConfig }),
|
|
367
|
+
currencyId,
|
|
368
|
+
{
|
|
369
|
+
type: 2,
|
|
370
|
+
feesStrategy: 'medium',
|
|
371
|
+
}
|
|
372
|
+
)
|
|
373
|
+
const fastFeeData = await api.getFeeData(
|
|
374
|
+
createMockEvmConfigInfo({ chainId: 1, node: ledgerConfig }),
|
|
375
|
+
currencyId,
|
|
376
|
+
{
|
|
377
|
+
type: 2,
|
|
378
|
+
feesStrategy: 'fast',
|
|
379
|
+
}
|
|
380
|
+
)
|
|
400
381
|
|
|
401
382
|
expect(slowFeeData).toEqual({
|
|
402
383
|
maxFeePerGas: new BigNumber(1),
|
|
@@ -441,7 +422,11 @@ describe('EVM Family', () => {
|
|
|
441
422
|
},
|
|
442
423
|
}))
|
|
443
424
|
|
|
444
|
-
const feeData = await api.getFeeData(
|
|
425
|
+
const feeData = await api.getFeeData(
|
|
426
|
+
createMockEvmConfigInfo({ chainId: 1, node: ledgerConfig }),
|
|
427
|
+
currencyId,
|
|
428
|
+
{ type: 2 }
|
|
429
|
+
)
|
|
445
430
|
|
|
446
431
|
expect(feeData).toEqual({
|
|
447
432
|
maxFeePerGas: new BigNumber(5),
|
|
@@ -579,7 +564,7 @@ describe('EVM Family', () => {
|
|
|
579
564
|
describe('getOptimismAdditionalFees', () => {
|
|
580
565
|
it('should return 0 for an incompatible currency', async () => {
|
|
581
566
|
const api = createLedgerNodeApi(ledgerConfig)
|
|
582
|
-
expect(await api.getOptimismAdditionalFees(currencyId,
|
|
567
|
+
expect(await api.getOptimismAdditionalFees(currencyId, '')).toEqual(new BigNumber(0))
|
|
583
568
|
})
|
|
584
569
|
|
|
585
570
|
it('should return the expected payload', async () => {
|
|
@@ -659,7 +644,7 @@ describe('EVM Family', () => {
|
|
|
659
644
|
describe('getScrollAdditionalFees', () => {
|
|
660
645
|
it('should return 0 for an incompatible currency', async () => {
|
|
661
646
|
const api = createLedgerNodeApi(ledgerConfig)
|
|
662
|
-
expect(await api.getScrollAdditionalFees(currencyId,
|
|
647
|
+
expect(await api.getScrollAdditionalFees(currencyId, '')).toEqual(new BigNumber(0))
|
|
663
648
|
})
|
|
664
649
|
|
|
665
650
|
it('should return the expected payload', async () => {
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import type { BlockFinalizationTag, LedgerNodeConfig } from '../../config'
|
|
5
|
+
import type { LedgerExplorerOperation } from '../../types'
|
|
6
|
+
import type { BlockByHeightResult, EvmCallParams, NodeApi, TransactionInfo } from './types'
|
|
7
|
+
import type { Batcher } from '@ledgerhq/live-network/batcher/types'
|
|
8
|
+
import type { AxiosRequestConfig } from 'axios'
|
|
4
9
|
import { makeBatcher } from '@ledgerhq/live-network/batcher/index'
|
|
5
|
-
import { Batcher } from '@ledgerhq/live-network/batcher/types'
|
|
6
10
|
import { log } from '@ledgerhq/logs'
|
|
7
|
-
import axios
|
|
11
|
+
import axios from 'axios'
|
|
8
12
|
import BigNumber from 'bignumber.js'
|
|
9
13
|
import { ethers } from 'ethers'
|
|
10
14
|
import ERC20Abi from '../../abis/erc20.abi.json'
|
|
11
15
|
import OptimismGasPriceOracleAbi from '../../abis/optimismGasPriceOracle.abi.json'
|
|
12
|
-
import { BlockFinalizationTag, LedgerNodeConfig } from '../../config'
|
|
13
16
|
import { GasEstimationError } from '../../errors'
|
|
14
|
-
import { LedgerExplorerOperation } from '../../types'
|
|
15
17
|
import { normalizeAddress, padHexString, safeEncodeEIP55 } from '../../utils'
|
|
16
18
|
import { getGasOptions } from '../gasTracker/ledger'
|
|
17
19
|
import { withRetries } from '../withRetries'
|
|
18
|
-
import { BlockByHeightResult, EvmCallParams, NodeApi, TransactionInfo } from './types'
|
|
19
20
|
|
|
20
21
|
const LEDGER_TIMEOUT = 10_000 // 10s for network call timeout
|
|
21
22
|
const LEDGER_TIME_BETWEEN_TRIES = 200 // 200ms between 2 calls
|
|
@@ -15,8 +15,6 @@ export function mockNodeApi(overrides: Partial<jest.Mocked<NodeApi>> = {}): jest
|
|
|
15
15
|
broadcastTransaction: jest.fn(),
|
|
16
16
|
getBlockByHeight: jest.fn(),
|
|
17
17
|
getBlockReceipts: jest.fn(),
|
|
18
|
-
traceBlockErigon: jest.fn(),
|
|
19
|
-
traceBlockGeth: jest.fn(),
|
|
20
18
|
getOptimismAdditionalFees: jest.fn(),
|
|
21
19
|
getScrollAdditionalFees: jest.fn(),
|
|
22
20
|
...overrides,
|
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import type { BlockFinalizationTag, EvmConfigInfo, ExternalNodeConfig } from '../../config'
|
|
5
|
+
import type { FeeHistory, FeeData } from '../../types'
|
|
6
|
+
import type {
|
|
7
|
+
NodeApi,
|
|
8
|
+
ERC20Transfer,
|
|
9
|
+
PrefetchedBlockTransaction,
|
|
10
|
+
LogWithAddress,
|
|
11
|
+
TransactionReceipt,
|
|
12
|
+
TraceBlockItem,
|
|
13
|
+
TransactionInfo,
|
|
14
|
+
BlockByHeightResult,
|
|
15
|
+
BlockReceiptInfo,
|
|
16
|
+
EvmCallParams,
|
|
17
|
+
} from './types'
|
|
5
18
|
/** ⚠️ keep this order of import. @see https://docs.ethers.io/v5/cookbook/react-native/#cookbook-reactnative ⚠️ */
|
|
6
19
|
import { makeLRUCache } from '@ledgerhq/live-network/cache'
|
|
7
20
|
import { log } from '@ledgerhq/logs'
|
|
@@ -11,7 +24,6 @@ import ERC20Abi from '../../abis/erc20.abi.json'
|
|
|
11
24
|
import OptimismGasPriceOracleAbi from '../../abis/optimismGasPriceOracle.abi.json'
|
|
12
25
|
import ScrollGasPriceOracleAbi from '../../abis/scrollGasPriceOracle.abi.json'
|
|
13
26
|
import { GasEstimationError, InsufficientFunds, UnsupportedRpcMethodError } from '../../errors'
|
|
14
|
-
import { FeeHistory, FeeData } from '../../types'
|
|
15
27
|
import { isSmartContractInput, safeEncodeEIP55, normalizeAddress } from '../../utils'
|
|
16
28
|
import { withRetries } from '../withRetries'
|
|
17
29
|
import { gethCallTracerToTraceBlockItems } from './gethCallTracerToTraceBlockItems'
|
|
@@ -21,19 +33,7 @@ import {
|
|
|
21
33
|
isUnsupportedRpcMethodErrorMsg,
|
|
22
34
|
isUnsupportedRpcMethodError,
|
|
23
35
|
} from './rpc.errors'
|
|
24
|
-
import {
|
|
25
|
-
NodeApi,
|
|
26
|
-
ERC20Transfer,
|
|
27
|
-
PrefetchedBlockTransaction,
|
|
28
|
-
LogWithAddress,
|
|
29
|
-
TransactionReceipt,
|
|
30
|
-
TraceBlockItem,
|
|
31
|
-
isTraceBlockItem,
|
|
32
|
-
TransactionInfo,
|
|
33
|
-
BlockByHeightResult,
|
|
34
|
-
BlockReceiptInfo,
|
|
35
|
-
EvmCallParams,
|
|
36
|
-
} from './types'
|
|
36
|
+
import { isTraceBlockItem } from './types'
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* ERC20 Transfer event topic: keccak256("Transfer(address,address,uint256)")
|