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

    match config.registration_fee {
        Some(fee) => {
            let paid = info
                .funds
                .iter()
                .any(|coin| coin.denom == fee.denom && coin.amount.u128() >= fee.amount.u128());

            if paid {
                Ok(())
            } else {
                Err(anyhow!(
                    "Insufficient payment sent for registration fee. Required amount is {}.{}",
                    fee.amount,
                    fee.denom
                ))
            }
        }
        _ => Ok(()),
    }?;

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

    let mut name_registry = NameRegistry::new(tld);

    name_registry.try_register(deps.storage, name, &info.sender)?;

    Ok(Response::new()
        .add_attribute("name", name)
        .add_attribute("tld", tld)
        .add_attribute("owner", &info.sender))
}
/// Attempt to register a name
/// Validates that the configured fee (if any) has been paid
/// Names that have been registered cannot be re-registered
Attempt to register a name
Validates that the configured fee (if any) has been paid
Names that have been registered cannot be re-registered
Attempt to register a name Validates that the configured fee ( if any ) has been paid Names that have been registered cannot be re - registered
pub fn try_register_name(
    deps: &mut DepsMut,
    info: &MessageInfo,
    name: &String,
    tld: &String,
) -> Result<Response> {
    let config = get_config(deps.storage)?;
    match config.registration_fee {
        Some(fee) => {
            let paid = info
                .funds
                .iter()
                .any(|coin| coin.denom == fee.denom && coin.amount.u128() >= fee.amount.u128());
            if paid {
                Ok(())
            } else {
                Err(anyhow!(
                    "Insufficient payment sent for registration fee. Required amount is {}.{}",
                    fee.amount,
                    fee.denom
                ))
            }
        }
        _ => Ok(()),
    }?;
    if !config.allowed_tlds.contains(tld) {
        return Err(anyhow!("Unknown TLD: {}", tld));
    }
    let mut name_registry = NameRegistry::new(tld);
    name_registry.try_register(deps.storage, name, &info.sender)?;
    Ok(Response::new()
        .add_attribute("name", name)
        .add_attribute("tld", tld)
        .add_attribute("owner", &info.sender))
}
pub fn try_register_name ( deps : & mut DepsMut , info : & MessageInfo , name : & String , tld : & String , ) -> Result < Response > { let config = get_config ( deps . storage ) ? ; match config . registration_fee { Some ( fee ) => { let paid = info . funds . iter ( ) . any ( | coin | coin . denom == fee . denom && coin . amount . u128 ( ) >= fee . amount . u128 ( ) ) ; if paid { Ok ( ( ) ) } else { Err ( anyhow ! ( " " fee amount fee denom ) ) } } _ => Ok ( ( ) ) , } ? ; if ! config . allowed_tlds . contains ( tld ) { return Err ( anyhow ! ( " " tld ) ) ; } let mut name_registry = NameRegistry :: new ( tld ) ; name_registry . try_register ( deps . storage , name , & info . sender ) ? ; Ok ( Response :: new ( ) . add_attribute ( " " , name ) . add_attribute ( " " , tld ) . add_attribute ( " " , & info . sender ) ) }
Attempt to register a name
Validates that the configured fee (if any) has been paid
Names that have been registered cannot be re-registered
Attempt to register a name Validates that the configured fee ( if any ) has been paid Names that have been registered cannot be re - registered
deps
&mut DepsMut
info
&MessageInfo
name
&String
tld
&String
deps
&mut DepsMut
info
&MessageInfo
name
&String
tld
&String