pub fn try_set_owner(
    deps: &mut DepsMut,
    info: &MessageInfo,
    name: &String,
    tld: &String,
    new_owner: Addr,
) -> Result<Response> {
    let config = get_config(deps.storage)?;

    if !config.allowed_tlds.contains(tld) {
        return Err(anyhow!("Unknown TLD: {}", tld));
    }

    let mut name_registry = NameRegistry::new(tld);
    let name_record = name_registry.try_resolve_name(deps.storage, name)?;

    if name_record.owner != info.sender {
        return Err(anyhow!("Only the name owner can change its owner"));
    }

    let name_record = name_registry.try_set_owner(deps.storage, name, new_owner)?;

    Ok(Response::new()
        .add_attribute("name", name)
        .add_attribute("tld", tld)
        .add_attribute("owner", name_record.owner))
}
/// Attempt to set the owner for a name
/// Validates that the current owner address is the one asking for the change
/// Returned data includes the new name record, including updated lineage hash
Attempt to set the owner for a name
Validates that the current owner address is the one asking for the change
Returned data includes the new name record, including updated lineage hash
Attempt to set the owner for a name Validates that the current owner address is the one asking for the change Returned data includes the new name record including updated lineage hash
pub fn try_set_owner(
    deps: &mut DepsMut,
    info: &MessageInfo,
    name: &String,
    tld: &String,
    new_owner: Addr,
) -> Result<Response> {
    let config = get_config(deps.storage)?;
    if !config.allowed_tlds.contains(tld) {
        return Err(anyhow!("Unknown TLD: {}", tld));
    }
    let mut name_registry = NameRegistry::new(tld);
    let name_record = name_registry.try_resolve_name(deps.storage, name)?;
    if name_record.owner != info.sender {
        return Err(anyhow!("Only the name owner can change its owner"));
    }
    let name_record = name_registry.try_set_owner(deps.storage, name, new_owner)?;
    Ok(Response::new()
        .add_attribute("name", name)
        .add_attribute("tld", tld)
        .add_attribute("owner", name_record.owner))
}
pub fn try_set_owner ( deps : & mut DepsMut , info : & MessageInfo , name : & String , tld : & String , new_owner : Addr , ) -> Result < Response > { let config = get_config ( deps . storage ) ? ; if ! config . allowed_tlds . contains ( tld ) { return Err ( anyhow ! ( " " tld ) ) ; } let mut name_registry = NameRegistry :: new ( tld ) ; let name_record = name_registry . try_resolve_name ( deps . storage , name ) ? ; if name_record . owner != info . sender { return Err ( anyhow ! ( " " ) ) ; } let name_record = name_registry . try_set_owner ( deps . storage , name , new_owner ) ? ; Ok ( Response :: new ( ) . add_attribute ( " " , name ) . add_attribute ( " " , tld ) . add_attribute ( " " , name_record . owner ) ) }
Attempt to set the owner for a name
Validates that the current owner address is the one asking for the change
Returned data includes the new name record, including updated lineage hash
Attempt to set the owner for a name Validates that the current owner address is the one asking for the change Returned data includes the new name record including updated lineage hash
deps
&mut DepsMut
info
&MessageInfo
name
&String
tld
&String
new_owner
Addr
deps
&mut DepsMut
info
&MessageInfo
name
&String
tld
&String
new_owner
Addr