Skip to content

Commit 0aed3d0

Browse files
committed
v0.24.1 [skip ci] (#1453)
2 parents 11cc665 + 8e8957f commit 0aed3d0

File tree

8 files changed

+107
-11
lines changed

8 files changed

+107
-11
lines changed

.github/workflows/checks.yml

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Checks
33
env:
44
CAIRO_LANG_VERSION: "0.13.1"
55
DEVNET_VERSION: "0.1.2"
6+
DEVNET_SHA: 7e7dbb5
67

78
on:
89
push:
@@ -97,7 +98,7 @@ jobs:
9798
# ====================== CONTRACTS v2 ====================== #
9899
- name: Cache contracts v2
99100
id: cache-contracts_v2
100-
uses: actions/cache@v3
101+
uses: actions/cache@v4
101102
with:
102103
path: starknet_py/tests/e2e/mock/contracts_v2/target
103104
key: ${{ runner.os }}-contracts-${{ hashFiles('starknet_py/tests/e2e/mock/contracts_v2') }}
@@ -111,7 +112,7 @@ jobs:
111112

112113
- name: Cache contracts v1
113114
id: cache-contracts_v1
114-
uses: actions/cache@v3
115+
uses: actions/cache@v4
115116
with:
116117
path: starknet_py/tests/e2e/mock/contracts_v1/target
117118
key: ${{ runner.os }}-contracts-${{ hashFiles('starknet_py/tests/e2e/mock/contracts_v1') }}
@@ -125,7 +126,7 @@ jobs:
125126

126127
- name: Cache contracts v0
127128
id: cache-contracts
128-
uses: actions/cache@v3
129+
uses: actions/cache@v4
129130
with:
130131
path: starknet_py/tests/e2e/mock/contracts_compiled
131132
key: ${{ runner.os }}-contracts-${{ hashFiles('starknet_py/tests/e2e/mock/contracts', 'poetry.lock') }}-${{ env.CAIRO_LANG_VERSION }}
@@ -358,11 +359,19 @@ jobs:
358359

359360
# ====================== SETUP DEVNET ====================== #
360361

362+
- name: Cache devnet build
363+
id: windows-devnet-cache
364+
uses: actions/cache@v4
365+
with:
366+
path: ${{ github.workspace }}\starknet_py\tests\e2e\devnet\bin
367+
key: ${{ runner.os }}-devnet-${{ env.DEVNET_SHA }}
368+
361369
- name: Install devnet
370+
if: steps.windows-devnet-cache.outputs.cache-hit != 'true'
362371
run: |
363-
$DEVNET_INSTALL_DIR = "$(git rev-parse --show-toplevel)/starknet_py/tests/e2e/devnet"
364-
cargo install --git https://github.com/0xSpaceShard/starknet-devnet-rs.git --locked --rev 7e7dbb5 --root $DEVNET_INSTALL_DIR
365-
372+
$DEVNET_INSTALL_DIR = "${{ github.workspace }}\starknet_py\tests\e2e\devnet"
373+
cargo install --git https://github.com/0xSpaceShard/starknet-devnet-rs.git --locked --rev ${{ env.DEVNET_SHA }} --root $DEVNET_INSTALL_DIR
374+
shell: pwsh
366375
# ====================== SETUP PYTHON ====================== #
367376

368377
- name: Install poetry
@@ -512,10 +521,19 @@ jobs:
512521
513522
# ====================== SETUP DEVNET ====================== #
514523

524+
- name: Cache devnet build
525+
id: windows-devnet-cache
526+
uses: actions/cache@v4
527+
with:
528+
path: ${{ github.workspace }}\starknet_py\tests\e2e\devnet\bin
529+
key: ${{ runner.os }}-devnet-${{ env.DEVNET_SHA }}
530+
515531
- name: Install devnet
532+
if: steps.windows-devnet-cache.outputs.cache-hit != 'true'
516533
run: |
517-
$DEVNET_INSTALL_DIR = "$(git rev-parse --show-toplevel)/starknet_py/tests/e2e/devnet"
518-
cargo install --git https://github.com/0xSpaceShard/starknet-devnet-rs.git --locked --rev 7e7dbb5 --root $DEVNET_INSTALL_DIR
534+
$DEVNET_INSTALL_DIR = "${{ github.workspace }}\starknet_py\tests\e2e\devnet"
535+
cargo install --git https://github.com/0xSpaceShard/starknet-devnet-rs.git --locked --rev ${{ env.DEVNET_SHA }} --root $DEVNET_INSTALL_DIR
536+
shell: pwsh
519537

520538
# ====================== RUN TESTS ====================== #
521539

.github/workflows/package.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Build wheels
2-
on: workflow_dispatch
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
37

48
jobs:
59
build_sdist:

docs/migration_guide.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
Migration guide
22
===============
33

4+
******************************
5+
0.24.1 Migration guide
6+
******************************
7+
This version contains a quick fix to parsing ABI for Cairo v2 contracts. Due to new release of compiler, `u96` is now compiled to `BoundedInt` in ABI.
8+
9+
0.24.1 Minor changes
10+
--------------------
11+
12+
1. Fixed parsing ABI that contains `u96` data type.
13+
2. Fixed `l1_address` deserialization in `L2toL1MessageSchema`.
14+
415
******************************
516
0.24.0 Migration guide
617
******************************

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "starknet-py"
3-
version = "0.24.0"
3+
version = "0.24.1"
44
description = "A python SDK for Starknet"
55
authors = ["Tomasz Rejowski <tomasz.rejowski@swmansion.com>", "Jakub Ptak <jakub.ptak@swmansion.com>"]
66
include = ["starknet_py", "starknet_py/utils/crypto/libcrypto_c_exports.*"]

starknet_py/abi/v2/parser_test.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import json
2+
from typing import cast
23

34
import pytest
45

56
from starknet_py.abi.v2 import Abi, AbiParser
7+
from starknet_py.cairo.data_types import UintType
68
from starknet_py.tests.e2e.fixtures.misc import ContractVersion, load_contract
79

810

@@ -31,3 +33,40 @@ def test_abi_parse(contract_name):
3133
parsed_abi = parser.parse()
3234

3335
assert isinstance(parsed_abi, Abi)
36+
37+
38+
def test_bounded_int_parse():
39+
abi_list = [
40+
{
41+
"type": "struct",
42+
"name": "core::circuit::u384",
43+
"members": [
44+
{
45+
"name": "limb0",
46+
"type": "core::internal::BoundedInt::<0, 79228162514264337593543950335>",
47+
},
48+
{
49+
"name": "limb1",
50+
"type": "core::internal::BoundedInt::<0, 79228162514264337593543950335>",
51+
},
52+
{
53+
"name": "limb2",
54+
"type": "core::internal::BoundedInt::<0, 79228162514264337593543950335>",
55+
},
56+
{
57+
"name": "limb3",
58+
"type": "core::internal::BoundedInt::<0, 79228162514264337593543950335>",
59+
},
60+
],
61+
}
62+
]
63+
64+
parser = AbiParser(abi_list)
65+
parsed_abi = parser.parse()
66+
67+
assert isinstance(parsed_abi, Abi)
68+
69+
uint = cast(
70+
UintType, parsed_abi.defined_structures["core::circuit::u384"].types["limb0"]
71+
)
72+
assert uint.bits == 96

starknet_py/abi/v2/parser_transformer.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from math import log2
12
from typing import Any, List, Optional
23

34
import lark
@@ -25,6 +26,7 @@
2526
| type_felt
2627
| type_bytes
2728
| type_uint
29+
| type_bounded_int
2830
| type_contract_address
2931
| type_class_hash
3032
| type_storage_address
@@ -40,6 +42,7 @@
4042
type_bytes: "core::bytes_31::bytes31"
4143
type_bool: "core::bool"
4244
type_uint: "core::integer::u" INT
45+
type_bounded_int: "core::internal::BoundedInt::<" INT "," WS? INT ">"
4346
type_contract_address: "core::starknet::contract_address::ContractAddress"
4447
type_class_hash: "core::starknet::class_hash::ClassHash"
4548
type_storage_address: "core::starknet::storage_access::StorageAddress"
@@ -109,6 +112,17 @@ def type_uint(self, value: List[Token]) -> UintType:
109112
"""
110113
return UintType(int(value[0]))
111114

115+
def type_bounded_int(self, value: List[Token]) -> UintType:
116+
"""
117+
BoundedInt Uint type contains information about its ranges. They are present in the value[0] and value[2].
118+
"""
119+
if value[0] != "0":
120+
raise ValueError("BoundedInt should start from 0.")
121+
122+
bits = log2(int(value[2]) + 1)
123+
124+
return UintType(int(bits))
125+
112126
def type_unit(self, _value: List[Any]) -> UnitType:
113127
"""
114128
`()` type.

starknet_py/net/schemas/common.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ class Felt(NumberAsHex):
8989
REGEX_PATTERN = r"^0x(0|[a-fA-F1-9]{1}[a-fA-F0-9]{0,62})$"
9090

9191

92+
class EthAddress(NumberAsHex):
93+
"""
94+
Field used to serialize and deserialize ETH address type.
95+
"""
96+
97+
MAX_VALUE = 2**160
98+
REGEX_PATTERN = r"^0x[a-fA-F0-9]{40}$"
99+
100+
92101
class Uint64(NumberAsHex):
93102
"""
94103
Field used to serialize and deserialize RPC u64 type.

starknet_py/net/schemas/rpc/transactions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
)
2828
from starknet_py.net.schemas.common import (
2929
DAModeField,
30+
EthAddress,
3031
ExecutionStatusField,
3132
Felt,
3233
FinalityStatusField,
@@ -45,7 +46,7 @@
4546

4647
class L2toL1MessageSchema(Schema):
4748
l2_address = Felt(data_key="from_address", required=True)
48-
l1_address = Felt(data_key="to_address", required=True)
49+
l1_address = EthAddress(data_key="to_address", required=True)
4950
payload = fields.List(Felt(), data_key="payload", required=True)
5051

5152
@post_load

0 commit comments

Comments
 (0)