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: ibc channel upgrade related methods are not supported #139

Merged
merged 9 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
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
8 changes: 5 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: cachix/install-nix-action@v30
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: install dependencies
run: python3 -m pip install --user --upgrade poetry
- name: install
run: poetry install
yihuang marked this conversation as resolved.
Show resolved Hide resolved
- name: Run tests
run: nix develop -c python -mpytest -vv -s
run: make test
yihuang marked this conversation as resolved.
Show resolved Hide resolved
nix-flake:
runs-on: ubuntu-latest
steps:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- [#128](https://github.com/crypto-com/pystarport/pull/128) fix wrong description on empty flag when create validator and align flags for edit validator.
- [#129](https://github.com/crypto-com/pystarport/pull/129) create and get validator are incompatible.
- [#137](https://github.com/crypto-com/pystarport/pull/137) support ica and icaauth cmd.
- [#139](https://github.com/crypto-com/pystarport/pull/139) support ibc channel upgrade related methods.

*Feb 7, 2023*

Expand Down
26 changes: 26 additions & 0 deletions pystarport/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,9 @@ def migrate_keystore(self, i=0):
def ibc_query_channels(self, connid, i=0, **kwargs):
return self.cosmos_cli(i).ibc_query_channels(connid, **kwargs)

def ibc_query_channel(self, port_id, channel_id, i=0, **kwargs):
return self.cosmos_cli(i).ibc_query_channel(port_id, channel_id, **kwargs)

def ica_register_account(self, connid, i=0, event_query_tx=True, **kwargs):
return self.cosmos_cli(i).ica_register_account(
connid,
Expand Down Expand Up @@ -813,6 +816,24 @@ def ica_submit_tx(
def ica_generate_packet_data(self, tx, memo=None, encoding="proto3", i=0, **kwargs):
return self.cosmos_cli(i).ica_generate_packet_data(memo, encoding, **kwargs)

def ibc_upgrade_channels(self, version, from_addr, i=0, **kwargs):
return self.cosmos_cli(i).ibc_upgrade_channels(version, from_addr, **kwargs)

def register_counterparty_payee(
self, port_id, channel_id, relayer, counterparty_payee, i=0, **kwargs
):
return self.cosmos_cli(i).register_counterparty_payee(
port_id, channel_id, relayer, counterparty_payee, **kwargs
)

def pay_packet_fee(self, port_id, channel_id, packet_seq, i=0, **kwargs):
return self.cosmos_cli(i).pay_packet_fee(
port_id, channel_id, packet_seq, **kwargs
)

def ibc_denom_trace(self, path, node, i=0):
return self.cosmos_cli(i).ibc_denom_trace(path, node)


def start_cluster(data_dir):
cmd = [
Expand Down Expand Up @@ -1190,6 +1211,11 @@ class Relayer(Enum):
RLY = "rly"


class ChannelOrder(Enum):
ORDERED = "ORDER_ORDERED"
UNORDERED = "ORDER_UNORDERED"


def init_cluster(
data_dir,
config_path,
Expand Down
88 changes: 88 additions & 0 deletions pystarport/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,23 @@ def ibc_query_channels(self, connid, **kwargs):
)
)

def ibc_query_channel(self, port_id, channel_id, **kwargs):
default_kwargs = {
"node": self.node_rpc,
"output": "json",
}
return json.loads(
self.raw(
"q",
"ibc",
"channel",
"end",
port_id,
channel_id,
**(default_kwargs | kwargs),
)
)

def ica_register_account(self, connid, event_query_tx=True, **kwargs):
"execute on host chain to attach an account to the connection"
default_kwargs = {
Expand Down Expand Up @@ -1357,3 +1374,74 @@ def ica_generate_packet_data(self, tx, memo=None, encoding="proto3", **kwargs):
**kwargs,
)
)

def ibc_upgrade_channels(self, version, from_addr, **kwargs):
return json.loads(
self.raw(
"tx",
"ibc",
"channel",
"upgrade-channels",
json.dumps(version),
"-y",
"--json",
from_=from_addr,
keyring_backend="test",
chain_id=self.chain_id,
home=self.data_dir,
stderr=subprocess.DEVNULL,
**kwargs,
)
)

def register_counterparty_payee(
self, port_id, channel_id, relayer, counterparty_payee, **kwargs
):
rsp = json.loads(
self.raw(
"tx",
"ibc-fee",
"register-counterparty-payee",
port_id,
channel_id,
relayer,
counterparty_payee,
"-y",
home=self.data_dir,
**kwargs,
)
)
if rsp["code"] == 0:
rsp = self.event_query_tx_for(rsp["txhash"])
return rsp

def pay_packet_fee(self, port_id, channel_id, packet_seq, **kwargs):
rsp = json.loads(
self.raw(
"tx",
"ibc-fee",
"pay-packet-fee",
port_id,
channel_id,
str(packet_seq),
"-y",
home=self.data_dir,
**kwargs,
)
)
if rsp["code"] == 0:
rsp = self.event_query_tx_for(rsp["txhash"])
return rsp

def ibc_denom_trace(self, path, node):
denom_hash = hashlib.sha256(path.encode()).hexdigest().upper()
return json.loads(
self.raw(
"q",
"ibc-transfer",
"denom-trace",
denom_hash,
node=node,
output="json",
)
)["denom_trace"]
Loading