@@ -40,7 +40,7 @@ import {
4040 TypedData ,
4141 UniversalDeployerContractPayload ,
4242} from '../types' ;
43- import { ETransactionVersion , ETransactionVersion3 } from '../types/api' ;
43+ import { ETransactionVersion , ETransactionVersion3 , ResourceBounds } from '../types/api' ;
4444import { CallData } from '../utils/calldata' ;
4545import { extractContractHashes , isSierra } from '../utils/contract' ;
4646import { starkCurve } from '../utils/ec' ;
@@ -161,7 +161,8 @@ export class Account extends Provider implements AccountInterface {
161161 const estimateFeeResponse = await super . getInvokeEstimateFee (
162162 { ...invocation } ,
163163 { ...v3Details ( details ) , version, nonce } ,
164- blockIdentifier
164+ blockIdentifier ,
165+ details . skipValidate
165166 ) ;
166167
167168 return {
@@ -201,7 +202,8 @@ export class Account extends Provider implements AccountInterface {
201202 const estimateFeeResponse = await super . getDeclareEstimateFee (
202203 declareContractTransaction ,
203204 { ...v3Details ( details ) , version, nonce } ,
204- blockIdentifier
205+ blockIdentifier ,
206+ details . skipValidate
205207 ) ;
206208
207209 return {
@@ -244,7 +246,8 @@ export class Account extends Provider implements AccountInterface {
244246 const estimateFeeResponse = await super . getDeployAccountEstimateFee (
245247 { ...payload } ,
246248 { ...v3Details ( details ) , version, nonce } ,
247- blockIdentifier
249+ blockIdentifier ,
250+ details . skipValidate
248251 ) ;
249252
250253 return {
@@ -279,6 +282,7 @@ export class Account extends Provider implements AccountInterface {
279282
280283 const EstimateFeeResponseBulk = await super . getEstimateFeeBulk ( accountInvocations , {
281284 blockIdentifier,
285+ skipValidate : details . skipValidate ,
282286 } ) ;
283287
284288 return [ ] . concat ( EstimateFeeResponseBulk as [ ] ) . map ( ( elem : EstimateFeeResponse ) => {
@@ -316,23 +320,43 @@ export class Account extends Provider implements AccountInterface {
316320 this . getPreferredVersion ( ETransactionVersion . V1 , ETransactionVersion . V3 ) , // TODO: does this depend on cairo version ?
317321 details . version
318322 ) ;
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+ }
328351
329352 const chainId = await this . getChainId ( ) ;
330353
331354 const signerDetails : InvocationsSignerDetails = {
332355 ...v3Details ( details ) ,
356+ resourceBounds,
333357 walletAddress : this . address ,
334358 nonce,
335- maxFee,
359+ maxFee : suggestedMaxFee ,
336360 version,
337361 chainId,
338362 cairoVersion : await this . getCairoVersion ( ) ,
@@ -346,8 +370,9 @@ export class Account extends Provider implements AccountInterface {
346370 { contractAddress : this . address , calldata, signature } ,
347371 {
348372 ...v3Details ( details ) ,
373+ resourceBounds,
349374 nonce,
350- maxFee,
375+ maxFee : suggestedMaxFee ,
351376 version,
352377 }
353378 ) ;
@@ -388,21 +413,45 @@ export class Account extends Provider implements AccountInterface {
388413 providedVersion
389414 ) ;
390415
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+
391450 const declareDetails : InvocationsSignerDetails = {
392451 ...v3Details ( details ) ,
452+ resourceBounds,
453+ maxFee : suggestedMaxFee ,
393454 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- ) ) ,
406455 version,
407456 chainId : await this . getChainId ( ) ,
408457 walletAddress : this . address ,
@@ -512,20 +561,43 @@ export class Account extends Provider implements AccountInterface {
512561 providedContractAddress ??
513562 calculateContractAddressFromHash ( addressSalt , classHash , compiledCalldata , 0 ) ;
514563
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+ }
529601
530602 const signature = await this . signer . signDeployAccountTransaction ( {
531603 ...v3Details ( details ) ,
@@ -534,7 +606,8 @@ export class Account extends Provider implements AccountInterface {
534606 contractAddress,
535607 addressSalt,
536608 chainId,
537- maxFee,
609+ resourceBounds,
610+ maxFee : suggestedMaxFee ,
538611 version,
539612 nonce,
540613 } ) ;
@@ -544,7 +617,8 @@ export class Account extends Provider implements AccountInterface {
544617 {
545618 ...v3Details ( details ) ,
546619 nonce,
547- maxFee,
620+ resourceBounds,
621+ maxFee : suggestedMaxFee ,
548622 version,
549623 }
550624 ) ;
@@ -579,10 +653,7 @@ export class Account extends Provider implements AccountInterface {
579653 return this . verifyMessageHash ( hash , signature ) ;
580654 }
581655
582- public async getSuggestedMaxFee (
583- { type, payload } : EstimateFeeAction ,
584- details : EstimateFeeDetails
585- ) {
656+ public async getSuggestedFee ( { type, payload } : EstimateFeeAction , details : EstimateFeeDetails ) {
586657 let feeEstimate : EstimateFee ;
587658
588659 switch ( type ) {
@@ -611,7 +682,7 @@ export class Account extends Provider implements AccountInterface {
611682 break ;
612683 }
613684
614- return feeEstimate . suggestedMaxFee ;
685+ return feeEstimate ;
615686 }
616687
617688 /**
0 commit comments