pub fn authorize_claim(
    deps: DepsMut,
    info: MessageInfo,
    env: Env,
    authorized_addr: String,
) -> Result<Response, ContractError> {
    let config: Config = CONFIG.load(deps.storage)?;
    let sender_raw: CanonicalAddr = deps.api.addr_canonicalize(info.sender.as_str())?;

    if sender_raw != config.owner {
        return Err(ContractError::Unauthorized {});
    }

    // validate and convert authorized address
    deps.api.addr_validate(authorized_addr.as_str())?;
    let authorized_addr_raw: CanonicalAddr =
        deps.api.addr_canonicalize(authorized_addr.as_str())?;

    let claim_start = env.block.time.seconds();
    let claim_end = claim_start + config.admin_claim_period;
    create_auth_record(deps.storage, authorized_addr_raw, claim_start, claim_end)?;

    Ok(Response::new().add_attributes(vec![
        attr("action", "authorize_claim"),
        attr("claim_start", claim_start.to_string()),
        attr("claim_end", claim_end.to_string()),
    ]))
}
/// Owner can authorize an `authorized_address` to execute `claim_admin` for a limited time period
Owner can authorize an `authorized_address` to execute `claim_admin` for a limited time period
Owner can authorize an ` authorized_address ` to execute ` claim_admin ` for a limited time period
pub fn authorize_claim(
    deps: DepsMut,
    info: MessageInfo,
    env: Env,
    authorized_addr: String,
) -> Result<Response, ContractError> {
    let config: Config = CONFIG.load(deps.storage)?;
    let sender_raw: CanonicalAddr = deps.api.addr_canonicalize(info.sender.as_str())?;
    if sender_raw != config.owner {
        return Err(ContractError::Unauthorized {});
    }
    // validate and convert authorized address
    deps.api.addr_validate(authorized_addr.as_str())?;
    let authorized_addr_raw: CanonicalAddr =
        deps.api.addr_canonicalize(authorized_addr.as_str())?;
    let claim_start = env.block.time.seconds();
    let claim_end = claim_start + config.admin_claim_period;
    create_auth_record(deps.storage, authorized_addr_raw, claim_start, claim_end)?;
    Ok(Response::new().add_attributes(vec![
        attr("action", "authorize_claim"),
        attr("claim_start", claim_start.to_string()),
        attr("claim_end", claim_end.to_string()),
    ]))
}
pub fn authorize_claim ( deps : DepsMut , info : MessageInfo , env : Env , authorized_addr : String , ) -> Result < Response , ContractError > { let config : Config = CONFIG . load ( deps . storage ) ? ; let sender_raw : CanonicalAddr = deps . api . addr_canonicalize ( info . sender . as_str ( ) ) ? ; if sender_raw != config . owner { return Err ( ContractError :: Unauthorized { } ) ; } // validate and convert authorized address deps . api . addr_validate ( authorized_addr . as_str ( ) ) ? ; let authorized_addr_raw : CanonicalAddr = deps . api . addr_canonicalize ( authorized_addr . as_str ( ) ) ? ; let claim_start = env . block . time . seconds ( ) ; let claim_end = claim_start + config . admin_claim_period ; create_auth_record ( deps . storage , authorized_addr_raw , claim_start , claim_end ) ? ; Ok ( Response :: new ( ) . add_attributes ( vec ! [ attr ( " " " " ) attr ( " " claim_start to_string ( ) ) attr ( " " claim_end to_string ( ) ) ] ) ) }
Owner can authorize an `authorized_address` to execute `claim_admin` for a limited time period
Owner can authorize an ` authorized_address ` to execute ` claim_admin ` for a limited time period
deps
DepsMut
info
MessageInfo
env
Env
authorized_addr
String
deps
DepsMut
info
MessageInfo
env
Env
authorized_addr
String