Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
ddoktorski committed Jan 11, 2024
2 parents 9cfb21c + b12812e commit 1927a4d
Show file tree
Hide file tree
Showing 96 changed files with 2,863 additions and 4,141 deletions.
138 changes: 46 additions & 92 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: Checks

env:
STARKNET_VERSION: "0.13.0"
RPC_SPEC_VERSION: "0.6.0"
DEVNET_SHA: "1bd447d"

on:
push:
branches:
Expand Down Expand Up @@ -115,48 +120,6 @@ jobs:
name: contract-artifacts
path: starknet_py/tests/e2e/mock/

# ====================== CAIRO SETUP ====================== #

- name: Install rust
run: |
curl https://sh.rustup.rs -sSf | sh -s -- -y
- name: Clone Cairo1 compiler repository
uses: actions/checkout@v3
with:
repository: starkware-libs/cairo
persist-credentials: false
ref: v2.0.0
path: cairo

- name: Cache rust dependencies
id: cache-rust
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Build compiler
if: steps.cache-rust.outputs.cache-hit != 'true'
working-directory: ./cairo
run: |
cargo build
- name: Build starknet-compile
working-directory: ./cairo
run: |
cargo run --bin starknet-compile -- --version
cargo run --bin starknet-sierra-compile -- --version
- name: Create manifest file
run: |
readlink -f cairo/Cargo.toml >> starknet_py/tests/e2e/manifest-path
# ---------------------------------------------------------- #
# ........................RUN-TESTS......................... #
# ---------------------------------------------------------- #
Expand All @@ -171,6 +134,8 @@ jobs:
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
steps:
- uses: actions/checkout@v3
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: Swatinem/rust-cache@v2

- name: Download contracts
uses: actions/download-artifact@v3
Expand Down Expand Up @@ -206,6 +171,14 @@ jobs:
run: |
poetry install --without py39-dev
# ====================== SETUP DEVNET ====================== #

- name: Install devnet
run: |
cargo install --locked \
--git https://github.com/0xSpaceShard/starknet-devnet-rs.git \
--rev ${{ env.DEVNET_SHA }}
# ====================== RUN TESTS ====================== #

- name: Check circular imports
Expand All @@ -214,10 +187,8 @@ jobs:
- name: Run tests
run: |
poetry run poe test_ci_full_node_v2
poetry run poe test_ci_full_node_v1
poetry run poe test_ci_gateway_v2
poetry run poe test_ci_gateway_v1
poetry run poe test_ci_v2
poetry run poe test_ci_v1
- name: Generate coverage in XML
run: |
Expand Down Expand Up @@ -288,8 +259,7 @@ jobs:
- name: Run tests
run: |
poetry run poe test_ci_on_networks_full_node
poetry run poe test_ci_on_networks_gateway
poetry run poe test_ci_on_networks
- name: Generate coverage in XML
run: |
Expand All @@ -313,6 +283,8 @@ jobs:
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
steps:
- uses: actions/checkout@v3
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: Swatinem/rust-cache@v2

- name: Download contracts
uses: actions/download-artifact@v3
Expand All @@ -325,22 +297,10 @@ jobs:
python-version: "3.9"
cache: 'pip'

# ====================== SETUP WSL ====================== #
# ====================== SETUP DEVNET ====================== #

- name: Setup WSL
uses: Vampire/setup-wsl@v2

- name: Setup WSL devnet
shell: wsl-bash {0}
run: |
sudo apt-get -y update
sudo apt install -y wget software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install -y python3.9
apt-get install -y python3-pip
sudo apt install -y libgmp3-dev
sudo apt-get install -y git
pip3 install git+https://github.com/0xSpaceShard/starknet-devnet.git@v0.6.2
- name: Install devnet
run: cargo install --locked --git https://github.com/0xSpaceShard/starknet-devnet-rs.git --rev ${{ env.DEVNET_SHA }}

# ====================== SETUP PYTHON ====================== #

