@ledgerhq/coin-evm 15.0.0 → 16.0.0
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/CHANGELOG.md +40 -0
- package/lib/adapters/etherscan.d.ts.map +1 -1
- package/lib/adapters/etherscan.js +14 -0
- package/lib/adapters/etherscan.js.map +1 -1
- package/lib/adapters/ledger.d.ts.map +1 -1
- package/lib/adapters/ledger.js +2 -0
- package/lib/adapters/ledger.js.map +1 -1
- package/lib/api/index.d.ts +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +14 -15
- package/lib/api/index.js.map +1 -1
- package/lib/chains.d.ts +7 -0
- package/lib/chains.d.ts.map +1 -1
- package/lib/chains.js +17 -1
- package/lib/chains.js.map +1 -1
- package/lib/config.d.ts +1 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +2 -1
- package/lib/config.js.map +1 -1
- package/lib/errors.d.ts +11 -0
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +17 -1
- package/lib/errors.js.map +1 -1
- package/lib/logic/broadcast.d.ts +1 -1
- package/lib/logic/broadcast.d.ts.map +1 -1
- package/lib/logic/broadcast.js +2 -2
- package/lib/logic/broadcast.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 +3 -3
- package/lib/logic/craftTransaction.js.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 +19 -4
- package/lib/logic/estimateFees.js.map +1 -1
- package/lib/logic/getBalance.d.ts +1 -2
- package/lib/logic/getBalance.d.ts.map +1 -1
- package/lib/logic/getBalance.js +5 -6
- 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 +23 -6
- package/lib/logic/getBlock.js.map +1 -1
- package/lib/logic/getBlockInfo.d.ts +1 -1
- package/lib/logic/getBlockInfo.d.ts.map +1 -1
- package/lib/logic/getBlockInfo.js +2 -2
- package/lib/logic/getBlockInfo.js.map +1 -1
- package/lib/logic/getNextSequence.d.ts +1 -1
- package/lib/logic/getNextSequence.d.ts.map +1 -1
- package/lib/logic/getNextSequence.js +2 -2
- package/lib/logic/getNextSequence.js.map +1 -1
- package/lib/logic/getStakes.d.ts +1 -1
- package/lib/logic/getStakes.d.ts.map +1 -1
- package/lib/logic/getStakes.js +2 -2
- package/lib/logic/getStakes.js.map +1 -1
- package/lib/logic/lastBlock.d.ts +1 -1
- package/lib/logic/lastBlock.d.ts.map +1 -1
- package/lib/logic/lastBlock.js +2 -2
- package/lib/logic/lastBlock.js.map +1 -1
- package/lib/logic/listOperations.d.ts +1 -1
- package/lib/logic/listOperations.d.ts.map +1 -1
- package/lib/logic/listOperations.js +4 -2
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/logic/validateIntent.d.ts +1 -1
- package/lib/logic/validateIntent.d.ts.map +1 -1
- package/lib/logic/validateIntent.js +3 -3
- package/lib/logic/validateIntent.js.map +1 -1
- package/lib/logic.d.ts.map +1 -1
- package/lib/logic.js +5 -10
- package/lib/logic.js.map +1 -1
- package/lib/network/node/explorerProxy.d.ts.map +1 -1
- package/lib/network/node/explorerProxy.js +2 -0
- package/lib/network/node/explorerProxy.js.map +1 -1
- package/lib/network/node/ledger.d.ts.map +1 -1
- package/lib/network/node/ledger.js +2 -9
- package/lib/network/node/ledger.js.map +1 -1
- package/lib/network/node/rpc.common.d.ts.map +1 -1
- package/lib/network/node/rpc.common.js +18 -9
- package/lib/network/node/rpc.common.js.map +1 -1
- package/lib/network/node/types.d.ts +3 -1
- package/lib/network/node/types.d.ts.map +1 -1
- package/lib/network/node/types.js.map +1 -1
- package/lib/staking/detectOperationType.js +1 -1
- package/lib/staking/validators/index.d.ts +1 -1
- package/lib/staking/validators/index.d.ts.map +1 -1
- package/lib/staking/validators/index.js +2 -2
- package/lib/staking/validators/index.js.map +1 -1
- package/lib/staking/validators/monadResolver.js +1 -1
- package/lib/staking/validators/monadResolver.js.map +1 -1
- package/lib-es/adapters/etherscan.d.ts.map +1 -1
- package/lib-es/adapters/etherscan.js +14 -0
- package/lib-es/adapters/etherscan.js.map +1 -1
- package/lib-es/adapters/ledger.d.ts.map +1 -1
- package/lib-es/adapters/ledger.js +2 -0
- package/lib-es/adapters/ledger.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/api/index.js +14 -15
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/chains.d.ts +7 -0
- package/lib-es/chains.d.ts.map +1 -1
- package/lib-es/chains.js +16 -0
- package/lib-es/chains.js.map +1 -1
- package/lib-es/config.d.ts +1 -1
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/config.js +1 -1
- package/lib-es/config.js.map +1 -1
- package/lib-es/errors.d.ts +11 -0
- package/lib-es/errors.d.ts.map +1 -1
- package/lib-es/errors.js +15 -0
- package/lib-es/errors.js.map +1 -1
- package/lib-es/logic/broadcast.d.ts +1 -1
- package/lib-es/logic/broadcast.d.ts.map +1 -1
- package/lib-es/logic/broadcast.js +2 -2
- package/lib-es/logic/broadcast.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 +3 -3
- package/lib-es/logic/craftTransaction.js.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 +19 -4
- package/lib-es/logic/estimateFees.js.map +1 -1
- package/lib-es/logic/getBalance.d.ts +1 -2
- package/lib-es/logic/getBalance.d.ts.map +1 -1
- package/lib-es/logic/getBalance.js +5 -6
- 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 +23 -6
- package/lib-es/logic/getBlock.js.map +1 -1
- package/lib-es/logic/getBlockInfo.d.ts +1 -1
- package/lib-es/logic/getBlockInfo.d.ts.map +1 -1
- package/lib-es/logic/getBlockInfo.js +2 -2
- package/lib-es/logic/getBlockInfo.js.map +1 -1
- package/lib-es/logic/getNextSequence.d.ts +1 -1
- package/lib-es/logic/getNextSequence.d.ts.map +1 -1
- package/lib-es/logic/getNextSequence.js +2 -2
- package/lib-es/logic/getNextSequence.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/getStakes.js +2 -2
- package/lib-es/logic/getStakes.js.map +1 -1
- package/lib-es/logic/lastBlock.d.ts +1 -1
- package/lib-es/logic/lastBlock.d.ts.map +1 -1
- package/lib-es/logic/lastBlock.js +2 -2
- package/lib-es/logic/lastBlock.js.map +1 -1
- package/lib-es/logic/listOperations.d.ts +1 -1
- package/lib-es/logic/listOperations.d.ts.map +1 -1
- package/lib-es/logic/listOperations.js +4 -2
- package/lib-es/logic/listOperations.js.map +1 -1
- package/lib-es/logic/validateIntent.d.ts +1 -1
- package/lib-es/logic/validateIntent.d.ts.map +1 -1
- package/lib-es/logic/validateIntent.js +3 -3
- package/lib-es/logic/validateIntent.js.map +1 -1
- package/lib-es/logic.d.ts.map +1 -1
- package/lib-es/logic.js +6 -11
- package/lib-es/logic.js.map +1 -1
- package/lib-es/network/node/explorerProxy.d.ts.map +1 -1
- package/lib-es/network/node/explorerProxy.js +2 -0
- package/lib-es/network/node/explorerProxy.js.map +1 -1
- package/lib-es/network/node/ledger.d.ts.map +1 -1
- package/lib-es/network/node/ledger.js +3 -10
- package/lib-es/network/node/ledger.js.map +1 -1
- package/lib-es/network/node/rpc.common.d.ts.map +1 -1
- package/lib-es/network/node/rpc.common.js +19 -10
- package/lib-es/network/node/rpc.common.js.map +1 -1
- package/lib-es/network/node/types.d.ts +3 -1
- package/lib-es/network/node/types.d.ts.map +1 -1
- package/lib-es/network/node/types.js.map +1 -1
- package/lib-es/staking/detectOperationType.js +1 -1
- package/lib-es/staking/validators/index.d.ts +1 -1
- package/lib-es/staking/validators/index.d.ts.map +1 -1
- package/lib-es/staking/validators/index.js +2 -2
- package/lib-es/staking/validators/index.js.map +1 -1
- package/lib-es/staking/validators/monadResolver.js +1 -1
- package/lib-es/staking/validators/monadResolver.js.map +1 -1
- package/package.json +2 -2
- package/src/adapters/etherscan.test.ts +57 -5
- package/src/adapters/etherscan.ts +15 -0
- package/src/adapters/ledger.test.ts +57 -9
- package/src/adapters/ledger.ts +2 -0
- package/src/api/index.ts +14 -17
- package/src/api/{getBlock.integ.test.ts → tests/getBlock.integ.test.ts} +7 -7
- package/src/api/{index.arbitrum.integ.test.ts → tests/index.arbitrum.integ.test.ts} +4 -4
- package/src/api/{index.arc.integ.test.ts → tests/index.arc.integ.test.ts} +4 -4
- package/src/api/{index.avalanche_c_chain_fuji.integ.test.ts → tests/index.avalanche_c_chain_fuji.integ.test.ts} +4 -4
- package/src/api/{index.cronos.integ.test.ts → tests/index.cronos.integ.test.ts} +4 -4
- package/src/api/{index.flare.integ.test.ts → tests/index.flare.integ.test.ts} +4 -4
- package/src/api/{index.integ.test.ts → tests/index.integ.test.ts} +8 -8
- package/src/api/{index.linea.integ.test.ts → tests/index.linea.integ.test.ts} +4 -4
- package/src/api/{index.monad_testnet.integ.test.ts → tests/index.monad_testnet.integ.test.ts} +5 -5
- package/src/api/{index.optimism.integ.test.ts → tests/index.optimism.integ.test.ts} +4 -4
- package/src/api/{index.rsk.integ.test.ts → tests/index.rsk.integ.test.ts} +4 -4
- package/src/api/{index.shape.integ.test.ts → tests/index.shape.integ.test.ts} +4 -4
- package/src/api/{index.somnia.integ.test.ts → tests/index.somnia.integ.test.ts} +4 -4
- package/src/api/{index.test.ts → tests/index.test.ts} +10 -10
- package/src/api/{index.zksync.integ.test.ts → tests/index.zksync.integ.test.ts} +3 -3
- package/src/chains.ts +17 -0
- package/src/config.ts +1 -1
- package/src/errors.ts +14 -0
- package/src/fixtures/context.fixtures.ts +2 -4
- package/src/logic/broadcast.ts +1 -2
- package/src/logic/craftTransaction.ts +2 -3
- package/src/logic/estimateFees.ts +22 -4
- package/src/logic/getBalance.ts +3 -6
- package/src/logic/getBlock.ts +39 -10
- package/src/logic/getBlockInfo.ts +2 -6
- package/src/logic/getNextSequence.ts +2 -6
- package/src/logic/getStakes.ts +1 -2
- package/src/logic/lastBlock.ts +2 -2
- package/src/logic/listOperations.ts +3 -2
- package/src/logic/tests/broadcast.integ.test.ts +1 -1
- package/src/logic/tests/broadcast.test.ts +5 -5
- package/src/logic/tests/broadcastSource.test.ts +4 -4
- package/src/logic/tests/common.test.ts +1 -1
- package/src/logic/tests/craftTransaction.test.ts +16 -21
- package/src/logic/tests/estimateFees.test.ts +40 -18
- package/src/logic/tests/getBalance.test.ts +20 -23
- package/src/logic/tests/getBlock.test.ts +159 -39
- package/src/logic/tests/getBlockInfo.test.ts +6 -6
- package/src/logic/tests/getNextSequence.test.ts +2 -2
- package/src/logic/tests/getStakes.test.ts +14 -14
- package/src/logic/tests/internalTransactionsFetcher.test.ts +1 -1
- package/src/logic/tests/lastBlock.test.ts +4 -4
- package/src/logic/tests/listOperations.test.ts +51 -55
- package/src/logic/tests/validateIntent.test.ts +39 -61
- package/src/logic/validateIntent.ts +2 -3
- package/src/logic.test.ts +24 -7
- package/src/logic.ts +6 -11
- package/src/network/node/explorerProxy.ts +2 -0
- package/src/network/node/ledger.ts +3 -10
- package/src/network/node/rpc.common.ts +23 -10
- package/src/network/node/types.ts +5 -2
- package/src/network/{explorer → tests/explorer}/etherscan.test.ts +8 -8
- package/src/network/{explorer → tests/explorer}/index.test.ts +11 -11
- package/src/network/{explorer → tests/explorer}/ledger.test.ts +11 -11
- package/src/network/{explorer → tests/explorer}/types.test.ts +1 -1
- package/src/network/{gasTracker → tests/gasTracker}/index.test.ts +3 -3
- package/src/network/{gasTracker → tests/gasTracker}/ledger.test.ts +4 -4
- package/src/network/{gasTracker → tests/gasTracker}/types.test.ts +1 -1
- package/src/network/{node → tests/node}/explorerProxy.test.ts +5 -2
- package/src/network/{node → tests/node}/gethCallTracerToTraceBlockItems.test.ts +4 -4
- package/src/network/{node → tests/node}/index.memoization.test.ts +3 -3
- package/src/network/{node → tests/node}/index.test.ts +3 -3
- package/src/network/{node → tests/node}/ledger.test.ts +9 -6
- package/src/network/{node → tests/node}/node.fixtures.ts +1 -1
- package/src/network/{node → tests/node}/rpc.errors.test.ts +1 -1
- package/src/network/{node → tests/node}/rpc.test.ts +57 -6
- package/src/network/{node → tests/node}/types.test.ts +1 -1
- package/src/network/{node → tests/node}/withNodeSources.test.ts +3 -3
- package/src/network/{withRetries.test.ts → tests/withRetries.test.ts} +2 -2
- package/src/staking/detectOperationType.ts +1 -1
- package/src/staking/redelegations.test.ts +3 -3
- package/src/staking/validators/index.ts +1 -2
- package/src/staking/validators/monadResolver.ts +1 -1
- package/src/staking/validators.integ.test.ts +1 -1
- package/src/staking/validators.test.ts +1 -1
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
import ledgerExplorer from '../../network/explorer/ledger'
|
|
43
43
|
import ledgerGasTracker from '../../network/gasTracker/ledger'
|
|
44
44
|
import { getNodeApi } from '../../network/node'
|
|
45
|
-
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
45
|
+
import { mockNodeApi } from '../../network/tests/node/node.fixtures'
|
|
46
46
|
import * as computeGasLimitModule from '../computeGasLimit'
|
|
47
47
|
import { validateIntent } from '../validateIntent'
|
|
48
48
|
|
|
@@ -159,7 +159,6 @@ describe('validateIntent', () => {
|
|
|
159
159
|
])('%s with too high fees on a %s asset', async (_s, assetType, expectedWarnings) => {
|
|
160
160
|
const res = await validateIntent(
|
|
161
161
|
context,
|
|
162
|
-
'ethereum',
|
|
163
162
|
eip1559Intent({
|
|
164
163
|
amount: 1n,
|
|
165
164
|
asset: { type: assetType },
|
|
@@ -177,12 +176,9 @@ describe('validateIntent', () => {
|
|
|
177
176
|
|
|
178
177
|
describe('recipient', () => {
|
|
179
178
|
it('detects the missing recipient with an error', async () => {
|
|
180
|
-
const res = await validateIntent(
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
eip1559Intent({ amount: 1n, recipient: '' }),
|
|
184
|
-
[{ value: 50n, asset: { type: 'native' } }]
|
|
185
|
-
)
|
|
179
|
+
const res = await validateIntent(context, eip1559Intent({ amount: 1n, recipient: '' }), [
|
|
180
|
+
{ value: 50n, asset: { type: 'native' } },
|
|
181
|
+
])
|
|
186
182
|
|
|
187
183
|
expect(res.errors).toEqual(
|
|
188
184
|
expect.objectContaining({
|
|
@@ -194,7 +190,6 @@ describe('validateIntent', () => {
|
|
|
194
190
|
it('detects the incorrect recipient not being an eth address with an error', async () => {
|
|
195
191
|
const res = await validateIntent(
|
|
196
192
|
context,
|
|
197
|
-
'ethereum',
|
|
198
193
|
eip1559Intent({ amount: 1n, recipient: 'invalid-address' }),
|
|
199
194
|
[{ value: 50n, asset: { type: 'native' } }]
|
|
200
195
|
)
|
|
@@ -211,7 +206,6 @@ describe('validateIntent', () => {
|
|
|
211
206
|
it('detects the recipient being an ICAP with an error', async () => {
|
|
212
207
|
const res = await validateIntent(
|
|
213
208
|
context,
|
|
214
|
-
'ethereum',
|
|
215
209
|
eip1559Intent({
|
|
216
210
|
amount: 1n,
|
|
217
211
|
recipient: 'XE89MW3Y75UITCQ4F53YDKR25UFLB1640YM', // ICAP version of recipient address
|
|
@@ -233,7 +227,6 @@ describe('validateIntent', () => {
|
|
|
233
227
|
function nativeSendToRecipient(overrides = {}) {
|
|
234
228
|
return validateIntent(
|
|
235
229
|
context,
|
|
236
|
-
'ethereum',
|
|
237
230
|
eip1559Intent({ amount: 1n, recipient: RECIPIENT, ...overrides }),
|
|
238
231
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
239
232
|
{ value: 0n, parameters: { gasLimit: 21000n, maxFeePerGas: 1n } }
|
|
@@ -322,7 +315,6 @@ describe('validateIntent', () => {
|
|
|
322
315
|
it('detects the recipient not being an EIP55 address with a warning', async () => {
|
|
323
316
|
const res = await validateIntent(
|
|
324
317
|
context,
|
|
325
|
-
'ethereum',
|
|
326
318
|
eip1559Intent({
|
|
327
319
|
amount: 1n,
|
|
328
320
|
recipient: '0xe2ca7390e76c5a992749bb622087310d2e63ca29',
|
|
@@ -342,7 +334,6 @@ describe('validateIntent', () => {
|
|
|
342
334
|
it('detects an intent for a smart contract interaction without amount-related errors', async () => {
|
|
343
335
|
const res = await validateIntent(
|
|
344
336
|
context,
|
|
345
|
-
'ethereum',
|
|
346
337
|
eip1559Intent({
|
|
347
338
|
amount: 0n,
|
|
348
339
|
asset: { type: 'native' },
|
|
@@ -361,7 +352,6 @@ describe('validateIntent', () => {
|
|
|
361
352
|
it('detects an intent for native asset sending without amount with an error', async () => {
|
|
362
353
|
const res = await validateIntent(
|
|
363
354
|
context,
|
|
364
|
-
'ethereum',
|
|
365
355
|
eip1559Intent({
|
|
366
356
|
amount: 0n,
|
|
367
357
|
asset: { type: 'native' },
|
|
@@ -381,7 +371,6 @@ describe('validateIntent', () => {
|
|
|
381
371
|
|
|
382
372
|
const res = await validateIntent(
|
|
383
373
|
context,
|
|
384
|
-
'ethereum',
|
|
385
374
|
eip1559Intent({
|
|
386
375
|
recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29',
|
|
387
376
|
amount: 0n,
|
|
@@ -403,7 +392,6 @@ describe('validateIntent', () => {
|
|
|
403
392
|
it('detects native asset sending intent with an error', async () => {
|
|
404
393
|
const res = await validateIntent(
|
|
405
394
|
context,
|
|
406
|
-
'ethereum',
|
|
407
395
|
eip1559Intent({
|
|
408
396
|
amount: 20n,
|
|
409
397
|
asset: { type: 'native' },
|
|
@@ -449,7 +437,6 @@ describe('validateIntent', () => {
|
|
|
449
437
|
|
|
450
438
|
const res = await validateIntent(
|
|
451
439
|
context,
|
|
452
|
-
'ethereum',
|
|
453
440
|
eip1559Intent({
|
|
454
441
|
sender: 'sender-address',
|
|
455
442
|
recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29',
|
|
@@ -481,7 +468,6 @@ describe('validateIntent', () => {
|
|
|
481
468
|
it('detects NotEnoughBalance when spending would dip into locked funds', async () => {
|
|
482
469
|
const res = await validateIntent(
|
|
483
470
|
context,
|
|
484
|
-
'ethereum',
|
|
485
471
|
eip1559Intent({
|
|
486
472
|
recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29',
|
|
487
473
|
amount: 60n,
|
|
@@ -516,7 +502,6 @@ describe('validateIntent', () => {
|
|
|
516
502
|
|
|
517
503
|
const res = await validateIntent(
|
|
518
504
|
context,
|
|
519
|
-
'ethereum',
|
|
520
505
|
legacyIntent({
|
|
521
506
|
recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29',
|
|
522
507
|
useAllAmount: true,
|
|
@@ -539,7 +524,6 @@ describe('validateIntent', () => {
|
|
|
539
524
|
it('detects missing validator address for delegate with an error', async () => {
|
|
540
525
|
const res = await validateIntent(
|
|
541
526
|
context,
|
|
542
|
-
'sei_evm',
|
|
543
527
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
544
528
|
type: 'staking-legacy',
|
|
545
529
|
mode: 'delegate',
|
|
@@ -563,7 +547,6 @@ describe('validateIntent', () => {
|
|
|
563
547
|
it('detects missing destination validator address for redelegate with an error', async () => {
|
|
564
548
|
const res = await validateIntent(
|
|
565
549
|
context,
|
|
566
|
-
'sei_evm',
|
|
567
550
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
568
551
|
type: 'staking-legacy',
|
|
569
552
|
mode: 'redelegate',
|
|
@@ -587,7 +570,6 @@ describe('validateIntent', () => {
|
|
|
587
570
|
it('detects delegate total spent greater than spendable balance with an error', async () => {
|
|
588
571
|
const res = await validateIntent(
|
|
589
572
|
context,
|
|
590
|
-
'sei_evm',
|
|
591
573
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
592
574
|
type: 'staking-legacy',
|
|
593
575
|
mode: 'delegate',
|
|
@@ -612,7 +594,6 @@ describe('validateIntent', () => {
|
|
|
612
594
|
it('allows undelegate when amount exceeds spendable but fees fit in spendable balance', async () => {
|
|
613
595
|
const res = await validateIntent(
|
|
614
596
|
context,
|
|
615
|
-
'sei_evm',
|
|
616
597
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
617
598
|
type: 'staking-legacy',
|
|
618
599
|
mode: 'undelegate',
|
|
@@ -634,7 +615,6 @@ describe('validateIntent', () => {
|
|
|
634
615
|
it('allows redelegate when amount exceeds spendable but fees fit in spendable balance', async () => {
|
|
635
616
|
const res = await validateIntent(
|
|
636
617
|
context,
|
|
637
|
-
'sei_evm',
|
|
638
618
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
639
619
|
type: 'staking-legacy',
|
|
640
620
|
mode: 'redelegate',
|
|
@@ -657,7 +637,6 @@ describe('validateIntent', () => {
|
|
|
657
637
|
it('detects staking fees greater than native balance with an error', async () => {
|
|
658
638
|
const res = await validateIntent(
|
|
659
639
|
context,
|
|
660
|
-
'sei_evm',
|
|
661
640
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
662
641
|
type: 'staking-legacy',
|
|
663
642
|
mode: 'delegate',
|
|
@@ -682,7 +661,6 @@ describe('validateIntent', () => {
|
|
|
682
661
|
it('should return an error when not enough balance for a claim reward', async () => {
|
|
683
662
|
const res = await validateIntent(
|
|
684
663
|
context,
|
|
685
|
-
'sei_evm',
|
|
686
664
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
687
665
|
type: 'staking-legacy',
|
|
688
666
|
mode: 'claimReward',
|
|
@@ -705,7 +683,6 @@ describe('validateIntent', () => {
|
|
|
705
683
|
it('should return an error when no validator specified for a claim reward', async () => {
|
|
706
684
|
const res = await validateIntent(
|
|
707
685
|
context,
|
|
708
|
-
'sei_evm',
|
|
709
686
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
710
687
|
type: 'staking-legacy',
|
|
711
688
|
mode: 'claimReward',
|
|
@@ -728,7 +705,6 @@ describe('validateIntent', () => {
|
|
|
728
705
|
it('should return no error for a valid claim reward', async () => {
|
|
729
706
|
const res = await validateIntent(
|
|
730
707
|
context,
|
|
731
|
-
'sei_evm',
|
|
732
708
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
733
709
|
type: 'staking-legacy',
|
|
734
710
|
mode: 'claimReward',
|
|
@@ -766,7 +742,6 @@ describe('validateIntent', () => {
|
|
|
766
742
|
const totalFees = 100_000n // gasLimit(100_000) × gasPrice(1)
|
|
767
743
|
const res = await validateIntent(
|
|
768
744
|
context,
|
|
769
|
-
'unknown_chain',
|
|
770
745
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
771
746
|
type: 'staking-legacy',
|
|
772
747
|
mode: 'delegate',
|
|
@@ -789,7 +764,6 @@ describe('validateIntent', () => {
|
|
|
789
764
|
const fees = 2n * 10n ** 17n // > configuredReserve
|
|
790
765
|
const res = await validateIntent(
|
|
791
766
|
seiContext,
|
|
792
|
-
'sei_evm',
|
|
793
767
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
794
768
|
type: 'staking-legacy',
|
|
795
769
|
mode: 'delegate',
|
|
@@ -817,7 +791,6 @@ describe('validateIntent', () => {
|
|
|
817
791
|
const fees = 10n ** 14n // < configuredReserve
|
|
818
792
|
const res = await validateIntent(
|
|
819
793
|
seiContext,
|
|
820
|
-
'sei_evm',
|
|
821
794
|
createStakingTransactionIntentMockData<MemoNotSupported, BufferTxData>({
|
|
822
795
|
type: 'staking-legacy',
|
|
823
796
|
mode: 'delegate',
|
|
@@ -870,7 +843,6 @@ describe('validateIntent', () => {
|
|
|
870
843
|
])('$name', async ({ amount, native }) => {
|
|
871
844
|
const res = await validateIntent(
|
|
872
845
|
context,
|
|
873
|
-
'sei_evm',
|
|
874
846
|
claimRewardIntent({ amount, native }),
|
|
875
847
|
claimRewardBalances(native),
|
|
876
848
|
claimRewardFees
|
|
@@ -897,7 +869,6 @@ describe('validateIntent', () => {
|
|
|
897
869
|
])('$name', async ({ amount, native }) => {
|
|
898
870
|
const res = await validateIntent(
|
|
899
871
|
context,
|
|
900
|
-
'sei_evm',
|
|
901
872
|
claimRewardIntent({ amount, native }),
|
|
902
873
|
claimRewardBalances(native),
|
|
903
874
|
claimRewardFees
|
|
@@ -915,7 +886,6 @@ describe('validateIntent', () => {
|
|
|
915
886
|
it('detects missing fees with an error', async () => {
|
|
916
887
|
const res = await validateIntent(
|
|
917
888
|
context,
|
|
918
|
-
'ethereum',
|
|
919
889
|
createIntent({}),
|
|
920
890
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
921
891
|
{ value: 0n }
|
|
@@ -931,7 +901,6 @@ describe('validateIntent', () => {
|
|
|
931
901
|
it('detects a missing gasLimit with an error', async () => {
|
|
932
902
|
const res = await validateIntent(
|
|
933
903
|
context,
|
|
934
|
-
'ethereum',
|
|
935
904
|
createIntent({}),
|
|
936
905
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
937
906
|
{
|
|
@@ -950,7 +919,6 @@ describe('validateIntent', () => {
|
|
|
950
919
|
it('detects a gasLimit = 0 with an error', async () => {
|
|
951
920
|
const res = await validateIntent(
|
|
952
921
|
context,
|
|
953
|
-
'ethereum',
|
|
954
922
|
createIntent({}),
|
|
955
923
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
956
924
|
{
|
|
@@ -969,7 +937,6 @@ describe('validateIntent', () => {
|
|
|
969
937
|
it('detects a customGasLimit = 0 with an error', async () => {
|
|
970
938
|
const res = await validateIntent(
|
|
971
939
|
context,
|
|
972
|
-
'ethereum',
|
|
973
940
|
createIntent({}),
|
|
974
941
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
975
942
|
{
|
|
@@ -988,7 +955,6 @@ describe('validateIntent', () => {
|
|
|
988
955
|
it('if the recipient has been set, detects fees being too high for the account balance with an error', async () => {
|
|
989
956
|
const notEnoughBalanceRes = await validateIntent(
|
|
990
957
|
context,
|
|
991
|
-
'ethereum',
|
|
992
958
|
createIntent({ recipient: 'recipient-address' }),
|
|
993
959
|
[{ value: 10n, asset: { type: 'native' } }],
|
|
994
960
|
{
|
|
@@ -1003,7 +969,6 @@ describe('validateIntent', () => {
|
|
|
1003
969
|
)
|
|
1004
970
|
const notEnoughBalanceSponsoredRes = await validateIntent(
|
|
1005
971
|
context,
|
|
1006
|
-
'ethereum',
|
|
1007
972
|
createIntent({ recipient: 'recipient-address' }),
|
|
1008
973
|
[{ value: 10n, asset: { type: 'native' } }],
|
|
1009
974
|
{
|
|
@@ -1019,7 +984,6 @@ describe('validateIntent', () => {
|
|
|
1019
984
|
)
|
|
1020
985
|
const enoughBalanceRes = await validateIntent(
|
|
1021
986
|
context,
|
|
1022
|
-
'ethereum',
|
|
1023
987
|
createIntent({ recipient: 'recipient-address' }),
|
|
1024
988
|
[{ value: 10n, asset: { type: 'native' } }],
|
|
1025
989
|
{
|
|
@@ -1050,12 +1014,46 @@ describe('validateIntent', () => {
|
|
|
1050
1014
|
)
|
|
1051
1015
|
})
|
|
1052
1016
|
|
|
1017
|
+
it('renders the native unit and network name in NotEnoughGas for Alpen', async () => {
|
|
1018
|
+
const alpenContext = createMockEvmContext(
|
|
1019
|
+
createMockEvmConfigInfo({
|
|
1020
|
+
chainId: CHAIN_ID.ALPEN_TESTNET,
|
|
1021
|
+
node: mkLedgerNode({ explorerId: 'eth' }),
|
|
1022
|
+
name: 'Alpen Testnet',
|
|
1023
|
+
unit: { name: 'BTC', code: 'BTC', magnitude: 18 },
|
|
1024
|
+
explorer: mkLedgerExplorer({ explorerId: 'eth' }),
|
|
1025
|
+
gasTracker: mkLedgerGasTracker({ explorerId: 'eth' }),
|
|
1026
|
+
})
|
|
1027
|
+
)
|
|
1028
|
+
|
|
1029
|
+
const res = await validateIntent(
|
|
1030
|
+
alpenContext,
|
|
1031
|
+
createIntent({ recipient: 'recipient-address' }),
|
|
1032
|
+
[{ value: 10n, asset: { type: 'native' } }],
|
|
1033
|
+
{
|
|
1034
|
+
value: 11n,
|
|
1035
|
+
parameters: {
|
|
1036
|
+
gasLimit: 11n,
|
|
1037
|
+
gasPrice: 1n,
|
|
1038
|
+
maxFeePerGas: 1n,
|
|
1039
|
+
maxPriorityFeePerGas: 1n,
|
|
1040
|
+
},
|
|
1041
|
+
}
|
|
1042
|
+
)
|
|
1043
|
+
|
|
1044
|
+
expect(res.errors.gasPrice).toBeInstanceOf(NotEnoughGas)
|
|
1045
|
+
expect(res.errors.gasPrice).toMatchObject({
|
|
1046
|
+
ticker: 'BTC',
|
|
1047
|
+
cryptoName: 'Alpen Testnet',
|
|
1048
|
+
fees: expect.stringMatching(/\S/),
|
|
1049
|
+
})
|
|
1050
|
+
})
|
|
1051
|
+
|
|
1053
1052
|
it('includes additionalFees (L2 L1-data fee) when deciding NotEnoughGas', async () => {
|
|
1054
1053
|
// gas fee alone fits in the available balance, but the additionalFees
|
|
1055
1054
|
// (e.g. L1 data fee on L2s) push the total above the native balance.
|
|
1056
1055
|
const res = await validateIntent(
|
|
1057
1056
|
context,
|
|
1058
|
-
'ethereum',
|
|
1059
1057
|
createIntent({ recipient: 'recipient-address' }),
|
|
1060
1058
|
[{ value: 10n, asset: { type: 'native' } }],
|
|
1061
1059
|
{
|
|
@@ -1080,7 +1078,6 @@ describe('validateIntent', () => {
|
|
|
1080
1078
|
it('if the recipient has not been set, does not detect gas being too high', async () => {
|
|
1081
1079
|
const notEnoughBalanceRes = await validateIntent(
|
|
1082
1080
|
context,
|
|
1083
|
-
'ethereum',
|
|
1084
1081
|
createIntent({ recipient: '' }),
|
|
1085
1082
|
[{ value: 10n, asset: { type: 'native' } }],
|
|
1086
1083
|
{
|
|
@@ -1094,7 +1091,6 @@ describe('validateIntent', () => {
|
|
|
1094
1091
|
)
|
|
1095
1092
|
const enoughBalanceRes = await validateIntent(
|
|
1096
1093
|
context,
|
|
1097
|
-
'ethereum',
|
|
1098
1094
|
createIntent({ recipient: '' }),
|
|
1099
1095
|
[{ value: 10n, asset: { type: 'native' } }],
|
|
1100
1096
|
{
|
|
@@ -1125,7 +1121,6 @@ describe('validateIntent', () => {
|
|
|
1125
1121
|
|
|
1126
1122
|
const res = await validateIntent(
|
|
1127
1123
|
context,
|
|
1128
|
-
'ethereum',
|
|
1129
1124
|
createIntent({}),
|
|
1130
1125
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1131
1126
|
{
|
|
@@ -1149,7 +1144,6 @@ describe('validateIntent', () => {
|
|
|
1149
1144
|
|
|
1150
1145
|
const res = await validateIntent(
|
|
1151
1146
|
context,
|
|
1152
|
-
'ethereum',
|
|
1153
1147
|
createIntent({}),
|
|
1154
1148
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1155
1149
|
{
|
|
@@ -1182,7 +1176,6 @@ describe('validateIntent', () => {
|
|
|
1182
1176
|
|
|
1183
1177
|
await validateIntent(
|
|
1184
1178
|
context,
|
|
1185
|
-
'ethereum',
|
|
1186
1179
|
createIntent({}),
|
|
1187
1180
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1188
1181
|
{ value: 0n, parameters: { gasLimit: 21000n } }
|
|
@@ -1198,7 +1191,6 @@ describe('validateIntent', () => {
|
|
|
1198
1191
|
it('forwards the EIP-7623 defaults when the coin config sets none', async () => {
|
|
1199
1192
|
await validateIntent(
|
|
1200
1193
|
context,
|
|
1201
|
-
'ethereum',
|
|
1202
1194
|
createIntent({}),
|
|
1203
1195
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1204
1196
|
{ value: 0n, parameters: { gasLimit: 21000n } }
|
|
@@ -1215,7 +1207,6 @@ describe('validateIntent', () => {
|
|
|
1215
1207
|
it('detects customGasLimit being lower than gasLimit with a warning', async () => {
|
|
1216
1208
|
const res = await validateIntent(
|
|
1217
1209
|
context,
|
|
1218
|
-
'ethereum',
|
|
1219
1210
|
createIntent({}),
|
|
1220
1211
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1221
1212
|
{
|
|
@@ -1240,7 +1231,6 @@ describe('validateIntent', () => {
|
|
|
1240
1231
|
it('detects a maxPriorityFeePerGas = 0 with an error', async () => {
|
|
1241
1232
|
const res = await validateIntent(
|
|
1242
1233
|
context,
|
|
1243
|
-
'ethereum',
|
|
1244
1234
|
eip1559Intent({}),
|
|
1245
1235
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1246
1236
|
{
|
|
@@ -1259,7 +1249,6 @@ describe('validateIntent', () => {
|
|
|
1259
1249
|
it('detects maxFeePerGas being greater than max gasOptions maxFeePerGas with an error', async () => {
|
|
1260
1250
|
const res = await validateIntent(
|
|
1261
1251
|
context,
|
|
1262
|
-
'ethereum',
|
|
1263
1252
|
eip1559Intent({}),
|
|
1264
1253
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1265
1254
|
{
|
|
@@ -1299,7 +1288,6 @@ describe('validateIntent', () => {
|
|
|
1299
1288
|
|
|
1300
1289
|
const res = await validateIntent(
|
|
1301
1290
|
context,
|
|
1302
|
-
'ethereum',
|
|
1303
1291
|
eip1559Intent({}),
|
|
1304
1292
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1305
1293
|
{
|
|
@@ -1339,7 +1327,6 @@ describe('validateIntent', () => {
|
|
|
1339
1327
|
|
|
1340
1328
|
const res = await validateIntent(
|
|
1341
1329
|
context,
|
|
1342
|
-
'ethereum',
|
|
1343
1330
|
eip1559Intent({}),
|
|
1344
1331
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1345
1332
|
{
|
|
@@ -1379,7 +1366,6 @@ describe('validateIntent', () => {
|
|
|
1379
1366
|
|
|
1380
1367
|
const res = await validateIntent(
|
|
1381
1368
|
context,
|
|
1382
|
-
'ethereum',
|
|
1383
1369
|
eip1559Intent({}),
|
|
1384
1370
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1385
1371
|
{
|
|
@@ -1411,7 +1397,6 @@ describe('validateIntent', () => {
|
|
|
1411
1397
|
it('raises an error when maxPriorityFeePerGas is below the chain minGasPrice', async () => {
|
|
1412
1398
|
const res = await validateIntent(
|
|
1413
1399
|
context,
|
|
1414
|
-
'ethereum',
|
|
1415
1400
|
eip1559Intent({}),
|
|
1416
1401
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1417
1402
|
{
|
|
@@ -1430,7 +1415,6 @@ describe('validateIntent', () => {
|
|
|
1430
1415
|
it('does not raise an error when maxPriorityFeePerGas is above the chain minGasPrice', async () => {
|
|
1431
1416
|
const res = await validateIntent(
|
|
1432
1417
|
context,
|
|
1433
|
-
'ethereum',
|
|
1434
1418
|
eip1559Intent({}),
|
|
1435
1419
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1436
1420
|
{
|
|
@@ -1465,7 +1449,6 @@ describe('validateIntent', () => {
|
|
|
1465
1449
|
it('raises an error when gasPrice is below the chain minGasPrice', async () => {
|
|
1466
1450
|
const res = await validateIntent(
|
|
1467
1451
|
context,
|
|
1468
|
-
'ethereum',
|
|
1469
1452
|
legacyIntent({ recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29' }),
|
|
1470
1453
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1471
1454
|
{
|
|
@@ -1484,7 +1467,6 @@ describe('validateIntent', () => {
|
|
|
1484
1467
|
it('does not raise an error when gasPrice is above the chain minGasPrice', async () => {
|
|
1485
1468
|
const res = await validateIntent(
|
|
1486
1469
|
context,
|
|
1487
|
-
'ethereum',
|
|
1488
1470
|
legacyIntent({ recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29' }),
|
|
1489
1471
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1490
1472
|
{
|
|
@@ -1628,7 +1610,6 @@ describe('validateIntent', () => {
|
|
|
1628
1610
|
|
|
1629
1611
|
const res = await validateIntent(
|
|
1630
1612
|
context,
|
|
1631
|
-
'ethereum',
|
|
1632
1613
|
legacyIntent({
|
|
1633
1614
|
...amount,
|
|
1634
1615
|
recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29',
|
|
@@ -1704,7 +1685,6 @@ describe('validateIntent', () => {
|
|
|
1704
1685
|
|
|
1705
1686
|
const res = await validateIntent(
|
|
1706
1687
|
context,
|
|
1707
|
-
'ethereum',
|
|
1708
1688
|
eip1559Intent({
|
|
1709
1689
|
...amount,
|
|
1710
1690
|
recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29',
|
|
@@ -1785,7 +1765,6 @@ describe('validateIntent', () => {
|
|
|
1785
1765
|
|
|
1786
1766
|
const res = await validateIntent(
|
|
1787
1767
|
context,
|
|
1788
|
-
'ethereum',
|
|
1789
1768
|
eip1559Intent({
|
|
1790
1769
|
...amount,
|
|
1791
1770
|
recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29',
|
|
@@ -1851,7 +1830,6 @@ describe('validateIntent', () => {
|
|
|
1851
1830
|
expect(
|
|
1852
1831
|
await validateIntent(
|
|
1853
1832
|
context,
|
|
1854
|
-
'ethereum',
|
|
1855
1833
|
createIntent({
|
|
1856
1834
|
amount: 2n,
|
|
1857
1835
|
recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29',
|
|
@@ -455,15 +455,14 @@ function refreshEstimationValue(
|
|
|
455
455
|
|
|
456
456
|
export async function validateIntent(
|
|
457
457
|
context: EvmContext,
|
|
458
|
-
currencyId: string,
|
|
459
458
|
intent: TransactionIntent<MemoNotSupported, BufferTxData>,
|
|
460
459
|
balances: Balance[],
|
|
461
460
|
customFees?: FeeEstimation
|
|
462
461
|
): Promise<TransactionValidation> {
|
|
463
|
-
const config = await context.config(
|
|
462
|
+
const config = await context.config()
|
|
464
463
|
const estimatedFees = customFees?.parameters
|
|
465
464
|
? { ...customFees, value: refreshEstimationValue(intent, customFees.parameters) }
|
|
466
|
-
: await estimateFees(context,
|
|
465
|
+
: await estimateFees(context, intent)
|
|
467
466
|
const balance = findBalance(intent.asset, balances)
|
|
468
467
|
const amount = computeAmount(config.chainId, intent, estimatedFees, balance)
|
|
469
468
|
const additionalFees =
|
package/src/logic.test.ts
CHANGED
|
@@ -8,12 +8,12 @@ jest.mock('./network/node/index', () => ({
|
|
|
8
8
|
),
|
|
9
9
|
}))
|
|
10
10
|
|
|
11
|
-
import { CHAIN_ID } from './config'
|
|
11
|
+
import { CHAIN_ID, OP_STACK_L1_FEE_CHAIN_IDS } from './config'
|
|
12
12
|
import { createMockEvmConfigInfo, mkExternalNode, testLogger } from './fixtures/context.fixtures'
|
|
13
13
|
import { getAdditionalLayer2Fees } from './logic'
|
|
14
14
|
import { padHexString, safeEncodeEIP55 } from './logic-public'
|
|
15
15
|
import { getNodeApi } from './network/node/index'
|
|
16
|
-
import { mockNodeApi } from './network/node/node.fixtures'
|
|
16
|
+
import { mockNodeApi } from './network/tests/node/node.fixtures'
|
|
17
17
|
|
|
18
18
|
const mockGetNodeApi = jest.mocked(getNodeApi)
|
|
19
19
|
const nodeApiMock = mockNodeApi()
|
|
@@ -45,12 +45,29 @@ describe('EVM Family', () => {
|
|
|
45
45
|
expect(mockGetScrollAdditionalFees).toHaveBeenCalled()
|
|
46
46
|
})
|
|
47
47
|
|
|
48
|
-
it(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
it.each(OP_STACK_L1_FEE_CHAIN_IDS)(
|
|
49
|
+
'should get the OP Stack L1 data fee for chain %s',
|
|
50
|
+
async (chainId) => {
|
|
51
|
+
const cfg = createMockEvmConfigInfo({ chainId, node: mkExternalNode() })
|
|
52
|
+
await getAdditionalLayer2Fees(cfg, '', testLogger)
|
|
53
|
+
expect(mockGetOptimismAdditionalFees).toHaveBeenCalled()
|
|
54
|
+
expect(mockGetScrollAdditionalFees).not.toHaveBeenCalled()
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
it('should include Shape in the OP Stack chains', () => {
|
|
59
|
+
expect(OP_STACK_L1_FEE_CHAIN_IDS).toContain(CHAIN_ID.SHAPE)
|
|
53
60
|
})
|
|
61
|
+
|
|
62
|
+
it.each([CHAIN_ID.ETHEREUM, CHAIN_ID.ARBITRUM, CHAIN_ID.LINEA])(
|
|
63
|
+
'should not try to get additionalFees for chain %s',
|
|
64
|
+
async (chainId) => {
|
|
65
|
+
const cfg = createMockEvmConfigInfo({ chainId, node: mkExternalNode() })
|
|
66
|
+
await getAdditionalLayer2Fees(cfg, '', testLogger)
|
|
67
|
+
expect(mockGetOptimismAdditionalFees).not.toHaveBeenCalled()
|
|
68
|
+
expect(mockGetScrollAdditionalFees).not.toHaveBeenCalled()
|
|
69
|
+
}
|
|
70
|
+
)
|
|
54
71
|
})
|
|
55
72
|
|
|
56
73
|
describe('padHexString', () => {
|
package/src/logic.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import type { EvmConfigInfo } from './config'
|
|
5
5
|
import type { Logger } from '@ledgerhq/coin-module-framework/config'
|
|
6
6
|
import type BigNumber from 'bignumber.js'
|
|
7
|
-
import { CHAIN_ID } from './config'
|
|
7
|
+
import { CHAIN_ID, OP_STACK_L1_FEE_CHAIN_IDS } from './config'
|
|
8
8
|
import { getNodeApi } from './network/node/index'
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -16,17 +16,12 @@ export const getAdditionalLayer2Fees = async (
|
|
|
16
16
|
transaction: string,
|
|
17
17
|
logger: Logger
|
|
18
18
|
): Promise<BigNumber | undefined> => {
|
|
19
|
+
if (OP_STACK_L1_FEE_CHAIN_IDS.includes(config.chainId)) {
|
|
20
|
+
const nodeApi = getNodeApi(config, logger)
|
|
21
|
+
const additionalFees = await nodeApi.getOptimismAdditionalFees(transaction)
|
|
22
|
+
return additionalFees
|
|
23
|
+
}
|
|
19
24
|
switch (config.chainId) {
|
|
20
|
-
case CHAIN_ID.OPTIMISM:
|
|
21
|
-
case CHAIN_ID.OPTIMISM_SEPOLIA:
|
|
22
|
-
case CHAIN_ID.BLAST:
|
|
23
|
-
case CHAIN_ID.BLAST_SEPOLIA:
|
|
24
|
-
case CHAIN_ID.BASE:
|
|
25
|
-
case CHAIN_ID.BASE_SEPOLIA: {
|
|
26
|
-
const nodeApi = getNodeApi(config, logger)
|
|
27
|
-
const additionalFees = await nodeApi.getOptimismAdditionalFees(transaction)
|
|
28
|
-
return additionalFees
|
|
29
|
-
}
|
|
30
25
|
case CHAIN_ID.SCROLL: {
|
|
31
26
|
const nodeApi = getNodeApi(config, logger)
|
|
32
27
|
const additionalFees = await nodeApi.getScrollAdditionalFees(transaction)
|
|
@@ -187,6 +187,7 @@ export async function getTransactionFromExplorerProxy(
|
|
|
187
187
|
parseHexBigInt(receipt.gasPrice) ??
|
|
188
188
|
parseHexBigInt(tx.gasPrice) ??
|
|
189
189
|
0n
|
|
190
|
+
const gasLimitBig = parseHexBigInt(tx.gas)
|
|
190
191
|
const statusBig = parseHexBigInt(receipt.status)
|
|
191
192
|
const blockNumberBig = parseHexBigInt(tx.blockNumber)
|
|
192
193
|
const txTypeBig = parseHexBigInt(receipt.type) ?? parseHexBigInt(tx.type)
|
|
@@ -241,6 +242,7 @@ export async function getTransactionFromExplorerProxy(
|
|
|
241
242
|
nonce: Number(nonceBig),
|
|
242
243
|
gasUsed: gasUsedBig.toString(),
|
|
243
244
|
gasPrice: gasPriceBig.toString(),
|
|
245
|
+
...(gasLimitBig !== null ? { gasLimit: gasLimitBig.toString() } : {}),
|
|
244
246
|
status: statusBig !== null ? Number(statusBig) : null,
|
|
245
247
|
value: valueBig.toString(),
|
|
246
248
|
from,
|
|
@@ -14,7 +14,7 @@ import { ethers } from 'ethers'
|
|
|
14
14
|
import { toInterfaceAbi } from '../../abis'
|
|
15
15
|
import ERC20Abi from '../../abis/erc20.abi.json'
|
|
16
16
|
import OptimismGasPriceOracleAbi from '../../abis/optimismGasPriceOracle.abi.json'
|
|
17
|
-
import { CHAIN_ID } from '../../config'
|
|
17
|
+
import { CHAIN_ID, OP_STACK_L1_FEE_CHAIN_IDS } from '../../config'
|
|
18
18
|
import { GasEstimationError } from '../../errors'
|
|
19
19
|
import { normalizeAddress, padHexString, safeEncodeEIP55 } from '../../logic-public'
|
|
20
20
|
import { getGasOptions } from '../gasTracker/ledger'
|
|
@@ -79,6 +79,7 @@ async function getTransaction(
|
|
|
79
79
|
blockHash: ledgerTransaction.block?.hash,
|
|
80
80
|
nonce: ledgerTransaction.nonce_value,
|
|
81
81
|
gasPrice: ledgerTransaction.gas_price,
|
|
82
|
+
...(ledgerTransaction.gas ? { gasLimit: ledgerTransaction.gas } : {}),
|
|
82
83
|
gasUsed: ledgerTransaction.gas_used,
|
|
83
84
|
value: ledgerTransaction.value,
|
|
84
85
|
status: ledgerTransaction.status,
|
|
@@ -287,15 +288,7 @@ async function getOptimismAdditionalFees(
|
|
|
287
288
|
config: LedgerNodeApiConfig,
|
|
288
289
|
transaction: string
|
|
289
290
|
): Promise<BigNumber> {
|
|
290
|
-
|
|
291
|
-
CHAIN_ID.OPTIMISM,
|
|
292
|
-
CHAIN_ID.OPTIMISM_SEPOLIA,
|
|
293
|
-
CHAIN_ID.BLAST,
|
|
294
|
-
CHAIN_ID.BLAST_SEPOLIA,
|
|
295
|
-
CHAIN_ID.BASE,
|
|
296
|
-
CHAIN_ID.BASE_SEPOLIA,
|
|
297
|
-
]
|
|
298
|
-
if (!optimismFeeChainIds.includes(config.chainId)) {
|
|
291
|
+
if (!OP_STACK_L1_FEE_CHAIN_IDS.includes(config.chainId)) {
|
|
299
292
|
return new BigNumber(0)
|
|
300
293
|
}
|
|
301
294
|
if (!transaction) {
|