Module addr

Source
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 and cosmwasm_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 since cosmwasm_std::Addr is usually converted to cosmwasm_std::CanonicalAddr first. The trait must be implemented on the non-canonical version of the type and the output of Canonize::canonize must return the canonical version of the same type which is represented by its sister trait Humanize. This relationship is enforced on the type level since Canonize::Output must implement Humanize and vice versa.
Humanize
The trait that represents the canonical version of the given type. See Canonize for more info.
MaybeAddress
Sealed marker trait for types that may represent an address. The types that may be a valid address are &str and String since they could potentially contain an address. We use cosmwasm_std::Api::addr_validate or cosmwasm_std::Api::addr_canonicalize to turn them into cosmwasm_std::Addr and cosmwasm_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 returns CanonicalAddr::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 returns Addr::default() instead.
validate_addresses
Validates a collection of strings that are expected to be valid addresses.