Expand Down Expand Up @@ -373,10 +333,8 @@ jobs:
- name: Run tests
run: |
poetry run poe test_ci_full_node_v2
poetry run poe test_ci_full_node_v1
poetry run poe test_ci_gateway_v2
poetry run poe test_ci_gateway_v1
poetry run poe test_ci_v2
poetry run poe test_ci_v1
- name: Generate coverage in XML
run: |
Expand All @@ -399,6 +357,8 @@ jobs:
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
steps:
- uses: actions/checkout@v3
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: Swatinem/rust-cache@v2

- name: Download contracts
uses: actions/download-artifact@v3
Expand Down Expand Up @@ -434,14 +394,20 @@ jobs:
run: |
poetry install --without py39-dev
# ====================== SETUP DEVNET ====================== #

- name: Install devnet
run: |
cargo install --locked \
--git https://github.com/0xSpaceShard/starknet-devnet-rs.git \
--rev ${{ env.DEVNET_SHA }}
# ====================== RUN TESTS ====================== #

- name: Run tests
run: |
poetry run poe test_ci_docs_full_node_v2
poetry run poe test_ci_docs_full_node_v1
poetry run poe test_ci_docs_gateway_v2
poetry run poe test_ci_docs_gateway_v1
poetry run poe test_ci_docs_v2
poetry run poe test_ci_docs_v1
- name: Generate coverage in XML
run: |
Expand All @@ -465,6 +431,8 @@ jobs:
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
steps:
- uses: actions/checkout@v3
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: Swatinem/rust-cache@v2

- name: Download contracts
uses: actions/download-artifact@v3
Expand All @@ -477,23 +445,6 @@ jobs:
python-version: "3.9"
cache: 'pip'

# ====================== SETUP WSL ====================== #

- name: Setup WSL
uses: Vampire/setup-wsl@v2

- name: Setup WSL devnet
shell: wsl-bash {0}
run: |
sudo apt-get -y update
sudo apt install -y wget software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install -y python3.9
apt-get install -y python3-pip
sudo apt install -y libgmp3-dev
sudo apt-get install -y git
pip3 install git+https://github.com/0xSpaceShard/starknet-devnet.git@v0.6.2
# ====================== SETUP PYTHON ====================== #

- name: Install poetry
Expand All @@ -517,14 +468,17 @@ jobs:
run: |
poetry install --without py39-dev
# ====================== SETUP DEVNET ====================== #

- name: Install devnet
run: cargo install --locked --git https://github.com/0xSpaceShard/starknet-devnet-rs.git --rev ${{ env.DEVNET_SHA }}

# ====================== RUN TESTS ====================== #

- name: Run tests
run: |
poetry run poe test_ci_docs_full_node_v2
poetry run poe test_ci_docs_full_node_v1
poetry run poe test_ci_docs_gateway_v2
poetry run poe test_ci_docs_gateway_v1
poetry run poe test_ci_docs_v2
poetry run poe test_ci_docs_v1
- name: Generate coverage in XML
run: |
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ This is the recommended way of using the SDK.

```python
from starknet_py.contract import Contract
from starknet_py.net.gateway_client import GatewayClient
from starknet_py.net.full_node_client import FullNodeClient

contract = await Contract.from_address(
address="0x06689f1bf69af5b8e94e5ab9778c885b37c593d1156234eb423967621f596e73",
client=GatewayClient("testnet"),
client=FullNodeClient(node_url="https://your.node.url"),
)
(value,) = await contract.functions["get_balance"].call()
```
Expand All @@ -52,11 +52,11 @@ You can access synchronous world with `_sync` postfix.

```python
from starknet_py.contract import Contract
from starknet_py.net.gateway_client import GatewayClient
from starknet_py.net.full_node_client import FullNodeClient

contract = Contract.from_address_sync(
address="0x06689f1bf69af5b8e94e5ab9778c885b37c593d1156234eb423967621f596e73",
client=GatewayClient("testnet"),
client=FullNodeClient(node_url="https://your.node.url"),
)
(value,) = contract.functions["get_balance"].call_sync()
```
Expand Down
1 change: 0 additions & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ API
.. toctree::

