Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add EurekaMsg #2340

Merged
merged 4 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ and this project adheres to

- cosmwasm-schema: The schema export now doesn't overwrite existing
`additionalProperties` values anymore ([#2310])
- cosmwasm-std: Added new `EurekaMsg` and `CosmosMsg::Eureka` variant ([#2340])
jawoznia marked this conversation as resolved.
Show resolved Hide resolved

[#2310]: https://github.com/CosmWasm/cosmwasm/pull/2310
jawoznia marked this conversation as resolved.
Show resolved Hide resolved
[#2340]: https://github.com/CosmWasm/cosmwasm/pull/2340

## [2.2.0] - 2024-12-17

Expand Down
84 changes: 84 additions & 0 deletions contracts/ibc-reflect-send/schema/ibc-reflect-send.json
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,18 @@
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"eureka"
],
"properties": {
"eureka": {
"$ref": "#/definitions/EurekaMsg"
}
},
"additionalProperties": false
}
]
},
Expand Down Expand Up @@ -364,6 +376,78 @@
"type": "object",
"additionalProperties": false
},
"EurekaMsg": {
"description": "These are messages in the IBC lifecycle using the new Eureka approach. Only usable by IBC-enabled contracts",
"oneOf": [
{
"description": "Sends an IBC packet with given payloads over the existing channel.",
"type": "object",
"required": [
"send_packet"
],
"properties": {
"send_packet": {
"type": "object",
"required": [
"channel_id",
"payloads",
"timeout"
],
"properties": {
"channel_id": {
"description": "existing channel to send the tokens over",
"type": "string"
},
"payloads": {
"type": "array",
"items": {
"$ref": "#/definitions/EurekaPayload"
}
},
"timeout": {
"$ref": "#/definitions/Timestamp"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
]
},
"EurekaPayload": {
"description": "Payload value should be encoded in a format defined by the channel version, and the module on the other side should know how to parse this.",
"type": "object",
"required": [
"destination_port",
"encoding",
"value",
"version"
],
"properties": {
"destination_port": {
"description": "The port id on the chain where the packet is sent to (external chain).",
"type": "string"
},
"encoding": {
"description": "Encoding used to serialize the [EurekaPayload::value].",
"type": "string"
},
"value": {
"description": "Encoded payload data.",
"allOf": [
{
"$ref": "#/definitions/Binary"
}
]
},
"version": {
"description": "Version of the receiving contract.",
"type": "string"
}
},
"additionalProperties": false
},
"GovMsg": {
"description": "This message type allows the contract interact with the [x/gov] module in order to cast votes.\n\n[x/gov]: https://github.com/cosmos/cosmos-sdk/tree/v0.45.12/x/gov\n\n## Examples\n\nCast a simple vote:\n\n``` # use cosmwasm_std::{ # HexBinary, # Storage, Api, Querier, DepsMut, Deps, entry_point, Env, StdError, MessageInfo, # Response, QueryResponse, # }; # type ExecuteMsg = (); use cosmwasm_std::{GovMsg, VoteOption};\n\n#[entry_point] pub fn execute( deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg, ) -> Result<Response, StdError> { // ... Ok(Response::new().add_message(GovMsg::Vote { proposal_id: 4, option: VoteOption::Yes, })) } ```\n\nCast a weighted vote:\n\n``` # 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};\n\n# #[cfg(feature = \"cosmwasm_1_2\")] #[entry_point] pub fn execute( deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg, ) -> Result<Response, StdError> { // ... 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), }, ], })) } ```",
"oneOf": [
Expand Down
84 changes: 84 additions & 0 deletions contracts/ibc-reflect-send/schema/ibc/packet_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,18 @@
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"eureka"
],
"properties": {
"eureka": {
"$ref": "#/definitions/EurekaMsg"
}
},
"additionalProperties": false
}
]
},
Expand Down Expand Up @@ -305,6 +317,78 @@
"type": "object",
"additionalProperties": false
},
"EurekaMsg": {
"description": "These are messages in the IBC lifecycle using the new Eureka approach. Only usable by IBC-enabled contracts",
"oneOf": [
{
"description": "Sends an IBC packet with given payloads over the existing channel.",
"type": "object",
"required": [
"send_packet"
],
"properties": {
"send_packet": {
"type": "object",
"required": [
"channel_id",
"payloads",
"timeout"
],
"properties": {
"channel_id": {
"description": "existing channel to send the tokens over",
"type": "string"
},
"payloads": {
"type": "array",
"items": {
"$ref": "#/definitions/EurekaPayload"
}
},
"timeout": {
"$ref": "#/definitions/Timestamp"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
]
},
"EurekaPayload": {
"description": "Payload value should be encoded in a format defined by the channel version, and the module on the other side should know how to parse this.",
"type": "object",
"required": [
"destination_port",
"encoding",
"value",
"version"
],
"properties": {
"destination_port": {
"description": "The port id on the chain where the packet is sent to (external chain).",
"type": "string"
},
"encoding": {
"description": "Encoding used to serialize the [EurekaPayload::value].",
"type": "string"
},
"value": {
"description": "Encoded payload data.",
"allOf": [
{
"$ref": "#/definitions/Binary"
}
]
},
"version": {
"description": "Version of the receiving contract.",
"type": "string"
}
},
"additionalProperties": false
},
"GovMsg": {
"description": "This message type allows the contract interact with the [x/gov] module in order to cast votes.\n\n[x/gov]: https://github.com/cosmos/cosmos-sdk/tree/v0.45.12/x/gov\n\n## Examples\n\nCast a simple vote:\n\n``` # use cosmwasm_std::{ # HexBinary, # Storage, Api, Querier, DepsMut, Deps, entry_point, Env, StdError, MessageInfo, # Response, QueryResponse, # }; # type ExecuteMsg = (); use cosmwasm_std::{GovMsg, VoteOption};\n\n#[entry_point] pub fn execute( deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg, ) -> Result<Response, StdError> { // ... Ok(Response::new().add_message(GovMsg::Vote { proposal_id: 4, option: VoteOption::Yes, })) } ```\n\nCast a weighted vote:\n\n``` # 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};\n\n# #[cfg(feature = \"cosmwasm_1_2\")] #[entry_point] pub fn execute( deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg, ) -> Result<Response, StdError> { // ... 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), }, ], })) } ```",
"oneOf": [
Expand Down
84 changes: 84 additions & 0 deletions contracts/ibc-reflect-send/schema/raw/execute.json
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,18 @@
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"eureka"
],
"properties": {
"eureka": {
"$ref": "#/definitions/EurekaMsg"
}
},
"additionalProperties": false
}
]
},
Expand Down Expand Up @@ -353,6 +365,78 @@
"type": "object",
"additionalProperties": false
},
"EurekaMsg": {
"description": "These are messages in the IBC lifecycle using the new Eureka approach. Only usable by IBC-enabled contracts",
"oneOf": [
{
"description": "Sends an IBC packet with given payloads over the existing channel.",
"type": "object",
"required": [
"send_packet"
],
"properties": {
"send_packet": {
"type": "object",
"required": [
"channel_id",
"payloads",
"timeout"
],
"properties": {
"channel_id": {
"description": "existing channel to send the tokens over",
"type": "string"
},
"payloads": {
"type": "array",
"items": {
"$ref": "#/definitions/EurekaPayload"
}
},
"timeout": {
"$ref": "#/definitions/Timestamp"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
]
},
"EurekaPayload": {
"description": "Payload value should be encoded in a format defined by the channel version, and the module on the other side should know how to parse this.",
"type": "object",
"required": [
"destination_port",
"encoding",
"value",
"version"
],
"properties": {
"destination_port": {
"description": "The port id on the chain where the packet is sent to (external chain).",
"type": "string"
},
"encoding": {
"description": "Encoding used to serialize the [EurekaPayload::value].",
"type": "string"
},
"value": {
"description": "Encoded payload data.",
"allOf": [
{
"$ref": "#/definitions/Binary"
}
]
},
"version": {
"description": "Version of the receiving contract.",
"type": "string"
}
},
"additionalProperties": false
},
"GovMsg": {
"description": "This message type allows the contract interact with the [x/gov] module in order to cast votes.\n\n[x/gov]: https://github.com/cosmos/cosmos-sdk/tree/v0.45.12/x/gov\n\n## Examples\n\nCast a simple vote:\n\n``` # use cosmwasm_std::{ # HexBinary, # Storage, Api, Querier, DepsMut, Deps, entry_point, Env, StdError, MessageInfo, # Response, QueryResponse, # }; # type ExecuteMsg = (); use cosmwasm_std::{GovMsg, VoteOption};\n\n#[entry_point] pub fn execute( deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg, ) -> Result<Response, StdError> { // ... Ok(Response::new().add_message(GovMsg::Vote { proposal_id: 4, option: VoteOption::Yes, })) } ```\n\nCast a weighted vote:\n\n``` # 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};\n\n# #[cfg(feature = \"cosmwasm_1_2\")] #[entry_point] pub fn execute( deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg, ) -> Result<Response, StdError> { // ... 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), }, ], })) } ```",
"oneOf": [
Expand Down
Loading
Loading