@ledgerhq/coin-evm 5.3.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 +6 -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 +1 -1
- 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 +248 -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 +4 -3
- 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 +1 -1
- 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 +3 -2
- 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 +1 -1
- package/src/network/explorer/etherscan.ts +12 -10
- 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/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.ts +2 -1
- 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/transaction.ts +1 -1
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import type { EvmConfig, EvmConfigInfo } from '../config'
|
|
5
|
+
import type {
|
|
5
6
|
BufferTxData,
|
|
6
|
-
FeeEstimation,
|
|
7
7
|
MemoNotSupported,
|
|
8
8
|
Operation,
|
|
9
9
|
StakingTransactionIntent,
|
|
10
10
|
} from '@ledgerhq/coin-module-framework/api/types'
|
|
11
11
|
import { ethers } from 'ethers'
|
|
12
|
-
import { EvmConfig, EvmConfigInfo } from '../config'
|
|
13
12
|
import { createMockEvmContext } from '../fixtures/context.fixtures'
|
|
14
13
|
import { createApi } from './index'
|
|
15
14
|
|
|
@@ -190,38 +189,16 @@ describe.each([
|
|
|
190
189
|
})
|
|
191
190
|
})
|
|
192
191
|
|
|
193
|
-
describe
|
|
194
|
-
|
|
195
|
-
'legacy',
|
|
196
|
-
(transaction: ethers.Transaction): void => {
|
|
197
|
-
expect(transaction.type).toBe(0)
|
|
198
|
-
expect(typeof transaction.gasPrice).toBe('bigint')
|
|
199
|
-
expect(transaction.gasPrice).toBeGreaterThan(0)
|
|
200
|
-
},
|
|
201
|
-
],
|
|
202
|
-
[
|
|
203
|
-
'eip1559',
|
|
204
|
-
(transaction: ethers.Transaction): void => {
|
|
205
|
-
expect(transaction.type).toBe(2)
|
|
206
|
-
expect(transaction.gasPrice).toBeNull()
|
|
207
|
-
expect(typeof transaction.maxFeePerGas).toBe('bigint')
|
|
208
|
-
expect(typeof transaction.maxPriorityFeePerGas).toBe('bigint')
|
|
209
|
-
expect(transaction.maxFeePerGas).toBeGreaterThan(0n)
|
|
210
|
-
expect(transaction.maxPriorityFeePerGas).toBeGreaterThan(0n)
|
|
211
|
-
},
|
|
212
|
-
],
|
|
213
|
-
])('craftTransaction', (mode, expectTransactionForMode) => {
|
|
214
|
-
it('crafts a transaction with the native asset', async () => {
|
|
192
|
+
describe('craftTransaction', () => {
|
|
193
|
+
it('crafts a legacy transaction with the native asset', async () => {
|
|
215
194
|
const { transaction: result } = await module.craftTransaction(context, {
|
|
216
|
-
type:
|
|
195
|
+
type: 'send-legacy',
|
|
217
196
|
intentType: 'transaction',
|
|
218
197
|
amount: 10n,
|
|
219
198
|
sender: '0x9bcd841436ef4f85dacefb1aec772af71619024e',
|
|
220
199
|
recipient: '0x7b2c7232f9e38f30e2868f0e5bf311cd83554b5a',
|
|
221
200
|
data: { type: 'buffer', value: Buffer.from([]) },
|
|
222
|
-
asset: {
|
|
223
|
-
type: 'native',
|
|
224
|
-
},
|
|
201
|
+
asset: { type: 'native' },
|
|
225
202
|
})
|
|
226
203
|
|
|
227
204
|
expect(result).toMatch(/^0x[A-Fa-f0-9]+$/)
|
|
@@ -229,14 +206,42 @@ describe.each([
|
|
|
229
206
|
value: 10n,
|
|
230
207
|
to: '0x7b2C7232f9E38F30E2868f0E5Bf311Cd83554b5A',
|
|
231
208
|
})
|
|
232
|
-
|
|
209
|
+
const tx = ethers.Transaction.from(result)
|
|
210
|
+
expect(tx.type).toBe(0)
|
|
211
|
+
expect(typeof tx.gasPrice).toBe('bigint')
|
|
212
|
+
expect(tx.gasPrice).toBeGreaterThan(0)
|
|
233
213
|
})
|
|
234
214
|
|
|
235
|
-
it('crafts
|
|
215
|
+
it('crafts an eip1559 transaction with the native asset', async () => {
|
|
216
|
+
const { transaction: result } = await module.craftTransaction(context, {
|
|
217
|
+
type: 'send-eip1559',
|
|
218
|
+
intentType: 'transaction',
|
|
219
|
+
amount: 10n,
|
|
220
|
+
sender: '0x9bcd841436ef4f85dacefb1aec772af71619024e',
|
|
221
|
+
recipient: '0x7b2c7232f9e38f30e2868f0e5bf311cd83554b5a',
|
|
222
|
+
data: { type: 'buffer', value: Buffer.from([]) },
|
|
223
|
+
asset: { type: 'native' },
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
expect(result).toMatch(/^0x[A-Fa-f0-9]+$/)
|
|
227
|
+
expect(ethers.Transaction.from(result)).toMatchObject({
|
|
228
|
+
value: 10n,
|
|
229
|
+
to: '0x7b2C7232f9E38F30E2868f0E5Bf311Cd83554b5A',
|
|
230
|
+
})
|
|
231
|
+
const tx = ethers.Transaction.from(result)
|
|
232
|
+
expect(tx.type).toBe(2)
|
|
233
|
+
expect(tx.gasPrice).toBeNull()
|
|
234
|
+
expect(typeof tx.maxFeePerGas).toBe('bigint')
|
|
235
|
+
expect(typeof tx.maxPriorityFeePerGas).toBe('bigint')
|
|
236
|
+
expect(tx.maxFeePerGas).toBeGreaterThan(0n)
|
|
237
|
+
expect(tx.maxPriorityFeePerGas).toBeGreaterThan(0n)
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
it('crafts a legacy transaction with the USDC asset', async () => {
|
|
236
241
|
const { transaction: result } = await module.craftTransaction(
|
|
237
242
|
context,
|
|
238
243
|
{
|
|
239
|
-
type:
|
|
244
|
+
type: 'send-legacy',
|
|
240
245
|
intentType: 'transaction',
|
|
241
246
|
amount: 10n,
|
|
242
247
|
sender: '0x9bcd841436ef4f85dacefb1aec772af71619024e',
|
|
@@ -257,7 +262,44 @@ describe.each([
|
|
|
257
262
|
value: 0n,
|
|
258
263
|
to: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
259
264
|
})
|
|
260
|
-
|
|
265
|
+
const tx = ethers.Transaction.from(result)
|
|
266
|
+
expect(tx.type).toBe(0)
|
|
267
|
+
expect(typeof tx.gasPrice).toBe('bigint')
|
|
268
|
+
expect(tx.gasPrice).toBeGreaterThan(0)
|
|
269
|
+
})
|
|
270
|
+
|
|
271
|
+
it('crafts an eip1559 transaction with the USDC asset', async () => {
|
|
272
|
+
const { transaction: result } = await module.craftTransaction(
|
|
273
|
+
context,
|
|
274
|
+
{
|
|
275
|
+
type: 'send-eip1559',
|
|
276
|
+
intentType: 'transaction',
|
|
277
|
+
amount: 10n,
|
|
278
|
+
sender: '0x9bcd841436ef4f85dacefb1aec772af71619024e',
|
|
279
|
+
recipient: '0x7b2c7232f9e38f30e2868f0e5bf311cd83554b5a',
|
|
280
|
+
data: { type: 'buffer', value: Buffer.from([]) },
|
|
281
|
+
asset: {
|
|
282
|
+
type: 'erc20',
|
|
283
|
+
assetReference: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
// The sender holds no USDC, so estimating this transfer reverts on-chain. Pin the gas
|
|
287
|
+
// limit so the test covers the crafted payload rather than a live token balance.
|
|
288
|
+
{ customFees: { value: 0n, parameters: { gasLimit: 60000n } } }
|
|
289
|
+
)
|
|
290
|
+
|
|
291
|
+
expect(result).toMatch(/^0x[A-Fa-f0-9]+$/)
|
|
292
|
+
expect(ethers.Transaction.from(result)).toMatchObject({
|
|
293
|
+
value: 0n,
|
|
294
|
+
to: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
295
|
+
})
|
|
296
|
+
const tx = ethers.Transaction.from(result)
|
|
297
|
+
expect(tx.type).toBe(2)
|
|
298
|
+
expect(tx.gasPrice).toBeNull()
|
|
299
|
+
expect(typeof tx.maxFeePerGas).toBe('bigint')
|
|
300
|
+
expect(typeof tx.maxPriorityFeePerGas).toBe('bigint')
|
|
301
|
+
expect(tx.maxFeePerGas).toBeGreaterThan(0n)
|
|
302
|
+
expect(tx.maxPriorityFeePerGas).toBeGreaterThan(0n)
|
|
261
303
|
})
|
|
262
304
|
})
|
|
263
305
|
|
|
@@ -372,7 +414,7 @@ describe.each([
|
|
|
372
414
|
expect(op.tx.fees).toBeGreaterThanOrEqual(0n) // fees not available for all internal transactions
|
|
373
415
|
expect(op.tx.date).toBeInstanceOf(Date)
|
|
374
416
|
})
|
|
375
|
-
expect(isCorrectlyOrdered(result))
|
|
417
|
+
expect(isCorrectlyOrdered(result)).toBe(true)
|
|
376
418
|
}
|
|
377
419
|
)
|
|
378
420
|
|
|
@@ -397,6 +439,7 @@ describe.each([
|
|
|
397
439
|
// TODO implement pagination for ledger explorer
|
|
398
440
|
// Pagination tests only make sense for etherscan-like explorers that support real pagination.
|
|
399
441
|
// Ledger explorer fetches all data in one call looping over all the pages and returns NO_TOKEN.
|
|
442
|
+
// oxlint-disable jest/no-standalone-expect -- ternary test runner not recognized by static analysis
|
|
400
443
|
;(isEtherscanLike ? it.each : it.skip.each)([
|
|
401
444
|
// note that the ASC mode is really slow
|
|
402
445
|
['ascending', 'asc'],
|
|
@@ -523,6 +566,7 @@ describe.each([
|
|
|
523
566
|
expect(hasOverlap).toBe(false)
|
|
524
567
|
}
|
|
525
568
|
})
|
|
569
|
+
// oxlint-enable jest/no-standalone-expect
|
|
526
570
|
})
|
|
527
571
|
|
|
528
572
|
describe('transactions non-regression', () => {
|
|
@@ -715,65 +759,93 @@ describe.each([
|
|
|
715
759
|
})
|
|
716
760
|
})
|
|
717
761
|
|
|
718
|
-
describe
|
|
719
|
-
|
|
720
|
-
'legacy',
|
|
721
|
-
(estimation: FeeEstimation): void => {
|
|
722
|
-
expect(estimation).toEqual({
|
|
723
|
-
value: expect.any(BigInt),
|
|
724
|
-
parameters: {
|
|
725
|
-
gasPrice: expect.any(BigInt),
|
|
726
|
-
gasLimit: expect.any(BigInt),
|
|
727
|
-
maxFeePerGas: null,
|
|
728
|
-
maxPriorityFeePerGas: null,
|
|
729
|
-
nextBaseFee: null,
|
|
730
|
-
type: 0,
|
|
731
|
-
},
|
|
732
|
-
})
|
|
733
|
-
expect(estimation.value).toBeGreaterThan(0)
|
|
734
|
-
expect(estimation.parameters?.gasPrice).toBeGreaterThan(0)
|
|
735
|
-
},
|
|
736
|
-
],
|
|
737
|
-
[
|
|
738
|
-
'eip1559',
|
|
739
|
-
(estimation: FeeEstimation): void => {
|
|
740
|
-
expect(estimation).toEqual({
|
|
741
|
-
value: expect.any(BigInt),
|
|
742
|
-
parameters: {
|
|
743
|
-
gasPrice: null,
|
|
744
|
-
gasLimit: expect.any(BigInt),
|
|
745
|
-
maxFeePerGas: expect.any(BigInt),
|
|
746
|
-
maxPriorityFeePerGas: expect.any(BigInt),
|
|
747
|
-
nextBaseFee: expect.any(BigInt),
|
|
748
|
-
type: 2,
|
|
749
|
-
},
|
|
750
|
-
})
|
|
751
|
-
expect(estimation.value).toBeGreaterThan(0)
|
|
752
|
-
expect(estimation.parameters?.maxFeePerGas).toBeGreaterThan(0)
|
|
753
|
-
expect(estimation.parameters?.maxPriorityFeePerGas).toBeGreaterThan(0)
|
|
754
|
-
expect(estimation.parameters?.nextBaseFee).toBeGreaterThan(0)
|
|
755
|
-
},
|
|
756
|
-
],
|
|
757
|
-
])('estimateFees for %s transaction', (mode, expectEstimationForMode) => {
|
|
758
|
-
it('estimates fees for native asset transfer', async () => {
|
|
762
|
+
describe('estimateFees', () => {
|
|
763
|
+
it('estimates fees for legacy native asset transfer', async () => {
|
|
759
764
|
const result = await module.estimateFees(context, {
|
|
760
|
-
type:
|
|
765
|
+
type: 'send-legacy',
|
|
761
766
|
intentType: 'transaction',
|
|
762
767
|
amount: 100000000000000n, // 0.0001 ETH (smaller amount)
|
|
763
768
|
sender: '0xDb3812cD8d20F27888677dDC97dF1241850f8c48',
|
|
764
769
|
recipient: '0x7b2C7232f9E38F30E2868f0E5Bf311Cd83554b5A',
|
|
765
770
|
data: { type: 'buffer', value: Buffer.from([]) },
|
|
771
|
+
asset: { type: 'native' },
|
|
772
|
+
})
|
|
773
|
+
|
|
774
|
+
expect(result).toEqual({
|
|
775
|
+
value: expect.any(BigInt),
|
|
776
|
+
parameters: {
|
|
777
|
+
gasPrice: expect.any(BigInt),
|
|
778
|
+
gasLimit: expect.any(BigInt),
|
|
779
|
+
maxFeePerGas: null,
|
|
780
|
+
maxPriorityFeePerGas: null,
|
|
781
|
+
nextBaseFee: null,
|
|
782
|
+
type: 0,
|
|
783
|
+
},
|
|
784
|
+
})
|
|
785
|
+
expect(result.value).toBeGreaterThan(0)
|
|
786
|
+
expect(result.parameters?.gasPrice).toBeGreaterThan(0)
|
|
787
|
+
})
|
|
788
|
+
|
|
789
|
+
it('estimates fees for eip1559 native asset transfer', async () => {
|
|
790
|
+
const result = await module.estimateFees(context, {
|
|
791
|
+
type: 'send-eip1559',
|
|
792
|
+
intentType: 'transaction',
|
|
793
|
+
amount: 100000000000000n, // 0.0001 ETH (smaller amount)
|
|
794
|
+
sender: '0xDb3812cD8d20F27888677dDC97dF1241850f8c48',
|
|
795
|
+
recipient: '0x7b2C7232f9E38F30E2868f0E5Bf311Cd83554b5A',
|
|
796
|
+
data: { type: 'buffer', value: Buffer.from([]) },
|
|
797
|
+
asset: { type: 'native' },
|
|
798
|
+
})
|
|
799
|
+
|
|
800
|
+
expect(result).toEqual({
|
|
801
|
+
value: expect.any(BigInt),
|
|
802
|
+
parameters: {
|
|
803
|
+
gasPrice: null,
|
|
804
|
+
gasLimit: expect.any(BigInt),
|
|
805
|
+
maxFeePerGas: expect.any(BigInt),
|
|
806
|
+
maxPriorityFeePerGas: expect.any(BigInt),
|
|
807
|
+
nextBaseFee: expect.any(BigInt),
|
|
808
|
+
type: 2,
|
|
809
|
+
},
|
|
810
|
+
})
|
|
811
|
+
expect(result.value).toBeGreaterThan(0)
|
|
812
|
+
expect(result.parameters?.maxFeePerGas).toBeGreaterThan(0)
|
|
813
|
+
expect(result.parameters?.maxPriorityFeePerGas).toBeGreaterThan(0)
|
|
814
|
+
expect(result.parameters?.nextBaseFee).toBeGreaterThan(0)
|
|
815
|
+
})
|
|
816
|
+
|
|
817
|
+
it('estimates fees for legacy USDC token transfer', async () => {
|
|
818
|
+
const result = await module.estimateFees(context, {
|
|
819
|
+
type: 'send-legacy',
|
|
820
|
+
intentType: 'transaction',
|
|
821
|
+
amount: 1000000n, // 1 USDC (6 decimals)
|
|
822
|
+
sender: '0xDb3812cD8d20F27888677dDC97dF1241850f8c48',
|
|
823
|
+
recipient: '0x7b2C7232f9E38F30E2868f0E5Bf311Cd83554b5A',
|
|
824
|
+
data: { type: 'buffer', value: Buffer.from([]) },
|
|
766
825
|
asset: {
|
|
767
|
-
type: '
|
|
826
|
+
type: 'erc20',
|
|
827
|
+
assetReference: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
768
828
|
},
|
|
769
829
|
})
|
|
770
830
|
|
|
771
|
-
|
|
831
|
+
expect(result).toEqual({
|
|
832
|
+
value: expect.any(BigInt),
|
|
833
|
+
parameters: {
|
|
834
|
+
gasPrice: expect.any(BigInt),
|
|
835
|
+
gasLimit: expect.any(BigInt),
|
|
836
|
+
maxFeePerGas: null,
|
|
837
|
+
maxPriorityFeePerGas: null,
|
|
838
|
+
nextBaseFee: null,
|
|
839
|
+
type: 0,
|
|
840
|
+
},
|
|
841
|
+
})
|
|
842
|
+
expect(result.value).toBeGreaterThan(0)
|
|
843
|
+
expect(result.parameters?.gasPrice).toBeGreaterThan(0)
|
|
772
844
|
})
|
|
773
845
|
|
|
774
|
-
it('estimates fees for USDC token transfer', async () => {
|
|
846
|
+
it('estimates fees for eip1559 USDC token transfer', async () => {
|
|
775
847
|
const result = await module.estimateFees(context, {
|
|
776
|
-
type:
|
|
848
|
+
type: 'send-eip1559',
|
|
777
849
|
intentType: 'transaction',
|
|
778
850
|
amount: 1000000n, // 1 USDC (6 decimals)
|
|
779
851
|
sender: '0xDb3812cD8d20F27888677dDC97dF1241850f8c48',
|
|
@@ -785,7 +857,21 @@ describe.each([
|
|
|
785
857
|
},
|
|
786
858
|
})
|
|
787
859
|
|
|
788
|
-
|
|
860
|
+
expect(result).toEqual({
|
|
861
|
+
value: expect.any(BigInt),
|
|
862
|
+
parameters: {
|
|
863
|
+
gasPrice: null,
|
|
864
|
+
gasLimit: expect.any(BigInt),
|
|
865
|
+
maxFeePerGas: expect.any(BigInt),
|
|
866
|
+
maxPriorityFeePerGas: expect.any(BigInt),
|
|
867
|
+
nextBaseFee: expect.any(BigInt),
|
|
868
|
+
type: 2,
|
|
869
|
+
},
|
|
870
|
+
})
|
|
871
|
+
expect(result.value).toBeGreaterThan(0)
|
|
872
|
+
expect(result.parameters?.maxFeePerGas).toBeGreaterThan(0)
|
|
873
|
+
expect(result.parameters?.maxPriorityFeePerGas).toBeGreaterThan(0)
|
|
874
|
+
expect(result.parameters?.nextBaseFee).toBeGreaterThan(0)
|
|
789
875
|
})
|
|
790
876
|
})
|
|
791
877
|
})
|
|
@@ -946,30 +1032,10 @@ describe('EVM Api (SEI Network)', () => {
|
|
|
946
1032
|
module = createApi('sei_evm')
|
|
947
1033
|
})
|
|
948
1034
|
|
|
949
|
-
describe
|
|
950
|
-
|
|
951
|
-
'legacy',
|
|
952
|
-
(transaction: ethers.Transaction): void => {
|
|
953
|
-
expect(transaction.type).toBe(0)
|
|
954
|
-
expect(typeof transaction.gasPrice).toBe('bigint')
|
|
955
|
-
expect(transaction.gasPrice).toBeGreaterThan(0)
|
|
956
|
-
},
|
|
957
|
-
],
|
|
958
|
-
[
|
|
959
|
-
'eip1559',
|
|
960
|
-
(transaction: ethers.Transaction): void => {
|
|
961
|
-
expect(transaction.type).toBe(2)
|
|
962
|
-
expect(transaction.gasPrice).toBeNull()
|
|
963
|
-
expect(typeof transaction.maxFeePerGas).toBe('bigint')
|
|
964
|
-
expect(typeof transaction.maxPriorityFeePerGas).toBe('bigint')
|
|
965
|
-
expect(transaction.maxFeePerGas).toBeGreaterThan(0n)
|
|
966
|
-
expect(transaction.maxPriorityFeePerGas).toBeGreaterThan(0n)
|
|
967
|
-
},
|
|
968
|
-
],
|
|
969
|
-
])('craftTransaction', (mode, expectTransactionForMode) => {
|
|
970
|
-
it('crafts a delegate transaction', async () => {
|
|
1035
|
+
describe('craftTransaction', () => {
|
|
1036
|
+
it('crafts a legacy delegate transaction', async () => {
|
|
971
1037
|
const { transaction: result } = await module.craftTransaction(context, {
|
|
972
|
-
type:
|
|
1038
|
+
type: 'staking-legacy',
|
|
973
1039
|
intentType: 'staking' as const,
|
|
974
1040
|
amount: seiStakingDelegationAmount,
|
|
975
1041
|
mode: 'delegate',
|
|
@@ -977,9 +1043,31 @@ describe('EVM Api (SEI Network)', () => {
|
|
|
977
1043
|
recipient: seiStakingRecipient,
|
|
978
1044
|
valAddress: 'seivaloper1ummny4p645xraxc4m7nphf7vxawfzt3p5hn47t',
|
|
979
1045
|
data: { type: 'buffer', value: Buffer.from([]) },
|
|
980
|
-
asset: {
|
|
981
|
-
|
|
982
|
-
|
|
1046
|
+
asset: { type: 'native' },
|
|
1047
|
+
} as StakingTransactionIntent<MemoNotSupported, BufferTxData>)
|
|
1048
|
+
|
|
1049
|
+
expect(result).toMatch(/^0x[A-Fa-f0-9]+$/)
|
|
1050
|
+
expect(ethers.Transaction.from(result)).toMatchObject({
|
|
1051
|
+
value: seiStakingDelegationAmount,
|
|
1052
|
+
to: seiStakingRecipient,
|
|
1053
|
+
})
|
|
1054
|
+
const tx = ethers.Transaction.from(result)
|
|
1055
|
+
expect(tx.type).toBe(0)
|
|
1056
|
+
expect(typeof tx.gasPrice).toBe('bigint')
|
|
1057
|
+
expect(tx.gasPrice).toBeGreaterThan(0)
|
|
1058
|
+
})
|
|
1059
|
+
|
|
1060
|
+
it('crafts an eip1559 delegate transaction', async () => {
|
|
1061
|
+
const { transaction: result } = await module.craftTransaction(context, {
|
|
1062
|
+
type: 'staking-eip1559',
|
|
1063
|
+
intentType: 'staking' as const,
|
|
1064
|
+
amount: seiStakingDelegationAmount,
|
|
1065
|
+
mode: 'delegate',
|
|
1066
|
+
sender: seiStakingSender,
|
|
1067
|
+
recipient: seiStakingRecipient,
|
|
1068
|
+
valAddress: 'seivaloper1ummny4p645xraxc4m7nphf7vxawfzt3p5hn47t',
|
|
1069
|
+
data: { type: 'buffer', value: Buffer.from([]) },
|
|
1070
|
+
asset: { type: 'native' },
|
|
983
1071
|
} as StakingTransactionIntent<MemoNotSupported, BufferTxData>)
|
|
984
1072
|
|
|
985
1073
|
expect(result).toMatch(/^0x[A-Fa-f0-9]+$/)
|
|
@@ -987,53 +1075,20 @@ describe('EVM Api (SEI Network)', () => {
|
|
|
987
1075
|
value: seiStakingDelegationAmount,
|
|
988
1076
|
to: seiStakingRecipient,
|
|
989
1077
|
})
|
|
990
|
-
|
|
1078
|
+
const tx = ethers.Transaction.from(result)
|
|
1079
|
+
expect(tx.type).toBe(2)
|
|
1080
|
+
expect(tx.gasPrice).toBeNull()
|
|
1081
|
+
expect(typeof tx.maxFeePerGas).toBe('bigint')
|
|
1082
|
+
expect(typeof tx.maxPriorityFeePerGas).toBe('bigint')
|
|
1083
|
+
expect(tx.maxFeePerGas).toBeGreaterThan(0n)
|
|
1084
|
+
expect(tx.maxPriorityFeePerGas).toBeGreaterThan(0n)
|
|
991
1085
|
})
|
|
992
1086
|
})
|
|
993
1087
|
|
|
994
|
-
describe
|
|
995
|
-
|
|
996
|
-
'legacy',
|
|
997
|
-
(estimation: FeeEstimation): void => {
|
|
998
|
-
expect(estimation).toEqual({
|
|
999
|
-
value: expect.any(BigInt),
|
|
1000
|
-
parameters: {
|
|
1001
|
-
gasPrice: expect.any(BigInt),
|
|
1002
|
-
gasLimit: expect.any(BigInt),
|
|
1003
|
-
maxFeePerGas: null,
|
|
1004
|
-
maxPriorityFeePerGas: null,
|
|
1005
|
-
nextBaseFee: null,
|
|
1006
|
-
type: 0,
|
|
1007
|
-
},
|
|
1008
|
-
})
|
|
1009
|
-
expect(estimation.value).toBeGreaterThan(0)
|
|
1010
|
-
expect(estimation.parameters?.gasPrice).toBeGreaterThan(0)
|
|
1011
|
-
},
|
|
1012
|
-
],
|
|
1013
|
-
[
|
|
1014
|
-
'eip1559',
|
|
1015
|
-
(estimation: FeeEstimation): void => {
|
|
1016
|
-
expect(estimation).toEqual({
|
|
1017
|
-
value: expect.any(BigInt),
|
|
1018
|
-
parameters: {
|
|
1019
|
-
gasPrice: null,
|
|
1020
|
-
gasLimit: expect.any(BigInt),
|
|
1021
|
-
maxFeePerGas: expect.any(BigInt),
|
|
1022
|
-
maxPriorityFeePerGas: expect.any(BigInt),
|
|
1023
|
-
nextBaseFee: expect.any(BigInt),
|
|
1024
|
-
type: 2,
|
|
1025
|
-
},
|
|
1026
|
-
})
|
|
1027
|
-
expect(estimation.value).toBeGreaterThan(0)
|
|
1028
|
-
expect(estimation.parameters?.maxFeePerGas).toBeGreaterThan(0)
|
|
1029
|
-
expect(estimation.parameters?.maxPriorityFeePerGas).toBeGreaterThan(0)
|
|
1030
|
-
expect(estimation.parameters?.nextBaseFee).toBeGreaterThan(0)
|
|
1031
|
-
},
|
|
1032
|
-
],
|
|
1033
|
-
])('estimateFees for %s transaction', (mode, expectEstimationForMode) => {
|
|
1034
|
-
it('estimates fees for staking delegation', async () => {
|
|
1088
|
+
describe('estimateFees', () => {
|
|
1089
|
+
it('estimates fees for legacy staking delegation', async () => {
|
|
1035
1090
|
const result = await module.estimateFees(context, {
|
|
1036
|
-
type:
|
|
1091
|
+
type: 'staking-legacy',
|
|
1037
1092
|
intentType: 'staking' as const,
|
|
1038
1093
|
amount: seiStakingDelegationAmount,
|
|
1039
1094
|
mode: 'delegate',
|
|
@@ -1041,12 +1096,52 @@ describe('EVM Api (SEI Network)', () => {
|
|
|
1041
1096
|
recipient: seiStakingRecipient,
|
|
1042
1097
|
valAddress: 'seivaloper1ummny4p645xraxc4m7nphf7vxawfzt3p5hn47t',
|
|
1043
1098
|
data: { type: 'buffer', value: Buffer.from([]) },
|
|
1044
|
-
asset: {
|
|
1045
|
-
|
|
1099
|
+
asset: { type: 'native' },
|
|
1100
|
+
} as StakingTransactionIntent<MemoNotSupported, BufferTxData>)
|
|
1101
|
+
|
|
1102
|
+
expect(result).toEqual({
|
|
1103
|
+
value: expect.any(BigInt),
|
|
1104
|
+
parameters: {
|
|
1105
|
+
gasPrice: expect.any(BigInt),
|
|
1106
|
+
gasLimit: expect.any(BigInt),
|
|
1107
|
+
maxFeePerGas: null,
|
|
1108
|
+
maxPriorityFeePerGas: null,
|
|
1109
|
+
nextBaseFee: null,
|
|
1110
|
+
type: 0,
|
|
1046
1111
|
},
|
|
1112
|
+
})
|
|
1113
|
+
expect(result.value).toBeGreaterThan(0)
|
|
1114
|
+
expect(result.parameters?.gasPrice).toBeGreaterThan(0)
|
|
1115
|
+
})
|
|
1116
|
+
|
|
1117
|
+
it('estimates fees for eip1559 staking delegation', async () => {
|
|
1118
|
+
const result = await module.estimateFees(context, {
|
|
1119
|
+
type: 'staking-eip1559',
|
|
1120
|
+
intentType: 'staking' as const,
|
|
1121
|
+
amount: seiStakingDelegationAmount,
|
|
1122
|
+
mode: 'delegate',
|
|
1123
|
+
sender: seiStakingSender,
|
|
1124
|
+
recipient: seiStakingRecipient,
|
|
1125
|
+
valAddress: 'seivaloper1ummny4p645xraxc4m7nphf7vxawfzt3p5hn47t',
|
|
1126
|
+
data: { type: 'buffer', value: Buffer.from([]) },
|
|
1127
|
+
asset: { type: 'native' },
|
|
1047
1128
|
} as StakingTransactionIntent<MemoNotSupported, BufferTxData>)
|
|
1048
1129
|
|
|
1049
|
-
|
|
1130
|
+
expect(result).toEqual({
|
|
1131
|
+
value: expect.any(BigInt),
|
|
1132
|
+
parameters: {
|
|
1133
|
+
gasPrice: null,
|
|
1134
|
+
gasLimit: expect.any(BigInt),
|
|
1135
|
+
maxFeePerGas: expect.any(BigInt),
|
|
1136
|
+
maxPriorityFeePerGas: expect.any(BigInt),
|
|
1137
|
+
nextBaseFee: expect.any(BigInt),
|
|
1138
|
+
type: 2,
|
|
1139
|
+
},
|
|
1140
|
+
})
|
|
1141
|
+
expect(result.value).toBeGreaterThan(0)
|
|
1142
|
+
expect(result.parameters?.maxFeePerGas).toBeGreaterThan(0)
|
|
1143
|
+
expect(result.parameters?.maxPriorityFeePerGas).toBeGreaterThan(0)
|
|
1144
|
+
expect(result.parameters?.nextBaseFee).toBeGreaterThan(0)
|
|
1050
1145
|
})
|
|
1051
1146
|
})
|
|
1052
1147
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { EvmConfig } from '../config'
|
|
4
|
+
import type { EvmConfig } from '../config'
|
|
5
5
|
import { createMockEvmContext } from '../fixtures/context.fixtures'
|
|
6
6
|
import { createApi } from './index'
|
|
7
7
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import type { EvmConfigInfo } from '../config'
|
|
5
|
-
import { Operation } from '@ledgerhq/coin-module-framework/api/types'
|
|
5
|
+
import type { Operation } from '@ledgerhq/coin-module-framework/api/types'
|
|
6
6
|
import { createMockEvmContext } from '../fixtures/context.fixtures'
|
|
7
7
|
import { createApi } from './index'
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import type { EvmConfig } from '../config'
|
|
4
5
|
import { fail } from 'assert'
|
|
5
|
-
import { EvmConfig } from '../config'
|
|
6
6
|
import { createMockEvmContext } from '../fixtures/context.fixtures'
|
|
7
7
|
import { createApi } from './index'
|
|
8
8
|
|
package/src/api/index.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 { EvmConfigInfo, EvmContext } from '../config'
|
|
4
5
|
import type { EvmCallParams } from '../network/node/types'
|
|
5
6
|
import type {
|
|
6
7
|
CoinModuleImpl,
|
|
@@ -22,7 +23,6 @@ import type {
|
|
|
22
23
|
Validator,
|
|
23
24
|
BalanceOptions,
|
|
24
25
|
} from '@ledgerhq/coin-module-framework/api/index'
|
|
25
|
-
import { type EvmConfigInfo, type EvmContext } from '../config'
|
|
26
26
|
import { craftTransactionData } from '../logic/craftTransactionData'
|
|
27
27
|
import {
|
|
28
28
|
broadcast,
|
package/src/config.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import type { InternalTxSourceList } from './internalTxSources'
|
|
5
|
-
import { Context, CurrencyConfig } from '@ledgerhq/coin-module-framework/config'
|
|
5
|
+
import type { Context, CurrencyConfig } from '@ledgerhq/coin-module-framework/config'
|
|
6
6
|
import { log } from '@ledgerhq/logs'
|
|
7
7
|
|
|
8
8
|
export type { InternalTxSource, InternalTxSourceList, NonEmptySource } from './internalTxSources'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { LedgerExplorerOperation } from '../types'
|
|
4
|
+
import type { LedgerExplorerOperation } from '../types'
|
|
5
5
|
|
|
6
6
|
export const coinOperation1: LedgerExplorerOperation = {
|
|
7
7
|
hash: '0xf350d4f8e910419e2d5cec294d44e69af8c6185b7089061d33bb4fc246cefb79',
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
internalTxSourcesFromList,
|
|
7
|
-
type InternalTxSourceList,
|
|
8
|
-
} from './internalTxSources'
|
|
4
|
+
import type { InternalTxSourceList } from './internalTxSources'
|
|
5
|
+
import { DEFAULT_INTERNAL_TX_SOURCES, internalTxSourcesFromList } from './internalTxSources'
|
|
9
6
|
|
|
10
7
|
describe('internalTxSourcesFromList', () => {
|
|
11
8
|
it('builds the default explorer-first strategy', () => {
|
|
@@ -73,7 +70,7 @@ describe('internalTxSourcesFromList', () => {
|
|
|
73
70
|
const raw = ['explorer', 'empty'] as const
|
|
74
71
|
// @ts-expect-error - InternalTxSourceList is branded; only internalTxSourcesFromList can produce it
|
|
75
72
|
const sources: InternalTxSourceList = raw
|
|
76
|
-
|
|
73
|
+
expect(sources).toEqual(raw)
|
|
77
74
|
})
|
|
78
75
|
})
|
|
79
76
|
})
|
|
@@ -136,7 +136,7 @@ describe('combine', () => {
|
|
|
136
136
|
const serializedUnsignedTx = ethers.Transaction.from(unsignedTx).unsignedSerialized
|
|
137
137
|
|
|
138
138
|
expect(() => {
|
|
139
|
-
combine(serializedUnsignedTx,
|
|
140
|
-
}).toThrow()
|
|
139
|
+
combine(serializedUnsignedTx, [])
|
|
140
|
+
}).toThrow('EVM combine expects exactly one signature')
|
|
141
141
|
})
|
|
142
142
|
})
|
package/src/logic/combine.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import type { SignatureLike } from 'ethers'
|
|
5
|
+
import { Signature, Transaction } from 'ethers'
|
|
5
6
|
|
|
6
7
|
function prefixHexString(hex: string): string {
|
|
7
8
|
return hex.startsWith('0x') ? hex : '0x' + hex
|
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
|
|