Skip to content

Commit e79cdf2

Browse files
Restore gas amount multiplier params (#1589)
* Remove todos; Restore multiplier params * Remove changes related with amount multipliers params * Restore gas amount multiplier params * Fix linting * Add `InnerCallExecutionResources`; Fix tests * Update migration guide * Update migration guide
1 parent d2d2820 commit e79cdf2

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

docs/migration_guide.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ Migration guide
55
0.26.1 Migration guide
66
**********************
77

8+
.. py:currentmodule:: starknet_py.net.client_models
9+
10+
1. Restored ``amount_multiplier`` and ``unit_price_multiplier`` params in :meth:`EstimatedFee.to_resource_bounds()`
11+
812
0.26.1 Bugfixes
913
---------------
1014

11-
.. py:currentmodule:: starknet_py.net.client_models
12-
1315
1. In :class:`FunctionInvocation`, ``execution_resources`` field is now of type :class:`InnerCallExecutionResources`.
1416

1517
**********************

starknet_py/net/client_models.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -656,26 +656,30 @@ class EstimatedFee:
656656
overall_fee: int
657657
unit: PriceUnit
658658

659-
def to_resource_bounds(self) -> ResourceBoundsMapping:
659+
def to_resource_bounds(
660+
self, amount_multiplier=1.5, unit_price_multiplier=1.5
661+
) -> ResourceBoundsMapping:
660662
"""
661663
Converts estimated fee to resource bounds with applied multipliers.
662664
665+
:param amount_multiplier: Multiplier for max amount, defaults to 1.5.
666+
:param unit_price_multiplier: Multiplier for max price per unit, defaults to 1.5.
663667
:return: Resource bounds with applied multipliers.
664668
"""
665669

666670
l1_resource_bounds = ResourceBounds(
667-
max_amount=self.l1_gas_consumed,
668-
max_price_per_unit=self.l1_gas_price,
671+
max_amount=int(self.l1_gas_consumed * amount_multiplier),
672+
max_price_per_unit=int(self.l1_gas_price * unit_price_multiplier),
669673
)
670674

671675
l2_resource_bounds = ResourceBounds(
672-
max_amount=self.l2_gas_consumed,
673-
max_price_per_unit=self.l2_gas_price,
676+
max_amount=int(self.l2_gas_consumed * amount_multiplier),
677+
max_price_per_unit=int(self.l2_gas_price * unit_price_multiplier),
674678
)
675679

676680
l1_data_resource_bounds = ResourceBounds(
677-
max_amount=self.l1_data_gas_consumed,
678-
max_price_per_unit=self.l1_data_gas_price,
681+
max_amount=int(self.l1_data_gas_consumed * amount_multiplier),
682+
max_price_per_unit=int(self.l1_data_gas_price * unit_price_multiplier),
679683
)
680684

681685
return ResourceBoundsMapping(

0 commit comments

Comments
 (0)