Skip to content

Commit

Permalink
Merge pull request #764 from CosmWasm/document-migrate-change
Browse files Browse the repository at this point in the history
Add CHANGELOG and MIGRATING entry for changed migrate signature
  • Loading branch information
ethanfrey authored Feb 5, 2021
2 parents 8a60668 + fd87cc8 commit d65ccca
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ and this project adheres to
- all: Change the encoding of the key/value region of the `db_next` import to a
more generic encoding that supports an arbitrary number of sections. This
encoding can then be reused for other multi value regions.
- all: Remove the `info: MessageInfo` argument from the `migrate` entry point
([#690]).
- cosmwasm-std: Remove `from_address` from `BankMsg::Send`, as it always sends
from the contract address, and this is consistent with other `CosmosMsg`
variants.
Expand All @@ -65,6 +67,7 @@ and this project adheres to
[#696]: https://github.com/CosmWasm/cosmwasm/issues/696
[#697]: https://github.com/CosmWasm/cosmwasm/issues/697
[#736]: https://github.com/CosmWasm/cosmwasm/pull/736
[#690]: https://github.com/CosmWasm/cosmwasm/issues/690

## [0.13.2] - 2021-01-14

Expand Down
28 changes: 28 additions & 0 deletions MIGRATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,34 @@ major releases of `cosmwasm`. Note that you can also view the
}
```

- Remove the `info: MessageInfo` field from the `migrate` entry point:

```rust
// Before
pub fn migrate(
deps: DepsMut,
env: Env,
_info: MessageInfo,
msg: MigrateMsg,
) -> StdResult<MigrateResponse> {
// ...
}

// After
pub fn migrate(deps: DepsMut, env: Env, msg: MigrateMsg) -> StdResult<MigrateResponse> {
// ...
}
```

`MessageInfo::sent_funds` was always empty since [MsgMigrateContract] does not
have a funds field. `MessageInfo::sender` should not be needed for
authentication because the chain checks permissions before calling `migrate`.
If the sender's address is needed for anything else, this should be expressed
as part of the migrate message.

[msgmigratecontract]:
https://github.com/CosmWasm/wasmd/blob/v0.15.0/x/wasm/internal/types/tx.proto#L86-L96

## 0.12 -> 0.13

- The minimum Rust supported version for 0.13 is 1.47.0.
Expand Down
4 changes: 2 additions & 2 deletions packages/std/schema/message_info.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "MessageInfo",
"description": "MessageInfo is sent with `init`, `handle`, and `migrate` calls, but not with queries. It contains the essential info for authorization - identity of the call, and payment",
"description": "Additional information from [MsgInstantiateContract] and [MsgExecuteContract], which is passed along with the contract execution message into the `init` and `handle` entry points.\n\nIt contains the essential info for authorization - identity of the call, and payment.\n\n[MsgInstantiateContract]: https://github.com/CosmWasm/wasmd/blob/v0.15.0/x/wasm/internal/types/tx.proto#L47-L61 [MsgExecuteContract]: https://github.com/CosmWasm/wasmd/blob/v0.15.0/x/wasm/internal/types/tx.proto#L68-L78",
"type": "object",
"required": [
"sender",
"sent_funds"
],
"properties": {
"sender": {
"description": "The `sender` field from the `wasm/MsgStoreCode`, `wasm/MsgInstantiateContract`, `wasm/MsgMigrateContract` or `wasm/MsgExecuteContract` message. You can think of this as the address that initiated the action (i.e. the message). What that means exactly heavily depends on the application.\n\nThe x/wasm module ensures that the sender address signed the transaction. Additional signers of the transaction that are either needed for other messages or contain unnecessary signatures are not propagated into the contract.\n\nThere is a discussion to open up this field to multiple initiators, which you're welcome to join if you have a specific need for that feature: https://github.com/CosmWasm/cosmwasm/issues/293",
"description": "The `sender` field from `MsgInstantiateContract` and `MsgExecuteContract`. You can think of this as the address that initiated the action (i.e. the message). What that means exactly heavily depends on the application.\n\nThe x/wasm module ensures that the sender address signed the transaction or is otherwise authorized to send the message.\n\nAdditional signers of the transaction that are either needed for other messages or contain unnecessary signatures are not propagated into the contract.",
"allOf": [
{
"$ref": "#/definitions/HumanAddr"
Expand Down
19 changes: 11 additions & 8 deletions packages/std/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,24 @@ pub struct BlockInfo {
pub chain_id: String,
}

/// MessageInfo is sent with `init`, `handle`, and `migrate` calls, but not with queries.
/// It contains the essential info for authorization - identity of the call, and payment
/// Additional information from [MsgInstantiateContract] and [MsgExecuteContract], which is passed
/// along with the contract execution message into the `init` and `handle` entry points.
///
/// It contains the essential info for authorization - identity of the call, and payment.
///
/// [MsgInstantiateContract]: https://github.com/CosmWasm/wasmd/blob/v0.15.0/x/wasm/internal/types/tx.proto#L47-L61
/// [MsgExecuteContract]: https://github.com/CosmWasm/wasmd/blob/v0.15.0/x/wasm/internal/types/tx.proto#L68-L78
#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, JsonSchema)]
pub struct MessageInfo {
/// The `sender` field from the `wasm/MsgStoreCode`, `wasm/MsgInstantiateContract`, `wasm/MsgMigrateContract`
/// or `wasm/MsgExecuteContract` message.
/// The `sender` field from `MsgInstantiateContract` and `MsgExecuteContract`.
/// You can think of this as the address that initiated the action (i.e. the message). What that
/// means exactly heavily depends on the application.
///
/// The x/wasm module ensures that the sender address signed the transaction.
/// The x/wasm module ensures that the sender address signed the transaction or
/// is otherwise authorized to send the message.
///
/// Additional signers of the transaction that are either needed for other messages or contain unnecessary
/// signatures are not propagated into the contract.
///
/// There is a discussion to open up this field to multiple initiators, which you're welcome to join
/// if you have a specific need for that feature: https://github.com/CosmWasm/cosmwasm/issues/293
pub sender: HumanAddr,
pub sent_funds: Vec<Coin>,
}
Expand Down

0 comments on commit d65ccca

Please sign in to comment.