You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was recently looking into native denom validation, and it turns out there are actually some reasonably strict rules in the SDK as to what strings may be denominations. We should be able to perform that validation in a contract reasonably enough. From dao-contracts:
/// Follows cosmos SDK validation logic. Specifically, the regex/// string `[a-zA-Z][a-zA-Z0-9/:._-]{2,127}`.////// <https://github.com/cosmos/cosmos-sdk/blob/7728516abfab950dc7a9120caad4870f1f962df5/types/coin.go#L865-L867>pubfnvalidate_native_denom(denom:String) -> Result<String,DenomError>{if denom.len() < 3 || denom.len() > 128{returnErr(DenomError::NativeDenomLength{len: denom.len()});}letmut chars = denom.chars();// Really this means that a non utf-8 character is in here, but// non-ascii is also correct.let first = chars.next().ok_or(DenomError::NonAlphabeticAscii)?;if !first.is_ascii_alphabetic(){returnErr(DenomError::NonAlphabeticAscii);}for c in chars {if !(c.is_ascii_alphanumeric() || c == '/' || c == ':' || c == '.' || c == '_' || c == '-'){returnErr(DenomError::InvalidCharacter{ c });}}Ok(denom)}
The text was updated successfully, but these errors were encountered:
I was recently looking into native denom validation, and it turns out there are actually some reasonably strict rules in the SDK as to what strings may be denominations. We should be able to perform that validation in a contract reasonably enough. From dao-contracts:
The text was updated successfully, but these errors were encountered: