Skip to content

Commit

Permalink
Merge pull request #2340 from CosmWasm/add-eureka-send-packet
Browse files Browse the repository at this point in the history
feat: Add EurekaMsg
  • Loading branch information
jawoznia authored Jan 20, 2025
2 parents 9c7b750 + f4daded commit 4c4af13
Show file tree
Hide file tree
Showing 10 changed files with 570 additions and 0 deletions.
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])

[#2310]: https://github.com/CosmWasm/cosmwasm/pull/2310
[#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

0 comments on commit 4c4af13

Please sign in to comment.