Skip to content

Commit

Permalink
Problem: sdk 0.50 not supported (#121)
Browse files Browse the repository at this point in the history
Problem: nix develop don't work (#120)

Solution:
- fix default devShell
- update link instruction in ci to use nix
- update python dev dependencies

Problem: sdk 0.50 not supported

Update CHANGELOG.md

Signed-off-by: yihuang <[email protected]>

backward compatible through runtime prob

git ignore
  • Loading branch information
yihuang authored Feb 26, 2024
1 parent ca7347d commit 2aa4851
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,7 @@ cython_debug/
.vscode

# macos
.DS_Store
.DS_Store

/.direnv
/.envrc
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- [#113](https://github.com/crypto-com/pystarport/pull/113) support ibc related cmd.
- [#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


*Feb 7, 2023*
Expand Down
25 changes: 21 additions & 4 deletions pystarport/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ class ChainCommand:
def __init__(self, cmd=None):
self.cmd = cmd or CHAIN

def prob_genesis_subcommand(self):
'test if the command has "genesis" subcommand, introduced in sdk 0.50'
try:
output = self("genesis")
except AssertionError:
# non-zero return code
return False

return "Available Commands" in output.decode()

def __call__(self, cmd, *args, stdin=None, stderr=subprocess.STDOUT, **kwargs):
"execute chain-maind"
args = " ".join(build_cli_args_safe(cmd, *args, **kwargs))
Expand Down Expand Up @@ -71,6 +81,7 @@ def __init__(
self.leger_button = LedgerButton(zemu_address, zemu_button_port)
self.output = None
self.error = None
self.has_genesis_subcommand = self.raw.prob_genesis_subcommand()

def node_id(self):
"get tendermint node id"
Expand Down Expand Up @@ -152,11 +163,17 @@ def init(self, moniker):
home=self.data_dir,
)

def genesis_subcommand(self, *args, **kwargs):
if self.has_genesis_subcommand:
return self.raw("genesis", *args, **kwargs)
else:
return self.raw(*args, **kwargs)

def validate_genesis(self, *args):
return self.raw("validate-genesis", *args, home=self.data_dir)
return self.genesis_subcommand("validate-genesis", *args, home=self.data_dir)

def add_genesis_account(self, addr, coins, **kwargs):
return self.raw(
return self.genesis_subcommand(
"add-genesis-account",
addr,
coins,
Expand All @@ -166,7 +183,7 @@ def add_genesis_account(self, addr, coins, **kwargs):
)

def gentx(self, name, coins, *args, min_self_delegation=1, pubkey=None, **kwargs):
return self.raw(
return self.genesis_subcommand(
"gentx",
name,
coins,
Expand All @@ -180,7 +197,7 @@ def gentx(self, name, coins, *args, min_self_delegation=1, pubkey=None, **kwargs
)

def collect_gentxs(self, gentx_dir):
return self.raw("collect-gentxs", gentx_dir, home=self.data_dir)
return self.genesis_subcommand("collect-gentxs", gentx_dir, home=self.data_dir)

def status(self):
return json.loads(self.raw("status", node=self.node_rpc))
Expand Down

0 comments on commit 2aa4851

Please sign in to comment.