Created
October 27, 2021 17:04
-
-
Save ethanfrey/0f454687009f90362f182c4f06c4cf25 to your computer and use it in GitHub Desktop.
Query Trusted Circle Whitelist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use cosmwasm_std::{Addr, QuerierWrapper}; | |
use cw4::Cw4Contract; | |
fn assert_membership(querier: &QuerierWrapper, contract: &Addr, account: &Addr) -> StdResult<()> { | |
let contract = Cw4Contract(addr.clone()); | |
if whitelist.is_member(&deps.querier, sender)?.is_none() { | |
return Err(StdError::generic("unauthorized")); | |
} | |
Ok(()) | |
} | |
pub fn execute( | |
deps: DepsMut, | |
_env: Env, | |
info: MessageInfo, | |
msg: ExecuteMsg, | |
) -> Result<Response, ContractError> { | |
let whitelist: Addr = WHITELIST.load(deps.storage)?; | |
assert_membership(deps.querier, &whitelist, &info.sender)?; | |
// process message... | |
Ok(Response::default()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment