Skip to content

Commit

Permalink
Problem: ibc related cmd is not supported (#113)
Browse files Browse the repository at this point in the history
* Problem: ibc related cmd is not supported

* icaauth_register_account

* icaauth_submit_tx

* Update CHANGELOG.md

Signed-off-by: mmsqe <mavis@crypto.com>

* ica_query_account

---------

Signed-off-by: mmsqe <mavis@crypto.com>
  • Loading branch information
mmsqe authored Jan 16, 2024
1 parent 4b03f1a commit 558d684
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 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 @@
- [#109](https://github.com/crypto-com/pystarport/pull/109) add feegrants in relayer config
- [#110](https://github.com/crypto-com/pystarport/pull/110) add event_query_tx_for to allow subscribe and wait for transaction.
- [#112](https://github.com/crypto-com/pystarport/pull/112) add cmd for migrate keystore.
- [#113](https://github.com/crypto-com/pystarport/pull/113) support ibc related cmd.


*Feb 7, 2023*

Expand Down
12 changes: 12 additions & 0 deletions pystarport/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,18 @@ def event_query_tx_for(self, hash, i=0):
def migrate_keystore(self, i=0):
return self.cosmos_cli(i).migrate_keystore()

def ibc_query_channels(self, connid, i=0):
return self.cosmos_cli(i).ibc_query_channels(connid)

def icaauth_register_account(self, connid, i=0):
return self.cosmos_cli(i).icaauth_register_account(connid)

def ica_query_account(self, connid, owner, i=0, **kwargs):
return self.cosmos_cli(i).ica_query_account(connid, owner, **kwargs)

def icaauth_submit_tx(self, connid, tx, timeout_duration="1h", i=0):
return self.cosmos_cli(i).icaauth_submit_tx(connid, tx, timeout_duration)


def start_cluster(data_dir):
cmd = [
Expand Down
78 changes: 78 additions & 0 deletions pystarport/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1070,3 +1070,81 @@ def event_query_tx_for(self, hash):

def migrate_keystore(self):
return self.raw("keys", "migrate", home=self.data_dir)

def ibc_query_channels(self, connid, **kwargs):
default_kwargs = {
"node": self.node_rpc,
"output": "json",
}
return json.loads(
self.raw(
"q",
"ibc",
"channel",
"connections",
connid,
**(default_kwargs | kwargs),
)
)

def icaauth_register_account(self, connid, **kwargs):
"execute on host chain to attach an account to the connection"
default_kwargs = {
"home": self.data_dir,
"node": self.node_rpc,
"chain_id": self.chain_id,
"keyring_backend": "test",
}
rsp = json.loads(
self.raw(
"tx",
"icaauth",
"register-account",
connid,
"-y",
**(default_kwargs | kwargs),
)
)
if rsp["code"] == 0:
rsp = self.event_query_tx_for(rsp["txhash"])
return rsp

def ica_query_account(self, connid, owner, **kwargs):
default_kwargs = {
"node": self.node_rpc,
"output": "json",
}
return json.loads(
self.raw(
"q",
"icaauth",
"interchain-account-address",
connid,
owner,
**(default_kwargs | kwargs),
)
)

def icaauth_submit_tx(self, connid, tx, timeout_duration="1h", **kwargs):
default_kwargs = {
"home": self.data_dir,
"node": self.node_rpc,
"chain_id": self.chain_id,
"keyring_backend": "test",
}
rsp = json.loads(
self.raw(
"tx",
"icaauth",
"submit-tx",
connid,
tx,
"--timeout-duration" if timeout_duration else None,
timeout_duration if timeout_duration else None,
"-y",
**(default_kwargs | kwargs),
)
)
if rsp["code"] == 0:
rsp = self.event_query_tx_for(rsp["txhash"])
return rsp

0 comments on commit 558d684

Please sign in to comment.