Struct AMPPkt

Source
pub struct AMPPkt {
    pub messages: Vec<AMPMsg>,
    pub ctx: AMPCtx,
}
Expand description

An Andromeda packet contains all message protocol related data, this is what is sent between ADOs when communicating It contains an original sender, if used for authorisation the sender must be authorised The previous sender is the one who sent the message A packet may contain several messages which allows for message batching

Fields§

§messages: Vec<AMPMsg>

Any messages associated with the packet

§ctx: AMPCtx

Implementations§

Source§

impl AMPPkt

Source

pub fn new( origin: impl Into<String>, previous_sender: impl Into<String>, messages: Vec<AMPMsg>, ) -> AMPPkt

Creates a new AMP Packet

Source

pub fn add_message(self, message: AMPMsg) -> Self

Adds a message to the current AMP Packet

Source

pub fn get_unique_recipients(&self) -> Vec<String>

Gets all unique recipients for messages

Source

pub fn get_messages_for_recipient(&self, recipient: String) -> Vec<AMPMsg>

Gets all messages for a given recipient

Source

pub fn verify_origin( &self, info: &MessageInfo, deps: &Deps<'_>, ) -> Result<(), ContractError>

Used to verify that the sender of the AMPPkt is authorised to attach the given origin field. A sender is valid if:

  1. The origin matches the sender
  2. The sender is the kernel
  3. The sender has a code ID stored within the ADODB (and as such is a valid ADO)

If the sender is not valid, an error is returned

Source

pub fn get_verified_origin( &self, info: &MessageInfo, deps: &Deps<'_>, ) -> Result<String, ContractError>

Verifies the origin of the AMPPkt and returns the origin if it is valid

Source

pub fn to_sub_msg( &self, address: impl Into<String>, funds: Option<Vec<Coin>>, id: u64, ) -> Result<SubMsg, ContractError>

Generates a SubMsg to send the AMPPkt to the kernel

Source

pub fn with_id(&self, id: u64) -> AMPPkt

Attaches an ID to the current packet

Source

pub fn to_ibc_hooks_memo( &self, contract_addr: String, callback_addr: String, ) -> String

Converts a given AMP Packet to an IBC Hook memo for use with Osmosis’ IBC Hooks module

Source

pub fn to_json(&self) -> String

Serializes the given AMP Packet to a JSON string

Source

pub fn from_ctx(ctx: Option<AMPPkt>, current_address: String) -> Self

Generates an AMP Packet from context

Trait Implementations§

Source§

impl Clone for AMPPkt

Source§

fn clone(&self) -> AMPPkt

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 AMPPkt

Source§

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

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

impl<'de> Deserialize<'de> for AMPPkt

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 JsonSchema for AMPPkt

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 for AMPPkt

Source§

fn eq(&self, other: &AMPPkt) -> 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 AMPPkt

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 AMPPkt

Auto Trait Implementations§

§

impl Freeze for AMPPkt

§

impl RefUnwindSafe for AMPPkt

§

impl Send for AMPPkt

§

impl Sync for AMPPkt

§

impl Unpin for AMPPkt

§

impl UnwindSafe for AMPPkt

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, 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>,