Expand description
cosmwasm_std::Addr
<->cosmwasm_std::CanonicalAddr
conversion for types that contain addresses.
Traits§
- Address
- Sealed marker trait for types that represent a valid address.
Those can only be
cosmwasm_std::Addr
andcosmwasm_std::CanonicalAddr
and thus are the only types that implement the trait. - Canonize
- The trait that represents any type which contains a
cosmwasm_std::Addr
and needs to be stored sincecosmwasm_std::Addr
is usually converted tocosmwasm_std::CanonicalAddr
first. The trait must be implemented on the non-canonical version of the type and the output ofCanonize::canonize
must return the canonical version of the same type which is represented by its sister traitHumanize
. This relationship is enforced on the type level sinceCanonize::Output
must implementHumanize
and vice versa. - Humanize
- The trait that represents the canonical version of the given type.
See
Canonize
for more info. - Maybe
Address - Sealed marker trait for types that may represent
an address. The types that may be a valid address are
&str
andString
since they could potentially contain an address. We usecosmwasm_std::Api::addr_validate
orcosmwasm_std::Api::addr_canonicalize
to turn them intocosmwasm_std::Addr
andcosmwasm_std::CanonicalAddr
respectively, both of which definitely do contain a valid address and therefore also satisfy this trait.
Functions§
- canonize_
maybe_ empty - Attempting to canonicalize an empty address will fail.
This function skips calling
cosmwasm_std::Api::addr_canonicalize
if the input is empty and returnsCanonicalAddr::default()
instead. - humanize_
maybe_ empty - Attempting to humanize an empty address will fail.
This function skips calling
cosmwasm_std::Api::addr_humanize
if the input is empty and returnsAddr::default()
instead. - validate_
addresses - Validates a collection of strings that are expected to be valid addresses.