Struct andromeda_std::amp::addresses::AndrAddr
source · pub struct AndrAddr(/* private fields */);
Expand description
An address that can be used within the Andromeda ecosystem.
Inspired by the cosmwasm-std Addr
type. https://github.com/CosmWasm/cosmwasm/blob/2a1c698520a1aacedfe3f4803b0d7d653892217a/packages/std/src/addresses.rs#L33
This address can be one of two things:
- A valid human readable address e.g.
cosmos1...
- A valid Andromeda VFS path e.g.
/home/user/app/component
VFS paths can be local in the case of an app and can be done by referencing ./component
they can also contain protocols for cross chain communication. A VFS path is usually structured as so:
<protocol>://<chain (required if ibc used)>/<path>
or ibc://cosmoshub-4/user/app/component
Implementations§
source§impl AndrAddr
impl AndrAddr
pub fn as_str(&self) -> &str
pub fn as_bytes(&self) -> &[u8] ⓘ
pub fn into_string(self) -> String
pub fn from_string(addr: impl Into<String>) -> AndrAddr
sourcepub fn validate(&self, api: &dyn Api) -> Result<(), ContractError>
pub fn validate(&self, api: &dyn Api) -> Result<(), ContractError>
Validates an AndrAddr
, to be valid the given address must either be a human readable address or a valid VFS path.
The existence of the provided path is not validated.
If you wish to validate the existence of the path you must use get_raw_address
.
sourcepub fn get_raw_address(&self, deps: &Deps<'_>) -> Result<Addr, ContractError>
pub fn get_raw_address(&self, deps: &Deps<'_>) -> Result<Addr, ContractError>
Retrieves the raw address represented by the AndrAddr.
If the address is a valid human readable address then that is returned, otherwise it is assumed to be a Andromeda VFS path and is resolved accordingly.
If the address is assumed to be a VFS path and no VFS contract address is provided then an appropriate error is returned.
sourcepub fn get_raw_address_from_vfs(
&self,
deps: &Deps<'_>,
vfs_contract: impl Into<String>
) -> Result<Addr, ContractError>
pub fn get_raw_address_from_vfs( &self, deps: &Deps<'_>, vfs_contract: impl Into<String> ) -> Result<Addr, ContractError>
Retrieves the raw address represented by the AndrAddr from the given VFS contract.
If the address is a valid human readable address then that is returned, otherwise it is assumed to be a Andromeda VFS path and is resolved accordingly.
If the address is assumed to be a VFS path and no VFS contract address is provided then an appropriate error is returned.
sourcepub fn is_local_path(&self) -> bool
pub fn is_local_path(&self) -> bool
Whether the provided address is local to the app
sourcepub fn is_vfs_path(&self) -> bool
pub fn is_vfs_path(&self) -> bool
Whether the provided address is a VFS path
sourcepub fn is_addr(&self, api: &dyn Api) -> bool
pub fn is_addr(&self, api: &dyn Api) -> bool
Whether the provided address is a valid human readable address
sourcepub fn get_chain(&self) -> Option<&str>
pub fn get_chain(&self) -> Option<&str>
Gets the chain for a given AndrAddr if it exists
E.g. ibc://cosmoshub-4/user/app/component
would return cosmoshub-4
A human readable address will always return None
sourcepub fn get_protocol(&self) -> Option<&str>
pub fn get_protocol(&self) -> Option<&str>
Gets the protocol for a given AndrAddr if it exists
E.g. ibc://cosmoshub-4/user/app/component
would return ibc
A human readable address will always return None
sourcepub fn get_raw_path(&self) -> &str
pub fn get_raw_path(&self) -> &str
Gets the raw path for a given AndrAddr by stripping away any protocols or chain declarations.
E.g. ibc://cosmoshub-4/user/app/component
would return /user/app/component
Returns the human readable address if the address is not a VFS path.
sourcepub fn get_root_dir(&self) -> &str
pub fn get_root_dir(&self) -> &str
Gets the root directory for a given AndrAddr
E.g. /home/user/app/component
would return home
Returns the human readable address if the address is not a VFS path or the local path if the address is a local reference
Trait Implementations§
source§impl<'de> Deserialize<'de> for AndrAddr
impl<'de> Deserialize<'de> for AndrAddr
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl JsonSchema for AndrAddr
impl JsonSchema for AndrAddr
source§fn schema_name() -> String
fn schema_name() -> String
source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read moresource§impl Ord for AndrAddr
impl Ord for AndrAddr
source§impl PartialEq<AndrAddr> for &str
impl PartialEq<AndrAddr> for &str
source§impl PartialEq<AndrAddr> for String
impl PartialEq<AndrAddr> for String
source§impl PartialEq<String> for AndrAddr
impl PartialEq<String> for AndrAddr
source§impl PartialEq for AndrAddr
impl PartialEq for AndrAddr
source§impl PartialOrd for AndrAddr
impl PartialOrd for AndrAddr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Eq for AndrAddr
impl StructuralPartialEq for AndrAddr
Auto Trait Implementations§
impl RefUnwindSafe for AndrAddr
impl Send for AndrAddr
impl Sync for AndrAddr
impl Unpin for AndrAddr
impl UnwindSafe for AndrAddr
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
self
to type T
. The semantics of numeric casting with the as
operator are followed, so <T as As>::as_::<U>
can be used in the same way as T as U
for numeric conversions. Read more