diff --git a/Cargo.lock b/Cargo.lock index b54699a..cd81dee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -567,7 +567,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "steak" -version = "2.0.0" +version = "2.0.1" dependencies = [ "cosmwasm-std", "cw20", @@ -577,7 +577,7 @@ dependencies = [ [[package]] name = "steak-hub" -version = "2.0.0" +version = "2.0.1" dependencies = [ "cosmwasm-std", "cw-storage-plus", diff --git a/contracts/hub/Cargo.toml b/contracts/hub/Cargo.toml index 84415c0..3c12810 100644 --- a/contracts/hub/Cargo.toml +++ b/contracts/hub/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "steak-hub" -version = "2.0.0" +version = "2.0.1" authors = ["larry ", "PFC "] edition = "2018" license = "GPL-3.0-or-later" diff --git a/contracts/hub/src/contract.rs b/contracts/hub/src/contract.rs index 99c0943..6865581 100644 --- a/contracts/hub/src/contract.rs +++ b/contracts/hub/src/contract.rs @@ -47,6 +47,9 @@ pub fn execute(deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg) -> S ExecuteMsg::RemoveValidator { validator, } => execute::remove_validator(deps, env, info.sender, validator), + ExecuteMsg::RemoveValidatorEx { + validator, + } => execute::remove_validator_ex(deps, env, info.sender, validator), ExecuteMsg::TransferOwnership { new_owner, } => execute::transfer_ownership(deps, info.sender, new_owner), diff --git a/contracts/hub/src/execute.rs b/contracts/hub/src/execute.rs index 482e7ac..a3e68e9 100644 --- a/contracts/hub/src/execute.rs +++ b/contracts/hub/src/execute.rs @@ -329,7 +329,7 @@ pub fn submit_batch(deps: DepsMut, env: Env) -> StdResult { let current_time = env.block.time.seconds(); if current_time < pending_batch.est_unbond_start_time { return Err(StdError::generic_err( - format!("batch can only be submitted for unbonding after {}", pending_batch.est_unbond_start_time), + format!("batch can only be submitted for unbonding after {}", pending_batch.est_unbond_start_time) )); } @@ -419,10 +419,7 @@ pub fn reconcile(deps: DepsMut, env: Env) -> StdResult { .filter(|b| current_time > b.est_unbond_end_time) .collect::>(); - let uluna_expected_received: Uint128 = batches - .iter() - .map(|b| b.uluna_unclaimed) - .sum(); + let uluna_expected_received: Uint128 = batches.iter().map(|b| b.uluna_unclaimed).sum(); let unlocked_coins = state.unlocked_coins.load(deps.storage)?; let uluna_expected_unlocked = Coins(unlocked_coins).find("uluna").amount; @@ -574,8 +571,7 @@ pub fn add_validator(deps: DepsMut, sender: Addr, validator: String) -> StdResul Ok(validators) })?; - let event = Event::new("steakhub/validator_added") - .add_attribute("validator", validator); + let event = Event::new("steakhub/validator_added").add_attribute("validator", validator); Ok(Response::new() .add_event(event) @@ -617,6 +613,31 @@ pub fn remove_validator( .add_event(event) .add_attribute("action", "steakhub/remove_validator")) } +pub fn remove_validator_ex( + deps: DepsMut, + _env: Env, + sender: Addr, + validator: String, +) -> StdResult { + let state = State::default(); + + state.assert_owner(deps.storage, &sender)?; + + state.validators.update(deps.storage, |mut validators| { + if !validators.contains(&validator) { + return Err(StdError::generic_err("validator is not already whitelisted")); + } + validators.retain(|v| *v != validator); + Ok(validators) + })?; + + let event = Event::new("steak/validator_removed_ex") + .add_attribute("validator", validator); + + Ok(Response::new() + .add_event(event) + .add_attribute("action", "steakhub/remove_validator_ex")) +} pub fn transfer_ownership(deps: DepsMut, sender: Addr, new_owner: String) -> StdResult { let state = State::default(); @@ -624,8 +645,7 @@ pub fn transfer_ownership(deps: DepsMut, sender: Addr, new_owner: String) -> Std state.assert_owner(deps.storage, &sender)?; state.new_owner.save(deps.storage, &deps.api.addr_validate(&new_owner)?)?; - Ok(Response::new() - .add_attribute("action", "steakhub/transfer_ownership")) + Ok(Response::new().add_attribute("action", "steakhub/transfer_ownership")) } pub fn accept_ownership(deps: DepsMut, sender: Addr) -> StdResult { @@ -635,7 +655,9 @@ pub fn accept_ownership(deps: DepsMut, sender: Addr) -> StdResult { let new_owner = state.new_owner.load(deps.storage)?; if sender != new_owner { - return Err(StdError::generic_err("unauthorized: sender is not new owner")); + return Err(StdError::generic_err( + "unauthorized: sender is not new owner", + )); } state.owner.save(deps.storage, &sender)?; diff --git a/packages/steak/Cargo.toml b/packages/steak/Cargo.toml index bbdd500..c79c579 100644 --- a/packages/steak/Cargo.toml +++ b/packages/steak/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "steak" -version = "2.0.0" +version = "2.0.1" authors = ["larry ", "PFC "] edition = "2018" description = "Liquid staking protocol for the cosmos" diff --git a/packages/steak/src/hub.rs b/packages/steak/src/hub.rs index b793be1..5893a72 100644 --- a/packages/steak/src/hub.rs +++ b/packages/steak/src/hub.rs @@ -29,25 +29,17 @@ pub enum ExecuteMsg { /// Implements the Cw20 receiver interface Receive(Cw20ReceiveMsg), /// Bond specified amount of Luna - Bond { - receiver: Option, - }, + Bond { receiver: Option }, /// Withdraw Luna that have finished unbonding in previous batches - WithdrawUnbonded { - receiver: Option, - }, + WithdrawUnbonded { receiver: Option }, /// Add a validator to the whitelist; callable by the owner - AddValidator { - validator: String, - }, + AddValidator { validator: String }, /// Remove a validator from the whitelist; callable by the owner - RemoveValidator { - validator: String, - }, + RemoveValidator { validator: String }, + /// Remove a validator from the whitelist; callable by the owner; does not undelegate; use with caution + RemoveValidatorEx { validator: String }, /// Transfer ownership to another account; will not take effect unless the new owner accepts - TransferOwnership { - new_owner: String, - }, + TransferOwnership { new_owner: String }, /// Accept an ownership transfer AcceptOwnership {}, /// Claim staking rewards, swap all for Luna, and restake @@ -67,9 +59,7 @@ pub enum ExecuteMsg { pub enum ReceiveMsg { /// Submit an unbonding request to the current unbonding queue; automatically invokes `unbond` /// if `epoch_time` has elapsed since when the last unbonding queue was executed. - QueueUnbond { - receiver: Option, - }, + QueueUnbond { receiver: Option }, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]