pub fn update_owner(
    deps: DepsMut,
    info: MessageInfo,
    owner: String,
) -> Result<Response, ContractError> {
    let mut 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 to raw
    deps.api.addr_validate(owner.as_str())?;
    let new_owner_raw: CanonicalAddr = deps.api.addr_canonicalize(owner.as_str())?;

    config.owner = new_owner_raw;
    CONFIG.save(deps.storage, &config)?;

    Ok(Response::new().add_attribute("action", "update_owner"))
}
/// Updates the owner of the contract
Updates the owner of the contract
Updates the owner of the contract
pub fn update_owner(
    deps: DepsMut,
    info: MessageInfo,
    owner: String,
) -> Result<Response, ContractError> {
    let mut 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 to raw
    deps.api.addr_validate(owner.as_str())?;
    let new_owner_raw: CanonicalAddr = deps.api.addr_canonicalize(owner.as_str())?;
    config.owner = new_owner_raw;
    CONFIG.save(deps.storage, &config)?;
    Ok(Response::new().add_attribute("action", "update_owner"))
}
pub fn update_owner ( deps : DepsMut , info : MessageInfo , owner : String , ) -> Result < Response , ContractError > { let mut 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 to raw deps . api . addr_validate ( owner . as_str ( ) ) ? ; let new_owner_raw : CanonicalAddr = deps . api . addr_canonicalize ( owner . as_str ( ) ) ? ; config . owner = new_owner_raw ; CONFIG . save ( deps . storage , & config ) ? ; Ok ( Response :: new ( ) . add_attribute ( " " , " " ) ) }
Updates the owner of the contract
Updates the owner of the contract
deps
DepsMut
info
MessageInfo
owner
String
deps
DepsMut
info
MessageInfo
owner
String