Skip to content

Commit

Permalink
Release 0.67.0. Closes #224
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankC01 committed Aug 12, 2024
1 parent 06b1a45 commit 14a15b0
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- [bug](https://github.com/FrankC01/pysui/issues/224) When previous txn digest not present

### Changed

- Bump version 0.67.0
Expand Down
29 changes: 27 additions & 2 deletions pgql_s_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def do_tx(client: SyncGqlClient):

handle_result(
client.execute_query_node(
with_node=qn.GetTx(digest="BJYyvkTgZBuMgBx8MmgcGtBTYqYZwpFQcc2YHZq4A6Z8")
with_node=qn.GetTx(digest="CqKm8efZcFJAFkfsygHmE8kHzWQJNPygSz8zmMginmHa")
)
)

Expand Down Expand Up @@ -595,6 +595,26 @@ def split_1_half(client: SyncGqlClient):
)


def split_any_half(client: SyncGqlClient):
"""Split the 1st coin in wallet to another another equal to 1/2 in wallet.
This will only run if there is more than 1 coin in wallet.
"""

result = client.execute_query_node(
with_node=qn.GetCoins(owner=client.config.active_address)
)
if result.is_ok() and len(result.result_data.data) > 1:
amount = int(int(result.result_data.data[0].balance) / 2)
txer: SuiTransaction = SuiTransaction(client=client)
scres = txer.split_coin(coin=result.result_data.data[0], amounts=[amount])
txer.transfer_objects(transfers=scres, recipient=client.config.active_address)
txdict = txer.build_and_sign()
handle_result(
client.execute_query_node(with_node=qn.ExecuteTransaction(**txdict))
)


def do_stake(client: SyncGqlClient):
"""Stake some coinage.
Expand Down Expand Up @@ -657,13 +677,17 @@ def do_unstake(client: SyncGqlClient):
client_init: SyncGqlClient = None
try:
cfg = PysuiConfiguration(
group_name=PysuiConfiguration.SUI_GQL_RPC_GROUP # , profile_name="testnet"
group_name=PysuiConfiguration.SUI_GQL_RPC_GROUP,
# profile_name="devnet",
# persist=True,
)
client_init = SyncGqlClient(write_schema=False, pysui_config=cfg)
print(f"Chain environment '{client_init.chain_environment}'")
print(f"Default schema base version '{client_init.base_schema_version}'")
print(f"Default schema build version '{client_init.schema_version()}'")
print()
# for pname in cfg.profile_names():
# print(pname)
## QueryNodes (fetch)
# do_coin_meta(client_init)
# do_coins_for_type(client_init)
Expand Down Expand Up @@ -703,6 +727,7 @@ def do_unstake(client: SyncGqlClient):
# do_dry_run_kind_new(client_init)
# do_execute_new(client_init)
# merge_some(client_init)
# split_any_half(client_init)
# split_1_half(client_init)
# do_stake(client_init)
# do_unstake(client_init)
Expand Down
5 changes: 5 additions & 0 deletions pysui/sui/sui_pgql/config/confgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ def active_profile(self, change_to: str) -> Profile:
return _res
raise ValueError(f"{change_to} profile does not exist")

@property
def profile_names(self) -> list[str]:
"""Fetch the names of the profiles in group."""
return [x.profile_name for x in self.profiles]

def get_profile(self, profile_name: str) -> Profile:
"""Attempt to fetch a profile considered available."""
_res = self._profile_exists(profile_name=profile_name)
Expand Down
15 changes: 15 additions & 0 deletions pysui/sui/sui_pgql/config/pysui_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,21 @@ def keypair_for_address(self, *, address: str, in_group: Optional[str] = None):
)
return _group.keypair_for_address(address=address)

def profile_names(self, *, in_group: Optional[str] = None) -> list[str]:
"""Return the profiles in a group. Default to active group."""
# If group specified and it's not the active
if in_group and self._model.group_active != in_group:
# If it exists and is not already the active group then set it
if _group := self._model.has_group(group_name=in_group):
self._model.active_group = in_group
_changes = True
else:
raise ValueError(f"{in_group} does not exist")
else:
_group = self.active_group

return _group.profile_names

def make_active(
self,
*,
Expand Down
3 changes: 2 additions & 1 deletion pysui/sui/sui_pgql/pgql_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ class ObjectReadGQL(PGQL_Type):
version: int # Yes
object_id: str # Yes
object_digest: str # Yes
previous_transaction_digest: str # Yes
object_kind: str # Yes

storage_rebate: str # Yes
Expand All @@ -302,10 +301,12 @@ class ObjectReadGQL(PGQL_Type):
SuiObjectOwnedShared,
SuiObjectOwnedImmutable,
]

has_public_transfer: Optional[bool] = False # Yes
object_type: Optional[str] = None
content: Optional[dict] = None
owner_id: Optional[str] = None
previous_transaction_digest: Optional[str] = None

@classmethod
def from_query(clz, in_data: dict) -> "ObjectReadGQL":
Expand Down

0 comments on commit 14a15b0

Please sign in to comment.