Skip to content
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

Bump the dev-dependencies group across 1 directory with 12 updates #1394

Merged
merged 11 commits into from
Jul 22, 2024
1 change: 1 addition & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ jobs:
if: steps.cache-contracts.outputs.cache-hit != 'true'
run: |
pip install --upgrade setuptools
pip install sympy==1.11.1
ddoktorski marked this conversation as resolved.
Show resolved Hide resolved
pip install cairo-lang==${{ env.CAIRO_LANG_VERSION }}

- name: Compile contracts v0
Expand Down
579 changes: 304 additions & 275 deletions poetry.lock

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ eth-keyfile = "^0.8.1"
docs = ["sphinx", "enum-tools", "furo"]

[tool.poetry.group.dev.dependencies]
pytest = "^7.2.2"
black = "^23.1.0"
poethepoet = "^0.24.4"
pytest = "^8.2.2"
black = "^24.4.2"
poethepoet = "^0.27.0"
coverage = "^7.2.1"
pytest-asyncio = "^0.21.1"
ddoktorski marked this conversation as resolved.
Show resolved Hide resolved
pylint = "3.0.3"
pylint = "3.2.5"
pytest-mock = "^3.6.1"
pytest-xdist = "^3.2.1"
pyright = "1.1.338"
pytest-cov = "^4.0.0"
pyright = "1.1.371"
pytest-cov = "^5.0.0"
isort = "^5.11.4"
pytest-rerunfailures = "^13.0"
pytest-rerunfailures = "^14.0"
python-dotenv = "^1.0.0"
setuptools = "^69.0.3"
setuptools = "^70.3.0"

[tool.poe.tasks]
test = [
Expand Down Expand Up @@ -136,4 +136,5 @@ exclude = [
"**/__pycache__",
"starknet_py/tests/e2e/docs",
]
stubPath = "" # fix "not a valid directory" error
reportIncompatibleMethodOverride = "warning"
reportIncompatibleVariableOverride = "warning"
franciszekjob marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion starknet_py/net/account/base_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ async def sign_deploy_account_v1(
contract_address_salt: int,
constructor_calldata: Optional[List[int]] = None,
*,
nonce: Optional[int] = None,
nonce: int = 0,
max_fee: Optional[int] = None,
auto_estimate: bool = False,
) -> DeployAccountV1:
Expand Down
6 changes: 4 additions & 2 deletions starknet_py/net/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
DeprecatedContractClass,
EstimatedFee,
Hash,
PendingBlockStateUpdate,
PendingStarknetBlock,
SentTransactionResponse,
SierraContractClass,
StarknetBlock,
Expand Down Expand Up @@ -45,7 +47,7 @@ async def get_block(
self,
block_hash: Optional[Union[Hash, Tag]] = None,
block_number: Optional[Union[int, Tag]] = None,
) -> StarknetBlock:
) -> Union[StarknetBlock, PendingStarknetBlock]:
"""
Retrieve the block's data by its number or hash

Expand Down Expand Up @@ -73,7 +75,7 @@ async def get_state_update(
self,
block_hash: Optional[Union[Hash, Tag]] = None,
block_number: Optional[Union[int, Tag]] = None,
) -> BlockStateUpdate:
) -> Union[BlockStateUpdate, PendingBlockStateUpdate]:
"""
Get the information about the result of executing the requested block

