From 1e3f06718b1c9ee508212c4a716082e646ec393c Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 26 Apr 2021 15:35:13 +0200 Subject: [PATCH 1/5] Add WasmMsg::UpdateAdmin,ClearAdmin --- packages/std/schema/cosmos_msg.json | 48 ++++++++++++++++++++++++++ packages/std/src/results/cosmos_msg.rs | 9 +++++ 2 files changed, 57 insertions(+) diff --git a/packages/std/schema/cosmos_msg.json b/packages/std/schema/cosmos_msg.json index 6ed6e2019c..e63f877477 100644 --- a/packages/std/schema/cosmos_msg.json +++ b/packages/std/schema/cosmos_msg.json @@ -249,6 +249,54 @@ } }, "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": [ + "contract_addr" + ], + "properties": { + "admin": { + "type": [ + "string", + "null" + ] + }, + "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 } ] } diff --git a/packages/std/src/results/cosmos_msg.rs b/packages/std/src/results/cosmos_msg.rs index bc57687092..cae0962255 100644 --- a/packages/std/src/results/cosmos_msg.rs +++ b/packages/std/src/results/cosmos_msg.rs @@ -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: Option, + }, + /// 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. From 94f050e0c81c82c0d62fc52ae1f838d0e1ca738c Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 26 Apr 2021 15:40:04 +0200 Subject: [PATCH 2/5] Update schemas --- .../ibc-reflect-send/schema/execute_msg.json | 48 +++++++++++++++++++ .../ibc-reflect-send/schema/packet_msg.json | 48 +++++++++++++++++++ contracts/ibc-reflect/schema/packet_msg.json | 48 +++++++++++++++++++ contracts/reflect/schema/execute_msg.json | 48 +++++++++++++++++++ .../schema/response_for__custom_msg.json | 48 +++++++++++++++++++ 5 files changed, 240 insertions(+) diff --git a/contracts/ibc-reflect-send/schema/execute_msg.json b/contracts/ibc-reflect-send/schema/execute_msg.json index 656c70add2..0e664a8c64 100644 --- a/contracts/ibc-reflect-send/schema/execute_msg.json +++ b/contracts/ibc-reflect-send/schema/execute_msg.json @@ -727,6 +727,54 @@ } }, "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": [ + "contract_addr" + ], + "properties": { + "admin": { + "type": [ + "string", + "null" + ] + }, + "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 } ] } diff --git a/contracts/ibc-reflect-send/schema/packet_msg.json b/contracts/ibc-reflect-send/schema/packet_msg.json index 06c155270c..1131b214c2 100644 --- a/contracts/ibc-reflect-send/schema/packet_msg.json +++ b/contracts/ibc-reflect-send/schema/packet_msg.json @@ -680,6 +680,54 @@ } }, "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": [ + "contract_addr" + ], + "properties": { + "admin": { + "type": [ + "string", + "null" + ] + }, + "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 } ] } diff --git a/contracts/ibc-reflect/schema/packet_msg.json b/contracts/ibc-reflect/schema/packet_msg.json index 46b6d6225a..2e04bb5480 100644 --- a/contracts/ibc-reflect/schema/packet_msg.json +++ b/contracts/ibc-reflect/schema/packet_msg.json @@ -679,6 +679,54 @@ } }, "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": [ + "contract_addr" + ], + "properties": { + "admin": { + "type": [ + "string", + "null" + ] + }, + "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 } ] } diff --git a/contracts/reflect/schema/execute_msg.json b/contracts/reflect/schema/execute_msg.json index bb8c6bf112..d9572014da 100644 --- a/contracts/reflect/schema/execute_msg.json +++ b/contracts/reflect/schema/execute_msg.json @@ -762,6 +762,54 @@ } }, "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": [ + "contract_addr" + ], + "properties": { + "admin": { + "type": [ + "string", + "null" + ] + }, + "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 } ] } diff --git a/contracts/reflect/schema/response_for__custom_msg.json b/contracts/reflect/schema/response_for__custom_msg.json index 0aac6c05a8..0875649176 100644 --- a/contracts/reflect/schema/response_for__custom_msg.json +++ b/contracts/reflect/schema/response_for__custom_msg.json @@ -750,6 +750,54 @@ } }, "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": [ + "contract_addr" + ], + "properties": { + "admin": { + "type": [ + "string", + "null" + ] + }, + "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 } ] } From 1b2b6f4016ca204c8c0f974541fe48e091034990 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 26 Apr 2021 15:43:33 +0200 Subject: [PATCH 3/5] [skip ci] Add CHANGELOG entry --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b73ec0e560..1f2dfc465a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,12 @@ and this project adheres to lexicographical ordering as implemented by `Vec`. - 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::UpdateAdmin` variant that allows an admin + contract (eg. multisig) to set another admin ([#900]) +- cosmwasm-std: Add optional `admin` field to `WasmMsg::Instantiate` to allow a + contract to be full admin (able to migrate) a contract it created [#692]: https://github.com/CosmWasm/cosmwasm/issues/692 [#706]: https://github.com/CosmWasm/cosmwasm/pull/706 @@ -80,6 +86,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 From 10bee3fc46e8c8293cfa925c731176eadb6356d5 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 26 Apr 2021 16:32:05 +0200 Subject: [PATCH 4/5] Fixes from PR comments --- CHANGELOG.md | 2 -- contracts/ibc-reflect-send/schema/execute_msg.json | 6 ++---- contracts/ibc-reflect-send/schema/packet_msg.json | 6 ++---- contracts/ibc-reflect/schema/packet_msg.json | 6 ++---- contracts/reflect/schema/execute_msg.json | 6 ++---- contracts/reflect/schema/response_for__custom_msg.json | 6 ++---- packages/std/schema/cosmos_msg.json | 6 ++---- packages/std/src/results/cosmos_msg.rs | 2 +- 8 files changed, 13 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f2dfc465a..4d5d9ac662 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,8 +71,6 @@ and this project adheres to contract (eg. multisig) to set another admin ([#900]) - cosmwasm-std: Added new `WasmMsg::UpdateAdmin` variant that allows an admin contract (eg. multisig) to set another admin ([#900]) -- cosmwasm-std: Add optional `admin` field to `WasmMsg::Instantiate` to allow a - contract to be full admin (able to migrate) a contract it created [#692]: https://github.com/CosmWasm/cosmwasm/issues/692 [#706]: https://github.com/CosmWasm/cosmwasm/pull/706 diff --git a/contracts/ibc-reflect-send/schema/execute_msg.json b/contracts/ibc-reflect-send/schema/execute_msg.json index 0e664a8c64..3d50e283dd 100644 --- a/contracts/ibc-reflect-send/schema/execute_msg.json +++ b/contracts/ibc-reflect-send/schema/execute_msg.json @@ -738,14 +738,12 @@ "update_admin": { "type": "object", "required": [ + "admin", "contract_addr" ], "properties": { "admin": { - "type": [ - "string", - "null" - ] + "type": "string" }, "contract_addr": { "type": "string" diff --git a/contracts/ibc-reflect-send/schema/packet_msg.json b/contracts/ibc-reflect-send/schema/packet_msg.json index 1131b214c2..89930b04bc 100644 --- a/contracts/ibc-reflect-send/schema/packet_msg.json +++ b/contracts/ibc-reflect-send/schema/packet_msg.json @@ -691,14 +691,12 @@ "update_admin": { "type": "object", "required": [ + "admin", "contract_addr" ], "properties": { "admin": { - "type": [ - "string", - "null" - ] + "type": "string" }, "contract_addr": { "type": "string" diff --git a/contracts/ibc-reflect/schema/packet_msg.json b/contracts/ibc-reflect/schema/packet_msg.json index 2e04bb5480..5817c3960d 100644 --- a/contracts/ibc-reflect/schema/packet_msg.json +++ b/contracts/ibc-reflect/schema/packet_msg.json @@ -690,14 +690,12 @@ "update_admin": { "type": "object", "required": [ + "admin", "contract_addr" ], "properties": { "admin": { - "type": [ - "string", - "null" - ] + "type": "string" }, "contract_addr": { "type": "string" diff --git a/contracts/reflect/schema/execute_msg.json b/contracts/reflect/schema/execute_msg.json index d9572014da..7853824fd7 100644 --- a/contracts/reflect/schema/execute_msg.json +++ b/contracts/reflect/schema/execute_msg.json @@ -773,14 +773,12 @@ "update_admin": { "type": "object", "required": [ + "admin", "contract_addr" ], "properties": { "admin": { - "type": [ - "string", - "null" - ] + "type": "string" }, "contract_addr": { "type": "string" diff --git a/contracts/reflect/schema/response_for__custom_msg.json b/contracts/reflect/schema/response_for__custom_msg.json index 0875649176..35cb5dcd77 100644 --- a/contracts/reflect/schema/response_for__custom_msg.json +++ b/contracts/reflect/schema/response_for__custom_msg.json @@ -761,14 +761,12 @@ "update_admin": { "type": "object", "required": [ + "admin", "contract_addr" ], "properties": { "admin": { - "type": [ - "string", - "null" - ] + "type": "string" }, "contract_addr": { "type": "string" diff --git a/packages/std/schema/cosmos_msg.json b/packages/std/schema/cosmos_msg.json index e63f877477..7f171da69b 100644 --- a/packages/std/schema/cosmos_msg.json +++ b/packages/std/schema/cosmos_msg.json @@ -260,14 +260,12 @@ "update_admin": { "type": "object", "required": [ + "admin", "contract_addr" ], "properties": { "admin": { - "type": [ - "string", - "null" - ] + "type": "string" }, "contract_addr": { "type": "string" diff --git a/packages/std/src/results/cosmos_msg.rs b/packages/std/src/results/cosmos_msg.rs index cae0962255..546b510dc6 100644 --- a/packages/std/src/results/cosmos_msg.rs +++ b/packages/std/src/results/cosmos_msg.rs @@ -153,7 +153,7 @@ pub enum WasmMsg { /// Fails if this contract is not currently admin of the target contract. UpdateAdmin { contract_addr: String, - admin: Option, + 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. From 55dc6f1edb2d730ba3460daa900fd30345183f80 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 26 Apr 2021 16:41:31 +0200 Subject: [PATCH 5/5] Fix changelog --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d5d9ac662..6f302b561e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,8 +69,9 @@ and this project adheres to 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::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