Skip to content

Commit

Permalink
Release 0.72.0
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankC01 committed Nov 11, 2024
1 parent 0e126c8 commit 7160530
Show file tree
Hide file tree
Showing 14 changed files with 297 additions and 64 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ protocol.json
backup/
ser_deser_txn.py
ser_sample.json
ser_txn.py
*_schema-*.graphql


Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@ 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.72.0] - Unpublished

### Added

- GraphQL: Transaction execution adds BCS in result (Base64 encoded bcs serialization of the on-chain transaction effects.)
- GraphQL: bcs_txne.py BCS Definition for V1 and V2 TransactionEffects

### Fixed

### Changed

- [change](https://github.com/FrankC01/pysui/issues/239)
- JSON RPC: Sync and Async transactions accept Argument as recipient in `transfer_objects`
- GraphQL: Sync and Async transactions accept Argument as recipient in `transfer_objects`

### Removed

## [0.71.0] - 2024-10-30

### Added
Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ Python Client SDK for Sui blockchain

## pysui SDK current (github)

**Release-0.71.0**
**Release-0.72.0**

**Note**: A new GraphQL schema change breaks usage on mainnet. Waiting for schema change to be
deployed there before releasing.

- Supports _SUI 1.37.x JSON RPC API_, _SUI 1.36.x GRAPHQL_
- Supports _SUI 1.38.x JSON RPC API_, _SUI 1.37.x GRAPHQL_
- JSON RPC API backwards compatable to _Sui 1.30.x_

See [CHANGELOG](https://github.com/FrankC01/pysui/blob/main/CHANGELOG.md)
Expand Down
4 changes: 2 additions & 2 deletions pysui/sui/sui_clients/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ class ClientMixin(Provider):
constructor consistency as well as utility functions
"""

_RPC_MINIMAL_VERSION: str = "1.30.0"
_RPC_REQUIRED_VERSION: str = "1.36.0"
_RPC_MINIMAL_VERSION: str = "1.31.0"
_RPC_REQUIRED_VERSION: str = "1.37.0"

@versionchanged(
version="0.26.1",
Expand Down
5 changes: 3 additions & 2 deletions pysui/sui/sui_pgql/pgql_async_txn.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,18 +306,19 @@ async def split_coin_equal(
res_count=retcount,
)

@versionchanged(version="0.72.0", reason="Support recipient passed as Argument")
async def transfer_objects(
self,
*,
transfers: list[Union[str, pgql_type.ObjectReadGQL, bcs.Argument]],
recipient: str,
recipient: Union[str, bcs.Argument],
) -> bcs.Argument:
"""transfer_objects Transfers one or more objects to a recipient.
:param transfers: A list or SuiArray of objects to transfer
:type transfers: list[Union[str, pgql_type.ObjectReadGQL, bcs.Argument]]
:param recipient: The recipient address that will receive the objects being transfered
:type recipient: str
:type recipient: Union[str, bcs.Argument]
:return: The command result. Can NOT be used as input in subsequent commands.
:rtype: bcs.Argument
"""
Expand Down
1 change: 1 addition & 0 deletions pysui/sui/sui_pgql/pgql_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -1567,6 +1567,7 @@ def as_document_node(self, schema: DSLSchema) -> DocumentNode:
schema.TransactionBlockEffects.transactionBlock.select(
schema.TransactionBlock.digest
),
schema.TransactionBlockEffects.bcs,
),
)
return dsl_gql(DSLMutation(qres))
Expand Down
5 changes: 3 additions & 2 deletions pysui/sui/sui_pgql/pgql_sync_txn.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,18 +301,19 @@ def split_coin_equal(
res_count=retcount,
)

@versionchanged(version="0.72.0", reason="Support recipient passed as Argument")
def transfer_objects(
self,
*,
transfers: list[Union[str, pgql_type.ObjectReadGQL, bcs.Argument]],
recipient: str,
recipient: Union[str, bcs.Argument],
) -> bcs.Argument:
"""transfer_objects Transfers one or more objects to a recipient.
:param transfers: A list or SuiArray of objects to transfer
:type transfers: list[Union[str, pgql_type.ObjectReadGQL, bcs.Argument]]
:param recipient: The recipient address that will receive the objects being transfered
:type recipient: str
:type recipient: Union[str, bcs.Argument]
:return: The command result. Can NOT be used as input in subsequent commands.
:rtype: bcs.Argument
"""
Expand Down
1 change: 1 addition & 0 deletions pysui/sui/sui_pgql/pgql_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ class ExecutionResultGQL(PGQL_Type):
status: str
lamport_version: int
digest: str
bcs: str
errors: Optional[list[str]] = None

@classmethod
Expand Down
14 changes: 10 additions & 4 deletions pysui/sui/sui_txn/async_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -1115,14 +1115,15 @@ async def public_transfer_object(
type_arguments=[obj_type_tag],
)

@versionchanged(version="0.72.0", reason="Support recipient passed as Argument")
async def transfer_objects(
self,
*,
transfers: Union[
list[Union[str, ObjectID, ObjectRead, SuiCoinObject, bcs.Argument]],
SuiArray,
],
recipient: Union[ObjectID, SuiAddress],
recipient: Union[ObjectID, SuiAddress, bcs.Argument],
) -> bcs.Argument:
"""transfer_objects Transfers one or more objects to a recipient.
Expand All @@ -1137,7 +1138,9 @@ async def transfer_objects(
assert isinstance(
transfers, (list, SuiArray, bcs.Argument)
), "Unsupported trasfers collection type"
assert isinstance(recipient, (ObjectID, SuiAddress)), "invalid recipient type"
assert isinstance(
recipient, (ObjectID, SuiAddress, bcs.Argument)
), "invalid recipient type"
if isinstance(transfers, (list, SuiArray)):
transfers = transfers if isinstance(transfers, list) else transfers.array
coerced_transfers: list = []
Expand All @@ -1151,9 +1154,12 @@ async def transfer_objects(
else:
coerced_transfers.append(txfer)
transfers = await self._resolve_arguments(coerced_transfers)
return self.builder.transfer_objects(
tx_builder.PureInput.as_input(recipient), transfers
recipient = (
tx_builder.PureInput.as_input(recipient)
if not isinstance(recipient, bcs.Argument)
else recipient
)
return self.builder.transfer_objects(recipient, transfers)

async def transfer_sui(
self,
Expand Down
14 changes: 10 additions & 4 deletions pysui/sui/sui_txn/sync_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -1130,14 +1130,15 @@ def public_transfer_object(
type_arguments=[obj_type_tag],
)

@versionchanged(version="0.72.0", reason="Support recipient passed as Argument")
def transfer_objects(
self,
*,
transfers: Union[
list[Union[str, ObjectID, ObjectRead, SuiCoinObject, bcs.Argument]],
SuiArray,
],
recipient: Union[ObjectID, SuiAddress],
recipient: Union[ObjectID, SuiAddress, bcs.Argument],
) -> bcs.Argument:
"""transfer_objects Transfers one or more objects to a recipient.
Expand All @@ -1152,7 +1153,9 @@ def transfer_objects(
assert isinstance(
transfers, (list, SuiArray, bcs.Argument)
), "Unsupported trasfers collection type"
assert isinstance(recipient, (ObjectID, SuiAddress)), "invalid recipient type"
assert isinstance(
recipient, (ObjectID, SuiAddress, bcs.Argument)
), "invalid recipient type"
if isinstance(transfers, (list, SuiArray)):
transfers = transfers if isinstance(transfers, list) else transfers.array
coerced_transfers: list = []
Expand All @@ -1166,9 +1169,12 @@ def transfer_objects(
else:
coerced_transfers.append(txfer)
transfers = self._resolve_arguments(coerced_transfers)
return self.builder.transfer_objects(
tx_builder.PureInput.as_input(recipient), transfers
recipient = (
tx_builder.PureInput.as_input(recipient)
if not isinstance(recipient, bcs.Argument)
else recipient
)
return self.builder.transfer_objects(recipient, transfers)

def transfer_sui(
self,
Expand Down
56 changes: 12 additions & 44 deletions pysui/sui/sui_types/bcs.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# Copyright Frank V. Castellucci
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# SPDX-License-Identifier: Apache-2.0

# -*- coding: utf-8 -*-

"""Sui BCS Types."""
"""Core Sui BCS Types."""

import binascii
import copy
Expand All @@ -25,7 +17,12 @@
from pysui.sui.sui_txresults.common import GenericRef
from pysui.sui.sui_txresults.single_tx import ObjectRead
from pysui.sui.sui_types.address import SuiAddress
from pysui.sui.sui_utils import b58str_to_list, hexstring_to_list, hexstring_to_sui_id
from pysui.sui.sui_utils import (
b58str_to_list,
hexstring_to_list,
hexstring_to_sui_id,
from_list_to_b58str,
)
import pysui.sui.sui_pgql.pgql_types as pgql_type

_ADDRESS_LENGTH: int = 32
Expand Down Expand Up @@ -66,6 +63,10 @@ class Digest(canoser.Struct):

_fields = [("Digest", canoser.ArrayT(canoser.Uint8, _DIGEST_LENGTH))]

def to_digest_str(self) -> str:
"""Convert bytes to base58 digest str."""
return from_list_to_b58str(self.Digest)

@classmethod
def from_str(cls, indata: str) -> "Digest":
"""Digest from base58 string."""
Expand Down Expand Up @@ -224,39 +225,6 @@ def from_gql_ref(cls, indata: pgql_type.ObjectReadGQL) -> "ObjectReference":
raise ValueError(f"{indata} is not valid")


# @versionadded(version="0.54.0", reason="Support argument inferencing")
# class ReceivingReference(canoser.Struct):
# """ReceivingReference represents an object by it's objects reference fields."""

# _fields = [
# ("ObjectID", Address),
# ("SequenceNumber", canoser.Uint64),
# ("ObjectDigest", Digest),
# ]

# @classmethod
# def from_obj_ref(cls, indata: ObjectReference) -> "ReceivingReference":
# """Convert from ObjectReference to ReceivingReference."""
# return cls(indata.ObjectID, indata.SequenceNumber, indata.ObjectDigest)

# @classmethod
# def from_gql_ref(cls, indata: pgql_type.ObjectReadGQL) -> "ReceivingReference":
# """from_generic_ref init construct with GenericRef from ObjectRead structure.

# :param indata: The reference information for an Object from ObjectRead
# :type indata: GenericRef
# :return: The instantiated BCS object
# :rtype: SharedObjectReference
# """
# if isinstance(indata, pgql_type.ObjectReadGQL):
# return cls(
# Address.from_str(indata.object_id),
# indata.version,
# Digest.from_str(indata.object_digest),
# )
# raise ValueError(f"{indata} is not valid")


class SharedObjectReference(canoser.Struct):
"""SharedObjectReference represents a shared object by it's objects reference fields."""

Expand Down
Loading

0 comments on commit 7160530

Please sign in to comment.