Skip to main content

pryzm_auth/
execute.rs

1use crate::auth::assert_admin;
2use crate::error::AuthError;
3use crate::state::{ADMIN, PAUSED};
4use cosmwasm_std::{DepsMut, MessageInfo, Response};
5
6pub fn execute_update_admin(
7    deps: DepsMut,
8    info: &MessageInfo,
9    address: String,
10) -> Result<Response, AuthError> {
11    assert_admin(&deps.as_ref(), info)?;
12    let addr = deps.api.addr_validate(address.as_str())?;
13    ADMIN.save(deps.storage, &addr)?;
14    Ok(Response::new()
15        .add_attribute("method", "update_admin")
16        .add_attribute("new_admin", address))
17}
18
19pub fn execute_set_paused(
20    deps: DepsMut,
21    info: &MessageInfo,
22    paused: bool,
23) -> Result<Response, AuthError> {
24    assert_admin(&deps.as_ref(), info)?;
25    PAUSED.save(deps.storage, &paused)?;
26    Ok(Response::new()
27        .add_attribute("method", "set_paused")
28        .add_attribute("paused", paused.to_string()))
29}