From db7c69e3d90974c3d2b27cbab7c844879f58c902 Mon Sep 17 00:00:00 2001 From: "Frank V. Castellucci" Date: Tue, 28 May 2024 04:10:08 -0400 Subject: [PATCH] Release 0.61.0 --- CHANGELOG.md | 4 +- README.md | 8 +-- doc/source/graphql_prog_txn.rst | 92 ++++++++++++++++++++++++++++++++- 3 files changed, 97 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 749fe98..f1a3afa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.61.0] - Unpublished +## [0.61.0] - 2024-05-28 ### Added @@ -31,7 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- Document updates +- Document updates (added graphql transaction builder samples) - Bumped dataclasses-json to 0.6.6 - Sui binary support range 1.20.x -> 1.27.x diff --git a/README.md b/README.md index 528c542..bce0557 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,10 @@ See [CHANGELOG](https://github.com/FrankC01/pysui/blob/main/CHANGELOG.md) ## PyPi current -**Release-0.60.0 - Released 2024-05-15** +**Release-0.61.0 - Released 2024-05-28** -- Supports _SUI 1.26.x RPC API_ -- Backwards compatable to _Sui 1.18.x RPC API_ +- Supports _SUI 1.27.x RPC API_ +- Backwards compatable to _Sui 1.20.x RPC API_ - [Latest PyPi Version](https://pypi.org/project/pysui/) @@ -39,7 +39,7 @@ MystenLabs announcement can be found [Here](https://github.com/mystenLabs/sui/is from JSON RPC to GraphQL RPC. Note: MystenLabs/Sui GraphQL RPC is available on devnet, testnet and mainnet. Note that devnet beta is still quite fragile and -we recommend using testnet beta. +we recommend using testnet beta. We are tracking a few failures we are monitoring [Isssues](https://github.com/FrankC01/pysui/issues?q=is%3Aissue+is%3Aopen++Sui+GraphQL+RPC). ### Sui GraphQL IDEs diff --git a/doc/source/graphql_prog_txn.rst b/doc/source/graphql_prog_txn.rst index 9c6491f..11da8c5 100644 --- a/doc/source/graphql_prog_txn.rst +++ b/doc/source/graphql_prog_txn.rst @@ -71,7 +71,7 @@ Legacy ) New ------- +--- .. code-block:: python :linenos: @@ -91,3 +91,93 @@ New "0x2::sui::SUI", ], ) + +=================== +DryRun Transaction +=================== + +Before executing a transaction for debugging and general insight into how the transaction may perform, you +can execute a DryRun: + +DryRun Lite +----------- +A lite weight dryrun just uses the TransactionKind (transaction before all gas is reconcilled). The query node to +use in this case is ``DryRunTransactionKind``. If no options are provided, Sui will provide defautls. See the +DryRunTransactionKind documentation. + +.. code-block:: python + :linenos: + + def dry_run_kind(txn:SuiTransaction): + """Uses defaults for DryRunTransactionKind.""" + raw_kind = txer.raw_kind() + raw_kind_ser = base64.b64encode(raw_kind.serialize().decode()) + + # Print the TransactionType BCS (pre-serialized) structure + # print(raw_kind.to_json(indent=2)) + # print(raw_kind_ser) + + # Execute the dry run for kind + result = txer.client.execute_query_node( + with_node=qn.DryRunTransactionKind(tx_bytestr=raw_kind_ser) + ) + + if result.is_ok(): + print(result.result_data.to_json(indent=2)) + else: + print(result.result_string) + +DryRun Full +----------- +The full dryrun is basiscally a fully built transaction without signatures, but +is dryrun for inspection + +.. code-block:: python + :linenos: + + def dry_run(txn:SuiTransaction): + """Uses fully built TransactionData for DryRunTransaction""" + raw_kind = txer.raw_kind() + # Print the TransactionData BCS (pre-serialized) structure + # print(raw_kind.to_json(indent=2)) + + # Execute the dry run + result = + txn.client.execute_query_node( + with_node=qn.DryRunTransaction(tx_bytestr=txn.build()) + ) + + if result.is_ok(): + print(result.result_data.to_json(indent=2)) + else: + print(result.result_string) + +=================== +Execute Transaction +=================== + +When it comes time to execute a transaction, both the bytecode of the transaction and signatures are +required: + +.. code-block:: python + :linenos: + + def transaction_execute(txn: SuiTransaction): + """Uses fully built and serialized TransactionData for ExecuteTransaction.""" + raw_kind = txn.raw_kind() + # Print the TransactionData BCS (pre-serialized) structure + # print(raw_kind.to_json(indent=2)) + + # Build and sign to get the base64 transaction bytes and list of signatures + tx_b64, sig_array = txer.build_and_sign() + # Execute the transaction + result = txer.client.execute_query_node( + with_node=qn.ExecuteTransaction(tx_bytestr=tx_b64, sig_array=sig_array)) + + if result.is_ok(): + # Unlike JSON RPC, the GraphRPC transaction execution just returns + # Status and the transaction digest. You can then take the transaction digest + # and then execute the GetTx for details. + print(result.result_data.to_json(indent=2)) + else: + print(result.result_string)