@ledgerhq/coin-evm 15.2.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 +24 -0
- package/lib/api/index.d.ts +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +14 -14
- package/lib/api/index.js.map +1 -1
- package/lib/chains.d.ts +6 -0
- package/lib/chains.d.ts.map +1 -1
- package/lib/chains.js +16 -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 +2 -2
- 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 +2 -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/ledger.d.ts.map +1 -1
- package/lib/network/node/ledger.js +1 -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 +1 -9
- package/lib/network/node/rpc.common.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/api/index.d.ts +1 -1
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +14 -14
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/chains.d.ts +6 -0
- package/lib-es/chains.d.ts.map +1 -1
- package/lib-es/chains.js +15 -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 +2 -2
- 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 +2 -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/ledger.d.ts.map +1 -1
- package/lib-es/network/node/ledger.js +2 -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 +2 -10
- package/lib-es/network/node/rpc.common.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 +1 -1
- package/src/api/index.ts +14 -16
- package/src/api/tests/getBlock.integ.test.ts +3 -3
- package/src/api/tests/index.arbitrum.integ.test.ts +1 -1
- package/src/api/tests/index.arc.integ.test.ts +1 -1
- package/src/api/tests/index.avalanche_c_chain_fuji.integ.test.ts +1 -1
- package/src/api/tests/index.cronos.integ.test.ts +1 -1
- package/src/api/tests/index.flare.integ.test.ts +1 -1
- package/src/api/tests/index.integ.test.ts +5 -5
- package/src/api/tests/index.linea.integ.test.ts +1 -1
- package/src/api/tests/index.monad_testnet.integ.test.ts +1 -1
- package/src/api/tests/index.optimism.integ.test.ts +1 -1
- package/src/api/tests/index.rsk.integ.test.ts +1 -1
- package/src/api/tests/index.shape.integ.test.ts +1 -1
- package/src/api/tests/index.somnia.integ.test.ts +1 -1
- package/src/api/tests/index.test.ts +6 -6
- package/src/api/tests/index.zksync.integ.test.ts +1 -1
- package/src/chains.ts +16 -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 +2 -6
- 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 +1 -2
- package/src/logic/tests/broadcast.integ.test.ts +1 -1
- package/src/logic/tests/broadcast.test.ts +4 -4
- package/src/logic/tests/broadcastSource.test.ts +3 -3
- package/src/logic/tests/craftTransaction.test.ts +15 -20
- package/src/logic/tests/estimateFees.test.ts +39 -17
- package/src/logic/tests/getBalance.test.ts +19 -22
- package/src/logic/tests/getBlock.test.ts +37 -38
- package/src/logic/tests/getBlockInfo.test.ts +5 -5
- package/src/logic/tests/getNextSequence.test.ts +1 -1
- package/src/logic/tests/getStakes.test.ts +14 -14
- package/src/logic/tests/lastBlock.test.ts +3 -3
- package/src/logic/tests/listOperations.test.ts +46 -52
- package/src/logic/tests/validateIntent.test.ts +3 -61
- package/src/logic/validateIntent.ts +2 -3
- package/src/logic.test.ts +23 -6
- package/src/logic.ts +6 -11
- package/src/network/node/ledger.ts +2 -10
- package/src/network/node/rpc.common.ts +2 -10
- package/src/network/tests/explorer/index.test.ts +4 -4
- package/src/network/tests/node/ledger.test.ts +2 -0
- package/src/network/tests/node/rpc.test.ts +42 -0
- 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
|
@@ -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
|
{
|
|
@@ -1064,7 +1028,6 @@ describe('validateIntent', () => {
|
|
|
1064
1028
|
|
|
1065
1029
|
const res = await validateIntent(
|
|
1066
1030
|
alpenContext,
|
|
1067
|
-
'alpen_testnet',
|
|
1068
1031
|
createIntent({ recipient: 'recipient-address' }),
|
|
1069
1032
|
[{ value: 10n, asset: { type: 'native' } }],
|
|
1070
1033
|
{
|
|
@@ -1091,7 +1054,6 @@ describe('validateIntent', () => {
|
|
|
1091
1054
|
// (e.g. L1 data fee on L2s) push the total above the native balance.
|
|
1092
1055
|
const res = await validateIntent(
|
|
1093
1056
|
context,
|
|
1094
|
-
'ethereum',
|
|
1095
1057
|
createIntent({ recipient: 'recipient-address' }),
|
|
1096
1058
|
[{ value: 10n, asset: { type: 'native' } }],
|
|
1097
1059
|
{
|
|
@@ -1116,7 +1078,6 @@ describe('validateIntent', () => {
|
|
|
1116
1078
|
it('if the recipient has not been set, does not detect gas being too high', async () => {
|
|
1117
1079
|
const notEnoughBalanceRes = await validateIntent(
|
|
1118
1080
|
context,
|
|
1119
|
-
'ethereum',
|
|
1120
1081
|
createIntent({ recipient: '' }),
|
|
1121
1082
|
[{ value: 10n, asset: { type: 'native' } }],
|
|
1122
1083
|
{
|
|
@@ -1130,7 +1091,6 @@ describe('validateIntent', () => {
|
|
|
1130
1091
|
)
|
|
1131
1092
|
const enoughBalanceRes = await validateIntent(
|
|
1132
1093
|
context,
|
|
1133
|
-
'ethereum',
|
|
1134
1094
|
createIntent({ recipient: '' }),
|
|
1135
1095
|
[{ value: 10n, asset: { type: 'native' } }],
|
|
1136
1096
|
{
|
|
@@ -1161,7 +1121,6 @@ describe('validateIntent', () => {
|
|
|
1161
1121
|
|
|
1162
1122
|
const res = await validateIntent(
|
|
1163
1123
|
context,
|
|
1164
|
-
'ethereum',
|
|
1165
1124
|
createIntent({}),
|
|
1166
1125
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1167
1126
|
{
|
|
@@ -1185,7 +1144,6 @@ describe('validateIntent', () => {
|
|
|
1185
1144
|
|
|
1186
1145
|
const res = await validateIntent(
|
|
1187
1146
|
context,
|
|
1188
|
-
'ethereum',
|
|
1189
1147
|
createIntent({}),
|
|
1190
1148
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1191
1149
|
{
|
|
@@ -1218,7 +1176,6 @@ describe('validateIntent', () => {
|
|
|
1218
1176
|
|
|
1219
1177
|
await validateIntent(
|
|
1220
1178
|
context,
|
|
1221
|
-
'ethereum',
|
|
1222
1179
|
createIntent({}),
|
|
1223
1180
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1224
1181
|
{ value: 0n, parameters: { gasLimit: 21000n } }
|
|
@@ -1234,7 +1191,6 @@ describe('validateIntent', () => {
|
|
|
1234
1191
|
it('forwards the EIP-7623 defaults when the coin config sets none', async () => {
|
|
1235
1192
|
await validateIntent(
|
|
1236
1193
|
context,
|
|
1237
|
-
'ethereum',
|
|
1238
1194
|
createIntent({}),
|
|
1239
1195
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1240
1196
|
{ value: 0n, parameters: { gasLimit: 21000n } }
|
|
@@ -1251,7 +1207,6 @@ describe('validateIntent', () => {
|
|
|
1251
1207
|
it('detects customGasLimit being lower than gasLimit with a warning', async () => {
|
|
1252
1208
|
const res = await validateIntent(
|
|
1253
1209
|
context,
|
|
1254
|
-
'ethereum',
|
|
1255
1210
|
createIntent({}),
|
|
1256
1211
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1257
1212
|
{
|
|
@@ -1276,7 +1231,6 @@ describe('validateIntent', () => {
|
|
|
1276
1231
|
it('detects a maxPriorityFeePerGas = 0 with an error', async () => {
|
|
1277
1232
|
const res = await validateIntent(
|
|
1278
1233
|
context,
|
|
1279
|
-
'ethereum',
|
|
1280
1234
|
eip1559Intent({}),
|
|
1281
1235
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1282
1236
|
{
|
|
@@ -1295,7 +1249,6 @@ describe('validateIntent', () => {
|
|
|
1295
1249
|
it('detects maxFeePerGas being greater than max gasOptions maxFeePerGas with an error', async () => {
|
|
1296
1250
|
const res = await validateIntent(
|
|
1297
1251
|
context,
|
|
1298
|
-
'ethereum',
|
|
1299
1252
|
eip1559Intent({}),
|
|
1300
1253
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1301
1254
|
{
|
|
@@ -1335,7 +1288,6 @@ describe('validateIntent', () => {
|
|
|
1335
1288
|
|
|
1336
1289
|
const res = await validateIntent(
|
|
1337
1290
|
context,
|
|
1338
|
-
'ethereum',
|
|
1339
1291
|
eip1559Intent({}),
|
|
1340
1292
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1341
1293
|
{
|
|
@@ -1375,7 +1327,6 @@ describe('validateIntent', () => {
|
|
|
1375
1327
|
|
|
1376
1328
|
const res = await validateIntent(
|
|
1377
1329
|
context,
|
|
1378
|
-
'ethereum',
|
|
1379
1330
|
eip1559Intent({}),
|
|
1380
1331
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1381
1332
|
{
|
|
@@ -1415,7 +1366,6 @@ describe('validateIntent', () => {
|
|
|
1415
1366
|
|
|
1416
1367
|
const res = await validateIntent(
|
|
1417
1368
|
context,
|
|
1418
|
-
'ethereum',
|
|
1419
1369
|
eip1559Intent({}),
|
|
1420
1370
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1421
1371
|
{
|
|
@@ -1447,7 +1397,6 @@ describe('validateIntent', () => {
|
|
|
1447
1397
|
it('raises an error when maxPriorityFeePerGas is below the chain minGasPrice', async () => {
|
|
1448
1398
|
const res = await validateIntent(
|
|
1449
1399
|
context,
|
|
1450
|
-
'ethereum',
|
|
1451
1400
|
eip1559Intent({}),
|
|
1452
1401
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1453
1402
|
{
|
|
@@ -1466,7 +1415,6 @@ describe('validateIntent', () => {
|
|
|
1466
1415
|
it('does not raise an error when maxPriorityFeePerGas is above the chain minGasPrice', async () => {
|
|
1467
1416
|
const res = await validateIntent(
|
|
1468
1417
|
context,
|
|
1469
|
-
'ethereum',
|
|
1470
1418
|
eip1559Intent({}),
|
|
1471
1419
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1472
1420
|
{
|
|
@@ -1501,7 +1449,6 @@ describe('validateIntent', () => {
|
|
|
1501
1449
|
it('raises an error when gasPrice is below the chain minGasPrice', async () => {
|
|
1502
1450
|
const res = await validateIntent(
|
|
1503
1451
|
context,
|
|
1504
|
-
'ethereum',
|
|
1505
1452
|
legacyIntent({ recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29' }),
|
|
1506
1453
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1507
1454
|
{
|
|
@@ -1520,7 +1467,6 @@ describe('validateIntent', () => {
|
|
|
1520
1467
|
it('does not raise an error when gasPrice is above the chain minGasPrice', async () => {
|
|
1521
1468
|
const res = await validateIntent(
|
|
1522
1469
|
context,
|
|
1523
|
-
'ethereum',
|
|
1524
1470
|
legacyIntent({ recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29' }),
|
|
1525
1471
|
[{ value: 50n, asset: { type: 'native' } }],
|
|
1526
1472
|
{
|
|
@@ -1664,7 +1610,6 @@ describe('validateIntent', () => {
|
|
|
1664
1610
|
|
|
1665
1611
|
const res = await validateIntent(
|
|
1666
1612
|
context,
|
|
1667
|
-
'ethereum',
|
|
1668
1613
|
legacyIntent({
|
|
1669
1614
|
...amount,
|
|
1670
1615
|
recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29',
|
|
@@ -1740,7 +1685,6 @@ describe('validateIntent', () => {
|
|
|
1740
1685
|
|
|
1741
1686
|
const res = await validateIntent(
|
|
1742
1687
|
context,
|
|
1743
|
-
'ethereum',
|
|
1744
1688
|
eip1559Intent({
|
|
1745
1689
|
...amount,
|
|
1746
1690
|
recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29',
|
|
@@ -1821,7 +1765,6 @@ describe('validateIntent', () => {
|
|
|
1821
1765
|
|
|
1822
1766
|
const res = await validateIntent(
|
|
1823
1767
|
context,
|
|
1824
|
-
'ethereum',
|
|
1825
1768
|
eip1559Intent({
|
|
1826
1769
|
...amount,
|
|
1827
1770
|
recipient: '0xe2ca7390e76c5A992749bB622087310d2e63ca29',
|
|
@@ -1887,7 +1830,6 @@ describe('validateIntent', () => {
|
|
|
1887
1830
|
expect(
|
|
1888
1831
|
await validateIntent(
|
|
1889
1832
|
context,
|
|
1890
|
-
'ethereum',
|
|
1891
1833
|
createIntent({
|
|
1892
1834
|
amount: 2n,
|
|
1893
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,7 +8,7 @@ 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'
|
|
@@ -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)
|
|
@@ -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'
|
|
@@ -288,15 +288,7 @@ async function getOptimismAdditionalFees(
|
|
|
288
288
|
config: LedgerNodeApiConfig,
|
|
289
289
|
transaction: string
|
|
290
290
|
): Promise<BigNumber> {
|
|
291
|
-
|
|
292
|
-
CHAIN_ID.OPTIMISM,
|
|
293
|
-
CHAIN_ID.OPTIMISM_SEPOLIA,
|
|
294
|
-
CHAIN_ID.BLAST,
|
|
295
|
-
CHAIN_ID.BLAST_SEPOLIA,
|
|
296
|
-
CHAIN_ID.BASE,
|
|
297
|
-
CHAIN_ID.BASE_SEPOLIA,
|
|
298
|
-
]
|
|
299
|
-
if (!optimismFeeChainIds.includes(config.chainId)) {
|
|
291
|
+
if (!OP_STACK_L1_FEE_CHAIN_IDS.includes(config.chainId)) {
|
|
300
292
|
return new BigNumber(0)
|
|
301
293
|
}
|
|
302
294
|
if (!transaction) {
|
|
@@ -22,7 +22,7 @@ import { ethers, FetchRequest, JsonRpcProvider } from 'ethers'
|
|
|
22
22
|
import ERC20Abi from '../../abis/erc20.abi.json'
|
|
23
23
|
import OptimismGasPriceOracleAbi from '../../abis/optimismGasPriceOracle.abi.json'
|
|
24
24
|
import ScrollGasPriceOracleAbi from '../../abis/scrollGasPriceOracle.abi.json'
|
|
25
|
-
import { CHAIN_ID } from '../../config'
|
|
25
|
+
import { CHAIN_ID, OP_STACK_L1_FEE_CHAIN_IDS } from '../../config'
|
|
26
26
|
import { GasEstimationError, InsufficientFunds, UnsupportedRpcMethodError } from '../../errors'
|
|
27
27
|
import { isSmartContractInput, safeEncodeEIP55, normalizeAddress } from '../../logic-public'
|
|
28
28
|
import {
|
|
@@ -914,15 +914,7 @@ async function getOptimismAdditionalFees(
|
|
|
914
914
|
chainId: ChainId,
|
|
915
915
|
transaction: string
|
|
916
916
|
): Promise<BigNumber> {
|
|
917
|
-
|
|
918
|
-
CHAIN_ID.OPTIMISM,
|
|
919
|
-
CHAIN_ID.OPTIMISM_SEPOLIA,
|
|
920
|
-
CHAIN_ID.BASE,
|
|
921
|
-
CHAIN_ID.BASE_SEPOLIA,
|
|
922
|
-
CHAIN_ID.BLAST,
|
|
923
|
-
CHAIN_ID.BLAST_SEPOLIA,
|
|
924
|
-
]
|
|
925
|
-
if (!optimismFeeChainIds.includes(chainId)) {
|
|
917
|
+
if (!OP_STACK_L1_FEE_CHAIN_IDS.includes(chainId)) {
|
|
926
918
|
return new BigNumber(0)
|
|
927
919
|
}
|
|
928
920
|
|
|
@@ -16,9 +16,9 @@ import { getExplorerApi } from '../../explorer/index'
|
|
|
16
16
|
import ledgerExplorerApi from '../../explorer/ledger'
|
|
17
17
|
import noExplorerAPI from '../../explorer/none'
|
|
18
18
|
|
|
19
|
-
const configFor = (
|
|
19
|
+
const configFor = (chainName: string): EvmConfigInfo => {
|
|
20
20
|
const node = mkExternalNode()
|
|
21
|
-
switch (
|
|
21
|
+
switch (chainName) {
|
|
22
22
|
case 'anything-coin':
|
|
23
23
|
return createMockEvmConfigInfo({
|
|
24
24
|
chainId: 1,
|
|
@@ -109,8 +109,8 @@ describe('EVM Family', () => {
|
|
|
109
109
|
['etherscan', 'etherscan-coin'],
|
|
110
110
|
['ledger', 'ledger-coin'],
|
|
111
111
|
['none', 'none-coin'],
|
|
112
|
-
])('%s arm exposes discoverTokenAssets', (_type,
|
|
113
|
-
const explorer = getExplorerApi(configFor(
|
|
112
|
+
])('%s arm exposes discoverTokenAssets', (_type, chainName) => {
|
|
113
|
+
const explorer = getExplorerApi(configFor(chainName))
|
|
114
114
|
|
|
115
115
|
expect(typeof explorer.discoverTokenAssets).toBe('function')
|
|
116
116
|
})
|
|
@@ -600,6 +600,8 @@ describe('EVM Family', () => {
|
|
|
600
600
|
['blast_sepolia', CHAIN_ID.BLAST_SEPOLIA],
|
|
601
601
|
['base', CHAIN_ID.BASE],
|
|
602
602
|
['base_sepolia', CHAIN_ID.BASE_SEPOLIA],
|
|
603
|
+
['shape', CHAIN_ID.SHAPE],
|
|
604
|
+
['boba', CHAIN_ID.BOBA],
|
|
603
605
|
])('should query the OP-stack gas oracle for %s (not return 0)', async (_name, chainId) => {
|
|
604
606
|
const api = createLedgerNodeApi({ ...ledgerConfig, chainId }, testLogger)
|
|
605
607
|
jest.spyOn(axios, 'request').mockImplementationOnce(async () => ({
|
|
@@ -1118,6 +1118,48 @@ describe('EVM Family', () => {
|
|
|
1118
1118
|
expect(result.gasPrice).toEqual(new BigNumber('20000000000'))
|
|
1119
1119
|
})
|
|
1120
1120
|
|
|
1121
|
+
describe('forceLegacyTransactions', () => {
|
|
1122
|
+
// Sparse fee market: the node reports a 1,000,000 wei gas price, a zero
|
|
1123
|
+
// eth_maxPriorityFeePerGas and zero feeHistory rewards, and the latest block
|
|
1124
|
+
// still carries a baseFeePerGas.
|
|
1125
|
+
beforeEach(() => {
|
|
1126
|
+
config = createMockEvmConfigInfo({
|
|
1127
|
+
chainId: 1,
|
|
1128
|
+
node: mkExternalNode({ uri: 'my-rpc.com' }),
|
|
1129
|
+
forceLegacyTransactions: true,
|
|
1130
|
+
minGasPrice: '2000000',
|
|
1131
|
+
})
|
|
1132
|
+
})
|
|
1133
|
+
|
|
1134
|
+
it('prices an EIP-1559 request as legacy at the minGasPrice floor', async () => {
|
|
1135
|
+
const sendSpy = jest.spyOn(JsonRpcProvider.prototype, 'send')
|
|
1136
|
+
jest
|
|
1137
|
+
.spyOn(JsonRpcProvider.prototype, 'getFeeData')
|
|
1138
|
+
.mockResolvedValueOnce(new FeeData(BigInt('1000000'), 0n, 0n))
|
|
1139
|
+
|
|
1140
|
+
const result = await nodeApi.getFeeData(config, eip1559Tx)
|
|
1141
|
+
|
|
1142
|
+
expect(result).toEqual({
|
|
1143
|
+
maxFeePerGas: null,
|
|
1144
|
+
maxPriorityFeePerGas: null,
|
|
1145
|
+
gasPrice: new BigNumber('2000000'),
|
|
1146
|
+
nextBaseFee: null,
|
|
1147
|
+
})
|
|
1148
|
+
expect(sendSpy).not.toHaveBeenCalledWith('eth_feeHistory', expect.anything())
|
|
1149
|
+
expect(sendSpy).not.toHaveBeenCalledWith('eth_maxPriorityFeePerGas', expect.anything())
|
|
1150
|
+
})
|
|
1151
|
+
|
|
1152
|
+
it('follows the node gas price when it is above the minGasPrice floor', async () => {
|
|
1153
|
+
jest
|
|
1154
|
+
.spyOn(JsonRpcProvider.prototype, 'getFeeData')
|
|
1155
|
+
.mockResolvedValueOnce(new FeeData(BigInt('3000000'), 0n, 0n))
|
|
1156
|
+
|
|
1157
|
+
const result = await nodeApi.getFeeData(config, eip1559Tx)
|
|
1158
|
+
|
|
1159
|
+
expect(result.gasPrice).toEqual(new BigNumber('3000000'))
|
|
1160
|
+
})
|
|
1161
|
+
})
|
|
1162
|
+
|
|
1121
1163
|
it('should return the expected payload for an EIP1559 tx when network returns 0 priority fee for 0G', async () => {
|
|
1122
1164
|
jest.spyOn(JsonRpcProvider.prototype, 'send').mockImplementationOnce(async (method) => {
|
|
1123
1165
|
if (method === 'eth_feeHistory') {
|
|
@@ -43,7 +43,7 @@ type SelectorEntry = {
|
|
|
43
43
|
/**
|
|
44
44
|
* Builds and caches, per currency, a selector → entry map derived from the staking ABI.
|
|
45
45
|
* The cache is bounded — one entry per staking-enabled currency — regardless of how many
|
|
46
|
-
* distinct `to` addresses appear in the tx history. A per-(
|
|
46
|
+
* distinct `to` addresses appear in the tx history. A per-(chainId, to) cache would
|
|
47
47
|
* grow unboundedly for factory-per-validator chains like 0G, since
|
|
48
48
|
* detectEvmStakingOperationType is called for every outgoing tx.
|
|
49
49
|
*
|