diff --git a/e2e/interchaintestv8/types/callbackcounter/msgs.go b/e2e/interchaintestv8/types/callbackcounter/msgs.go index ab10e6b6..ef20b33e 100644 --- a/e2e/interchaintestv8/types/callbackcounter/msgs.go +++ b/e2e/interchaintestv8/types/callbackcounter/msgs.go @@ -13,93 +13,12 @@ type QueryMsg struct { // GetCallbackCounter returns the callback counter. GetCallbackCounter *QueryMsg_GetCallbackCounter `json:"get_callback_counter,omitempty"` } -type ExecuteMsg_ReceiveIcaCallback IcaControllerCallbackMsg - -/* -A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0 - -The greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18) -*/ -type Decimal string - -// In IBC each package must set at least one type of timeout: the timestamp or the block height. Using this rather complex enum instead of two timeout fields we ensure that at least one timeout is set. -type IbcTimeout struct { - Block *IbcTimeoutBlock `json:"block,omitempty"` - Timestamp *Timestamp `json:"timestamp,omitempty"` -} - -/* -Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline. - -This is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also . -*/ -type Binary string - -type QueryMsg_GetCallbackCounter struct{} - -type IbcEndpoint struct { - ChannelId string `json:"channel_id"` - PortId string `json:"port_id"` -} - -// The response type for the [`cosmwasm_std::StakingQuery`] queries. -type StakingQueryResponse struct { - // Response for the [`cosmwasm_std::StakingQuery::BondedDenom`] query. - BondedDenom *StakingQueryResponse_BondedDenom `json:"bonded_denom,omitempty"` - // Response for the [`cosmwasm_std::StakingQuery::AllDelegations`] query. - AllDelegations *StakingQueryResponse_AllDelegations `json:"all_delegations,omitempty"` - // Response for the [`cosmwasm_std::StakingQuery::Delegation`] query. - Delegation *StakingQueryResponse_Delegation `json:"delegation,omitempty"` - // Response for the [`cosmwasm_std::StakingQuery::AllValidators`] query. - AllValidators *StakingQueryResponse_AllValidators `json:"all_validators,omitempty"` - // Response for the [`cosmwasm_std::StakingQuery::Validator`] query. - Validator *StakingQueryResponse_Validator `json:"validator,omitempty"` -} - -/* -A human readable address. - -In Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length. - -This type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances. - -This type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance. -*/ -type Addr string type Coin struct { Amount Uint128 `json:"amount"` Denom string `json:"denom"` } -// IbcOrder defines if a channel is ORDERED or UNORDERED Values come from https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/ibc/core/channel/v1/channel.proto#L69-L80 Naming comes from the protobuf files and go translations. -type IbcOrder string - -const ( - IbcOrder_OrderUnordered IbcOrder = "ORDER_UNORDERED" - IbcOrder_OrderOrdered IbcOrder = "ORDER_ORDERED" -) - -// CallbackCounter tracks the number of callbacks in store. -type CallbackCounter struct { - // The successful callbacks. - Success []IcaControllerCallbackMsg `json:"success"` - // The timeout callbacks. The channel is closed after a timeout if the channel is ordered due to the semantics of ordered channels. - Timeout []IcaControllerCallbackMsg `json:"timeout"` - // The erroneous callbacks. - Error []IcaControllerCallbackMsg `json:"error"` -} - -type DenomMetadataResponse struct { - // The metadata for the queried denom. - Metadata DenomMetadata `json:"metadata"` -} - -type AllBalanceResponse struct { - // Returns all non-zero coins held by this account. - Amount []Coin `json:"amount"` -} - /* A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq. @@ -113,18 +32,21 @@ let b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ``` */ type Uint64 string -// Instances are created in the querier. -type Validator struct { - /* - The operator address of the validator (e.g. cosmosvaloper1...). See https://github.com/cosmos/cosmos-sdk/blob/v0.47.4/proto/cosmos/staking/v1beta1/staking.proto#L95-L96 for more information. +// Replicates the cosmos-sdk bank module DenomUnit type +type DenomUnit struct { + Aliases []string `json:"aliases"` + Denom string `json:"denom"` + Exponent int `json:"exponent"` +} - This uses `String` instead of `Addr` since the bech32 address prefix is different from the ones that regular user accounts use. - */ - Address string `json:"address"` - Commission Decimal `json:"commission"` - // The maximum daily increase of the commission - MaxChangeRate Decimal `json:"max_change_rate"` - MaxCommission Decimal `json:"max_commission"` +// The response for a successful ICA query. +type IcaQueryResponse struct { + // Response for a [`cosmwasm_std::BankQuery`]. + Bank *IcaQueryResponse_Bank `json:"bank,omitempty"` + // Response for a [`cosmwasm_std::QueryRequest::Stargate`]. Protobuf encoded bytes stored as [`cosmwasm_std::Binary`]. + Stargate *IcaQueryResponse_Stargate `json:"stargate,omitempty"` + // Response for a [`cosmwasm_std::StakingQuery`]. + Staking *IcaQueryResponse_Staking `json:"staking,omitempty"` } // `Data` is the response to an ibc packet. It either contains a result or an error. @@ -135,62 +57,43 @@ type Data struct { Error *Data_Error `json:"error,omitempty"` } -// The response type for the [`cosmwasm_std::BankQuery`] queries. -type BankQueryResponse struct { - // Response for the [`cosmwasm_std::BankQuery::Supply`] query. - Supply *BankQueryResponse_Supply `json:"supply,omitempty"` - // Response for the [`cosmwasm_std::BankQuery::Balance`] query. - Balance *BankQueryResponse_Balance `json:"balance,omitempty"` - // Response for the [`cosmwasm_std::BankQuery::AllBalances`] query. - AllBalances *BankQueryResponse_AllBalances `json:"all_balances,omitempty"` - // Response for the [`cosmwasm_std::BankQuery::DenomMetadata`] query. - DenomMetadata *BankQueryResponse_DenomMetadata `json:"denom_metadata,omitempty"` - // Response for the [`cosmwasm_std::BankQuery::AllDenomMetadata`] query. - AllDenomMetadata *BankQueryResponse_AllDenomMetadata `json:"all_denom_metadata,omitempty"` -} - -// BondedDenomResponse is data format returned from StakingRequest::BondedDenom query -type BondedDenomResponse struct { - Denom string `json:"denom"` -} - -// IBCTimeoutHeight Height is a monotonically increasing data type that can be compared against another Height for the purposes of updating and freezing clients. Ordering is (revision_number, timeout_height) -type IbcTimeoutBlock struct { - // block height after which the packet times out. the height within the given revision - Height int `json:"height"` - // the version that the client is currently on (e.g. after resetting the chain this could increment 1 as height drops to 0) - Revision int `json:"revision"` -} - // The data format returned from StakingRequest::Validator query type ValidatorResponse struct { Validator *Validator `json:"validator,omitempty"` } -// The response for a successful ICA query. -type IcaQueryResponse struct { - // Response for a [`cosmwasm_std::BankQuery`]. - Bank *IcaQueryResponse_Bank `json:"bank,omitempty"` - // Response for a [`cosmwasm_std::QueryRequest::Stargate`]. Protobuf encoded bytes stored as [`cosmwasm_std::Binary`]. - Stargate *IcaQueryResponse_Stargate `json:"stargate,omitempty"` - // Response for a [`cosmwasm_std::StakingQuery`]. - Staking *IcaQueryResponse_Staking `json:"staking,omitempty"` -} - // Response for the [`cosmwasm_std::StakingQuery::AllDelegations`] query over ICA. type IcaAllDelegationsResponse struct { // The delegations. Delegations []Delegation `json:"delegations"` } -// The result of an ICA query packet. -type IcaQueryResult struct { - // The query was successful and the responses are included. - Success *IcaQueryResult_Success `json:"success,omitempty"` - // The query failed with an error message. The error string often does not contain useful information for the end user. - Error *IcaQueryResult_Error `json:"error,omitempty"` +/* +A point in time in nanosecond precision. + +This type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z. + +## Examples + +``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202); + +let ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ``` +*/ +type Timestamp Uint64 + +type AllBalanceResponse struct { + // Returns all non-zero coins held by this account. + Amount []Coin `json:"amount"` } +// IbcOrder defines if a channel is ORDERED or UNORDERED Values come from https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/ibc/core/channel/v1/channel.proto#L69-L80 Naming comes from the protobuf files and go translations. +type IbcOrder string + +const ( + IbcOrder_OrderUnordered IbcOrder = "ORDER_UNORDERED" + IbcOrder_OrderOrdered IbcOrder = "ORDER_ORDERED" +) + // `TxEncoding` is the encoding of the transactions sent to the ICA host. type TxEncoding string @@ -201,6 +104,65 @@ const ( TxEncoding_Proto3Json TxEncoding = "proto3json" ) +// IbcChannel defines all information on a channel. This is generally used in the hand-shake process, but can be queried directly. +type IbcChannel struct { + CounterpartyEndpoint IbcEndpoint `json:"counterparty_endpoint"` + Endpoint IbcEndpoint `json:"endpoint"` + Order IbcOrder `json:"order"` + // Note: in ibcv3 this may be "", in the IbcOpenChannel handshake messages + Version string `json:"version"` + // The connection upon which this channel was created. If this is a multi-hop channel, we only expose the first hop. + ConnectionId string `json:"connection_id"` +} + +// CallbackCounter tracks the number of callbacks in store. +type CallbackCounter struct { + // The timeout callbacks. The channel is closed after a timeout if the channel is ordered due to the semantics of ordered channels. + Timeout []IcaControllerCallbackMsg `json:"timeout"` + // The erroneous callbacks. + Error []IcaControllerCallbackMsg `json:"error"` + // The successful callbacks. + Success []IcaControllerCallbackMsg `json:"success"` +} + +// The result of an ICA query packet. +type IcaQueryResult struct { + // The query was successful and the responses are included. + Success *IcaQueryResult_Success `json:"success,omitempty"` + // The query failed with an error message. The error string often does not contain useful information for the end user. + Error *IcaQueryResult_Error `json:"error,omitempty"` +} + +type AllDenomMetadataResponse struct { + // Always returns metadata for all token denoms on the base chain. + Metadata []DenomMetadata `json:"metadata"` + NextKey *Binary `json:"next_key,omitempty"` +} + +type BalanceResponse struct { + // Always returns a Coin with the requested denom. This may be of 0 amount if no such funds. + Amount Coin `json:"amount"` +} + +/* +Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline. + +This is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also . +*/ +type Binary string + +type IbcEndpoint struct { + ChannelId string `json:"channel_id"` + PortId string `json:"port_id"` +} + +type SupplyResponse struct { + // Always returns a Coin with the requested denom. This will be of zero amount if the denom does not exist. + Amount Coin `json:"amount"` +} + +type QueryMsg_GetCallbackCounter struct{} + // Delegation is the detailed information about a delegation. type Delegation struct { // Delegation amount. @@ -211,18 +173,36 @@ type Delegation struct { Validator string `json:"validator"` } -/* -A point in time in nanosecond precision. - -This type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z. +// The data format returned from StakingRequest::AllValidators query +type AllValidatorsResponse struct { + Validators []Validator `json:"validators"` +} -## Examples +type IbcPacket struct { + Timeout IbcTimeout `json:"timeout"` + // The raw data sent from the other side in the packet + Data Binary `json:"data"` + // identifies the channel and port on the receiving chain. + Dest IbcEndpoint `json:"dest"` + // The sequence number of the packet on the given channel + Sequence int `json:"sequence"` + // identifies the channel and port on the sending chain. + Src IbcEndpoint `json:"src"` +} -``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202); +// In IBC each package must set at least one type of timeout: the timestamp or the block height. Using this rather complex enum instead of two timeout fields we ensure that at least one timeout is set. +type IbcTimeout struct { + Block *IbcTimeoutBlock `json:"block,omitempty"` + Timestamp *Timestamp `json:"timestamp,omitempty"` +} -let ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ``` -*/ -type Timestamp Uint64 +// IBCTimeoutHeight Height is a monotonically increasing data type that can be compared against another Height for the purposes of updating and freezing clients. Ordering is (revision_number, timeout_height) +type IbcTimeoutBlock struct { + // block height after which the packet times out. the height within the given revision + Height int `json:"height"` + // the version that the client is currently on (e.g. after resetting the chain this could increment 1 as height drops to 0) + Revision int `json:"revision"` +} /* A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq. @@ -239,10 +219,16 @@ let c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ``` */ type Uint128 string -// The data format returned from StakingRequest::AllValidators query -type AllValidatorsResponse struct { - Validators []Validator `json:"validators"` -} +/* +A human readable address. + +In Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length. + +This type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances. + +This type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance. +*/ +type Addr string // Response for the [`cosmwasm_std::StakingQuery::Delegation`] query over ICA. type IcaDelegationResponse struct { @@ -250,33 +236,9 @@ type IcaDelegationResponse struct { Delegation *Delegation `json:"delegation,omitempty"` } -// Replicates the cosmos-sdk bank module Metadata type -type DenomMetadata struct { - Display string `json:"display"` - Name string `json:"name"` - Symbol string `json:"symbol"` - Uri string `json:"uri"` - UriHash string `json:"uri_hash"` - Base string `json:"base"` - DenomUnits []DenomUnit `json:"denom_units"` - Description string `json:"description"` -} - -type BalanceResponse struct { - // Always returns a Coin with the requested denom. This may be of 0 amount if no such funds. - Amount Coin `json:"amount"` -} - -type IbcPacket struct { - // The raw data sent from the other side in the packet - Data Binary `json:"data"` - // identifies the channel and port on the receiving chain. - Dest IbcEndpoint `json:"dest"` - // The sequence number of the packet on the given channel - Sequence int `json:"sequence"` - // identifies the channel and port on the sending chain. - Src IbcEndpoint `json:"src"` - Timeout IbcTimeout `json:"timeout"` +type DenomMetadataResponse struct { + // The metadata for the queried denom. + Metadata DenomMetadata `json:"metadata"` } // `IcaControllerCallbackMsg` is the type of message that this contract can send to other contracts. @@ -288,61 +250,89 @@ type IcaControllerCallbackMsg struct { // `OnChannelOpenAckCallback` is the callback that this contract makes to other contracts when it receives a channel open acknowledgement. OnChannelOpenAckCallback *IcaControllerCallbackMsg_OnChannelOpenAckCallback `json:"on_channel_open_ack_callback,omitempty"` } +type ExecuteMsg_ReceiveIcaCallback IcaControllerCallbackMsg -// IbcChannel defines all information on a channel. This is generally used in the hand-shake process, but can be queried directly. -type IbcChannel struct { - Order IbcOrder `json:"order"` - // Note: in ibcv3 this may be "", in the IbcOpenChannel handshake messages - Version string `json:"version"` - // The connection upon which this channel was created. If this is a multi-hop channel, we only expose the first hop. - ConnectionId string `json:"connection_id"` - CounterpartyEndpoint IbcEndpoint `json:"counterparty_endpoint"` - Endpoint IbcEndpoint `json:"endpoint"` +// Replicates the cosmos-sdk bank module Metadata type +type DenomMetadata struct { + Base string `json:"base"` + DenomUnits []DenomUnit `json:"denom_units"` + Description string `json:"description"` + Display string `json:"display"` + Name string `json:"name"` + Symbol string `json:"symbol"` + Uri string `json:"uri"` + UriHash string `json:"uri_hash"` } -type SupplyResponse struct { - // Always returns a Coin with the requested denom. This will be of zero amount if the denom does not exist. - Amount Coin `json:"amount"` +/* +A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0 + +The greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18) +*/ +type Decimal string + +// The response type for the [`cosmwasm_std::StakingQuery`] queries. +type StakingQueryResponse struct { + // Response for the [`cosmwasm_std::StakingQuery::BondedDenom`] query. + BondedDenom *StakingQueryResponse_BondedDenom `json:"bonded_denom,omitempty"` + // Response for the [`cosmwasm_std::StakingQuery::AllDelegations`] query. + AllDelegations *StakingQueryResponse_AllDelegations `json:"all_delegations,omitempty"` + // Response for the [`cosmwasm_std::StakingQuery::Delegation`] query. + Delegation *StakingQueryResponse_Delegation `json:"delegation,omitempty"` + // Response for the [`cosmwasm_std::StakingQuery::AllValidators`] query. + AllValidators *StakingQueryResponse_AllValidators `json:"all_validators,omitempty"` + // Response for the [`cosmwasm_std::StakingQuery::Validator`] query. + Validator *StakingQueryResponse_Validator `json:"validator,omitempty"` } -// Replicates the cosmos-sdk bank module DenomUnit type -type DenomUnit struct { - Exponent int `json:"exponent"` - Aliases []string `json:"aliases"` - Denom string `json:"denom"` +// Instances are created in the querier. +type Validator struct { + /* + The operator address of the validator (e.g. cosmosvaloper1...). See https://github.com/cosmos/cosmos-sdk/blob/v0.47.4/proto/cosmos/staking/v1beta1/staking.proto#L95-L96 for more information. + + This uses `String` instead of `Addr` since the bech32 address prefix is different from the ones that regular user accounts use. + */ + Address string `json:"address"` + Commission Decimal `json:"commission"` + // The maximum daily increase of the commission + MaxChangeRate Decimal `json:"max_change_rate"` + MaxCommission Decimal `json:"max_commission"` } -type AllDenomMetadataResponse struct { - NextKey *Binary `json:"next_key,omitempty"` - // Always returns metadata for all token denoms on the base chain. - Metadata []DenomMetadata `json:"metadata"` +// BondedDenomResponse is data format returned from StakingRequest::BondedDenom query +type BondedDenomResponse struct { + Denom string `json:"denom"` } -type IcaQueryResult_Success struct { - // The height of the block at which the queries were executed on the counterparty chain. - Height int `json:"height"` - // The responses to the queries. - Responses []IcaQueryResponse `json:"responses"` +// The response type for the [`cosmwasm_std::BankQuery`] queries. +type BankQueryResponse struct { + // Response for the [`cosmwasm_std::BankQuery::Supply`] query. + Supply *BankQueryResponse_Supply `json:"supply,omitempty"` + // Response for the [`cosmwasm_std::BankQuery::Balance`] query. + Balance *BankQueryResponse_Balance `json:"balance,omitempty"` + // Response for the [`cosmwasm_std::BankQuery::AllBalances`] query. + AllBalances *BankQueryResponse_AllBalances `json:"all_balances,omitempty"` + // Response for the [`cosmwasm_std::BankQuery::DenomMetadata`] query. + DenomMetadata *BankQueryResponse_DenomMetadata `json:"denom_metadata,omitempty"` + // Response for the [`cosmwasm_std::BankQuery::AllDenomMetadata`] query. + AllDenomMetadata *BankQueryResponse_AllDenomMetadata `json:"all_denom_metadata,omitempty"` } -type Data_Result Binary +type BankQueryResponse_AllDenomMetadata AllDenomMetadataResponse +type StakingQueryResponse_BondedDenom BondedDenomResponse -type IcaControllerCallbackMsg_OnAcknowledgementPacketCallback struct { - // The relayer that submitted acknowledgement packet - Relayer Addr `json:"relayer"` - // The deserialized ICA acknowledgement data - IcaAcknowledgement Data `json:"ica_acknowledgement"` +type IcaQueryResult_Error string + +type IcaControllerCallbackMsg_OnTimeoutPacketCallback struct { // The original packet that was sent OriginalPacket IbcPacket `json:"original_packet"` - // The responses to the queries. - QueryResult *IcaQueryResult `json:"query_result,omitempty"` + // The relayer that submitted acknowledgement packet + Relayer Addr `json:"relayer"` } -type BankQueryResponse_Supply SupplyResponse -type BankQueryResponse_DenomMetadata DenomMetadataResponse -type IcaQueryResponse_Staking StakingQueryResponse -type StakingQueryResponse_AllDelegations IcaAllDelegationsResponse -type BankQueryResponse_AllBalances AllBalanceResponse -type StakingQueryResponse_Validator ValidatorResponse +type StakingQueryResponse_Delegation IcaDelegationResponse +type BankQueryResponse_Balance BalanceResponse type StakingQueryResponse_AllValidators AllValidatorsResponse +type StakingQueryResponse_Validator ValidatorResponse +type Data_Result Binary type IcaControllerCallbackMsg_OnChannelOpenAckCallback struct { // The tx encoding this ICA channel uses. @@ -352,20 +342,7 @@ type IcaControllerCallbackMsg_OnChannelOpenAckCallback struct { // The address of the interchain account that was created. IcaAddress string `json:"ica_address"` } -type BankQueryResponse_Balance BalanceResponse -type StakingQueryResponse_BondedDenom BondedDenomResponse - -type IcaControllerCallbackMsg_OnTimeoutPacketCallback struct { - // The original packet that was sent - OriginalPacket IbcPacket `json:"original_packet"` - // The relayer that submitted acknowledgement packet - Relayer Addr `json:"relayer"` -} -type StakingQueryResponse_Delegation IcaDelegationResponse - -type Data_Error string -type BankQueryResponse_AllDenomMetadata AllDenomMetadataResponse -type IcaQueryResponse_Bank BankQueryResponse +type BankQueryResponse_Supply SupplyResponse type IcaQueryResponse_Stargate struct { // The response bytes. @@ -373,5 +350,28 @@ type IcaQueryResponse_Stargate struct { // The query grpc method Path string `json:"path"` } +type IcaQueryResponse_Staking StakingQueryResponse +type IcaQueryResponse_Bank BankQueryResponse +type BankQueryResponse_AllBalances AllBalanceResponse +type BankQueryResponse_DenomMetadata DenomMetadataResponse -type IcaQueryResult_Error string +type Data_Error string + +type IcaQueryResult_Success struct { + // The height of the block at which the queries were executed on the counterparty chain. + Height int `json:"height"` + // The responses to the queries. + Responses []IcaQueryResponse `json:"responses"` +} + +type IcaControllerCallbackMsg_OnAcknowledgementPacketCallback struct { + // The relayer that submitted acknowledgement packet + Relayer Addr `json:"relayer"` + // The deserialized ICA acknowledgement data + IcaAcknowledgement Data `json:"ica_acknowledgement"` + // The original packet that was sent + OriginalPacket IbcPacket `json:"original_packet"` + // The responses to the queries. + QueryResult *IcaQueryResult `json:"query_result,omitempty"` +} +type StakingQueryResponse_AllDelegations IcaAllDelegationsResponse diff --git a/e2e/interchaintestv8/types/callbackcounter/query.go b/e2e/interchaintestv8/types/callbackcounter/query.go index 2e985f38..936bd0da 100644 --- a/e2e/interchaintestv8/types/callbackcounter/query.go +++ b/e2e/interchaintestv8/types/callbackcounter/query.go @@ -62,7 +62,7 @@ func (q *queryClient) queryContract(ctx context.Context, rawQueryData []byte, op } func (q *queryClient) GetCallbackCounter(ctx context.Context, req *QueryMsg_GetCallbackCounter, opts ...grpc.CallOption) (*CallbackCounter, error) { - rawQueryData, err := json.Marshal(&QueryMsg{GetCallbackCounter: req}) + rawQueryData, err := json.Marshal(map[string]any{"get_callback_counter": req}) if err != nil { return nil, err } diff --git a/e2e/interchaintestv8/types/cwicacontroller/msgs.go b/e2e/interchaintestv8/types/cwicacontroller/msgs.go index ae307b3a..398851a6 100644 --- a/e2e/interchaintestv8/types/cwicacontroller/msgs.go +++ b/e2e/interchaintestv8/types/cwicacontroller/msgs.go @@ -39,46 +39,104 @@ type QueryMsg struct { Ownership *QueryMsg_Ownership `json:"ownership,omitempty"` } -/* -A human readable address. +// IbcChannel defines all information on a channel. This is generally used in the hand-shake process, but can be queried directly. +type IbcChannel struct { + // The connection upon which this channel was created. If this is a multi-hop channel, we only expose the first hop. + ConnectionId string `json:"connection_id"` + CounterpartyEndpoint IbcEndpoint `json:"counterparty_endpoint"` + Endpoint IbcEndpoint `json:"endpoint"` + Order IbcOrder `json:"order"` + // Note: in ibcv3 this may be "", in the IbcOpenChannel handshake messages + Version string `json:"version"` +} -In Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length. +// `TxEncoding` is the encoding of the transactions sent to the ICA host. +type TxEncoding string -This type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances. +const ( + // `Protobuf` is the protobuf serialization of the CosmosSDK's Any. + TxEncoding_Proto3 TxEncoding = "proto3" + // `Proto3Json` is the json serialization of the CosmosSDK's Any. + TxEncoding_Proto3Json TxEncoding = "proto3json" +) -This type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance. +type Coin struct { + Amount Uint128 `json:"amount"` + Denom string `json:"denom"` +} + +// Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future) +type Expiration struct { + // AtHeight will expire when `env.block.height` >= height + AtHeight *Expiration_AtHeight `json:"at_height,omitempty"` + // AtTime will expire when `env.block.time` >= time + AtTime *Expiration_AtTime `json:"at_time,omitempty"` + // Never will never expire. Used to express the empty variant + Never *Expiration_Never `json:"never,omitempty"` +} + +/* +The message types of the wasm module. + +See https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto */ -type Addr string -type ExecuteMsg_UpdateOwnership Action +type WasmMsg struct { + /* + Dispatches a call to another contract at a known address (with known ABI). -type BankQuery struct { - // This calls into the native bank module for querying the total supply of one denomination. It does the same as the SupplyOf call in Cosmos SDK's RPC API. Return value is of type SupplyResponse. - Supply *BankQuery_Supply `json:"supply,omitempty"` - // This calls into the native bank module for one denomination Return value is BalanceResponse - Balance *BankQuery_Balance `json:"balance,omitempty"` - // This calls into the native bank module for all denominations. Note that this may be much more expensive than Balance and should be avoided if possible. Return value is AllBalanceResponse. - AllBalances *BankQuery_AllBalances `json:"all_balances,omitempty"` - // This calls into the native bank module for querying metadata for a specific bank token. Return value is DenomMetadataResponse - DenomMetadata *BankQuery_DenomMetadata `json:"denom_metadata,omitempty"` - // This calls into the native bank module for querying metadata for all bank tokens that have a metadata entry. Return value is AllDenomMetadataResponse - AllDenomMetadata *BankQuery_AllDenomMetadata `json:"all_denom_metadata,omitempty"` + This is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address. + */ + Execute *WasmMsg_Execute `json:"execute,omitempty"` + /* + Instantiates a new contracts from previously uploaded Wasm code. + + The contract address is non-predictable. But it is guaranteed that when emitting the same Instantiate message multiple times, multiple instances on different addresses will be generated. See also Instantiate2. + + This is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.29.2/proto/cosmwasm/wasm/v1/tx.proto#L53-L71). `sender` is automatically filled with the current contract's address. + */ + Instantiate *WasmMsg_Instantiate `json:"instantiate,omitempty"` + /* + Instantiates a new contracts from previously uploaded Wasm code using a predictable address derivation algorithm implemented in [`cosmwasm_std::instantiate2_address`]. + + This is translated to a [MsgInstantiateContract2](https://github.com/CosmWasm/wasmd/blob/v0.29.2/proto/cosmwasm/wasm/v1/tx.proto#L73-L96). `sender` is automatically filled with the current contract's address. `fix_msg` is automatically set to false. + */ + Instantiate2 *WasmMsg_Instantiate2 `json:"instantiate2,omitempty"` + /* + Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior. + + Only the contract admin (as defined in wasmd), if any, is able to make this call. + + This is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address. + */ + Migrate *WasmMsg_Migrate `json:"migrate,omitempty"` + // Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract. + UpdateAdmin *WasmMsg_UpdateAdmin `json:"update_admin,omitempty"` + // Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract. + ClearAdmin *WasmMsg_ClearAdmin `json:"clear_admin,omitempty"` } -type Coin struct { - Amount Uint128 `json:"amount"` - Denom string `json:"denom"` +type WasmQuery struct { + // this queries the public API of another contract at a known address (with known ABI) Return value is whatever the contract returns (caller should know), wrapped in a ContractResult that is JSON encoded. + Smart *WasmQuery_Smart `json:"smart,omitempty"` + // this queries the raw kv-store of the contract. returns the raw, unparsed data stored at that key, which may be an empty vector if not present + Raw *WasmQuery_Raw `json:"raw,omitempty"` + // Returns a [`ContractInfoResponse`] with metadata on the contract from the runtime + ContractInfo *WasmQuery_ContractInfo `json:"contract_info,omitempty"` + // Returns a [`CodeInfoResponse`] with metadata of the code + CodeInfo *WasmQuery_CodeInfo `json:"code_info,omitempty"` } type QueryMsg_Ownership struct{} -// The contract's ownership info -type Ownership_for_String struct { - // The contract's current owner. `None` if the ownership has been renounced. - Owner *string `json:"owner,omitempty"` - // The deadline for the pending owner to accept the ownership. `None` if there isn't a pending ownership transfer, or if a transfer exists and it doesn't have a deadline. - PendingExpiry *Expiration `json:"pending_expiry,omitempty"` - // The account who has been proposed to take over the ownership. `None` if there isn't a pending ownership transfer. - PendingOwner *string `json:"pending_owner,omitempty"` +type ExecuteMsg_SendCosmosMsgs struct { + // The stargate messages to convert and send to the ICA host. + Messages []CosmosMsg_for_Empty `json:"messages"` + // Optional memo to include in the ibc packet. + PacketMemo *string `json:"packet_memo,omitempty"` + // The stargate queries to convert and send to the ICA host. The queries are executed after the messages. + Queries []QueryRequest_for_Empty `json:"queries"` + // Optional timeout in seconds to include with the ibc packet. If not specified, the [default timeout](crate::ibc::types::packet::DEFAULT_TIMEOUT_SECONDS) is used. + TimeoutSeconds *int `json:"timeout_seconds,omitempty"` } type VoteOption string @@ -90,11 +148,23 @@ const ( VoteOption_NoWithVeto VoteOption = "no_with_veto" ) -// Simplified version of the PageRequest type for pagination from the cosmos-sdk -type PageRequest struct { - Reverse bool `json:"reverse"` - Key *Binary `json:"key,omitempty"` - Limit int `json:"limit"` +/* +A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0 + +The greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18) +*/ +type Decimal string + +type CosmosMsg_for_Empty struct { + Bank *CosmosMsg_for_Empty_Bank `json:"bank,omitempty"` + Custom *CosmosMsg_for_Empty_Custom `json:"custom,omitempty"` + Staking *CosmosMsg_for_Empty_Staking `json:"staking,omitempty"` + Distribution *CosmosMsg_for_Empty_Distribution `json:"distribution,omitempty"` + // A Stargate message encoded the same way as a protobuf [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) + Stargate *CosmosMsg_for_Empty_Stargate `json:"stargate,omitempty"` + Ibc *CosmosMsg_for_Empty_Ibc `json:"ibc,omitempty"` + Wasm *CosmosMsg_for_Empty_Wasm `json:"wasm,omitempty"` + Gov *CosmosMsg_for_Empty_Gov `json:"gov,omitempty"` } /* @@ -113,14 +183,50 @@ type StakingMsg struct { // The options needed to initialize the IBC channel. type ChannelOpenInitOptions struct { - // The order of the channel. If not specified, [`IbcOrder::Ordered`] is used. [`IbcOrder::Unordered`] is only supported if the counterparty chain is using `ibc-go` v8.1.0 or later. - ChannelOrdering *IbcOrder `json:"channel_ordering,omitempty"` - // The connection id on this chain. - ConnectionId string `json:"connection_id"` // The counterparty connection id on the counterparty chain. CounterpartyConnectionId string `json:"counterparty_connection_id"` // The counterparty port id. If not specified, [`crate::ibc::types::keys::HOST_PORT_ID`] is used. Currently, this contract only supports the host port. CounterpartyPortId *string `json:"counterparty_port_id,omitempty"` + // The order of the channel. If not specified, [`IbcOrder::Ordered`] is used. [`IbcOrder::Unordered`] is only supported if the counterparty chain is using `ibc-go` v8.1.0 or later. + ChannelOrdering *IbcOrder `json:"channel_ordering,omitempty"` + // The connection id on this chain. + ConnectionId string `json:"connection_id"` +} +type ExecuteMsg_UpdateOwnership Action + +/* +The message types of the distribution module. + +See https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto +*/ +type DistributionMsg struct { + // This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address. + SetWithdrawAddress *DistributionMsg_SetWithdrawAddress `json:"set_withdraw_address,omitempty"` + // This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address. + WithdrawDelegatorReward *DistributionMsg_WithdrawDelegatorReward `json:"withdraw_delegator_reward,omitempty"` + // This is translated to a [[MsgFundCommunityPool](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#LL69C1-L76C2). `depositor` is automatically filled with the current contract's address. + FundCommunityPool *DistributionMsg_FundCommunityPool `json:"fund_community_pool,omitempty"` +} + +/* +A human readable address. + +In Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length. + +This type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances. + +This type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance. +*/ +type Addr string + +// The contract's ownership info +type Ownership_for_String struct { + // The contract's current owner. `None` if the ownership has been renounced. + Owner *string `json:"owner,omitempty"` + // The deadline for the pending owner to accept the ownership. `None` if there isn't a pending ownership transfer, or if a transfer exists and it doesn't have a deadline. + PendingExpiry *Expiration `json:"pending_expiry,omitempty"` + // The account who has been proposed to take over the ownership. `None` if there isn't a pending ownership transfer. + PendingOwner *string `json:"pending_owner,omitempty"` } // IbcOrder defines if a channel is ORDERED or UNORDERED Values come from https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/ibc/core/channel/v1/channel.proto#L69-L80 Naming comes from the protobuf files and go translations. @@ -138,165 +244,131 @@ This is only needed as serde-json-{core,wasm} has a horrible encoding for Vec + DelegatorWithdrawAddress *DistributionQuery_DelegatorWithdrawAddress `json:"delegator_withdraw_address,omitempty"` + // See + DelegationRewards *DistributionQuery_DelegationRewards `json:"delegation_rewards,omitempty"` + // See + DelegationTotalRewards *DistributionQuery_DelegationTotalRewards `json:"delegation_total_rewards,omitempty"` + // See + DelegatorValidators *DistributionQuery_DelegatorValidators `json:"delegator_validators,omitempty"` } -// IbcChannel defines all information on a channel. This is generally used in the hand-shake process, but can be queried directly. -type IbcChannel struct { - // Note: in ibcv3 this may be "", in the IbcOpenChannel handshake messages - Version string `json:"version"` - // The connection upon which this channel was created. If this is a multi-hop channel, we only expose the first hop. - ConnectionId string `json:"connection_id"` - CounterpartyEndpoint IbcEndpoint `json:"counterparty_endpoint"` - Endpoint IbcEndpoint `json:"endpoint"` - Order IbcOrder `json:"order"` +type IbcEndpoint struct { + ChannelId string `json:"channel_id"` + PortId string `json:"port_id"` } -// State is the state of the contract. -type State struct { - // The address of the callback contract. - CallbackAddress *Addr `json:"callback_address,omitempty"` - // The Interchain Account (ICA) info needed to send packets. This is set during the handshake. - IcaInfo *IcaInfo `json:"ica_info,omitempty"` +// IcaInfo is the ICA address and channel ID. +type IcaInfo struct { + ChannelId string `json:"channel_id"` + Encoding TxEncoding `json:"encoding"` + IcaAddress string `json:"ica_address"` } /* -This message type allows the contract interact with the [x/gov] module in order to cast votes. +A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq. -## Examples +# Examples -Cast a simple vote: +Use `from` to create instances of this and `u128` to get the value out: -``` # use cosmwasm_std::{ # HexBinary, # Storage, Api, Querier, DepsMut, Deps, entry_point, Env, StdError, MessageInfo, # Response, QueryResponse, # }; # type ExecuteMsg = (); use cosmwasm_std::{GovMsg, VoteOption}; +``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123); -#[entry_point] pub fn execute( deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg, ) -> Result { // ... Ok(Response::new().add_message(GovMsg::Vote { proposal_id: 4, vote: VoteOption::Yes, })) } ``` +let b = Uint128::from(42u64); assert_eq!(b.u128(), 42); -Cast a weighted vote: - -``` # use cosmwasm_std::{ # HexBinary, # Storage, Api, Querier, DepsMut, Deps, entry_point, Env, StdError, MessageInfo, # Response, QueryResponse, # }; # type ExecuteMsg = (); # #[cfg(feature = "cosmwasm_1_2")] use cosmwasm_std::{Decimal, GovMsg, VoteOption, WeightedVoteOption}; - -# #[cfg(feature = "cosmwasm_1_2")] #[entry_point] pub fn execute( deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg, ) -> Result { // ... Ok(Response::new().add_message(GovMsg::VoteWeighted { proposal_id: 4, options: vec![ WeightedVoteOption { option: VoteOption::Yes, weight: Decimal::percent(65), }, WeightedVoteOption { option: VoteOption::Abstain, weight: Decimal::percent(35), }, ], })) } ``` - -[x/gov]: https://github.com/cosmos/cosmos-sdk/tree/v0.45.12/x/gov -*/ -type GovMsg struct { - // This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address. - Vote *GovMsg_Vote `json:"vote,omitempty"` - // This maps directly to [MsgVoteWeighted](https://github.com/cosmos/cosmos-sdk/blob/v0.45.8/proto/cosmos/gov/v1beta1/tx.proto#L66-L78) in the Cosmos SDK with voter set to the contract address. - VoteWeighted *GovMsg_VoteWeighted `json:"vote_weighted,omitempty"` -} +let c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ``` +*/ +type Uint128 string /* -A point in time in nanosecond precision. - -This type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z. - -## Examples - -``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202); +An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message. -let ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ``` +It is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451) */ -type Timestamp Uint64 +type Empty struct{} -// `TxEncoding` is the encoding of the transactions sent to the ICA host. -type TxEncoding string +// Status is the status of an IBC channel. +type ChannelStatus string const ( - // `Protobuf` is the protobuf serialization of the CosmosSDK's Any. - TxEncoding_Proto3 TxEncoding = "proto3" - // `Proto3Json` is the json serialization of the CosmosSDK's Any. - TxEncoding_Proto3Json TxEncoding = "proto3json" + // Uninitialized is the default state of the channel. + ChannelStatus_StateUninitializedUnspecified ChannelStatus = "STATE_UNINITIALIZED_UNSPECIFIED" + // Init is the state of the channel when it is created. + ChannelStatus_StateInit ChannelStatus = "STATE_INIT" + // TryOpen is the state of the channel when it is trying to open. + ChannelStatus_StateTryopen ChannelStatus = "STATE_TRYOPEN" + // Open is the state of the channel when it is open. + ChannelStatus_StateOpen ChannelStatus = "STATE_OPEN" + // Closed is the state of the channel when it is closed. + ChannelStatus_StateClosed ChannelStatus = "STATE_CLOSED" + // The channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. Added in `ibc-go` v8.1.0. + ChannelStatus_StateFlushing ChannelStatus = "STATE_FLUSHING" + // The channel has just completed flushing any in-flight packets. Added in `ibc-go` v8.1.0. + ChannelStatus_StateFlushcomplete ChannelStatus = "STATE_FLUSHCOMPLETE" ) -type ExecuteMsg_CloseChannel struct{} - -type ExecuteMsg_SendCosmosMsgs struct { - // The stargate messages to convert and send to the ICA host. - Messages []CosmosMsg_for_Empty `json:"messages"` - // Optional memo to include in the ibc packet. - PacketMemo *string `json:"packet_memo,omitempty"` - // The stargate queries to convert and send to the ICA host. The queries are executed after the messages. - Queries []QueryRequest_for_Empty `json:"queries"` - // Optional timeout in seconds to include with the ibc packet. If not specified, the [default timeout](crate::ibc::types::packet::DEFAULT_TIMEOUT_SECONDS) is used. - TimeoutSeconds *int `json:"timeout_seconds,omitempty"` +type ExecuteMsg_CreateChannel struct { + // The options to initialize the IBC channel. If not specified, the options specified in the last channel creation are used. Must be `None` if the sender is not the owner. + ChannelOpenInitOptions *ChannelOpenInitOptions `json:"channel_open_init_options,omitempty"` } -type QueryMsg_GetChannel struct{} +type ExecuteMsg_CloseChannel struct{} -type IbcEndpoint struct { - ChannelId string `json:"channel_id"` - PortId string `json:"port_id"` +type BankQuery struct { + // This calls into the native bank module for querying the total supply of one denomination. It does the same as the SupplyOf call in Cosmos SDK's RPC API. Return value is of type SupplyResponse. + Supply *BankQuery_Supply `json:"supply,omitempty"` + // This calls into the native bank module for one denomination Return value is BalanceResponse + Balance *BankQuery_Balance `json:"balance,omitempty"` + // This calls into the native bank module for all denominations. Note that this may be much more expensive than Balance and should be avoided if possible. Return value is AllBalanceResponse. + AllBalances *BankQuery_AllBalances `json:"all_balances,omitempty"` + // This calls into the native bank module for querying metadata for a specific bank token. Return value is DenomMetadataResponse + DenomMetadata *BankQuery_DenomMetadata `json:"denom_metadata,omitempty"` + // This calls into the native bank module for querying metadata for all bank tokens that have a metadata entry. Return value is AllDenomMetadataResponse + AllDenomMetadata *BankQuery_AllDenomMetadata `json:"all_denom_metadata,omitempty"` } -// IcaInfo is the ICA address and channel ID. -type IcaInfo struct { - IcaAddress string `json:"ica_address"` - ChannelId string `json:"channel_id"` - Encoding TxEncoding `json:"encoding"` -} +type StakingQuery struct { + // Returns the denomination that can be bonded (if there are multiple native tokens on the chain) + BondedDenom *StakingQuery_BondedDenom `json:"bonded_denom,omitempty"` + // AllDelegations will return all delegations by the delegator + AllDelegations *StakingQuery_AllDelegations `json:"all_delegations,omitempty"` + // Delegation will return more detailed info on a particular delegation, defined by delegator/validator pair + Delegation *StakingQuery_Delegation `json:"delegation,omitempty"` + /* + Returns all validators in the currently active validator set. -type ExecuteMsg_CreateChannel struct { - // The options to initialize the IBC channel. If not specified, the options specified in the last channel creation are used. Must be `None` if the sender is not the owner. - ChannelOpenInitOptions *ChannelOpenInitOptions `json:"channel_open_init_options,omitempty"` -} + The query response type is `AllValidatorsResponse`. + */ + AllValidators *StakingQuery_AllValidators `json:"all_validators,omitempty"` + /* + Returns the validator at the given address. Returns None if the validator is not part of the currently active validator set. -type DistributionQuery struct { - // See - DelegatorWithdrawAddress *DistributionQuery_DelegatorWithdrawAddress `json:"delegator_withdraw_address,omitempty"` - // See - DelegationRewards *DistributionQuery_DelegationRewards `json:"delegation_rewards,omitempty"` - // See - DelegationTotalRewards *DistributionQuery_DelegationTotalRewards `json:"delegation_total_rewards,omitempty"` - // See - DelegatorValidators *DistributionQuery_DelegatorValidators `json:"delegator_validators,omitempty"` + The query response type is `ValidatorResponse`. + */ + Validator *StakingQuery_Validator `json:"validator,omitempty"` } /* -A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq. +A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq. # Examples -Use `from` to create instances of this and `u128` to get the value out: - -``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123); +Use `from` to create instances of this and `u64` to get the value out: -let b = Uint128::from(42u64); assert_eq!(b.u128(), 42); +``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42); -let c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ``` +let b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ``` */ -type Uint128 string +type Uint64 string -type WeightedVoteOption struct { - Option VoteOption `json:"option"` - Weight Decimal `json:"weight"` +// State is the state of the contract. +type State struct { + // The address of the callback contract. + CallbackAddress *Addr `json:"callback_address,omitempty"` + // The Interchain Account (ICA) info needed to send packets. This is set during the handshake. + IcaInfo *IcaInfo `json:"ica_info,omitempty"` } type ExecuteMsg_UpdateCallbackAddress struct { @@ -304,139 +376,79 @@ type ExecuteMsg_UpdateCallbackAddress struct { CallbackAddress *string `json:"callback_address,omitempty"` } -// Actions that can be taken to alter the contract's ownership -type Action interface { - Implements_Action() +// IBCTimeoutHeight Height is a monotonically increasing data type that can be compared against another Height for the purposes of updating and freezing clients. Ordering is (revision_number, timeout_height) +type IbcTimeoutBlock struct { + // block height after which the packet times out. the height within the given revision + Height int `json:"height"` + // the version that the client is currently on (e.g. after resetting the chain this could increment 1 as height drops to 0) + Revision int `json:"revision"` } -var _ Action = (*Action_TransferOwnership)(nil) - -type Action_TransferOwnership struct { - Expiry *Expiration `json:"expiry,omitempty"` - NewOwner string `json:"new_owner"` +// In IBC each package must set at least one type of timeout: the timestamp or the block height. Using this rather complex enum instead of two timeout fields we ensure that at least one timeout is set. +type IbcTimeout struct { + Block *IbcTimeoutBlock `json:"block,omitempty"` + Timestamp *Timestamp `json:"timestamp,omitempty"` } -func (*Action_TransferOwnership) Implements_Action() {} - -var _ Action = (*Action_AcceptOwnership)(nil) - -type Action_AcceptOwnership string - /* -Accept the pending ownership transfer. +The message types of the bank module. -Can only be called by the pending owner. +See https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto */ -const Action_AcceptOwnership_Value Action_AcceptOwnership = "accept_ownership" - -func (*Action_AcceptOwnership) Implements_Action() {} +type BankMsg struct { + /* + Sends native tokens from the contract to the given address. -var _ Action = (*Action_RenounceOwnership)(nil) + This is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address. + */ + Send *BankMsg_Send `json:"send,omitempty"` + // This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired. + Burn *BankMsg_Burn `json:"burn,omitempty"` +} -type Action_RenounceOwnership string +type WeightedVoteOption struct { + Option VoteOption `json:"option"` + Weight Decimal `json:"weight"` +} /* -Give up the contract's ownership and the possibility of appointing a new owner. +This message type allows the contract interact with the [x/gov] module in order to cast votes. -Can only be invoked by the contract's current owner. +## Examples -Any existing pending ownership transfer is canceled. -*/ -const Action_RenounceOwnership_Value Action_RenounceOwnership = "renounce_ownership" +Cast a simple vote: -func (*Action_RenounceOwnership) Implements_Action() {} +``` # use cosmwasm_std::{ # HexBinary, # Storage, Api, Querier, DepsMut, Deps, entry_point, Env, StdError, MessageInfo, # Response, QueryResponse, # }; # type ExecuteMsg = (); use cosmwasm_std::{GovMsg, VoteOption}; -/* -An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message. +#[entry_point] pub fn execute( deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg, ) -> Result { // ... Ok(Response::new().add_message(GovMsg::Vote { proposal_id: 4, vote: VoteOption::Yes, })) } ``` -It is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451) -*/ -type Empty struct{} +Cast a weighted vote: -// These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points) -type IbcMsg struct { - // Sends bank tokens owned by the contract to the given address on another chain. The channel must already be established between the ibctransfer module on this chain and a matching module on the remote chain. We cannot select the port_id, this is whatever the local chain has bound the ibctransfer module to. - Transfer *IbcMsg_Transfer `json:"transfer,omitempty"` - // Sends an IBC packet with given data over the existing channel. Data should be encoded in a format defined by the channel version, and the module on the other side should know how to parse this. - SendPacket *IbcMsg_SendPacket `json:"send_packet,omitempty"` - // This will close an existing channel that is owned by this contract. Port is auto-assigned to the contract's IBC port - CloseChannel *IbcMsg_CloseChannel `json:"close_channel,omitempty"` -} +``` # use cosmwasm_std::{ # HexBinary, # Storage, Api, Querier, DepsMut, Deps, entry_point, Env, StdError, MessageInfo, # Response, QueryResponse, # }; # type ExecuteMsg = (); # #[cfg(feature = "cosmwasm_1_2")] use cosmwasm_std::{Decimal, GovMsg, VoteOption, WeightedVoteOption}; -type WasmQuery struct { - // this queries the public API of another contract at a known address (with known ABI) Return value is whatever the contract returns (caller should know), wrapped in a ContractResult that is JSON encoded. - Smart *WasmQuery_Smart `json:"smart,omitempty"` - // this queries the raw kv-store of the contract. returns the raw, unparsed data stored at that key, which may be an empty vector if not present - Raw *WasmQuery_Raw `json:"raw,omitempty"` - // Returns a [`ContractInfoResponse`] with metadata on the contract from the runtime - ContractInfo *WasmQuery_ContractInfo `json:"contract_info,omitempty"` - // Returns a [`CodeInfoResponse`] with metadata of the code - CodeInfo *WasmQuery_CodeInfo `json:"code_info,omitempty"` -} +# #[cfg(feature = "cosmwasm_1_2")] #[entry_point] pub fn execute( deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg, ) -> Result { // ... Ok(Response::new().add_message(GovMsg::VoteWeighted { proposal_id: 4, options: vec![ WeightedVoteOption { option: VoteOption::Yes, weight: Decimal::percent(65), }, WeightedVoteOption { option: VoteOption::Abstain, weight: Decimal::percent(35), }, ], })) } ``` -// State is the state of the IBC application's channel. This application only supports one channel. -type ChannelState struct { - // The IBC channel, as defined by cosmwasm. - Channel IbcChannel `json:"channel"` - // The status of the channel. - ChannelStatus ChannelStatus `json:"channel_status"` +[x/gov]: https://github.com/cosmos/cosmos-sdk/tree/v0.45.12/x/gov +*/ +type GovMsg struct { + // This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address. + Vote *GovMsg_Vote `json:"vote,omitempty"` + // This maps directly to [MsgVoteWeighted](https://github.com/cosmos/cosmos-sdk/blob/v0.45.8/proto/cosmos/gov/v1beta1/tx.proto#L66-L78) in the Cosmos SDK with voter set to the contract address. + VoteWeighted *GovMsg_VoteWeighted `json:"vote_weighted,omitempty"` } /* -The message types of the wasm module. - -See https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto -*/ -type WasmMsg struct { - /* - Dispatches a call to another contract at a known address (with known ABI). - - This is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address. - */ - Execute *WasmMsg_Execute `json:"execute,omitempty"` - /* - Instantiates a new contracts from previously uploaded Wasm code. - - The contract address is non-predictable. But it is guaranteed that when emitting the same Instantiate message multiple times, multiple instances on different addresses will be generated. See also Instantiate2. - - This is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.29.2/proto/cosmwasm/wasm/v1/tx.proto#L53-L71). `sender` is automatically filled with the current contract's address. - */ - Instantiate *WasmMsg_Instantiate `json:"instantiate,omitempty"` - /* - Instantiates a new contracts from previously uploaded Wasm code using a predictable address derivation algorithm implemented in [`cosmwasm_std::instantiate2_address`]. - - This is translated to a [MsgInstantiateContract2](https://github.com/CosmWasm/wasmd/blob/v0.29.2/proto/cosmwasm/wasm/v1/tx.proto#L73-L96). `sender` is automatically filled with the current contract's address. `fix_msg` is automatically set to false. - */ - Instantiate2 *WasmMsg_Instantiate2 `json:"instantiate2,omitempty"` - /* - Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior. +A point in time in nanosecond precision. - Only the contract admin (as defined in wasmd), if any, is able to make this call. +This type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z. - This is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address. - */ - Migrate *WasmMsg_Migrate `json:"migrate,omitempty"` - // Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract. - UpdateAdmin *WasmMsg_UpdateAdmin `json:"update_admin,omitempty"` - // Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract. - ClearAdmin *WasmMsg_ClearAdmin `json:"clear_admin,omitempty"` -} +## Examples -/* -The message types of the bank module. +``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202); -See https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto +let ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ``` */ -type BankMsg struct { - /* - Sends native tokens from the contract to the given address. - - This is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address. - */ - Send *BankMsg_Send `json:"send,omitempty"` - // This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired. - Burn *BankMsg_Burn `json:"burn,omitempty"` -} +type Timestamp Uint64 type QueryRequest_for_Empty struct { Bank *QueryRequest_for_Empty_Bank `json:"bank,omitempty"` @@ -449,281 +461,234 @@ type QueryRequest_for_Empty struct { Wasm *QueryRequest_for_Empty_Wasm `json:"wasm,omitempty"` } -type StakingQuery struct { - // Returns the denomination that can be bonded (if there are multiple native tokens on the chain) - BondedDenom *StakingQuery_BondedDenom `json:"bonded_denom,omitempty"` - // AllDelegations will return all delegations by the delegator - AllDelegations *StakingQuery_AllDelegations `json:"all_delegations,omitempty"` - // Delegation will return more detailed info on a particular delegation, defined by delegator/validator pair - Delegation *StakingQuery_Delegation `json:"delegation,omitempty"` +// State is the state of the IBC application's channel. This application only supports one channel. +type ChannelState struct { + // The IBC channel, as defined by cosmwasm. + Channel IbcChannel `json:"channel"` + // The status of the channel. + ChannelStatus ChannelStatus `json:"channel_status"` +} + +type QueryMsg_GetContractState struct{} + +// These are queries to the various IBC modules to see the state of the contract's IBC connection. These will return errors if the contract is not "ibc enabled" +type IbcQuery struct { /* - Returns all validators in the currently active validator set. + Gets the Port ID the current contract is bound to. - The query response type is `AllValidatorsResponse`. + Returns a `PortIdResponse`. */ - AllValidators *StakingQuery_AllValidators `json:"all_validators,omitempty"` + PortId *IbcQuery_PortId `json:"port_id,omitempty"` /* - Returns the validator at the given address. Returns None if the validator is not part of the currently active validator set. + Lists all channels that are bound to a given port. If `port_id` is omitted, this list all channels bound to the contract's port. - The query response type is `ValidatorResponse`. + Returns a `ListChannelsResponse`. */ - Validator *StakingQuery_Validator `json:"validator,omitempty"` -} + ListChannels *IbcQuery_ListChannels `json:"list_channels,omitempty"` + /* + Lists all information for a (portID, channelID) pair. If port_id is omitted, it will default to the contract's own channel. (To save a PortId{} call) -// Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future) -type Expiration struct { - // AtHeight will expire when `env.block.height` >= height - AtHeight *Expiration_AtHeight `json:"at_height,omitempty"` - // AtTime will expire when `env.block.time` >= time - AtTime *Expiration_AtTime `json:"at_time,omitempty"` - // Never will never expire. Used to express the empty variant - Never *Expiration_Never `json:"never,omitempty"` + Returns a `ChannelResponse`. + */ + Channel *IbcQuery_Channel `json:"channel,omitempty"` } -type QueryMsg_GetContractState struct{} - -// Status is the status of an IBC channel. -type ChannelStatus string - -const ( - // Uninitialized is the default state of the channel. - ChannelStatus_StateUninitializedUnspecified ChannelStatus = "STATE_UNINITIALIZED_UNSPECIFIED" - // Init is the state of the channel when it is created. - ChannelStatus_StateInit ChannelStatus = "STATE_INIT" - // TryOpen is the state of the channel when it is trying to open. - ChannelStatus_StateTryopen ChannelStatus = "STATE_TRYOPEN" - // Open is the state of the channel when it is open. - ChannelStatus_StateOpen ChannelStatus = "STATE_OPEN" - // Closed is the state of the channel when it is closed. - ChannelStatus_StateClosed ChannelStatus = "STATE_CLOSED" - // The channel has just accepted the upgrade handshake attempt and is flushing in-flight packets. Added in `ibc-go` v8.1.0. - ChannelStatus_StateFlushing ChannelStatus = "STATE_FLUSHING" - // The channel has just completed flushing any in-flight packets. Added in `ibc-go` v8.1.0. - ChannelStatus_StateFlushcomplete ChannelStatus = "STATE_FLUSHCOMPLETE" -) - -/* -A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0 - -The greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18) -*/ -type Decimal string - -// In IBC each package must set at least one type of timeout: the timestamp or the block height. Using this rather complex enum instead of two timeout fields we ensure that at least one timeout is set. -type IbcTimeout struct { - Block *IbcTimeoutBlock `json:"block,omitempty"` - Timestamp *Timestamp `json:"timestamp,omitempty"` +// Actions that can be taken to alter the contract's ownership +type Action interface { + Implements_Action() } -/* -A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq. +var _ Action = (*Action_TransferOwnership)(nil) -# Examples +type Action_TransferOwnership struct { + Expiry *Expiration `json:"expiry,omitempty"` + NewOwner string `json:"new_owner"` +} -Use `from` to create instances of this and `u64` to get the value out: +func (*Action_TransferOwnership) Implements_Action() {} -``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42); +var _ Action = (*Action_AcceptOwnership)(nil) -let b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ``` -*/ -type Uint64 string +type Action_AcceptOwnership string /* -The message types of the distribution module. +Accept the pending ownership transfer. -See https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto +Can only be called by the pending owner. */ -type DistributionMsg struct { - // This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address. - SetWithdrawAddress *DistributionMsg_SetWithdrawAddress `json:"set_withdraw_address,omitempty"` - // This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address. - WithdrawDelegatorReward *DistributionMsg_WithdrawDelegatorReward `json:"withdraw_delegator_reward,omitempty"` - // This is translated to a [[MsgFundCommunityPool](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#LL69C1-L76C2). `depositor` is automatically filled with the current contract's address. - FundCommunityPool *DistributionMsg_FundCommunityPool `json:"fund_community_pool,omitempty"` -} - -type CosmosMsg_for_Empty struct { - Bank *CosmosMsg_for_Empty_Bank `json:"bank,omitempty"` - Custom *CosmosMsg_for_Empty_Custom `json:"custom,omitempty"` - Staking *CosmosMsg_for_Empty_Staking `json:"staking,omitempty"` - Distribution *CosmosMsg_for_Empty_Distribution `json:"distribution,omitempty"` - // A Stargate message encoded the same way as a protobuf [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) - Stargate *CosmosMsg_for_Empty_Stargate `json:"stargate,omitempty"` - Ibc *CosmosMsg_for_Empty_Ibc `json:"ibc,omitempty"` - Wasm *CosmosMsg_for_Empty_Wasm `json:"wasm,omitempty"` - Gov *CosmosMsg_for_Empty_Gov `json:"gov,omitempty"` -} - -type WasmMsg_Migrate struct { - ContractAddr string `json:"contract_addr"` - // msg is the json-encoded MigrateMsg struct that will be passed to the new code - Msg Binary `json:"msg"` - // the code_id of the new logic to place in the given contract - NewCodeId int `json:"new_code_id"` -} -type QueryRequest_for_Empty_Distribution DistributionQuery +const Action_AcceptOwnership_Value Action_AcceptOwnership = "accept_ownership" -type DistributionQuery_DelegatorValidators struct { - DelegatorAddress string `json:"delegator_address"` -} -type Expiration_AtTime Timestamp -type CosmosMsg_for_Empty_Distribution DistributionMsg +func (*Action_AcceptOwnership) Implements_Action() {} -type IbcMsg_SendPacket struct { - ChannelId string `json:"channel_id"` - Data Binary `json:"data"` - // when packet times out, measured on remote chain - Timeout IbcTimeout `json:"timeout"` -} +var _ Action = (*Action_RenounceOwnership)(nil) -type DistributionQuery_DelegationRewards struct { - DelegatorAddress string `json:"delegator_address"` - ValidatorAddress string `json:"validator_address"` -} +type Action_RenounceOwnership string -type StakingQuery_Validator struct { - // The validator's address (e.g. (e.g. cosmosvaloper1...)) - Address string `json:"address"` -} +/* +Give up the contract's ownership and the possibility of appointing a new owner. -type WasmMsg_UpdateAdmin struct { - Admin string `json:"admin"` - ContractAddr string `json:"contract_addr"` -} +Can only be invoked by the contract's current owner. -type StakingQuery_Delegation struct { - Delegator string `json:"delegator"` - Validator string `json:"validator"` -} +Any existing pending ownership transfer is canceled. +*/ +const Action_RenounceOwnership_Value Action_RenounceOwnership = "renounce_ownership" -type DistributionMsg_SetWithdrawAddress struct { - // The `withdraw_address` - Address string `json:"address"` -} +func (*Action_RenounceOwnership) Implements_Action() {} -type StakingMsg_Undelegate struct { - Amount Coin `json:"amount"` - Validator string `json:"validator"` +// Simplified version of the PageRequest type for pagination from the cosmos-sdk +type PageRequest struct { + Limit int `json:"limit"` + Reverse bool `json:"reverse"` + Key *Binary `json:"key,omitempty"` } -type DistributionMsg_WithdrawDelegatorReward struct { - // The `validator_address` - Validator string `json:"validator"` +// These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points) +type IbcMsg struct { + // Sends bank tokens owned by the contract to the given address on another chain. The channel must already be established between the ibctransfer module on this chain and a matching module on the remote chain. We cannot select the port_id, this is whatever the local chain has bound the ibctransfer module to. + Transfer *IbcMsg_Transfer `json:"transfer,omitempty"` + // Sends an IBC packet with given data over the existing channel. Data should be encoded in a format defined by the channel version, and the module on the other side should know how to parse this. + SendPacket *IbcMsg_SendPacket `json:"send_packet,omitempty"` + // This will close an existing channel that is owned by this contract. Port is auto-assigned to the contract's IBC port + CloseChannel *IbcMsg_CloseChannel `json:"close_channel,omitempty"` } -type Expiration_Never struct{} +type QueryMsg_GetChannel struct{} -type BankQuery_Balance struct { - Address string `json:"address"` - Denom string `json:"denom"` +type WasmMsg_ClearAdmin struct { + ContractAddr string `json:"contract_addr"` } +type QueryRequest_for_Empty_Distribution DistributionQuery -type DistributionQuery_DelegatorWithdrawAddress struct { +type DistributionQuery_DelegatorValidators struct { DelegatorAddress string `json:"delegator_address"` } +type QueryRequest_for_Empty_Wasm WasmQuery -type BankMsg_Burn struct { - Amount []Coin `json:"amount"` +type DistributionQuery_DelegationTotalRewards struct { + DelegatorAddress string `json:"delegator_address"` } -type WasmMsg_Instantiate2 struct { - Admin *string `json:"admin,omitempty"` - CodeId int `json:"code_id"` - Funds []Coin `json:"funds"` +type Expiration_AtHeight int + +type IbcQuery_PortId struct{} +type CosmosMsg_for_Empty_Bank BankMsg + +type GovMsg_Vote struct { + ProposalId int `json:"proposal_id"` /* - A human-readable label for the contract. + The vote option. - Valid values should: - not be empty - not be bigger than 128 bytes (or some chain-specific limit) - not start / end with whitespace + This should be called "option" for consistency with Cosmos SDK. Sorry for that. See . */ - Label string `json:"label"` - // msg is the JSON-encoded InstantiateMsg struct (as raw Binary) - Msg Binary `json:"msg"` - Salt Binary `json:"salt"` -} -type QueryRequest_for_Empty_Custom Empty - -type QueryRequest_for_Empty_Stargate struct { - // this is the expected protobuf message type (not any), binary encoded - Data Binary `json:"data"` - // this is the fully qualified service path used for routing, eg. custom/cosmos_sdk.x.bank.v1.Query/QueryBalance - Path string `json:"path"` + Vote VoteOption `json:"vote"` } -type WasmQuery_Smart struct { +type WasmMsg_Migrate struct { ContractAddr string `json:"contract_addr"` - // msg is the json-encoded QueryMsg struct + // msg is the json-encoded MigrateMsg struct that will be passed to the new code Msg Binary `json:"msg"` + // the code_id of the new logic to place in the given contract + NewCodeId int `json:"new_code_id"` } -type QueryRequest_for_Empty_Bank BankQuery -type QueryRequest_for_Empty_Wasm WasmQuery - -type StakingQuery_AllValidators struct{} +type QueryRequest_for_Empty_Custom Empty -type DistributionQuery_DelegationTotalRewards struct { - DelegatorAddress string `json:"delegator_address"` +type BankQuery_DenomMetadata struct { + Denom string `json:"denom"` } type WasmMsg_Execute struct { - // msg is the json-encoded ExecuteMsg struct (as raw Binary) - Msg Binary `json:"msg"` ContractAddr string `json:"contract_addr"` Funds []Coin `json:"funds"` + // msg is the json-encoded ExecuteMsg struct (as raw Binary) + Msg Binary `json:"msg"` } +type CosmosMsg_for_Empty_Gov GovMsg -type WasmQuery_CodeInfo struct { - CodeId int `json:"code_id"` +type StakingQuery_Validator struct { + // The validator's address (e.g. (e.g. cosmosvaloper1...)) + Address string `json:"address"` } -type CosmosMsg_for_Empty_Bank BankMsg +type CosmosMsg_for_Empty_Ibc IbcMsg type IbcMsg_Transfer struct { + // packet data only supports one coin https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/ibc/applications/transfer/v1/transfer.proto#L11-L20 + Amount Coin `json:"amount"` // existing channel to send the tokens over ChannelId string `json:"channel_id"` // when packet times out, measured on remote chain Timeout IbcTimeout `json:"timeout"` // address on the remote chain to receive these tokens ToAddress string `json:"to_address"` - // packet data only supports one coin https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/ibc/applications/transfer/v1/transfer.proto#L11-L20 - Amount Coin `json:"amount"` } -type IbcMsg_CloseChannel struct { +type IbcQuery_Channel struct { ChannelId string `json:"channel_id"` + PortId *string `json:"port_id,omitempty"` } +type CosmosMsg_for_Empty_Distribution DistributionMsg +type CosmosMsg_for_Empty_Staking StakingMsg -type BankQuery_DenomMetadata struct { - Denom string `json:"denom"` +type QueryRequest_for_Empty_Stargate struct { + // this is the expected protobuf message type (not any), binary encoded + Data Binary `json:"data"` + // this is the fully qualified service path used for routing, eg. custom/cosmos_sdk.x.bank.v1.Query/QueryBalance + Path string `json:"path"` } -type CosmosMsg_for_Empty_Ibc IbcMsg -type CosmosMsg_for_Empty_Gov GovMsg -type StakingMsg_Redelegate struct { - Amount Coin `json:"amount"` - DstValidator string `json:"dst_validator"` - SrcValidator string `json:"src_validator"` +type WasmQuery_Smart struct { + ContractAddr string `json:"contract_addr"` + // msg is the json-encoded QueryMsg struct + Msg Binary `json:"msg"` +} + +type GovMsg_VoteWeighted struct { + Options []WeightedVoteOption `json:"options"` + ProposalId int `json:"proposal_id"` } +type BankMsg_Burn struct { + Amount []Coin `json:"amount"` +} +type QueryRequest_for_Empty_Staking StakingQuery + type CosmosMsg_for_Empty_Stargate struct { TypeUrl string `json:"type_url"` Value Binary `json:"value"` } -type DistributionMsg_FundCommunityPool struct { - // The amount to spend - Amount []Coin `json:"amount"` +type IbcQuery_ListChannels struct { + PortId *string `json:"port_id,omitempty"` +} + +type WasmMsg_Instantiate2 struct { + /* + A human-readable label for the contract. + + Valid values should: - not be empty - not be bigger than 128 bytes (or some chain-specific limit) - not start / end with whitespace + */ + Label string `json:"label"` + // msg is the JSON-encoded InstantiateMsg struct (as raw Binary) + Msg Binary `json:"msg"` + Salt Binary `json:"salt"` + Admin *string `json:"admin,omitempty"` + CodeId int `json:"code_id"` + Funds []Coin `json:"funds"` } -type CosmosMsg_for_Empty_Staking StakingMsg type BankQuery_AllDenomMetadata struct { Pagination *PageRequest `json:"pagination,omitempty"` } -type Expiration_AtHeight int - -type WasmMsg_ClearAdmin struct { - ContractAddr string `json:"contract_addr"` +type BankQuery_Supply struct { + Denom string `json:"denom"` } -type IbcQuery_PortId struct{} +type Expiration_Never struct{} + +type BankQuery_Balance struct { + Address string `json:"address"` + Denom string `json:"denom"` +} type WasmMsg_Instantiate struct { CodeId int `json:"code_id"` @@ -738,65 +703,100 @@ type WasmMsg_Instantiate struct { Msg Binary `json:"msg"` Admin *string `json:"admin,omitempty"` } -type QueryRequest_for_Empty_Staking StakingQuery +type Expiration_AtTime Timestamp +type CosmosMsg_for_Empty_Wasm WasmMsg -type GovMsg_VoteWeighted struct { - Options []WeightedVoteOption `json:"options"` - ProposalId int `json:"proposal_id"` +type BankQuery_AllBalances struct { + Address string `json:"address"` } -type CosmosMsg_for_Empty_Custom Empty -type WasmQuery_ContractInfo struct { - ContractAddr string `json:"contract_addr"` +type StakingMsg_Delegate struct { + Validator string `json:"validator"` + Amount Coin `json:"amount"` } -type BankQuery_Supply struct { - Denom string `json:"denom"` +type IbcMsg_SendPacket struct { + ChannelId string `json:"channel_id"` + Data Binary `json:"data"` + // when packet times out, measured on remote chain + Timeout IbcTimeout `json:"timeout"` } -type StakingQuery_AllDelegations struct { +type StakingQuery_Delegation struct { Delegator string `json:"delegator"` + Validator string `json:"validator"` } -type BankQuery_AllBalances struct { - Address string `json:"address"` +type IbcMsg_CloseChannel struct { + ChannelId string `json:"channel_id"` } -type CosmosMsg_for_Empty_Wasm WasmMsg -type IbcQuery_Channel struct { - ChannelId string `json:"channel_id"` - PortId *string `json:"port_id,omitempty"` +type DistributionQuery_DelegationRewards struct { + DelegatorAddress string `json:"delegator_address"` + ValidatorAddress string `json:"validator_address"` } -type GovMsg_Vote struct { - ProposalId int `json:"proposal_id"` - /* - The vote option. +type DistributionQuery_DelegatorWithdrawAddress struct { + DelegatorAddress string `json:"delegator_address"` +} - This should be called "option" for consistency with Cosmos SDK. Sorry for that. See . - */ - Vote VoteOption `json:"vote"` +type StakingQuery_AllValidators struct{} + +type StakingMsg_Undelegate struct { + Amount Coin `json:"amount"` + Validator string `json:"validator"` } +type CosmosMsg_for_Empty_Custom Empty -type IbcQuery_ListChannels struct { - PortId *string `json:"port_id,omitempty"` +type DistributionMsg_SetWithdrawAddress struct { + // The `withdraw_address` + Address string `json:"address"` } -type QueryRequest_for_Empty_Ibc IbcQuery -type StakingQuery_BondedDenom struct{} +type WasmQuery_CodeInfo struct { + CodeId int `json:"code_id"` +} + +type DistributionMsg_WithdrawDelegatorReward struct { + // The `validator_address` + Validator string `json:"validator"` +} type WasmQuery_Raw struct { + ContractAddr string `json:"contract_addr"` // Key is the raw key used in the contracts Storage Key Binary `json:"key"` - ContractAddr string `json:"contract_addr"` } -type StakingMsg_Delegate struct { - Amount Coin `json:"amount"` - Validator string `json:"validator"` +type DistributionMsg_FundCommunityPool struct { + // The amount to spend + Amount []Coin `json:"amount"` } +type QueryRequest_for_Empty_Bank BankQuery type BankMsg_Send struct { Amount []Coin `json:"amount"` ToAddress string `json:"to_address"` } + +type WasmQuery_ContractInfo struct { + ContractAddr string `json:"contract_addr"` +} + +type StakingMsg_Redelegate struct { + Amount Coin `json:"amount"` + DstValidator string `json:"dst_validator"` + SrcValidator string `json:"src_validator"` +} + +type StakingQuery_AllDelegations struct { + Delegator string `json:"delegator"` +} + +type StakingQuery_BondedDenom struct{} +type QueryRequest_for_Empty_Ibc IbcQuery + +type WasmMsg_UpdateAdmin struct { + Admin string `json:"admin"` + ContractAddr string `json:"contract_addr"` +} diff --git a/e2e/interchaintestv8/types/cwicacontroller/query.go b/e2e/interchaintestv8/types/cwicacontroller/query.go index 8346e587..de2b3f84 100644 --- a/e2e/interchaintestv8/types/cwicacontroller/query.go +++ b/e2e/interchaintestv8/types/cwicacontroller/query.go @@ -13,12 +13,12 @@ import ( // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { - // GetContractState is the client API for the QueryMsg_GetContractState query message - GetContractState(ctx context.Context, req *QueryMsg_GetContractState, opts ...grpc.CallOption) (*State, error) // Ownership is the client API for the QueryMsg_Ownership query message Ownership(ctx context.Context, req *QueryMsg_Ownership, opts ...grpc.CallOption) (*Ownership_for_String, error) // GetChannel is the client API for the QueryMsg_GetChannel query message GetChannel(ctx context.Context, req *QueryMsg_GetChannel, opts ...grpc.CallOption) (*ChannelState, error) + // GetContractState is the client API for the QueryMsg_GetContractState query message + GetContractState(ctx context.Context, req *QueryMsg_GetContractState, opts ...grpc.CallOption) (*State, error) } type queryClient struct { @@ -65,8 +65,8 @@ func (q *queryClient) queryContract(ctx context.Context, rawQueryData []byte, op return out.Data, nil } -func (q *queryClient) Ownership(ctx context.Context, req *QueryMsg_Ownership, opts ...grpc.CallOption) (*Ownership_for_String, error) { - rawQueryData, err := json.Marshal(&QueryMsg{Ownership: req}) +func (q *queryClient) GetContractState(ctx context.Context, req *QueryMsg_GetContractState, opts ...grpc.CallOption) (*State, error) { + rawQueryData, err := json.Marshal(map[string]any{"get_contract_state": req}) if err != nil { return nil, err } @@ -76,7 +76,7 @@ func (q *queryClient) Ownership(ctx context.Context, req *QueryMsg_Ownership, op return nil, err } - var response Ownership_for_String + var response State if err := json.Unmarshal(rawResponseData, &response); err != nil { return nil, err } @@ -84,8 +84,8 @@ func (q *queryClient) Ownership(ctx context.Context, req *QueryMsg_Ownership, op return &response, nil } -func (q *queryClient) GetChannel(ctx context.Context, req *QueryMsg_GetChannel, opts ...grpc.CallOption) (*ChannelState, error) { - rawQueryData, err := json.Marshal(&QueryMsg{GetChannel: req}) +func (q *queryClient) Ownership(ctx context.Context, req *QueryMsg_Ownership, opts ...grpc.CallOption) (*Ownership_for_String, error) { + rawQueryData, err := json.Marshal(map[string]any{"ownership": req}) if err != nil { return nil, err } @@ -95,7 +95,7 @@ func (q *queryClient) GetChannel(ctx context.Context, req *QueryMsg_GetChannel, return nil, err } - var response ChannelState + var response Ownership_for_String if err := json.Unmarshal(rawResponseData, &response); err != nil { return nil, err } @@ -103,8 +103,8 @@ func (q *queryClient) GetChannel(ctx context.Context, req *QueryMsg_GetChannel, return &response, nil } -func (q *queryClient) GetContractState(ctx context.Context, req *QueryMsg_GetContractState, opts ...grpc.CallOption) (*State, error) { - rawQueryData, err := json.Marshal(&QueryMsg{GetContractState: req}) +func (q *queryClient) GetChannel(ctx context.Context, req *QueryMsg_GetChannel, opts ...grpc.CallOption) (*ChannelState, error) { + rawQueryData, err := json.Marshal(map[string]any{"get_channel": req}) if err != nil { return nil, err } @@ -114,7 +114,7 @@ func (q *queryClient) GetContractState(ctx context.Context, req *QueryMsg_GetCon return nil, err } - var response State + var response ChannelState if err := json.Unmarshal(rawResponseData, &response); err != nil { return nil, err } diff --git a/e2e/interchaintestv8/types/cwicaowner/msgs.go b/e2e/interchaintestv8/types/cwicaowner/msgs.go index 05696a31..0b5acb69 100644 --- a/e2e/interchaintestv8/types/cwicaowner/msgs.go +++ b/e2e/interchaintestv8/types/cwicaowner/msgs.go @@ -27,33 +27,32 @@ type QueryMsg struct { GetIcaCount *QueryMsg_GetIcaCount `json:"get_ica_count,omitempty"` } -type IbcPacket struct { - Timeout IbcTimeout `json:"timeout"` - // The raw data sent from the other side in the packet - Data Binary `json:"data"` - // identifies the channel and port on the receiving chain. - Dest IbcEndpoint `json:"dest"` - // The sequence number of the packet on the given channel - Sequence int `json:"sequence"` - // identifies the channel and port on the sending chain. - Src IbcEndpoint `json:"src"` -} - -// In IBC each package must set at least one type of timeout: the timestamp or the block height. Using this rather complex enum instead of two timeout fields we ensure that at least one timeout is set. -type IbcTimeout struct { - Timestamp *Timestamp `json:"timestamp,omitempty"` - Block *IbcTimeoutBlock `json:"block,omitempty"` -} - -// IcaState is the state of the ICA. -type IcaState struct { - IcaAddr string `json:"ica_addr"` +type ExecuteMsg_SendPredefinedAction struct { + // The ICA ID. IcaId int `json:"ica_id"` - TxEncoding TxEncoding `json:"tx_encoding"` - ChannelState ChannelState `json:"channel_state"` + // The recipient's address, on the counterparty chain, to send the tokens to from ICA host. + ToAddress string `json:"to_address"` } type ExecuteMsg_ReceiveIcaCallback IcaControllerCallbackMsg +// IbcOrder defines if a channel is ORDERED or UNORDERED Values come from https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/ibc/core/channel/v1/channel.proto#L69-L80 Naming comes from the protobuf files and go translations. +type IbcOrder string + +const ( + IbcOrder_OrderUnordered IbcOrder = "ORDER_UNORDERED" + IbcOrder_OrderOrdered IbcOrder = "ORDER_ORDERED" +) + +// `TxEncoding` is the encoding of the transactions sent to the ICA host. +type TxEncoding string + +const ( + // `Protobuf` is the protobuf serialization of the CosmosSDK's Any. + TxEncoding_Proto3 TxEncoding = "proto3" + // `Proto3Json` is the json serialization of the CosmosSDK's Any. + TxEncoding_Proto3Json TxEncoding = "proto3json" +) + // The options needed to initialize the IBC channel. type ChannelOpenInitOptions struct { // The counterparty connection id on the counterparty chain. @@ -66,22 +65,6 @@ type ChannelOpenInitOptions struct { ConnectionId string `json:"connection_id"` } -// IbcOrder defines if a channel is ORDERED or UNORDERED Values come from https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/ibc/core/channel/v1/channel.proto#L69-L80 Naming comes from the protobuf files and go translations. -type IbcOrder string - -const ( - IbcOrder_OrderUnordered IbcOrder = "ORDER_UNORDERED" - IbcOrder_OrderOrdered IbcOrder = "ORDER_ORDERED" -) - -// State is the state of the IBC application's channel. This application only supports one channel. -type ChannelState struct { - // The IBC channel, as defined by cosmwasm. - Channel IbcChannel `json:"channel"` - // The status of the channel. - ChannelStatus ChannelStatus `json:"channel_status"` -} - // `Data` is the response to an ibc packet. It either contains a result or an error. type Data struct { // Result is the result of a successful transaction. @@ -90,16 +73,41 @@ type Data struct { Error *Data_Error `json:"error,omitempty"` } -type QueryMsg_GetIcaCount struct{} +/* +A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq. -// ContractState is the state of the IBC application. -type ContractState struct { - // The admin of this contract. - Admin Addr `json:"admin"` - // The code ID of the cw-ica-controller contract. - IcaControllerCodeId int `json:"ica_controller_code_id"` +# Examples + +Use `from` to create instances of this and `u64` to get the value out: + +``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42); + +let b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ``` +*/ +type Uint64 string + +type QueryMsg_GetIcaContractState struct { + IcaId int `json:"ica_id"` } +type ExecuteMsg_CreateIcaContract struct { + ChannelOpenInitOptions ChannelOpenInitOptions `json:"channel_open_init_options"` + Salt *string `json:"salt,omitempty"` +} + +/* +A point in time in nanosecond precision. + +This type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z. + +## Examples + +``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202); + +let ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ``` +*/ +type Timestamp Uint64 + type QueryMsg_GetContractState struct{} // Status is the status of an IBC channel. @@ -122,9 +130,20 @@ const ( ChannelStatus_StateFlushcomplete ChannelStatus = "STATE_FLUSHCOMPLETE" ) -type ExecuteMsg_CreateIcaContract struct { - ChannelOpenInitOptions ChannelOpenInitOptions `json:"channel_open_init_options"` - Salt *string `json:"salt,omitempty"` +// `IcaControllerCallbackMsg` is the type of message that this contract can send to other contracts. +type IcaControllerCallbackMsg struct { + // `OnAcknowledgementPacketCallback` is the callback that this contract makes to other contracts when it receives an acknowledgement packet. + OnAcknowledgementPacketCallback *IcaControllerCallbackMsg_OnAcknowledgementPacketCallback `json:"on_acknowledgement_packet_callback,omitempty"` + // `OnTimeoutPacketCallback` is the callback that this contract makes to other contracts when it receives a timeout packet. + OnTimeoutPacketCallback *IcaControllerCallbackMsg_OnTimeoutPacketCallback `json:"on_timeout_packet_callback,omitempty"` + // `OnChannelOpenAckCallback` is the callback that this contract makes to other contracts when it receives a channel open acknowledgement. + OnChannelOpenAckCallback *IcaControllerCallbackMsg_OnChannelOpenAckCallback `json:"on_channel_open_ack_callback,omitempty"` +} + +// In IBC each package must set at least one type of timeout: the timestamp or the block height. Using this rather complex enum instead of two timeout fields we ensure that at least one timeout is set. +type IbcTimeout struct { + Block *IbcTimeoutBlock `json:"block,omitempty"` + Timestamp *Timestamp `json:"timestamp,omitempty"` } /* @@ -145,38 +164,41 @@ This is only needed as serde-json-{core,wasm} has a horrible encoding for Vec