@@ -4,7 +4,8 @@ use async_trait::async_trait;
4
4
use starknet_core:: {
5
5
crypto:: compute_hash_on_elements,
6
6
types:: {
7
- BlockId , BlockTag , BroadcastedDeployAccountTransaction , BroadcastedTransaction ,
7
+ BlockId , BlockTag , BroadcastedDeployAccountTransaction ,
8
+ BroadcastedDeployAccountTransactionV1 , BroadcastedTransaction ,
8
9
DeployAccountTransactionResult , FeeEstimate , FieldElement , SimulatedTransaction ,
9
10
SimulationFlag , StarknetError ,
10
11
} ,
@@ -103,6 +104,8 @@ pub enum AccountFactoryError<S> {
103
104
Signing ( S ) ,
104
105
#[ error( transparent) ]
105
106
Provider ( ProviderError ) ,
107
+ #[ error( "fee calculation overflow" ) ]
108
+ FeeOutOfRange ,
106
109
}
107
110
108
111
impl < ' f , F > AccountDeployment < ' f , F > {
@@ -237,7 +240,10 @@ where
237
240
Some ( value) => value,
238
241
None => {
239
242
let fee_estimate = self . estimate_fee_with_nonce ( nonce) . await ?;
240
- ( ( fee_estimate. overall_fee as f64 * self . fee_estimate_multiplier ) as u64 ) . into ( )
243
+ ( ( ( ( TryInto :: < u64 > :: try_into ( fee_estimate. overall_fee )
244
+ . map_err ( |_| AccountFactoryError :: FeeOutOfRange ) ?) as f64 )
245
+ * self . fee_estimate_multiplier ) as u64 )
246
+ . into ( )
241
247
}
242
248
} ;
243
249
@@ -272,6 +278,7 @@ where
272
278
. provider ( )
273
279
. estimate_fee_single (
274
280
BroadcastedTransaction :: DeployAccount ( deploy) ,
281
+ [ ] ,
275
282
self . factory . block_id ( ) ,
276
283
)
277
284
. await
@@ -375,16 +382,18 @@ where
375
382
) -> Result < BroadcastedDeployAccountTransaction , F :: SignError > {
376
383
let signature = self . factory . sign_deployment ( & self . inner ) . await ?;
377
384
378
- Ok ( BroadcastedDeployAccountTransaction {
379
- max_fee : self . inner . max_fee ,
380
- signature,
381
- nonce : self . inner . nonce ,
382
- contract_address_salt : self . inner . salt ,
383
- constructor_calldata : self . factory . calldata ( ) ,
384
- class_hash : self . factory . class_hash ( ) ,
385
- // TODO: make use of query version tx for estimating fees
386
- is_query : false ,
387
- } )
385
+ Ok ( BroadcastedDeployAccountTransaction :: V1 (
386
+ BroadcastedDeployAccountTransactionV1 {
387
+ max_fee : self . inner . max_fee ,
388
+ signature,
389
+ nonce : self . inner . nonce ,
390
+ contract_address_salt : self . inner . salt ,
391
+ constructor_calldata : self . factory . calldata ( ) ,
392
+ class_hash : self . factory . class_hash ( ) ,
393
+ // TODO: make use of query version tx for estimating fees
394
+ is_query : false ,
395
+ } ,
396
+ ) )
388
397
}
389
398
}
390
399
0 commit comments