Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
overcat committed Nov 22, 2024
1 parent 601875b commit c250bc9
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Release History

### Pending

#### Update
- feat: add `stellar_sdk.contract.ContractClient` and `stellar_sdk.contract.ContractClientAsync`, this greatly reduces the difficulty of calling contracts, and you can learn more through the documentation and [examples](https://github.com/StellarCN/py-stellar-base/blob/main/examples/soroban_invoke_contract_function.py). ([#998](https://github.com/StellarCN/py-stellar-base/pull/998))

### Version 12.0.0-beta3

Released on November 14, 2024
Expand Down
32 changes: 32 additions & 0 deletions docs/en/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,39 @@ Response
.. autoclass:: stellar_sdk.client.response.Response
:members:

Contract
^^^^^^^^

ContractClient
---------------

.. autoclass:: stellar_sdk.contract.ContractClient
:members:

AssembledTransaction
--------------------

.. autoclass:: stellar_sdk.contract.AssembledTransaction
:members:


ContractClientAsync
-------------------

.. autoclass:: stellar_sdk.contract.ContractClientAsync
:members:

AssembledTransactionAsync
-------------------------

.. autoclass:: stellar_sdk.contract.AssembledTransactionAsync
:members:

Exceptions
----------

.. automodule:: stellar_sdk.contract.exceptions
:members:

Exceptions
^^^^^^^^^^
Expand Down
9 changes: 6 additions & 3 deletions examples/soroban_invoke_contract_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def parse_result_xdr(result):


te: AssembledTransaction[List[str]] = ContractClient(
contract_id, rpc_server_url, network_passphrase
).invoke("hello", [scval.to_string("world")])
te.result()
contract_id, rpc_server_url, network_passphrase,
).invoke("hello", [scval.to_string("world")], parse_result_xdr_fn=parse_result_xdr)
print(f"Result from simulation: {te.result}")

# hello is a read-only function, so we don't need to sign and submit the transaction.
# You can check `soroban_auth_atomic_swap.py` for an example of a function that requires signing and submitting.
8 changes: 4 additions & 4 deletions stellar_sdk/contract/assembled_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ class AssembledTransaction(Generic[T]):
"""A class representing an assembled Soroban transaction that can be simulated and sent.
The lifecycle of a transaction typically follows these steps:
1. Construct the transaction (usually via a Client)
2. Simulate the transaction
3. Sign the transaction
4. Submit the transaction
1. Construct the transaction (usually via a Client)
2. Simulate the transaction
3. Sign the transaction
4. Submit the transaction
:param transaction_builder: The transaction builder including the operation to invoke
:param server: The Soroban server instance to use
Expand Down
8 changes: 4 additions & 4 deletions stellar_sdk/contract/assembled_transaction_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ class AssembledTransactionAsync(Generic[T]):
"""A class representing an assembled Soroban transaction that can be simulated and sent.
The lifecycle of a transaction typically follows these steps:
1. Construct the transaction (usually via a Client)
2. Simulate the transaction
3. Sign the transaction
4. Submit the transaction
1. Construct the transaction (usually via a Client)
2. Simulate the transaction
3. Sign the transaction
4. Submit the transaction
:param transaction_builder: The transaction builder including the operation to invoke
:param server: The Soroban server instance to use
Expand Down

0 comments on commit c250bc9

Please sign in to comment.