File tree Expand file tree Collapse file tree 1 file changed +30
-2
lines changed Expand file tree Collapse file tree 1 file changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -16,8 +16,36 @@ use crate::{to_json_binary, Binary};
16
16
17
17
use super :: Empty ;
18
18
19
- /// Like CustomQuery for better type clarity.
20
- /// Also makes it shorter to use as a trait bound.
19
+ /// A trait for custom message types which are embedded in `CosmosMsg::Custom(..)`.
20
+ /// Those are messages that the contract and the chain need
21
+ /// to agree on in advance as the chain must be able to deserialize and execute them.
22
+ ///
23
+ /// Custom messages are always JSON-encoded when sent from the contract to the environment.
24
+ ///
25
+ /// This trait is similar to [`CustomQuery`](crate::CustomQuery) for better type clarity and
26
+ /// makes it shorter to use as a trait bound. It does not require fields or functions to be implemented.
27
+ ///
28
+ /// An alternative approach is using [`CosmosMsg::Any`][crate::CosmosMsg#variant.Any]
29
+ /// which provides more flexibility but offers less type-safety.
30
+ ///
31
+ /// ## Examples
32
+ ///
33
+ /// Some real-world examples of such custom message types are
34
+ /// [TgradeMsg](https://github.com/confio/poe-contracts/blob/v0.17.1/packages/bindings/src/msg.rs#L13),
35
+ /// [ArchwayMsg](https://github.com/archway-network/arch3.rs/blob/bindings/v0.2.1/packages/bindings/src/msg.rs#L22) or
36
+ /// [NeutronMsg](https://github.com/neutron-org/neutron-sdk/blob/v0.11.0/packages/neutron-sdk/src/bindings/msg.rs#L33).
37
+ ///
38
+ /// ```
39
+ /// use cosmwasm_schema::cw_serde;
40
+ /// use cosmwasm_std::CustomQuery;
41
+ ///
42
+ /// #[cw_serde]
43
+ /// pub enum MyMsg {
44
+ /// // ...
45
+ /// }
46
+ ///
47
+ /// impl CustomQuery for MyMsg {}
48
+ /// ```
21
49
pub trait CustomMsg : Serialize + Clone + fmt:: Debug + PartialEq + JsonSchema { }
22
50
23
51
impl CustomMsg for Empty { }
You can’t perform that action at this time.
0 commit comments