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

Add Update and Clear admin to WasmMsg #900

Merged
merged 5 commits into from
Apr 26, 2021
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ and this project adheres to
lexicographical ordering as implemented by `Vec<u8>`.
- cosmwasm-std: Implement `PartialOrd` and `Ord` for `Addr` using the same
lexicographical ordering as implemented by `String`.
- cosmwasm-std: Added new `WasmMsg::UpdateAdmin` variant that allows an admin
contract (eg. multisig) to set another admin ([#900])
- cosmwasm-std: Added new `WasmMsg::ClearAdmin` variant that allows an admin
contract (eg. multisig) to clear the admin, to prevent future migrations
([#900])

[#692]: https://github.com/CosmWasm/cosmwasm/issues/692
[#706]: https://github.com/CosmWasm/cosmwasm/pull/706
Expand All @@ -80,6 +85,7 @@ and this project adheres to
[#796]: https://github.com/CosmWasm/cosmwasm/pull/796
[#802]: https://github.com/CosmWasm/cosmwasm/pull/802
[#860]: https://github.com/CosmWasm/cosmwasm/pull/860
[#900]: https://github.com/CosmWasm/cosmwasm/pull/900

### Changed

Expand Down
46 changes: 46 additions & 0 deletions contracts/ibc-reflect-send/schema/execute_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,52 @@
}
},
"additionalProperties": false
},
{
"description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.",
"type": "object",
"required": [
"update_admin"
],
"properties": {
"update_admin": {
"type": "object",
"required": [
"admin",
"contract_addr"
],
"properties": {
"admin": {
"type": "string"
},
"contract_addr": {
"type": "string"
}
}
}
},
"additionalProperties": false
},
{
"description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.",
"type": "object",
"required": [
"clear_admin"
],
"properties": {
"clear_admin": {
"type": "object",
"required": [
"contract_addr"
],
"properties": {
"contract_addr": {
"type": "string"
}
}
}
},
"additionalProperties": false
}
]
}
Expand Down
46 changes: 46 additions & 0 deletions contracts/ibc-reflect-send/schema/packet_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,52 @@
}
},
"additionalProperties": false
},
{
"description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.",
"type": "object",
"required": [
"update_admin"
],
"properties": {
"update_admin": {
"type": "object",
"required": [
"admin",
"contract_addr"
],
"properties": {
"admin": {
"type": "string"
},
"contract_addr": {
"type": "string"
}
}
}
},
"additionalProperties": false
},
{
"description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.",
"type": "object",
"required": [
"clear_admin"
],
"properties": {
"clear_admin": {
"type": "object",
"required": [
"contract_addr"
],
"properties": {
"contract_addr": {
"type": "string"
}
}
}
},
"additionalProperties": false
}
]
}
Expand Down
46 changes: 46 additions & 0 deletions contracts/ibc-reflect/schema/packet_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,52 @@
}
},
"additionalProperties": false
},
{
"description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.",
"type": "object",
"required": [
"update_admin"
],
"properties": {
"update_admin": {
"type": "object",
"required": [
"admin",
"contract_addr"
],
"properties": {
"admin": {
"type": "string"
},
"contract_addr": {
"type": "string"
}
}
}
},
"additionalProperties": false
},
{
"description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.",
"type": "object",
"required": [
"clear_admin"
],
"properties": {
"clear_admin": {
"type": "object",
"required": [
"contract_addr"
],
"properties": {
"contract_addr": {
"type": "string"
}
}
}
},
"additionalProperties": false
}
]
}
Expand Down
46 changes: 46 additions & 0 deletions contracts/reflect/schema/execute_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,52 @@
}
},
"additionalProperties": false
},
{
"description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.",
"type": "object",
"required": [
"update_admin"
],
"properties": {
"update_admin": {
"type": "object",
"required": [
"admin",
"contract_addr"
],
"properties": {
"admin": {
"type": "string"
},
"contract_addr": {
"type": "string"
}
}
}
},
"additionalProperties": false
},
{
"description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.",
"type": "object",
"required": [
"clear_admin"
],
"properties": {
"clear_admin": {
"type": "object",
"required": [
"contract_addr"
],
"properties": {
"contract_addr": {
"type": "string"
}
}
}
},
"additionalProperties": false
}
]
}
Expand Down
46 changes: 46 additions & 0 deletions contracts/reflect/schema/response_for__custom_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,52 @@
}
},
"additionalProperties": false
},
{
"description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.",
"type": "object",
"required": [
"update_admin"
],
"properties": {
"update_admin": {
"type": "object",
"required": [
"admin",
"contract_addr"
],
"properties": {
"admin": {
"type": "string"
},
"contract_addr": {
"type": "string"
}
}
}
},
"additionalProperties": false
},
{
"description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.",
"type": "object",
"required": [
"clear_admin"
],
"properties": {
"clear_admin": {
"type": "object",
"required": [
"contract_addr"
],
"properties": {
"contract_addr": {
"type": "string"
}
}
}
},
"additionalProperties": false
}
]
}
Expand Down
46 changes: 46 additions & 0 deletions packages/std/schema/cosmos_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,52 @@
}
},
"additionalProperties": false
},
{
"description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.",
"type": "object",
"required": [
"update_admin"
],
"properties": {
"update_admin": {
"type": "object",
"required": [
"admin",
"contract_addr"
],
"properties": {
"admin": {
"type": "string"
},
"contract_addr": {
"type": "string"
}
}
}
},
"additionalProperties": false
},
{
"description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.",
"type": "object",
"required": [
"clear_admin"
],
"properties": {
"clear_admin": {
"type": "object",
"required": [
"contract_addr"
],
"properties": {
"contract_addr": {
"type": "string"
}
}
}
},
"additionalProperties": false
}
]
}
Expand Down
9 changes: 9 additions & 0 deletions packages/std/src/results/cosmos_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@ pub enum WasmMsg {
/// msg is the json-encoded MigrateMsg struct that will be passed to the new code
msg: Binary,
},
/// Sets a new admin (for migrate) on the given contract.
/// Fails if this contract is not currently admin of the target contract.
UpdateAdmin {
contract_addr: String,
admin: String,
},
/// Clears the admin on the given contract, so no more migration possible.
/// Fails if this contract is not currently admin of the target contract.
ClearAdmin { contract_addr: String },
}

/// Shortcut helper as the construction of WasmMsg::Instantiate can be quite verbose in contract code.
Expand Down