api/client
api/gateway_client
api/full_node_client
api/account
api/client_models
Expand Down
2 changes: 1 addition & 1 deletion docs/api/client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Client
======

Base class for clients interacting with Starknet.
Implemented by :ref:`GatewayClient` and :ref:`FullNodeClient`.
Implemented by :ref:`FullNodeClient`.

.. py:module:: starknet_py.net.client
Expand Down
8 changes: 0 additions & 8 deletions docs/api/gateway_client.rst

This file was deleted.

15 changes: 12 additions & 3 deletions docs/api/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,25 @@ Module containing base models and functions to operate on them.
:exclude-members: __init__, __new__
:members:

.. autoclass:: DeployAccount
.. autoclass:: DeployAccountV1
:exclude-members: __init__, __new__

.. autoclass:: Declare
.. autoclass:: DeployAccountV3
:exclude-members: __init__, __new__

.. autoclass:: DeclareV1
:exclude-members: __init__, __new__

.. autoclass:: DeclareV2
:exclude-members: __init__, __new__

.. autoclass:: Invoke
.. autoclass:: DeclareV3
:exclude-members: __init__, __new__

.. autoclass:: InvokeV1
:exclude-members: __init__, __new__

.. autoclass:: InvokeV3
:exclude-members: __init__, __new__

.. autoenum:: StarknetChainId
Expand Down
3 changes: 3 additions & 0 deletions docs/api/transaction_errors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ Transaction errors
.. autoclass:: TransactionRejectedError
:exclude-members: __init__, __new__

.. autoclass:: TransactionRevertedError
:exclude-members: __init__, __new__

.. autoclass:: TransactionNotReceivedError
:exclude-members: __init__, __new__
22 changes: 17 additions & 5 deletions docs/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,23 @@ Make sure running ``poetry run python --version`` returns ``Python 3.9.x``.
Setup
-----

In order to run Cairo1 devnet tests and compile contracts in Cairo1 via poetry command,
you need to create ``manifest-path`` file in ``starknet_py/tests/e2e/`` directory and pass the path in it to Cairo compiler.
An example file - ``manifest-path.template`` is in the same directory. Additional info can be found in `devnet docs <https://0xspaceshard.github.io/starknet-devnet/docs/guide/cairo1-support>`_.
In order to run tests on devnet, you need to install `starknet-devnet-rs <https://github.com/0xSpaceShard/starknet-devnet-rs>`_.
The correct version of devnet to use corresponds to the Starknet and RPC specification that are currently supported by Starknet.py.
Information about the supported version for the latest release can be found in the :doc:`migration guide<migration_guide>`.

To avoid version discrepancies or other related issues, we recommend installing this dependency using the ``cargo install`` command, and specifying a certain commit along with the correct Starknet and RPC versions.

Below is the command you can use to do this, designed for compatibility with the current version of Starknet.py:

.. code-block:: bash
STARKNET_VERSION="0.12.3" RPC_SPEC_VERSION="0.5.1" \
cargo install \
--locked \
--git https://github.com/0xSpaceShard/starknet-devnet-rs.git \
--rev 78527de
If you choose to install `starknet-devnet-rs <https://github.com/0xSpaceShard/starknet-devnet-rs>`_ using a different method, please make sure to add the executable ``starknet-devnet`` to your ``PATH`` environment variable.

In order to be able to run tests on testnet and integration networks (``starknet_py/tests/e2e/tests_on_networks/``), you must set some environmental variables:

Expand All @@ -38,8 +52,6 @@ You can find an example file ``test-variables.env.template`` in the same directo
# Compile contracts
poe compile_contracts
poe compile_contracts_v1
poe compile_contracts_v2
# Make sure everything was installed properly
poe test
Expand Down
Loading

0 comments on commit 1927a4d

Please sign in to comment.