Skip to content

Commit 8cb1ea5

Browse files
Fix bounded int parsing post cairo 2.8.0 (#1463)
* Fix bounded int parsint post cairo 2.8.0 --------- Co-authored-by: Franciszek Job <54181625+franciszekjob@users.noreply.github.com>
1 parent 042e2f5 commit 8cb1ea5

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

starknet_py/abi/v2/parser_test.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_abi_parse(contract_name):
3535
assert isinstance(parsed_abi, Abi)
3636

3737

38-
def test_bounded_int_parse():
38+
def test_bounded_int_parse_pre_2_8_0():
3939
abi_list = [
4040
{
4141
"type": "struct",
@@ -70,3 +70,40 @@ def test_bounded_int_parse():
7070
UintType, parsed_abi.defined_structures["core::circuit::u384"].types["limb0"]
7171
)
7272
assert uint.bits == 96
73+
74+
75+
def test_bounded_int_parse_post_2_8_0():
76+
abi_list = [
77+
{
78+
"type": "struct",
79+
"name": "core::circuit::u384",
80+
"members": [
81+
{
82+
"name": "limb0",
83+
"type": "core::internal::bounded_int::BoundedInt::<0, 79228162514264337593543950335>",
84+
},
85+
{
86+
"name": "limb1",
87+
"type": "core::internal::bounded_int::BoundedInt::<0, 79228162514264337593543950335>",
88+
},
89+
{
90+
"name": "limb2",
91+
"type": "core::internal::bounded_int::BoundedInt::<0, 79228162514264337593543950335>",
92+
},
93+
{
94+
"name": "limb3",
95+
"type": "core::internal::bounded_int::BoundedInt::<0, 79228162514264337593543950335>",
96+
},
97+
],
98+
}
99+
]
100+
101+
parser = AbiParser(abi_list)
102+
parsed_abi = parser.parse()
103+
104+
assert isinstance(parsed_abi, Abi)
105+
106+
uint = cast(
107+
UintType, parsed_abi.defined_structures["core::circuit::u384"].types["limb0"]
108+
)
109+
assert uint.bits == 96

starknet_py/abi/v2/parser_transformer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
type_bytes: "core::bytes_31::bytes31"
4343
type_bool: "core::bool"
4444
type_uint: "core::integer::u" INT
45-
type_bounded_int: "core::internal::BoundedInt::<" INT "," WS? INT ">"
45+
type_bounded_int: "core::internal::BoundedInt::<" INT "," WS? INT ">" | "core::internal::bounded_int::BoundedInt::<" INT "," WS? INT ">"
4646
type_contract_address: "core::starknet::contract_address::ContractAddress"
4747
type_class_hash: "core::starknet::class_hash::ClassHash"
4848
type_storage_address: "core::starknet::storage_access::StorageAddress"

0 commit comments

Comments
 (0)