Skip to content

Commit

Permalink
Fix l1_address deserialization in L2toL1MessageSchema (#1435)
Browse files Browse the repository at this point in the history
* Add `ETHAddress` field

* Revert "Add `ETHAddress` field"

This reverts commit 0046dc9.

* Add `ETHAddress` field

* Update starknet_py/net/schemas/common.py

Co-authored-by: ddoktorski <[email protected]>

* Update starknet_py/net/schemas/common.py

Co-authored-by: ddoktorski <[email protected]>

* Fix imports

---------

Co-authored-by: ddoktorski <[email protected]>
  • Loading branch information
franciszekjob and ddoktorski authored Aug 12, 2024
1 parent f3e2056 commit 08d1cea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions starknet_py/net/schemas/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ class Felt(NumberAsHex):
REGEX_PATTERN = r"^0x(0|[a-fA-F1-9]{1}[a-fA-F0-9]{0,62})$"


class EthAddress(NumberAsHex):
"""
Field used to serialize and deserialize ETH address type.
"""

MAX_VALUE = 2**160
REGEX_PATTERN = r"^0x[a-fA-F0-9]{40}$"


class Uint64(NumberAsHex):
"""
Field used to serialize and deserialize RPC u64 type.
Expand Down
3 changes: 2 additions & 1 deletion starknet_py/net/schemas/rpc/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
)
from starknet_py.net.schemas.common import (
DAModeField,
EthAddress,
ExecutionStatusField,
Felt,
FinalityStatusField,
Expand All @@ -45,7 +46,7 @@

class L2toL1MessageSchema(Schema):
l2_address = Felt(data_key="from_address", required=True)
l1_address = Felt(data_key="to_address", required=True)
l1_address = EthAddress(data_key="to_address", required=True)
payload = fields.List(Felt(), data_key="payload", required=True)

@post_load
Expand Down

0 comments on commit 08d1cea

Please sign in to comment.