Skip to content

Commit

Permalink
Merge pull request #354 from CosmWasm/subkeys-permission-bug-fixes
Browse files Browse the repository at this point in the history
Permission bugs corrected in cw1-subkeys
  • Loading branch information
ethanfrey authored Jul 26, 2021
2 parents 86a24d7 + 1ff5056 commit 7a6d61b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 11 additions & 2 deletions contracts/cw1-subkeys/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub fn check_staking_permissions(
return Err(ContractError::ReDelegatePerm {});
}
}
s => panic!("Unsupported staking message: {:?}", s),
_ => return Err(ContractError::UnsupportedMessage {}),
}
Ok(true)
}
Expand All @@ -167,7 +167,7 @@ pub fn check_distribution_permissions(
return Err(ContractError::WithdrawPerm {});
}
}
s => panic!("Unsupported distribution message: {:?}", s),
_ => return Err(ContractError::UnsupportedMessage {}),
}
Ok(true)
}
Expand Down Expand Up @@ -362,6 +362,15 @@ fn can_execute(deps: Deps, sender: String, msg: CosmosMsg) -> StdResult<bool> {
None => Ok(false),
}
}
CosmosMsg::Distribution(distribution_msg) => {
let perm_opt = PERMISSIONS.may_load(deps.storage, &sender)?;
match perm_opt {
Some(permission) => {
Ok(check_distribution_permissions(&distribution_msg, permission).is_ok())
}
None => Ok(false),
}
}
_ => Ok(false),
}
}
Expand Down
3 changes: 3 additions & 0 deletions contracts/cw1-subkeys/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ pub enum ContractError {

#[error("Set withdraw address is not allowed")]
WithdrawAddrPerm {},

#[error("Unsupported message")]
UnsupportedMessage {},
}

impl From<cw1_whitelist::ContractError> for ContractError {
Expand Down

0 comments on commit 7a6d61b

Please sign in to comment.