Skip to content

Commit 174f0b7

Browse files
Migrate docs to FullNodeClient (#1092)
* migrated docs to fullnode * format * review fixes * docs change * docs fix * Update docs/guide/account_and_client.rst --------- Co-authored-by: Kamil Jankowski <kamil.jankowski.x@gmail.com>
1 parent 76f02e7 commit 174f0b7

File tree

9 files changed

+36
-50
lines changed

9 files changed

+36
-50
lines changed

docs/guide/account_and_client.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ Note that the nonce will be bumped only by 1.
4343
FullNodeClient usage
4444
--------------------
4545

46-
Use a :ref:`FullNodeClient` to interact with services providing `Starknet rpc interface <https://github.com/starkware-libs/starknet-specs/blob/606c21e06be92ea1543fd0134b7f98df622c2fbf/api/starknet_api_openrpc.json>`_
47-
like `Pathfinder Full Node <https://github.com/eqlabs/pathfinder>`_ or starknet-devnet. starknet.py provides uniform interface for
48-
both gateway and full node client - usage is exactly the same as gateway client minus some optional
49-
parameters.
50-
46+
Use a :ref:`FullNodeClient` to interact with services providing `Starknet RPC interface <https://github.com/starkware-libs/starknet-specs/blob/606c21e06be92ea1543fd0134b7f98df622c2fbf/api/starknet_api_openrpc.json>`_
47+
like `Pathfinder <https://github.com/eqlabs/pathfinder>`_,
48+
`Papyrus <https://github.com/starkware-libs/papyrus>`_, `Juno <https://github.com/NethermindEth/juno>`_
49+
or `starknet-devnet <https://github.com/0xSpaceShard/starknet-devnet>`_.
5150
Using own full node allows for querying Starknet with better performance.
52-
Since gateway will be deprecated at some point in the future, having ``FullNodeClient`` with interface uniform with that of ``GatewayClient``
53-
will allow for simple migration for starknet.py users.
51+
52+
Since GatewayClient is deprecated and will be removed at some point in the future, having ``FullNodeClient``
53+
with interface uniform with that of ``GatewayClient`` will allow for simple migration for starknet.py users.
5454

5555
.. codesnippet:: ../../starknet_py/tests/e2e/docs/guide/test_full_node_client.py
5656
:language: python

starknet_py/tests/e2e/docs/account_creation/test_deploy_prefunded_account.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@ async def test_deploy_prefunded_account(
1212
account_with_validate_deploy_class_hash: int,
1313
network: str,
1414
fee_contract: Contract,
15-
gateway_client: Client,
15+
full_node_client: Client,
1616
):
1717
# pylint: disable=import-outside-toplevel, too-many-locals
1818
# docs: start
1919
from starknet_py.hash.address import compute_address
2020
from starknet_py.net.account.account import Account
21-
from starknet_py.net.gateway_client import GatewayClient
21+
from starknet_py.net.full_node_client import FullNodeClient
2222
from starknet_py.net.models import StarknetChainId
23-
from starknet_py.net.networks import TESTNET
2423
from starknet_py.net.signer.stark_curve_signer import KeyPair
2524

2625
# First, make sure to generate private key and salt
@@ -50,11 +49,11 @@ async def test_deploy_prefunded_account(
5049
# docs: start
5150

5251
# Define the client to be used to interact with Starknet
53-
client = GatewayClient(net=TESTNET)
52+
client = FullNodeClient(node_url="your.node.url")
5453
chain = StarknetChainId.TESTNET
5554
# docs: end
5655

57-
client = gateway_client
56+
client = full_node_client
5857
chain = chain_from_network(net=network, chain=StarknetChainId.TESTNET)
5958
# docs: start
6059

starknet_py/tests/e2e/docs/code_examples/test_account.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717

1818
def test_init():
1919
# docs-start: init
20+
account = Account(
21+
address=0x123,
22+
client=FullNodeClient(node_url="your.node.url"),
23+
key_pair=KeyPair(12, 34),
24+
chain=StarknetChainId.TESTNET,
25+
)
26+
# or (not recommended, soon GatewayClient will be removed)
2027
account = Account(
2128
address=0x123,
2229
client=GatewayClient(net=TESTNET),
@@ -26,13 +33,6 @@ def test_init():
2633
chain_id=StarknetChainId.TESTNET,
2734
),
2835
)
29-
# or
30-
account = Account(
31-
address=0x123,
32-
client=FullNodeClient(node_url="your.node.url"),
33-
key_pair=KeyPair(12, 34),
34-
chain=StarknetChainId.TESTNET,
35-
)
3636
# docs-end: init
3737

3838

starknet_py/tests/e2e/docs/code_examples/test_contract.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ def test_init():
2424
],
2525
provider=Account(
2626
address=0x321,
27-
client=GatewayClient(TESTNET),
27+
client=FullNodeClient(node_url="your.node.url"),
2828
key_pair=KeyPair(12, 34),
2929
chain=StarknetChainId.TESTNET,
3030
),
3131
)
32-
# or
32+
# or (not recommended, soon GatewayClient will be removed)
3333
contract = Contract(
3434
address=0x123,
3535
abi=[
@@ -42,7 +42,7 @@ def test_init():
4242
],
4343
provider=Account(
4444
address=0x321,
45-
client=FullNodeClient(TESTNET),
45+
client=GatewayClient(TESTNET),
4646
key_pair=KeyPair(12, 34),
4747
chain=StarknetChainId.TESTNET,
4848
),

starknet_py/tests/e2e/docs/guide/test_cairo1_contract.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import pytest
44

55
from starknet_py.net.client_models import CasmClass
6-
from starknet_py.net.gateway_client import GatewayClient
76
from starknet_py.net.udc_deployer.deployer import _get_random_salt
87
from starknet_py.tests.e2e.fixtures.constants import CONTRACTS_COMPILED_V1_DIR, MAX_FEE
98
from starknet_py.tests.e2e.fixtures.misc import read_contract
@@ -13,23 +12,17 @@
1312
async def test_cairo1_contract(
1413
account,
1514
sierra_minimal_compiled_contract_and_class_hash,
16-
another_sierra_minimal_compiled_contract_and_class_hash,
1715
gateway_client,
1816
):
19-
# pylint: disable=import-outside-toplevel, too-many-locals
17+
# pylint: disable=too-many-locals
18+
# pylint: disable=import-outside-toplevel
2019
(
2120
compiled_contract,
2221
compiled_class_hash,
23-
) = (
24-
sierra_minimal_compiled_contract_and_class_hash
25-
if isinstance(account.client, GatewayClient)
26-
else another_sierra_minimal_compiled_contract_and_class_hash
27-
)
22+
) = sierra_minimal_compiled_contract_and_class_hash
2823

