@@ -40,7 +40,7 @@ import {
40
40
TypedData ,
41
41
UniversalDeployerContractPayload ,
42
42
} from '../types' ;
43
- import { ETransactionVersion , ETransactionVersion3 } from '../types/api' ;
43
+ import { ETransactionVersion , ETransactionVersion3 , ResourceBounds } from '../types/api' ;
44
44
import { CallData } from '../utils/calldata' ;
45
45
import { extractContractHashes , isSierra } from '../utils/contract' ;
46
46
import { starkCurve } from '../utils/ec' ;
@@ -161,7 +161,8 @@ export class Account extends Provider implements AccountInterface {
161
161
const estimateFeeResponse = await super . getInvokeEstimateFee (
162
162
{ ...invocation } ,
163
163
{ ...v3Details ( details ) , version, nonce } ,
164
- blockIdentifier
164
+ blockIdentifier ,
165
+ details . skipValidate
165
166
) ;
166
167
167
168
return {
@@ -201,7 +202,8 @@ export class Account extends Provider implements AccountInterface {
201
202
const estimateFeeResponse = await super . getDeclareEstimateFee (
202
203
declareContractTransaction ,
203
204
{ ...v3Details ( details ) , version, nonce } ,
204
- blockIdentifier
205
+ blockIdentifier ,
206
+ details . skipValidate
205
207
) ;
206
208
207
209
return {
@@ -244,7 +246,8 @@ export class Account extends Provider implements AccountInterface {
244
246
const estimateFeeResponse = await super . getDeployAccountEstimateFee (
245
247
{ ...payload } ,
246
248
{ ...v3Details ( details ) , version, nonce } ,
247
- blockIdentifier
249
+ blockIdentifier ,
250
+ details . skipValidate
248
251
) ;
249
252
250
253
return {
@@ -279,6 +282,7 @@ export class Account extends Provider implements AccountInterface {
279
282
280
283
const EstimateFeeResponseBulk = await super . getEstimateFeeBulk ( accountInvocations , {
281
284
blockIdentifier,
285
+ skipValidate : details . skipValidate ,
282
286
} ) ;
283
287
284
288
return [ ] . concat ( EstimateFeeResponseBulk as [ ] ) . map ( ( elem : EstimateFeeResponse ) => {
@@ -316,23 +320,43 @@ export class Account extends Provider implements AccountInterface {
316
320
this . getPreferredVersion ( ETransactionVersion . V1 , ETransactionVersion . V3 ) , // TODO: does this depend on cairo version ?
317
321
details . version
318
322
) ;
319
- const maxFee =
320
- details . maxFee ??
321
- ( await this . getSuggestedMaxFee (
322
- { type : TransactionType . INVOKE , payload : calls } ,
323
- {
324
- ...details ,
325
- version,
326
- }
327
- ) ) ;
323
+
324
+ let suggestedMaxFee : BigNumberish = 0 ;
325
+ let resourceBounds : ResourceBounds = estimateFeeToBounds ( ZERO ) ;
326
+ if ( version === ETransactionVersion . V3 ) {
327
+ resourceBounds =
328
+ details . resourceBounds ??
329
+ (
330
+ await this . getSuggestedFee (
331
+ { type : TransactionType . INVOKE , payload : calls } ,
332
+ {
333
+ ...details ,
334
+ version,
335
+ }
336
+ )
337
+ ) . resourceBounds ;
338
+ } else {
339
+ suggestedMaxFee =
340
+ details . maxFee ??
341
+ (
342
+ await this . getSuggestedFee (
343
+ { type : TransactionType . INVOKE , payload : calls } ,
344
+ {
345
+ ...details ,
346
+ version,
347
+ }
348
+ )
349
+ ) . suggestedMaxFee ;
350
+ }
328
351
329
352
const chainId = await this . getChainId ( ) ;
330
353
331
354
const signerDetails : InvocationsSignerDetails = {
332
355
...v3Details ( details ) ,
356
+ resourceBounds,
333
357
walletAddress : this . address ,
334
358
nonce,
335
- maxFee,
359
+ maxFee : suggestedMaxFee ,
336
360
version,
337
361
chainId,
338
362
cairoVersion : await this . getCairoVersion ( ) ,
@@ -346,8 +370,9 @@ export class Account extends Provider implements AccountInterface {
346
370
{ contractAddress : this . address , calldata, signature } ,
347
371
{
348
372
...v3Details ( details ) ,
373
+ resourceBounds,
349
374
nonce,
350
- maxFee,
375
+ maxFee : suggestedMaxFee ,
351
376
version,
352
377
}
353
378
) ;
@@ -388,21 +413,45 @@ export class Account extends Provider implements AccountInterface {
388
413
providedVersion
389
414
) ;
390
415
416
+ let suggestedMaxFee : BigNumberish = 0 ;
417
+ let resourceBounds : ResourceBounds = estimateFeeToBounds ( ZERO ) ;
418
+ if ( version === ETransactionVersion . V3 ) {
419
+ resourceBounds =
420
+ details . resourceBounds ??
421
+ (
422
+ await this . getSuggestedFee (
423
+ {
424
+ type : TransactionType . DECLARE ,
425
+ payload : declareContractPayload ,
426
+ } ,
427
+ {
428
+ ...details ,
429
+ version,
430
+ }
431
+ )
432
+ ) . resourceBounds ;
433
+ } else {
434
+ suggestedMaxFee =
435
+ maxFee ??
436
+ (
437
+ await this . getSuggestedFee (
438
+ {
439
+ type : TransactionType . DECLARE ,
440
+ payload : declareContractPayload ,
441
+ } ,
442
+ {
443
+ ...details ,
444
+ version,
445
+ }
446
+ )
447
+ ) . suggestedMaxFee ;
448
+ }
449
+
391
450
const declareDetails : InvocationsSignerDetails = {
392
451
...v3Details ( details ) ,
452
+ resourceBounds,
453
+ maxFee : suggestedMaxFee ,
393
454
nonce : toBigInt ( nonce ?? ( await this . getNonce ( ) ) ) ,
394
- maxFee :
395
- maxFee ??
396
- ( await this . getSuggestedMaxFee (
397
- {
398
- type : TransactionType . DECLARE ,
399
- payload : declareContractPayload ,
400
- } ,
401
- {
402
- ...details ,
403
- version,
404
- }
405
- ) ) ,
406
455
version,
407
456
chainId : await this . getChainId ( ) ,
408
457
walletAddress : this . address ,
@@ -512,20 +561,43 @@ export class Account extends Provider implements AccountInterface {
512
561
providedContractAddress ??
513
562
calculateContractAddressFromHash ( addressSalt , classHash , compiledCalldata , 0 ) ;
514
563
515
- const maxFee =
516
- details . maxFee ??
517
- ( await this . getSuggestedMaxFee (
518
- {
519
- type : TransactionType . DEPLOY_ACCOUNT ,
520
- payload : {
521
- classHash,
522
- constructorCalldata : compiledCalldata ,
523
- addressSalt,
524
- contractAddress,
525
- } ,
526
- } ,
527
- details
528
- ) ) ;
564
+ let suggestedMaxFee : BigNumberish = 0 ;
565
+ let resourceBounds : ResourceBounds = estimateFeeToBounds ( ZERO ) ;
566
+ if ( version === ETransactionVersion . V3 ) {
567
+ resourceBounds =
568
+ details . resourceBounds ??
569
+ (
570
+ await this . getSuggestedFee (
571
+ {
572
+ type : TransactionType . DEPLOY_ACCOUNT ,
573
+ payload : {
574
+ classHash,
575
+ constructorCalldata : compiledCalldata ,
576
+ addressSalt,
577
+ contractAddress,
578
+ } ,
579
+ } ,
580
+ details
581
+ )
582
+ ) . resourceBounds ;
583
+ } else {
584
+ suggestedMaxFee =
585
+ details . maxFee ??
586
+ (
587
+ await this . getSuggestedFee (
588
+ {
589
+ type : TransactionType . DEPLOY_ACCOUNT ,
590
+ payload : {
591
+ classHash,
592
+ constructorCalldata : compiledCalldata ,
593
+ addressSalt,
594
+ contractAddress,
595
+ } ,
596
+ } ,
597
+ details
598
+ )
599
+ ) . suggestedMaxFee ;
600
+ }
529
601
530
602
const signature = await this . signer . signDeployAccountTransaction ( {
531
603
...v3Details ( details ) ,
@@ -534,7 +606,8 @@ export class Account extends Provider implements AccountInterface {
534
606
contractAddress,
535
607
addressSalt,
536
608
chainId,
537
- maxFee,
609
+ resourceBounds,
610
+ maxFee : suggestedMaxFee ,
538
611
version,
539
612
nonce,
540
613
} ) ;
@@ -544,7 +617,8 @@ export class Account extends Provider implements AccountInterface {
544
617
{
545
618
...v3Details ( details ) ,
546
619
nonce,
547
- maxFee,
620
+ resourceBounds,
621
+ maxFee : suggestedMaxFee ,
548
622
version,
549
623
}
550
624
) ;
@@ -579,10 +653,7 @@ export class Account extends Provider implements AccountInterface {
579
653
return this . verifyMessageHash ( hash , signature ) ;
580
654
}
581
655
582
- public async getSuggestedMaxFee (
583
- { type, payload } : EstimateFeeAction ,
584
- details : EstimateFeeDetails
585
- ) {
656
+ public async getSuggestedFee ( { type, payload } : EstimateFeeAction , details : EstimateFeeDetails ) {
586
657
let feeEstimate : EstimateFee ;
587
658
588
659
switch ( type ) {
@@ -611,7 +682,7 @@ export class Account extends Provider implements AccountInterface {
611
682
break ;
612
683
}
613
684
614
- return feeEstimate . suggestedMaxFee ;
685
+ return feeEstimate ;
615
686
}
616
687
617
688
/**
0 commit comments