-
Notifications
You must be signed in to change notification settings - Fork 626
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
Add host cli to generate ica packet data #2297
Add host cli to generate ica packet data #2297
Conversation
This pull request introduces 1 alert when merging 1f12260 into 80ea89a - view on LGTM.com new alerts:
|
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #2297 +/- ##
==========================================
- Coverage 79.54% 78.59% -0.95%
==========================================
Files 175 178 +3
Lines 12069 12323 +254
==========================================
+ Hits 9600 9685 +85
- Misses 2045 2206 +161
- Partials 424 432 +8
|
…rate-ica-packet-data
…rate-ica-packet-data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work! Great test by the way!
…rate-ica-packet-data
…cket-data' of https://github.com/cosmos/ibc-go into cian/issue#2243-add-a-ics27-host-cli-to-generate-ica-packet-data
@colin-axner thanks for the great suggestion! I adapted the link you sent and added support for both a single message in bytes, as well as a json array of messages in bytes. Tests were added for the new multi message scenario. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! good dev ux improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really awesome job on the tests. They're super clean and easy to reason about.
LGTM! 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done, @chatton!
Short: "Generates ICA packet data.", | ||
Long: `generate-packet-data accepts a message string and serializes it | ||
into packet data which is outputted to stdout. It can be used in conjunction with send-tx" | ||
which submits pre-built packet data containing messages to be executed on the host chain. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to add an example here? Maybe we can just use the regular bank transfer message used in the example in the ica-demo repo?
'{
"@type":"/cosmos.bank.v1beta1.MsgSend",
"from_address":"cosmos15ccshhmp0gsx29qpqq6g4zmltnnvgmyu9ueuadh9y2nc5zj0szls5gtddz",
"to_address":"cosmos10h9stc5v6ntgeygf5xf945njqq5h32r53uquvw",
"amount": [
{
"denom": "stake",
"amount": "1000"
}
]
}'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great suggestions, I'll add this as an example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@crodriguezvega I added this example and also a multi message example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @chatton!
assertionFn func(t *testing.T, msgs []sdk.Msg) | ||
}{ | ||
{ | ||
name: "multi message", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name: "multi message", | |
name: "packet data generation succeeds (MsgDelegate & MsgSend)", |
banktypes.RegisterInterfaces(registry) | ||
}, | ||
assertionFn: func(t *testing.T, msgs []sdk.Msg) { | ||
assertMsgDelegate(t, msgs, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a nit, but instead of passing the slice of messages and the index, couldn't you just pass msgs[0]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes you're right, this can simplify things a little bit!
func NewTxCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "host", | ||
Short: "interchain-accounts host subcommands", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Short: "interchain-accounts host subcommands", | |
Short: "IBC interchain accounts host transaction subcommands", |
See this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I left a couple of new nits! Other than that, great work!
into packet data which is outputted to stdout. It can be used in conjunction with send-tx" | ||
which submits pre-built packet data containing messages to be executed on the host chain. | ||
`, | ||
Example: `<binary> tx interchain-accounts host generate-packet-data '{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use version.AppName
instead of <binary>
like in here?
Short: "Generates ICA packet data.", | ||
Long: `generate-packet-data accepts a message string and serializes it | ||
into packet data which is outputted to stdout. It can be used in conjunction with send-tx" | ||
which submits pre-built packet data containing messages to be executed on the host chain. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @chatton!
Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work!
…rate-ica-packet-data
…rate-ica-packet-data
(cherry picked from commit 8f0e7d5) # Conflicts: # CHANGELOG.md
* Add host cli to generate ica packet data (#2297) (cherry picked from commit 8f0e7d5) # Conflicts: # CHANGELOG.md * fix conflict Co-authored-by: Cian Hatton <cian@interchain.io> Co-authored-by: Carlos Rodriguez <carlos@interchain.io> Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
Description
This PR creates a new cli command which generates ics27 packet data. I opted to display the packet data to stdout rather than writing to a file as I believe this is more flexible. In order to create a file we simply need
simd tx host generate-packet-data ... > packet-data.json
Note: this is a
tx
command although it is a bit of an outlier as no tx is being broadcast. There is no good place that I can find to put this unique type of cli command so I stuck with thetx
subcommand.closes: #2243
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes