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
pub fn to_lowercase(&self) -> 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 local_path_to_vfs_path(
&self,
storage: &dyn Storage,
querier: &QuerierWrapper<'_>,
vfs_contract: impl Into<String>,
) -> Result<AndrAddr, ContractError>
pub fn local_path_to_vfs_path( &self, storage: &dyn Storage, querier: &QuerierWrapper<'_>, vfs_contract: impl Into<String>, ) -> Result<AndrAddr, ContractError>
Converts a local path to a valid VFS path by replacing ./
with the app contract address
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(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read more