2924
contract_compiled_casm = read_contract(
30-
"minimal_contract_compiled.casm"
31-
if isinstance(account.client, GatewayClient)
32-
else "another_minimal_contract_compiled.casm",
25+
"minimal_contract_compiled.casm",
3326
directory=CONTRACTS_COMPILED_V1_DIR,
3427
)
3528

@@ -94,6 +87,6 @@ async def test_cairo1_contract(
9487
assert contract_deployment.address != 0
9588

9689
compiled_class = await gateway_client.get_compiled_class_by_class_hash(
97-
sierra_class_hash
90+
class_hash=sierra_class_hash
9891
)
9992
assert isinstance(compiled_class, CasmClass)

starknet_py/tests/e2e/docs/guide/test_custom_nonce.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77

88
@pytest.mark.asyncio
9-
async def test_custom_nonce(gateway_client):
9+
async def test_custom_nonce(full_node_client):
1010
# pylint: disable=import-outside-toplevel
1111
address = 0x1
12-
client = gateway_client
12+
client = full_node_client
1313
private_key = 0x1
1414

1515
# docs: start

starknet_py/tests/e2e/docs/guide/test_custom_signer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ async def test_custom_signer():
99

1010
# docs: start
1111
from starknet_py.net.account.account import Account
12-
from starknet_py.net.gateway_client import GatewayClient
12+
from starknet_py.net.full_node_client import FullNodeClient
1313
from starknet_py.net.models import StarknetChainId, Transaction
1414
from starknet_py.net.signer import BaseSigner
1515
from starknet_py.utils.typed_data import TypedData
@@ -30,7 +30,7 @@ def sign_message(
3030

3131
# Create an Account instance with the signer you've implemented
3232
custom_signer = CustomSigner()
33-
client = GatewayClient("testnet")
33+
client = FullNodeClient(node_url="your.node.url")
3434
account = Account(
3535
client=client,
3636
address=0x1111,

starknet_py/tests/e2e/docs/guide/test_sign_offchain_message.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ async def test_sign_offchain_message(account):
77

88
# docs: start
99
from starknet_py.net.account.account import Account
10-
from starknet_py.net.gateway_client import GatewayClient
10+
from starknet_py.net.full_node_client import FullNodeClient
1111
from starknet_py.net.models import StarknetChainId
1212
from starknet_py.net.signer.stark_curve_signer import KeyPair
1313
from starknet_py.utils.typed_data import TypedData
@@ -52,7 +52,7 @@ async def test_sign_offchain_message(account):
5252
# docs: start
5353

5454
# Create an Account instance
55-
client = GatewayClient("testnet")
55+
client = FullNodeClient(node_url="your.node.url")
5656
account = Account(
5757
client=client,
5858
address="0x1111",

starknet_py/tests/e2e/docs/quickstart/test_creating_account.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,17 @@
44

55

66
@pytest.mark.asyncio
7-
async def test_creating_account(network):
7+
async def test_creating_account():
88
# pylint: disable=import-outside-toplevel, unused-variable
99
# docs: start
1010
from starknet_py.net.account.account import Account
11-
from starknet_py.net.gateway_client import GatewayClient
11+
from starknet_py.net.full_node_client import FullNodeClient
1212
from starknet_py.net.models.chains import StarknetChainId
1313
from starknet_py.net.signer.stark_curve_signer import KeyPair
1414

15-
testnet = "testnet"
16-
# docs: end
17-
testnet = network
18-
# docs: start
19-
20-
# Creates an instance of account which is already deployed (testnet)
21-
15+
# Creates an instance of account which is already deployed
2216
# Account using transaction version=1 (has __validate__ function)
23-
client = GatewayClient(net=testnet)
17+
client = FullNodeClient(node_url="your.node.url")
2418
account = Account(
2519
client=client,
2620
address="0x4321",

0 commit comments

Comments
 (0)