Compare commits

...

1 Commits

Author SHA1 Message Date
durch 6564be90f3 Check if staking address exists first 2023-01-05 17:40:29 +01:00
2 changed files with 7 additions and 0 deletions
+5
View File
@@ -313,6 +313,11 @@ fn try_update_staking_address(
info: MessageInfo,
deps: DepsMut<'_>,
) -> Result<Response, ContractError> {
if let Some(ref to_address) = to_address {
if let Ok(_account) = account_from_address(&to_address, deps.storage, deps.api) {
return Err(ContractError::StakingAccountExists(to_address.to_string()));
}
}
let address = info.sender.clone();
let to_address = to_address.and_then(|x| deps.api.addr_validate(&x).ok());
let mut account = account_from_address(info.sender.as_str(), deps.storage, deps.api)?;
+2
View File
@@ -52,4 +52,6 @@ pub enum ContractError {
LockedPledgeCapReached { current: Uint128, cap: Uint128 },
#[error("VESTING: ({}: Account owned by {owner} has unpopulated vesting periods!", line!())]
UnpopulatedVestingPeriods { owner: Addr },
#[error("VESTING: Vesting account associated with {0} already exists, only addresses with not existing vesting accounts can be added as staking addresses")]
StakingAccountExists(String),
}