From 8a6bd4dad28e56b572fadc0ae4189736e536ffce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kuras?= Date: Tue, 26 Oct 2021 15:01:23 +0200 Subject: [PATCH 1/3] tg-valset: Returning created rewards contract address in instantiate response --- contracts/tgrade-valset/src/contract.rs | 8 ++++---- contracts/tgrade-valset/src/msg.rs | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/contracts/tgrade-valset/src/contract.rs b/contracts/tgrade-valset/src/contract.rs index 53332266..e1acacfc 100644 --- a/contracts/tgrade-valset/src/contract.rs +++ b/contracts/tgrade-valset/src/contract.rs @@ -21,7 +21,7 @@ use tg_utils::Duration; use crate::error::ContractError; use crate::msg::{ - ConfigResponse, EpochResponse, ExecuteMsg, InstantiateMsg, JailingPeriod, + ConfigResponse, EpochResponse, ExecuteMsg, InstantiateMsg, InstantiateResponse, JailingPeriod, ListActiveValidatorsResponse, ListValidatorResponse, OperatorResponse, QueryMsg, RewardsDistribution, RewardsInstantiateMsg, ValidatorMetadata, ValidatorResponse, }; @@ -634,9 +634,9 @@ pub fn rewards_instantiate_reply(deps: DepsMut, msg: Reply) -> Result Date: Tue, 26 Oct 2021 16:41:01 +0200 Subject: [PATCH 2/3] tg-valset: Corrected response type --- contracts/tgrade-valset/src/contract.rs | 6 +++--- contracts/tgrade-valset/src/msg.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/contracts/tgrade-valset/src/contract.rs b/contracts/tgrade-valset/src/contract.rs index e1acacfc..227cd414 100644 --- a/contracts/tgrade-valset/src/contract.rs +++ b/contracts/tgrade-valset/src/contract.rs @@ -634,9 +634,9 @@ pub fn rewards_instantiate_reply(deps: DepsMut, msg: Reply) -> Result Date: Wed, 27 Oct 2021 10:20:35 +0200 Subject: [PATCH 3/3] tg-valset: Returning proper instantiate response --- contracts/tgrade-valset/Cargo.toml | 3 ++- contracts/tgrade-valset/src/contract.rs | 23 ++++++++++++++++++----- contracts/tgrade-valset/src/error.rs | 3 +++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/contracts/tgrade-valset/Cargo.toml b/contracts/tgrade-valset/Cargo.toml index 917e798b..e2215022 100644 --- a/contracts/tgrade-valset/Cargo.toml +++ b/contracts/tgrade-valset/Cargo.toml @@ -42,7 +42,7 @@ protobuf = { version = "2", features = ["with-bytes"] } [dev-dependencies] cosmwasm-schema = { version = "1.0.0-beta" } -cw-multi-test = { version = "0.10.0" } +cw-multi-test = "0.10.0" tg4-engagement = { path = "../tg4-engagement", version = "0.5.0-alpha" } tg4-stake = { path = "../tg4-stake", version = "0.5.0-alpha" } # we enable multitest feature only for tests @@ -50,3 +50,4 @@ tg-bindings-test = { path = "../../packages/bindings-test", version = "0.5.0-alp derivative = "2" anyhow = "1" assert_matches = "1.5" + diff --git a/contracts/tgrade-valset/src/contract.rs b/contracts/tgrade-valset/src/contract.rs index 227cd414..492eec4e 100644 --- a/contracts/tgrade-valset/src/contract.rs +++ b/contracts/tgrade-valset/src/contract.rs @@ -603,14 +603,18 @@ fn calculate_diff( } #[cfg_attr(not(feature = "library"), entry_point)] -pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result { +pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> Result { match msg.id { - REWARDS_INIT_REPLY_ID => rewards_instantiate_reply(deps, msg), + REWARDS_INIT_REPLY_ID => rewards_instantiate_reply(deps, env, msg), _ => Err(ContractError::UnrecognisedReply(msg.id)), } } -pub fn rewards_instantiate_reply(deps: DepsMut, msg: Reply) -> Result { +pub fn rewards_instantiate_reply( + deps: DepsMut, + env: Env, + msg: Reply, +) -> Result { let id = msg.id; let res: MsgInstantiateContractResponse = Message::parse_from_bytes( msg.result @@ -634,9 +638,18 @@ pub fn rewards_instantiate_reply(deps: DepsMut, msg: Reply) -> Result