From 0aee15eb64e3200027b252b9be12d92353e097fb Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Wed, 28 Jun 2023 10:21:42 +0300 Subject: [PATCH 1/2] Add WasmMsg::{Migrate,UpdateAdmin,ClearAdmin} --- packages/std/src/results/cosmos_msg.rs | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/std/src/results/cosmos_msg.rs b/packages/std/src/results/cosmos_msg.rs index 8d214a2615..fa5bf2a8d8 100644 --- a/packages/std/src/results/cosmos_msg.rs +++ b/packages/std/src/results/cosmos_msg.rs @@ -150,6 +150,33 @@ pub enum WasmMsg { /// A human-readbale label for the contract, must be unique across all contracts label: String, }, + /// Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to + /// customize behavior. + /// + /// Only the contract admin (as defined in wasmd), if any, is able to make this call. + /// + /// This is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). + /// `sender` is automatically filled with the current contract's address. + Migrate { + contract_addr: String, + /// new_code_hash is the hex encoded hash of the new code. This is used by Secret Network to harden against replaying the contract + /// It is used to bind the request to a destination contract in a stronger way than just the contract address which can be faked + new_code_hash: String, + /// the code_id of the new logic to place in the given contract + new_code_id: u64, + /// msg is the json-encoded MigrateMsg struct that will be passed to the new code + #[derivative(Debug(format_with = "binary_to_string"))] + 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 }, } #[cfg(feature = "stargate")] From c6c5ee775f7656d12196bd1acfb7cb9e26aa75d6 Mon Sep 17 00:00:00 2001 From: Assaf Morami Date: Wed, 5 Jul 2023 21:39:12 +0300 Subject: [PATCH 2/2] Update WasmMsg::Migrate to have more consistent field names --- packages/std/src/results/cosmos_msg.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/std/src/results/cosmos_msg.rs b/packages/std/src/results/cosmos_msg.rs index 9e65fb15fd..ee104fb2b9 100644 --- a/packages/std/src/results/cosmos_msg.rs +++ b/packages/std/src/results/cosmos_msg.rs @@ -177,11 +177,11 @@ pub enum WasmMsg { /// `sender` is automatically filled with the current contract's address. Migrate { contract_addr: String, - /// new_code_hash is the hex encoded hash of the new code. This is used by Secret Network to harden against replaying the contract + /// code_hash is the hex encoded hash of the **new** code. This is used by Secret Network to harden against replaying the contract /// It is used to bind the request to a destination contract in a stronger way than just the contract address which can be faked - new_code_hash: String, - /// the code_id of the new logic to place in the given contract - new_code_id: u64, + code_hash: String, + /// the code_id of the **new** logic to place in the given contract + code_id: u64, /// msg is the json-encoded MigrateMsg struct that will be passed to the new code #[derivative(Debug(format_with = "binary_to_string"))] msg: Binary,