-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support RPC 0.8.0 #1510
base: development
Are you sure you want to change the base?
Support RPC 0.8.0 #1510
Changes from 13 commits
931f4cd
f1f5d50
3fe3460
ecf4f06
5d15915
f0a5bfd
b8dc86a
ddea26e
19036e4
e832c30
b182eff
e82c017
bb2d82e
9621f36
e6e7c53
3b7ffe2
6e11803
76e789c
bae1f49
bd9d693
b8748e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,13 @@ | |
from starknet_py.hash.selector import get_selector_from_name | ||
from starknet_py.net.account.base_account import BaseAccount | ||
from starknet_py.net.client import Client | ||
from starknet_py.net.client_models import Call, EstimatedFee, Hash, ResourceBounds, Tag | ||
from starknet_py.net.client_models import ( | ||
Call, | ||
EstimatedFee, | ||
Hash, | ||
ResourceBoundsMapping, | ||
Tag, | ||
) | ||
from starknet_py.net.models import AddressRepresentation, parse_address | ||
from starknet_py.net.models.transaction import Declare, Invoke | ||
from starknet_py.net.udc_deployer.deployer import Deployer | ||
|
@@ -231,7 +237,7 @@ async def deploy_v3( | |
unique: bool = True, | ||
constructor_args: Optional[Union[List, Dict]] = None, | ||
nonce: Optional[int] = None, | ||
l1_resource_bounds: Optional[ResourceBounds] = None, | ||
resource_bounds: Optional[ResourceBoundsMapping] = None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe having 2 parameters There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tbh I don't think it's good to pass all fields of data class separately. |
||
auto_estimate: bool = False, | ||
) -> "DeployResult": | ||
""" | ||
|
@@ -244,7 +250,7 @@ async def deploy_v3( | |
:param unique: Determines if the contract should be salted with the account address. | ||
:param constructor_args: a ``list`` or ``dict`` of arguments for the constructor. | ||
:param nonce: Nonce of the transaction with call to deployer. | ||
:param l1_resource_bounds: Max amount and max price per unit of L1 gas (in Fri) used when executing | ||
:param resource_bounds: Max amount and max price per unit of L1 and L2 gas (in Fri) used when executing | ||
this transaction. | ||
:param auto_estimate: Use automatic fee estimation (not recommended, as it may lead to high costs). | ||
:return: DeployResult instance. | ||
|
@@ -260,7 +266,7 @@ async def deploy_v3( | |
deployer_address=deployer_address, | ||
cairo_version=self._cairo_version, | ||
nonce=nonce, | ||
l1_resource_bounds=l1_resource_bounds, | ||
resource_bounds=resource_bounds, | ||
auto_estimate=auto_estimate, | ||
salt=salt, | ||
unique=unique, | ||
|
@@ -462,19 +468,19 @@ class PreparedFunctionInvokeV3(PreparedFunctionInvoke): | |
Prepared date to send an InvokeV3 transaction. | ||
""" | ||
|
||
l1_resource_bounds: Optional[ResourceBounds] | ||
resource_bounds: Optional[ResourceBoundsMapping] | ||
|
||
async def invoke( | ||
self, | ||
l1_resource_bounds: Optional[ResourceBounds] = None, | ||
resource_bounds: Optional[ResourceBoundsMapping] = None, | ||
auto_estimate: bool = False, | ||
*, | ||
nonce: Optional[int] = None, | ||
) -> InvokeResult: | ||
""" | ||
Send an Invoke transaction version 3 for the prepared data. | ||
|
||
:param l1_resource_bounds: Max amount and max price per unit of L1 gas (in Fri) used when executing | ||
:param resource_bounds: Max amount and max price per unit of L1 and L2 gas (in Fri) used when executing | ||
this transaction. | ||
:param auto_estimate: Use automatic fee estimation (not recommended, as it may lead to high costs). | ||
:param nonce: Nonce of the transaction. | ||
|
@@ -484,7 +490,7 @@ async def invoke( | |
transaction = await self.get_account.sign_invoke_v3( | ||
calls=self, | ||
nonce=nonce, | ||
l1_resource_bounds=l1_resource_bounds or self.l1_resource_bounds, | ||
resource_bounds=resource_bounds or self.resource_bounds, | ||
auto_estimate=auto_estimate, | ||
) | ||
|
||
|
@@ -498,7 +504,9 @@ async def estimate_fee( | |
nonce: Optional[int] = None, | ||
) -> EstimatedFee: | ||
tx = await self.get_account.sign_invoke_v3( | ||
calls=self, nonce=nonce, l1_resource_bounds=ResourceBounds.init_with_zeros() | ||
calls=self, | ||
nonce=nonce, | ||
resource_bounds=ResourceBoundsMapping.init_with_zeros(), | ||
) | ||
estimate_tx = await self.get_account.sign_for_fee_estimate(transaction=tx) | ||
|
||
|
@@ -652,15 +660,15 @@ async def invoke_v1( | |
def prepare_invoke_v3( | ||
self, | ||
*args, | ||
l1_resource_bounds: Optional[ResourceBounds] = None, | ||
resource_bounds: Optional[ResourceBoundsMapping] = None, | ||
**kwargs, | ||
) -> PreparedFunctionInvokeV3: | ||
""" | ||
``*args`` and ``**kwargs`` are translated into Cairo calldata. | ||
Creates a ``PreparedFunctionInvokeV3`` instance which exposes calldata for every argument | ||
and adds more arguments when calling methods. | ||
|
||
:param l1_resource_bounds: Max amount and max price per unit of L1 gas (in Fri) used when executing | ||
:param resource_bounds: Max amount and max price per unit of L1 and L2 gas (in Fri) used when executing | ||
this transaction. | ||
:return: PreparedFunctionInvokeV3. | ||
""" | ||
|
@@ -670,7 +678,7 @@ def prepare_invoke_v3( | |
to_addr=self.contract_data.address, | ||
calldata=calldata, | ||
selector=self.get_selector(self.name), | ||
l1_resource_bounds=l1_resource_bounds, | ||
resource_bounds=resource_bounds, | ||
_contract_data=self.contract_data, | ||
_client=self.client, | ||
_account=self.account, | ||
|
@@ -680,7 +688,7 @@ def prepare_invoke_v3( | |
async def invoke_v3( | ||
self, | ||
*args, | ||
l1_resource_bounds: Optional[ResourceBounds] = None, | ||
resource_bounds: Optional[ResourceBoundsMapping] = None, | ||
auto_estimate: bool = False, | ||
nonce: Optional[int] = None, | ||
**kwargs, | ||
|
@@ -689,15 +697,15 @@ async def invoke_v3( | |
Invoke contract's function. ``*args`` and ``**kwargs`` are translated into Cairo calldata. | ||
Equivalent of ``.prepare_invoke_v3(*args, **kwargs).invoke()``. | ||
|
||
:param l1_resource_bounds: Max amount and max price per unit of L1 gas (in Fri) used when executing | ||
:param resource_bounds: Max amount and max price per unit of L1 and L2 gas (in Fri) used when executing | ||
this transaction. | ||
:param auto_estimate: Use automatic fee estimation (not recommended, as it may lead to high costs). | ||
:param nonce: Nonce of the transaction. | ||
:return: InvokeResult. | ||
""" | ||
prepared_invoke = self.prepare_invoke_v3(*args, **kwargs) | ||
return await prepared_invoke.invoke( | ||
l1_resource_bounds=l1_resource_bounds, | ||
resource_bounds=resource_bounds, | ||
nonce=nonce, | ||
auto_estimate=auto_estimate, | ||
) | ||
|
@@ -896,7 +904,7 @@ async def declare_v3( | |
compiled_contract_casm: Optional[str] = None, | ||
compiled_class_hash: Optional[int] = None, | ||
nonce: Optional[int] = None, | ||
l1_resource_bounds: Optional[ResourceBounds] = None, | ||
resource_bounds: Optional[ResourceBoundsMapping] = None, | ||
auto_estimate: bool = False, | ||
) -> DeclareResult: | ||
# pylint: disable=too-many-arguments | ||
|
@@ -909,7 +917,7 @@ async def declare_v3( | |
:param compiled_contract_casm: String containing the content of the starknet-sierra-compile (.casm file). | ||
:param compiled_class_hash: Hash of the compiled_contract_casm. | ||
:param nonce: Nonce of the transaction. | ||
:param l1_resource_bounds: Max amount and max price per unit of L1 gas (in Fri) used when executing | ||
:param resource_bounds: Max amount and max price per unit of L1 and L2 gas (in Fri) used when executing | ||
this transaction. | ||
:param auto_estimate: Use automatic fee estimation (not recommended, as it may lead to high costs). | ||
:return: DeclareResult instance. | ||
|
@@ -923,7 +931,7 @@ async def declare_v3( | |
compiled_contract=compiled_contract, | ||
compiled_class_hash=compiled_class_hash, | ||
nonce=nonce, | ||
l1_resource_bounds=l1_resource_bounds, | ||
resource_bounds=resource_bounds, | ||
auto_estimate=auto_estimate, | ||
) | ||
|
||
|
@@ -1006,7 +1014,7 @@ async def deploy_contract_v3( | |
deployer_address: AddressRepresentation = DEFAULT_DEPLOYER_ADDRESS, | ||
cairo_version: int = 1, | ||
nonce: Optional[int] = None, | ||
l1_resource_bounds: Optional[ResourceBounds] = None, | ||
resource_bounds: Optional[ResourceBoundsMapping] = None, | ||
auto_estimate: bool = False, | ||
salt: Optional[int] = None, | ||
unique: bool = True, | ||
|
@@ -1024,7 +1032,7 @@ async def deploy_contract_v3( | |
:param cairo_version: Version of the Cairo in which contract is written. | ||
By default, it is set to 1. | ||
:param nonce: Nonce of the transaction. | ||
:param l1_resource_bounds: Max amount and max price per unit of L1 gas (in Fri) used when executing | ||
:param resource_bounds: Max amount and max price per unit of L1 and L2 gas (in Fri) used when executing | ||
this transaction. | ||
:param auto_estimate: Use automatic fee estimation (not recommended, as it may lead to high costs). | ||
:param salt: Optional salt. Random value is selected if it is not provided. | ||
|
@@ -1047,7 +1055,7 @@ async def deploy_contract_v3( | |
res = await account.execute_v3( | ||
calls=deploy_call, | ||
nonce=nonce, | ||
l1_resource_bounds=l1_resource_bounds, | ||
resource_bounds=resource_bounds, | ||
auto_estimate=auto_estimate, | ||
) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: Migration guide will be updated once we confirm that all introduced changes are correct.