Skip to content

Commit

Permalink
Add more docs to Cosmos message types
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Jan 12, 2021
1 parent 67c3e76 commit 4fd5c9e
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 21 deletions.
12 changes: 10 additions & 2 deletions contracts/reflect/schema/handle_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@
],
"definitions": {
"BankMsg": {
"description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto",
"anyOf": [
{
"description": "Sends native tokens from the contract to the given address.\n\nThis 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.",
"type": "object",
"required": [
"send"
Expand Down Expand Up @@ -173,8 +175,10 @@
"type": "string"
},
"StakingMsg": {
"description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto",
"anyOf": [
{
"description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.",
"type": "object",
"required": [
"delegate"
Expand All @@ -198,6 +202,7 @@
}
},
{
"description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.",
"type": "object",
"required": [
"undelegate"
Expand All @@ -221,6 +226,7 @@
}
},
{
"description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37) followed by a [MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.",
"type": "object",
"required": [
"withdraw"
Expand Down Expand Up @@ -251,6 +257,7 @@
}
},
{
"description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105). `delegator_address` is automatically filled with the current contract's address.",
"type": "object",
"required": [
"redelegate"
Expand Down Expand Up @@ -283,9 +290,10 @@
"type": "string"
},
"WasmMsg": {
"description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto",
"anyOf": [
{
"description": "this dispatches a call to another contract at a known address (with known ABI)",
"description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis 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.",
"type": "object",
"required": [
"execute"
Expand Down Expand Up @@ -321,7 +329,7 @@
}
},
{
"description": "this instantiates a new contracts from previously uploaded wasm code",
"description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.",
"type": "object",
"required": [
"instantiate"
Expand Down
12 changes: 10 additions & 2 deletions contracts/reflect/schema/handle_response_for__custom_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@
}
},
"BankMsg": {
"description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto",
"anyOf": [
{
"description": "Sends native tokens from the contract to the given address.\n\nThis 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.",
"type": "object",
"required": [
"send"
Expand Down Expand Up @@ -176,8 +178,10 @@
"type": "string"
},
"StakingMsg": {
"description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto",
"anyOf": [
{
"description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.",
"type": "object",
"required": [
"delegate"
Expand All @@ -201,6 +205,7 @@
}
},
{
"description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.",
"type": "object",
"required": [
"undelegate"
Expand All @@ -224,6 +229,7 @@
}
},
{
"description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37) followed by a [MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.",
"type": "object",
"required": [
"withdraw"
Expand Down Expand Up @@ -254,6 +260,7 @@
}
},
{
"description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105). `delegator_address` is automatically filled with the current contract's address.",
"type": "object",
"required": [
"redelegate"
Expand Down Expand Up @@ -286,9 +293,10 @@
"type": "string"
},
"WasmMsg": {
"description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto",
"anyOf": [
{
"description": "this dispatches a call to another contract at a known address (with known ABI)",
"description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis 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.",
"type": "object",
"required": [
"execute"
Expand Down Expand Up @@ -324,7 +332,7 @@
}
},
{
"description": "this instantiates a new contracts from previously uploaded wasm code",
"description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.",
"type": "object",
"required": [
"instantiate"
Expand Down
12 changes: 10 additions & 2 deletions packages/std/schema/cosmos_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@
],
"definitions": {
"BankMsg": {
"description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto",
"anyOf": [
{
"description": "Sends native tokens from the contract to the given address.\n\nThis 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.",
"type": "object",
"required": [
"send"
Expand Down Expand Up @@ -105,8 +107,10 @@
"type": "string"
},
"StakingMsg": {
"description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto",
"anyOf": [
{
"description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.",
"type": "object",
"required": [
"delegate"
Expand All @@ -130,6 +134,7 @@
}
},
{
"description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.",
"type": "object",
"required": [
"undelegate"
Expand All @@ -153,6 +158,7 @@
}
},
{
"description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37) followed by a [MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.",
"type": "object",
"required": [
"withdraw"
Expand Down Expand Up @@ -183,6 +189,7 @@
}
},
{
"description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105). `delegator_address` is automatically filled with the current contract's address.",
"type": "object",
"required": [
"redelegate"
Expand Down Expand Up @@ -215,9 +222,10 @@
"type": "string"
},
"WasmMsg": {
"description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto",
"anyOf": [
{
"description": "this dispatches a call to another contract at a known address (with known ABI)",
"description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis 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.",
"type": "object",
"required": [
"execute"
Expand Down Expand Up @@ -253,7 +261,7 @@
}
},
{
"description": "this instantiates a new contracts from previously uploaded wasm code",
"description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.",
"type": "object",
"required": [
"instantiate"
Expand Down
47 changes: 32 additions & 15 deletions packages/std/src/results/cosmos_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,55 +22,72 @@ where
Wasm(WasmMsg),
}

/// The message types of the bank module.
///
/// See https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum BankMsg {
// sends tokens from the contract in the underlying sdk
/// 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 {
to_address: HumanAddr,
amount: Vec<Coin>,
},
}

/// The message types of the staking module.
///
/// See https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum StakingMsg {
Delegate {
// delegator is automatically set to address of the calling contract
validator: HumanAddr,
amount: Coin,
},
Undelegate {
// delegator is automatically set to address of the calling contract
validator: HumanAddr,
amount: Coin,
},
/// This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90).
/// `delegator_address` is automatically filled with the current contract's address.
Delegate { validator: HumanAddr, amount: Coin },
/// This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121).
/// `delegator_address` is automatically filled with the current contract's address.
Undelegate { validator: HumanAddr, amount: Coin },
/// This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37)
/// followed by a [MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50).
/// `delegator_address` is automatically filled with the current contract's address.
Withdraw {
// delegator is automatically set to address of the calling contract
validator: HumanAddr,
/// this is the "withdraw address", the one that should receive the rewards
/// if None, then use delegator address
recipient: Option<HumanAddr>,
},
/// This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105).
/// `delegator_address` is automatically filled with the current contract's address.
Redelegate {
// delegator is automatically set to address of the calling contract
src_validator: HumanAddr,
dst_validator: HumanAddr,
amount: Coin,
},
}

/// The message types of the wasm module.
///
/// See https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum WasmMsg {
/// this dispatches a call to another contract at a known address (with known ABI)
/// 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 {
contract_addr: HumanAddr,
/// msg is the json-encoded HandleMsg struct (as raw Binary)
msg: Binary,
send: Vec<Coin>,
},
/// this instantiates a new contracts from previously uploaded wasm code
/// Instantiates a new contracts from previously uploaded Wasm code.
///
/// This is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L47-L61).
/// `sender` is automatically filled with the current contract's address.
Instantiate {
code_id: u64,
/// msg is the json-encoded InitMsg struct (as raw Binary)
Expand Down

0 comments on commit 4fd5c9e

Please sign in to comment.