pub fn try_set_value(
    deps: &mut DepsMut,
    info: &MessageInfo,
    name: &String,
    tld: &String,
    value: Option<String>,
) -> 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 value"));
    }

    let name_record = name_registry.try_set_value(deps.storage, name, value)?;

    let response = Response::new()
        .add_attribute("name", name)
        .add_attribute("tld", tld)
        .add_attribute("owner", name_record.owner);

    Ok(match name_record.value {
        Some(value) => response.add_attribute("value", value),
        None => response,
    })
}
/// Attempt to set the value for a name record
/// Validates that the owner address is the one setting the value
/// Returned data includes the new name record, including updated lineage hash
Attempt to set the value for a name record
Validates that the owner address is the one setting the value
Returned data includes the new name record, including updated lineage hash
Attempt to set the value for a name record Validates that the owner address is the one setting the value Returned data includes the new name record including updated lineage hash
pub fn try_set_value(
    deps: &mut DepsMut,
    info: &MessageInfo,
    name: &String,
    tld: &String,
    value: Option<String>,
) -> 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 value"));
    }
    let name_record = name_registry.try_set_value(deps.storage, name, value)?;
    let response = Response::new()
        .add_attribute("name", name)
        .add_attribute("tld", tld)
        .add_attribute("owner", name_record.owner);
    Ok(match name_record.value {
        Some(value) => response.add_attribute("value", value),
        None => response,
    })
}
pub fn try_set_value ( deps : & mut DepsMut , info : & MessageInfo , name : & String , tld : & String , value : Option < String > , ) -> 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_value ( deps . storage , name , value ) ? ; let response = Response :: new ( ) . add_attribute ( " " , name ) . add_attribute ( " " , tld ) . add_attribute ( " " , name_record . owner ) ; Ok ( match name_record . value { Some ( value ) => response . add_attribute ( " " , value ) , None => response , } ) }
Attempt to set the value for a name record
Validates that the owner address is the one setting the value
Returned data includes the new name record, including updated lineage hash
Attempt to set the value for a name record Validates that the owner address is the one setting the value Returned data includes the new name record including updated lineage hash
deps
&mut DepsMut
info
&MessageInfo
name
&String
tld
&String
value
Option<String>
deps
&mut DepsMut
info
&MessageInfo
name
&String
tld
&String
value
Option<String>