Skip to content

Instantly share code, notes, and snippets.

@ethanfrey
Created October 27, 2021 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ethanfrey/0f454687009f90362f182c4f06c4cf25 to your computer and use it in GitHub Desktop.
Save ethanfrey/0f454687009f90362f182c4f06c4cf25 to your computer and use it in GitHub Desktop.
Query Trusted Circle Whitelist
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