File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -79,10 +79,20 @@ describe('stark', () => {
7979 overall_fee : '1000' ,
8080 unit : 'FRI' ,
8181 } ;
82+ const estimateFeeResponse07 : FeeEstimate = {
83+ ...estimateFeeResponse ,
84+ data_gas_consumed : '100' ,
85+ data_gas_price : '10' ,
86+ overall_fee : '2000' ,
87+ } ;
8288 expect ( stark . estimateFeeToBounds ( estimateFeeResponse ) ) . toStrictEqual ( {
8389 l2_gas : { max_amount : '0x0' , max_price_per_unit : '0x0' } ,
8490 l1_gas : { max_amount : '0x6e' , max_price_per_unit : '0xf' } ,
8591 } ) ;
92+ expect ( stark . estimateFeeToBounds ( estimateFeeResponse07 ) ) . toStrictEqual ( {
93+ l2_gas : { max_amount : '0x0' , max_price_per_unit : '0x0' } ,
94+ l1_gas : { max_amount : '0xdc' , max_price_per_unit : '0xf' } ,
95+ } ) ;
8696 } ) ;
8797
8898 test ( 'v3Details' , ( ) => {
Original file line number Diff line number Diff line change @@ -114,7 +114,11 @@ export function estimateFeeToBounds(
114114 if ( typeof estimate . gas_consumed === 'undefined' || typeof estimate . gas_price === 'undefined' ) {
115115 throw Error ( 'estimateFeeToBounds: estimate is undefined' ) ;
116116 }
117- const maxUnits = toHex ( addPercent ( estimate . gas_consumed , amountOverhead ) ) ;
117+
118+ const maxUnits =
119+ estimate . data_gas_consumed !== undefined && estimate . data_gas_price !== undefined // RPC v0.7
120+ ? toHex ( addPercent ( BigInt ( estimate . overall_fee ) / BigInt ( estimate . gas_price ) , amountOverhead ) )
121+ : toHex ( addPercent ( estimate . gas_consumed , amountOverhead ) ) ;
118122 const maxUnitPrice = toHex ( addPercent ( estimate . gas_price , priceOverhead ) ) ;
119123 return {
120124 l2_gas : { max_amount : '0x0' , max_price_per_unit : '0x0' } ,
You can’t perform that action at this time.
0 commit comments