Struct 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:

  1. A valid human readable address e.g. cosmos1...
  2. 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

Source

pub fn as_str(&self) -> &str

Source

pub fn as_bytes(&self) -> &[u8]

Source

pub fn into_string(self) -> String

Source

pub fn from_string(addr: impl Into<String>) -> AndrAddr

Source

pub fn to_lowercase(&self) -> AndrAddr

Source

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.

Source

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.

Source

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.

Source

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

Source

pub fn is_local_path(&self) -> bool

Whether the provided address is local to the app

Source

pub fn is_vfs_path(&self) -> bool

Whether the provided address is a VFS path

Source

pub fn is_addr(&self, api: &dyn Api) -> bool

Whether the provided address is a valid human readable address

Source

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

Source

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

Source

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.

Source

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 AsRef<str> for AndrAddr

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for AndrAddr

Source§

fn clone(&self) -> AndrAddr

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AndrAddr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for AndrAddr

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for AndrAddr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> FMTResult

Formats the value using the given formatter. Read more
Source§

impl From<&AndrAddr> for String

Source§

fn from(addr: &AndrAddr) -> Self

Converts to this type from the input type.
Source§

impl From<AndrAddr> for String

Source§

fn from(addr: AndrAddr) -> Self

Converts to this type from the input type.
Source§

impl JsonSchema for AndrAddr

Source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq<&str> for AndrAddr

Source§

fn eq(&self, rhs: &&str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<AndrAddr> for &str

Source§

fn eq(&self, rhs: &AndrAddr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<AndrAddr> for String

Source§

fn eq(&self, rhs: &AndrAddr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<String> for AndrAddr

Source§

fn eq(&self, rhs: &String) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for AndrAddr

Source§

fn eq(&self, other: &AndrAddr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for AndrAddr

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for AndrAddr

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<U> As for U

Source§

fn as_<T>(self) -> T
where T: CastFrom<U>,

Casts 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
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,