Skip to content

Commit

Permalink
Version 0.11.0. References #51
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankC01 committed Feb 2, 2023
1 parent f2d69bd commit c56c918
Show file tree
Hide file tree
Showing 10 changed files with 345 additions and 59 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unpublished]

Breaking changes

### Added

- Reintroduce GetRawObject builder and results
Expand All @@ -15,8 +17,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Added new required field for DevInspectTransaction `sender_address` as per [SUI 0.24.0](https://github.com/MystenLabs/sui/releases/tag/devnet-0.24.0)
- `package` on MoveCall transaction result type is now just a object ID string as per [SUI 0.24.0](https://github.com/MystenLabs/sui/releases/tag/devnet-0.24.0)

### Removed

- DevInspectMoveCall as per [SUI 0.24.0](https://github.com/MystenLabs/sui/releases/tag/devnet-0.24.0)

## [0.10.0] 2023-01-25

Breaking changes
Expand Down
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,26 @@
Python Client SDK for Sui blockchain

**NOTICE: README FIRST**
SUI 0.21.0 introduces a change to keystore (file) keystring persist.
SUI 0.21.0 introduced a change to keystore/keypair keystring.

If you still have keystores from pre 0.21.0, run the utility [keys-to-0210](https://github.com/FrankC01/pysui/blob/main/samples/README.md)

This utility SHOULD BE RUN BEFORE USING `pysui` SDK or samples

If you have already regenerated keys with the SUI 0.21.0, or later, binary install you can ignore the utility usage.

**Release-0.10.0**
**Release-0.11.0**

- Breaking changes
- 100% coverage (builders, return types, etc.) for parity with _SUI 0.23.0 API_ on devnet (see Testnet below)
- 100% coverage (builders, return types, etc.) for parity with _SUI 0.24.0 API_ on devnet (see Testnet below)
- ed25519,secp256k1 and secp256r1 account/keypairs supported
- `--with-unpublished-dependencies` on publish not yet supported [sui](https://github.com/MystenLabs/sui/pull/7426)
- Refer to the [Changes](https://github.com/FrankC01/pysui/blob/main/CHANGELOG.md) log for recent additions, changes, fixes and removals...

_Testnet support_
_Testnet not supported!_

- Testnet RPC API is versioned at 0.22.0 so some calls and results may break
- Publishing requires the 0.22.0 binaries installed
- Publishing requires the 0.22.0 binaries installed conflicting with the more recent devnet 0.24.0 binaries

**PyPi**

Expand All @@ -36,8 +37,6 @@ you may find interesting. It is a separate package also on on PyPi.

- [ReadTheDocs](https://pysui.readthedocs.io/en/latest/index.html)

Refer to the [Changes](https://github.com/FrankC01/pysui/blob/main/CHANGELOG.md) log for recent additions, changes, fixes and removals...

## Ready to run

Requires:
Expand Down
85 changes: 48 additions & 37 deletions pysui/sui/sui_builders/exec_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,53 +96,64 @@ class InspectTransaction(_NativeTransactionBuilder):
"""

@sui_builder()
def __init__(self, *, tx_bytes: SuiTxBytes, epoch: Optional[SuiInteger] = None) -> None:
def __init__(
self,
*,
sender_address: SuiAddress,
tx_bytes: SuiTxBytes,
gas_price: Optional[SuiInteger],
epoch: Optional[SuiInteger] = None,
) -> None:
"""__init__ Initialize builder.
:param sender_address: The sender/signer of transaction bytes
:type tx_bytes: SuiAddress
:param tx_bytes: The transaction bytes returned from previous tx executions to inspect
:type tx_bytes: SuiTxBytes
:param gas_price: Gas is not charged, but gas usage is still calculated. Default to use reference gas price
:type gas_price: Optional[SuiInteger]
:param epoch: The epoch to perform the call. Will be set from the system state object if not provided
:type epoch: Optional[SuiInteger]
"""
super().__init__("sui_devInspectTransaction", handler_cls=TxInspectionResult, handler_func="from_dict")


class InspectMoveCall(_NativeTransactionBuilder):
"""InspectMoveCall when executed, Similar to `MoveCall` but does not require gas object and budget.
The main purpose of this is to inspect the changes/effects of the call.
"""

@sui_builder()
def __init__(
self,
*,
sender_address: SuiAddress,
package_object_id: ObjectID,
module: SuiString,
function: SuiString,
type_arguments: SuiArray[SuiString],
arguments: SuiArray[SuiString],
epoch: Optional[SuiInteger] = None,
) -> None:
"""__init__ Builder initializer.
:param sender_address: the transaction signer's Sui address
:type sender_address: SuiAddress
:param package_object_id: the Move package ID, e.g. `0x2`
:type package_object_id: ObjectID
:param module: the Move module name, e.g. `devnet_nft`
:type module: SuiString
:param function: the move function name, e.g. `mint`
:type function: SuiString
:param type_arguments: the type arguments of the Move function
:type type_arguments: SuiArray[SuiString]
:param arguments: the arguments to be passed into the Move function
:type arguments: SuiArray[SuiString]
:param epoch: The epoch to perform the call. Will be set from the system state object if not provided
:type epoch: Optional[SuiInteger]
"""
super().__init__("sui_devInspectMoveCall", handler_cls=TxInspectionResult, handler_func="from_dict")
# class InspectMoveCall(_NativeTransactionBuilder):
# """InspectMoveCall when executed, Similar to `MoveCall` but does not require gas object and budget.

# The main purpose of this is to inspect the changes/effects of the call.
# """

# @sui_builder()
# def __init__(
# self,
# *,
# sender_address: SuiAddress,
# package_object_id: ObjectID,
# module: SuiString,
# function: SuiString,
# type_arguments: SuiArray[SuiString],
# arguments: SuiArray[SuiString],
# epoch: Optional[SuiInteger] = None,
# ) -> None:
# """__init__ Builder initializer.

# :param sender_address: the transaction signer's Sui address
# :type sender_address: SuiAddress
# :param package_object_id: the Move package ID, e.g. `0x2`
# :type package_object_id: ObjectID
# :param module: the Move module name, e.g. `devnet_nft`
# :type module: SuiString
# :param function: the move function name, e.g. `mint`
# :type function: SuiString
# :param type_arguments: the type arguments of the Move function
# :type type_arguments: SuiArray[SuiString]
# :param arguments: the arguments to be passed into the Move function
# :type arguments: SuiArray[SuiString]
# :param epoch: The epoch to perform the call. Will be set from the system state object if not provided
# :type epoch: Optional[SuiInteger]
# """
# super().__init__("sui_devInspectMoveCall", handler_cls=TxInspectionResult, handler_func="from_dict")


class _MoveCallTransactionBuilder(SuiBaseBuilder):
Expand Down
10 changes: 10 additions & 0 deletions pysui/sui/sui_builders/get_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,3 +675,13 @@ class GetReferenceGasPrice(_NativeTransactionBuilder):
def __init__(self):
"""Builder initializer."""
super().__init__("sui_getReferenceGasPrice")


class SignRandomnessObject(_NativeTransactionBuilder):
"""SignRandomnessObject Sign an a Randomness object with threshold BLS."""

@sui_builder()
def __init__(self, object_id: ObjectID, commitment_type: SuiString):
"""."""
super().__init__("sui_tblsSignRandomnessObject")
raise NotImplementedError(self)
12 changes: 5 additions & 7 deletions pysui/sui/sui_txresults/complex_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from dataclasses import dataclass, field
from typing import Any, Optional, Union
from dataclasses_json import DataClassJsonMixin, LetterCase, config
from pysui.sui.sui_txresults.common import CoinRef, GenericOwnerRef, GenericRef, PackageRef, SuiTxReturnType
from pysui.sui.sui_txresults.common import CoinRef, GenericOwnerRef, GenericRef, SuiTxReturnType
from pysui.sui.sui_types.collections import EventID


Expand All @@ -26,11 +26,9 @@ class MoveCallTx(SuiTxReturnType, DataClassJsonMixin):

function: str
module: str
package: PackageRef
arguments: Optional[list[Union[str, list[int]]]] = field(
metadata=config(letter_case=LetterCase.CAMEL), default_factory=list
)
type_arguments: Optional[list[str]] = field(metadata=config(letter_case=LetterCase.CAMEL), default_factory=list)
package: str
arguments: list[Any] = field(default_factory=list)
type_arguments: list[Any] = field(metadata=config(letter_case=LetterCase.CAMEL), default_factory=list)


@dataclass
Expand Down Expand Up @@ -282,7 +280,7 @@ class MoveEvent(SuiTxReturnType, DataClassJsonMixin):
package_id: str = field(metadata=config(letter_case=LetterCase.CAMEL))
transaction_module: str = field(metadata=config(letter_case=LetterCase.CAMEL))
sender: str
type: str = field(metadata=config(letter_case=LetterCase.CAMEL))
event_type: str = field(metadata=config(field_name="type"))
bcs: str
fields: dict

Expand Down
10 changes: 3 additions & 7 deletions pysui/sui/sui_txresults/single_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,9 @@ def __post_init__(self):
def _differentiate(cls, indata: dict) -> Union["ObjectRawRead", ObjectNotExist, ObjectDeleted]:
"""_differentiate determines concrete type and instantiates it.
:param indata: Dictionary mapped from JSON result of `sui_getObject`
:param indata: Dictionary mapped from JSON result of `sui_getRawObject`
:type indata: dict
:return: If it exists, ObjectRead subclass, if not ObjectNotExist or ObjectDeleted if it has been
:return: If it exists, ObjectRawRead subclass, if not ObjectNotExist or ObjectDeleted if it has been
:rtype: Union[ObjectRawRead, ObjectNotExist, ObjectDeleted]
"""
read_object = indata["details"]
Expand All @@ -423,10 +423,6 @@ def _differentiate(cls, indata: dict) -> Union["ObjectRawRead", ObjectNotExist,
result = ObjectRawRead.from_dict(read_object)
case "ObjectNotExists" | "NotExists":
result: ObjectRead = ObjectNotExist.from_dict({"object_id": read_object})
case "VersionNotFound":
result: ObjectRead = ObjectVersionNotFound.from_dict(
{"object_id": read_object[0], "version_requested": read_object[1]}
)
case "Deleted":
result: ObjectRead = ObjectDeleted.from_dict({"reference": read_object})
return result
Expand All @@ -435,7 +431,7 @@ def _differentiate(cls, indata: dict) -> Union["ObjectRawRead", ObjectNotExist,
def factory(cls, indata: Union[dict, list[dict]]) -> Union[Any, list]:
"""factory that consumes inbound data result.
:param indata: Data received from `sui_getObject`
:param indata: Data received from `sui_getRawObject`
:type indata: Union[dict, list[dict]]
:return: results of `indata` parse
:rtype: Union[Any, list]
Expand Down
10 changes: 10 additions & 0 deletions pysui/sui/sui_types/scalars.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ def limit(self) -> str:
"""Alias for transactions."""
return self.value

@property
def commitment_type(self) -> str:
"""Alias for transactions."""
return self.value


class SuiTxBytes(SuiString):
"""Sui Base64 tx_bytes string."""
Expand Down Expand Up @@ -287,6 +292,11 @@ def gas_budget(self) -> int:
"""Alias for transactions."""
return self.value

@property
def gas_price(self) -> int:
"""Alias for transactions."""
return self.value

@property
def amount(self) -> int:
"""Alias for transactions."""
Expand Down
2 changes: 1 addition & 1 deletion pysui/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# -*- coding: utf-8 -*-

"""Pysui Version."""
__version__ = "0.10.1"
__version__ = "0.11.0"
Loading

0 comments on commit c56c918

Please sign in to comment.