Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: staking related cli is not supported in sdk 0.50 #122

Merged
merged 6 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Problem: status and staking related cli is not adjusted for sdk 0.50
  • Loading branch information
mmsqe committed Mar 14, 2024
commit 15e628b62c13bdb56b51174586bc68b34aeb49fe
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- [#115](https://github.com/crypto-com/pystarport/pull/115) avoid cli redundant migrated key log in stdout.
- [#117](https://github.com/crypto-com/pystarport/pull/117) make event_query_tx_for optional.
- [#121](https://github.com/crypto-com/pystarport/pull/121) Support sdk 0.50
- [#122](https://github.com/crypto-com/pystarport/pull/122) Adjust status and staking related cli for sdk 0.50


*Feb 7, 2023*
Expand Down
6 changes: 3 additions & 3 deletions pystarport/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from .cosmoscli import ChainCommand, CosmosCLI, ModuleAccount, module_address
from .expansion import expand_jsonnet, expand_yaml
from .ledger import ZEMU_BUTTON_PORT, ZEMU_HOST
from .utils import format_doc_string, interact, write_ini
from .utils import format_doc_string, get_sync_info, interact, write_ini

COMMON_PROG_OPTIONS = {
# redirect to supervisord's stdout, easier to collect all logs
Expand Down Expand Up @@ -235,7 +235,7 @@ def create_node(

def custom_edit_tm(doc):
if statesync:
info = self.status()["SyncInfo"]
info = get_sync_info(self.status())
doc["statesync"].update(
{
"enable": True,
Expand Down Expand Up @@ -621,7 +621,7 @@ def query_proposals(self, depositor=None, limit=None, status=None, voter=None, i
return self.cosmos_cli(i).query_proposals(depositor, limit, status, voter)

def query_proposal(self, proposal_id, i=0):
return self.cosmos_cli(i).query_proposal(proposal_id)
return self.cosmos_cli(i).query_proposal(proposal_id)["proposal"]
mmsqe marked this conversation as resolved.
Show resolved Hide resolved

def query_tally(self, proposal_id, i=0):
return self.cosmos_cli(i).query_tally(proposal_id)
Expand Down
21 changes: 11 additions & 10 deletions pystarport/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from .app import CHAIN
from .ledger import ZEMU_BUTTON_PORT, ZEMU_HOST, LedgerButton
from .utils import build_cli_args_safe, format_doc_string, interact
from .utils import build_cli_args_safe, format_doc_string, get_sync_info, interact


class ModuleAccount(enum.Enum):
Expand Down Expand Up @@ -203,10 +203,10 @@ def status(self):
return json.loads(self.raw("status", node=self.node_rpc))

def block_height(self):
return int(self.status()["SyncInfo"]["latest_block_height"])
return int(get_sync_info(self.status())["latest_block_height"])

def block_time(self):
return isoparse(self.status()["SyncInfo"]["latest_block_time"])
return isoparse(get_sync_info(self.status())["latest_block_time"])

def balances(self, addr, height=0):
return json.loads(
Expand Down Expand Up @@ -337,11 +337,10 @@ def staking_params(self):
)

def staking_pool(self, bonded=True):
return int(
json.loads(
self.raw("query", "staking", "pool", output="json", node=self.node_rpc)
)["bonded_tokens" if bonded else "not_bonded_tokens"]
)
res = self.raw("query", "staking", "pool", output="json", node=self.node_rpc)
res = json.loads(res)
res = res.get("pool") if res.get("pool") else res
mmsqe marked this conversation as resolved.
Show resolved Hide resolved
return int(res["bonded_tokens" if bonded else "not_bonded_tokens"])

def transfer(
self,
Expand Down Expand Up @@ -880,7 +879,7 @@ def query_proposals(self, depositor=None, limit=None, status=None, voter=None):
)

def query_proposal(self, proposal_id):
return json.loads(
res = json.loads(
self.raw(
"query",
"gov",
Expand All @@ -890,9 +889,10 @@ def query_proposal(self, proposal_id):
node=self.node_rpc,
)
)
return res.get("proposal") if res.get("proposal") else res
mmsqe marked this conversation as resolved.
Show resolved Hide resolved

def query_tally(self, proposal_id):
return json.loads(
res = json.loads(
self.raw(
"query",
"gov",
Expand All @@ -902,6 +902,7 @@ def query_tally(self, proposal_id):
node=self.node_rpc,
)
)
return res.get("tally") if res.get("tally") else res
mmsqe marked this conversation as resolved.
Show resolved Hide resolved

def ibc_transfer(
self,
Expand Down
4 changes: 4 additions & 0 deletions pystarport/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ def decorator(target):
return target

return decorator


def get_sync_info(s):
return s.get("SyncInfo") if s.get("SyncInfo") else s.get("sync_info")
mmsqe marked this conversation as resolved.
Show resolved Hide resolved