Expand Down
6 changes: 3 additions & 3 deletions starknet_py/net/full_node_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,9 @@ async def estimate_fee(
method_name="estimateFee",
params={
"request": [_create_broadcasted_txn(transaction=t) for t in tx],
"simulation_flags": [SimulationFlag.SKIP_VALIDATE]
if skip_validate
else [],
"simulation_flags": (
[SimulationFlag.SKIP_VALIDATE] if skip_validate else []
),
**block_identifier,
},
)
Expand Down
49 changes: 29 additions & 20 deletions starknet_py/net/models/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
SierraContractClass,
TransactionType,
)
from starknet_py.net.schemas.common import Felt, TransactionTypeField
from starknet_py.net.schemas.common import Felt
from starknet_py.net.schemas.rpc.contract import (
ContractClassSchema,
SierraContractClassSchema,
Expand Down Expand Up @@ -134,7 +134,10 @@ class DeclareV3(_AccountTransactionV3):
compiled_class_hash: int
contract_class: SierraContractClass
account_deployment_data: List[int] = field(default_factory=list)
type: TransactionType = TransactionType.DECLARE

@property
def type(self) -> TransactionType:
return TransactionType.DECLARE

def calculate_hash(self, chain_id: int) -> int:
return compute_declare_v3_transaction_hash(
Expand All @@ -161,10 +164,10 @@ class DeclareV2(_DeprecatedAccountTransaction):
)
compiled_class_hash: int = field(metadata={"marshmallow_field": Felt()})
sender_address: int = field(metadata={"marshmallow_field": Felt()})
type: TransactionType = field(
metadata={"marshmallow_field": TransactionTypeField()},
default=TransactionType.DECLARE,
)

@property
def type(self) -> TransactionType:
return TransactionType.DECLARE

def calculate_hash(self, chain_id: int) -> int:
return compute_declare_v2_transaction_hash(
Expand All @@ -191,10 +194,10 @@ class DeclareV1(_DeprecatedAccountTransaction):
)
# The address of the account contract sending the declaration transaction.
sender_address: int = field(metadata={"marshmallow_field": Felt()})
type: TransactionType = field(
metadata={"marshmallow_field": TransactionTypeField()},
default=TransactionType.DECLARE,
)

@property
def type(self) -> TransactionType:
return TransactionType.DECLARE

@marshmallow.post_dump
def post_dump(self, data: Dict[str, Any], **kwargs) -> Dict[str, Any]:
Expand Down Expand Up @@ -232,7 +235,10 @@ class DeployAccountV3(_AccountTransactionV3):
class_hash: int
contract_address_salt: int
constructor_calldata: List[int]
type: TransactionType = TransactionType.DEPLOY_ACCOUNT

@property
def type(self) -> TransactionType:
return TransactionType.DEPLOY_ACCOUNT

def calculate_hash(self, chain_id: int) -> int:
contract_address = compute_address(
Expand Down Expand Up @@ -265,10 +271,10 @@ class DeployAccountV1(_DeprecatedAccountTransaction):
constructor_calldata: List[int] = field(
metadata={"marshmallow_field": fields.List(fields.String())}
)
type: TransactionType = field(
metadata={"marshmallow_field": TransactionTypeField()},
default=TransactionType.DEPLOY_ACCOUNT,
)

@property
def type(self) -> TransactionType:
return TransactionType.DEPLOY_ACCOUNT

def calculate_hash(self, chain_id: int) -> int:
"""
Expand Down Expand Up @@ -302,7 +308,10 @@ class InvokeV3(_AccountTransactionV3):
calldata: List[int]
sender_address: int
account_deployment_data: List[int] = field(default_factory=list)
type: TransactionType = TransactionType.INVOKE

@property
def type(self) -> TransactionType:
return TransactionType.INVOKE

def calculate_hash(self, chain_id: int) -> int:
return compute_invoke_v3_transaction_hash(
Expand All @@ -327,10 +336,10 @@ class InvokeV1(_DeprecatedAccountTransaction):
calldata: List[int] = field(
metadata={"marshmallow_field": fields.List(fields.String())}
)
type: TransactionType = field(
metadata={"marshmallow_field": TransactionTypeField()},
default=TransactionType.INVOKE,
)

@property
def type(self) -> TransactionType:
return TransactionType.INVOKE

def calculate_hash(self, chain_id: int) -> int:
"""
Expand Down
28 changes: 1 addition & 27 deletions starknet_py/net/models/transaction_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@
from typing import cast

from starknet_py.common import create_contract_class
from starknet_py.net.client_models import TransactionType
from starknet_py.net.models.transaction import (
Declare,
DeclareV1,
DeclareV1Schema,
InvokeV1,
InvokeV1Schema,
)
from starknet_py.net.models.transaction import Declare, DeclareV1, DeclareV1Schema


def test_declare_compress_program(balance_contract):
Expand All @@ -36,22 +29,3 @@ def test_declare_compress_program(balance_contract):

deserialized = cast(Declare, schema.load(serialized))
assert deserialized.contract_class == contract_class


def test_serialize_deserialize_invoke():
data = {
"sender_address": "0x1",
"calldata": ["0x1", "0x2", "0x3"],
"max_fee": "0x1",
"signature": [],
"nonce": "0x1",
"version": "0x1",
"type": "INVOKE_FUNCTION",
}
invoke = InvokeV1Schema().load(data)
serialized_invoke = InvokeV1Schema().dump(invoke)

assert isinstance(invoke, InvokeV1)
assert invoke.type == TransactionType.INVOKE
assert isinstance(serialized_invoke, dict)
assert serialized_invoke["type"] == "INVOKE_FUNCTION"
franciszekjob marked this conversation as resolved.
Show resolved Hide resolved
26 changes: 13 additions & 13 deletions starknet_py/net/schemas/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class NumberAsHex(fields.Field):
MAX_VALUE = sys.maxsize
REGEX_PATTERN = r"^0x[a-fA-F0-9]+$"

def _serialize(self, value: Any, attr: str, obj: Any, **kwargs):
def _serialize(self, value: Any, attr: Union[str, None], obj: Any, **kwargs):
ddoktorski marked this conversation as resolved.
Show resolved Hide resolved
if self._is_int_and_in_range(value):
return hex(value)

Expand Down Expand Up @@ -108,7 +108,7 @@ class Uint128(NumberAsHex):


class NonPrefixedHex(fields.Field):
def _serialize(self, value: Any, attr: str, obj: Any, **kwargs):
def _serialize(self, value: Any, attr: Union[str, None], obj: Any, **kwargs):
return hex(value).lstrip("0x")

def _deserialize(
Expand All @@ -122,7 +122,7 @@ def _deserialize(


class StatusField(fields.Field):
def _serialize(self, value: Any, attr: str, obj: Any, **kwargs):
def _serialize(self, value: Any, attr: Union[str, None], obj: Any, **kwargs):
return value.name if value is not None else ""

def _deserialize(
Expand All @@ -143,7 +143,7 @@ def _deserialize(


class ExecutionStatusField(fields.Field):
def _serialize(self, value: Any, attr: str, obj: Any, **kwargs):
def _serialize(self, value: Any, attr: Union[str, None], obj: Any, **kwargs):
return value.name if value is not None else ""

def _deserialize(
Expand All @@ -164,7 +164,7 @@ def _deserialize(


class FinalityStatusField(fields.Field):
def _serialize(self, value: Any, attr: str, obj: Any, **kwargs):
def _serialize(self, value: Any, attr: Union[str, None], obj: Any, **kwargs):
return value.name if value is not None else ""

def _deserialize(
Expand All @@ -185,7 +185,7 @@ def _deserialize(


class BlockStatusField(fields.Field):
def _serialize(self, value: Any, attr: str, obj: Any, **kwargs):
def _serialize(self, value: Any, attr: Union[str, None], obj: Any, **kwargs):
return value.name if value is not None else ""

def _deserialize(
Expand All @@ -207,7 +207,7 @@ def _deserialize(


class TransactionTypeField(fields.Field):
def _serialize(self, value: Any, attr: str, obj: Any, **kwargs):
def _serialize(self, value: Any, attr: Union[str, None], obj: Any, **kwargs):
if value == TransactionType.INVOKE:
return "INVOKE_FUNCTION"
return value.name
Expand All @@ -233,7 +233,7 @@ def _deserialize(


class EntryPointTypeField(fields.Field):
def _serialize(self, value: Any, attr: str, obj: Any, **kwargs):
def _serialize(self, value: Any, attr: Union[str, None], obj: Any, **kwargs):
return value.name if value is not None else ""

def _deserialize(
Expand All @@ -254,7 +254,7 @@ def _deserialize(


class CallTypeField(fields.Field):
def _serialize(self, value: Any, attr: str, obj: Any, **kwargs):
def _serialize(self, value: Any, attr: Union[str, None], obj: Any, **kwargs):
return value.name if value is not None else ""

def _deserialize(
Expand All @@ -273,7 +273,7 @@ def _deserialize(


class L1DAModeField(fields.Field):
def _serialize(self, value: Any, attr: str, obj: Any, **kwargs):
def _serialize(self, value: Any, attr: Union[str, None], obj: Any, **kwargs):
return value.name if value is not None else ""

def _deserialize(
Expand All @@ -292,7 +292,7 @@ def _deserialize(


class PriceUnitField(fields.Field):
def _serialize(self, value: Any, attr: str, obj: Any, **kwargs):
def _serialize(self, value: Any, attr: Union[str, None], obj: Any, **kwargs):
return value.name if value is not None else ""

def _deserialize(
Expand All @@ -311,7 +311,7 @@ def _deserialize(


class DAModeField(fields.Field):
def _serialize(self, value: Any, attr: str, obj: Any, **kwargs):
def _serialize(self, value: Any, attr: Union[str, None], obj: Any, **kwargs):
return value.name if value is not None else ""

def _deserialize(
Expand Down Expand Up @@ -349,7 +349,7 @@ class Revision(Enum):


class RevisionField(fields.Field):
def _serialize(self, value: Any, attr: str, obj: Any, **kwargs):
def _serialize(self, value: Any, attr: Union[str, None], obj: Any, **kwargs):
if value is None or value == Revision.V0:
return str(Revision.V0.value)
return value.value
Expand Down
1 change: 1 addition & 0 deletions starknet_py/serialization/serialization_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
The purpose of this file is to test serialization for complex abi.
"""

import json
from typing import NamedTuple

Expand Down
8 changes: 2 additions & 6 deletions starknet_py/utils/iterable.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
T = TypeVar("T")


# pyright: reportGeneralTypeIssues=false
def ensure_iterable(value: Union[T, Iterable[T]]) -> Iterable[T]:
try:
iter(value)
# Now we now it is iterable
if isinstance(value, Iterable):
return value
except TypeError:
return [value]
return [value]
Loading