-
Notifications
You must be signed in to change notification settings - Fork 337
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 IbcSend message type to stargate code #710
Conversation
/// A Stargate message encoded the same way as a protobof [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). | ||
/// This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md) | ||
#[cfg(feature = "stargate")] | ||
Stargate { | ||
type_url: String, | ||
data: Binary, | ||
}, | ||
Wasm(WasmMsg), | ||
/// Sends *native tokens* owned by the contract to the given address on another 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.
What mean "native token" exactly? A bank token of the contract's 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.
good 👁️ . This can be a bank token but also a ibc voucher or anything else that got minted on the sdk mint module.
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.
Yes. As opposed to a cw20 token.
I will use the term bank token (others in cosmos used native token)
/// We cannot select the port_id, this is whatever the local chain has bound the ibctransfer | ||
/// module to. | ||
#[cfg(feature = "stargate")] | ||
IbcSend { |
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 pull this out into a
IbcMsg
enum, which groups all IBC messages? - Can we rename this to
Ics20Transfer
and link https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer?
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.
Sure, I will rebase on another PR that adds IBC message types.
My issue was that the other ones (SendPacket and CloseChannel) only are valid for contracts that actively participate in ibc channels (and have 6 entry points for that). This one could be used by any contract.
I guess I can make that distinction with docstrings as well
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.
agree that is a transfer
is a better naming. it is used in the sdk module as well as on the cli.
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.
My issue was that the other ones (SendPacket and CloseChannel) only are valid for contracts that actively participate in ibc channels (and have 6 entry points for that). This one could be used by any contract.
I guess I can make that distinction with docstrings as well
Yeah, I think this way would be better.
I guess this would be reflected in the necessary fiels as well (the other messages would require more fields that include all this channel state information)?
packages/std/src/query.rs
Outdated
@@ -24,7 +25,6 @@ pub enum QueryRequest<C: CustomQuery> { | |||
/// this is the expected protobuf message type (not any), binary encoded | |||
data: Binary, | |||
}, | |||
Wasm(WasmQuery), |
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.
What's the idea behind this move? Before it was alphabetically. I'm happy either way but I'd like to understand how you want to order this.
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.
I left it alphabetic for the standard ones, then all the stargate ones below (under feature flag). So sorting (is_stargate, name).
Maybe that is not very good idea, as staking is also under a different feature flag. I can make it alphabetical again
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.
I'd either use plain alphabetic order or introduce ordered groups that are separated by an empty line
/// A Stargate message encoded the same way as a protobof [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). | ||
/// This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md) | ||
#[cfg(feature = "stargate")] | ||
Stargate { | ||
type_url: String, | ||
data: Binary, | ||
}, | ||
Wasm(WasmMsg), | ||
/// Sends *native tokens* owned by the contract to the given address on another 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.
good 👁️ . This can be a bank token but also a ibc voucher or anything else that got minted on the sdk mint module.
/// We cannot select the port_id, this is whatever the local chain has bound the ibctransfer | ||
/// module to. | ||
#[cfg(feature = "stargate")] | ||
IbcSend { |
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.
agree that is a transfer
is a better naming. it is used in the sdk module as well as on the cli.
/// packet data only supports one coin | ||
/// https://github.com/cosmos/cosmos-sdk/blob/master/proto/ibc/applications/transfer/v1/transfer.proto#L11-L20 | ||
amount: Coin, | ||
}, |
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 have an optional field port_id:String
?
The default should be transfer
but this can be set in the genesis for every 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.
Optinal fields are not super convenient in Rust (you cannot omit them like in JavaScript/Go). Instead you always have to write them either port: Some(value)
or port: None
.
Would it be an option to store this as a constant in the chain code, such that it is added when the Rust type is translated to a Cosmos SDK type?
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 have an optional field port_id:String?
The default should betransfer
but this can be set in the genesis for every chain
This detail is super important for the Go module handling the transfers. There should be one official IbcTransfer port for the application, which may be name transfer
or ibctransfer
or foobar
or wasm12334556775fg4g43tuhti44tt4yt74yt47
.
The contract should run the same on any chain, regardless of how genesis was set up. By just sending a token, we leave the port naming up to the wasmd-based app. The channel is needed to differentiate various chains and should be set by the calling user.
Does that make sense? Setting a port to anything other than what the ibctransfer module was bound to will lead to an error, so let's just set it for them, as there is only one "right" value
58d33dd
to
b8acfed
Compare
Okay, I rebased this on #711 and then simplified it from the comments. |
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.
LGTM
Expose simple message to allow contracts to send native tokens to other chains