Crates.io | cw-simple-auth |
lib.rs | cw-simple-auth |
version | 1.0.1 |
source | src |
created_at | 2025-04-13 17:15:32.859493+00 |
updated_at | 2025-04-13 18:06:45.692588+00 |
description | Helpers to work with sender assertions and updating config admin in CosmWasm contracts |
homepage | |
repository | https://github.com/M-Daeva/cw-simple-auth |
max_upload_size | |
id | 1632004 |
size | 29,012 |
Helpers to work with sender assertions and updating config admin in CosmWasm contracts
use cosmwasm_std::{DepsMut, Env, MessageInfo, Response, StdResult};
use cw_simple_auth::{Auth, TransferAdminState};
pub fn try_update_admin(
deps: DepsMut,
env: Env,
info: MessageInfo,
admin: String,
) -> Result<Response, ContractError> {
let config = CONFIG.load(deps.storage)?;
Auth::simple(&config.admin).assert(&info.sender)?;
TransferAdminState::update_admin(
deps,
&env,
&info.sender,
&config.admin,
&admin,
TRANSFER_ADMIN_TIMEOUT,
)?;
// ...
}
pub fn try_accept_admin(
deps: DepsMut,
env: Env,
info: MessageInfo,
) -> Result<Response, ContractError> {
let admin = TransferAdminState::accept_admin(deps, &env, &info.sender)?;
CONFIG.update(deps.storage, |mut x| -> StdResult<_> {
x.admin = admin;
Ok(x)
})?;
// ...
}
This repo is licensed under Apache 2.0.