Skip to content

Commit de689fd

Browse files
Add StorageKeySchema (#1685)
1 parent c755e6b commit de689fd

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed
Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
1-
from marshmallow import fields
1+
from marshmallow import fields, validate
22

33
from starknet_py.net.schemas.common import Felt
44
from starknet_py.utils.schema import Schema
55

6+
STORAGE_KEY_PATTERN = r"^0x(0|[0-7]{1}[a-fA-F0-9]{0,62})$"
7+
8+
9+
class StorageKeySchema(fields.Str):
10+
"""
11+
Storage key schema, represented as a string of hex digits
12+
"""
13+
14+
def __init__(self, **kwargs):
15+
super().__init__(
16+
validate=validate.Regexp(
17+
regex=STORAGE_KEY_PATTERN,
18+
error=f"Storage key must match the pattern: {STORAGE_KEY_PATTERN}",
19+
),
20+
**kwargs,
21+
)
22+
623

724
class ContractsStorageKeysSchema(Schema):
825
contract_address = Felt(data_key="contract_address", required=True)
9-
storage_keys = fields.List(Felt(), data_key="storage_keys", required=True)
26+
storage_keys = fields.List(
27+
StorageKeySchema(), data_key="storage_keys", required=True
28+
)

starknet_py/net/schemas/rpc/executables_api.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
AssertLtAssertValidInputInner,
2222
BinOp,
2323
BinOpInner,
24-
CasmClass,
25-
CasmClassEntryPointsByType,
2624
CellRef,
2725
Cheatcode,
2826
CheatcodeInner,

0 commit comments

Comments
 (0)