pub struct Recipient {
pub address: AndrAddr,
pub msg: Option<Binary>,
pub ibc_recovery_address: Option<AndrAddr>,
}
Expand description
A simple struct used for inter-contract communication. The struct can be used in two ways:
- Simply just providing an
AndrAddr
which will treat the communication as a transfer of any related funds - Providing an
AndrAddr
and aBinary
message which will be sent to the contract at the resolved address
The Binary
message can be any message that the contract at the resolved address can handle.
Fields§
§address: AndrAddr
§msg: Option<Binary>
§ibc_recovery_address: Option<AndrAddr>
Implementations§
Source§impl Recipient
impl Recipient
pub fn new(addr: impl Into<String>, msg: Option<Binary>) -> Recipient
Sourcepub fn validate(&self, deps: &Deps<'_>) -> Result<(), ContractError>
pub fn validate(&self, deps: &Deps<'_>) -> Result<(), ContractError>
Validates a recipient by validating its address and recovery address (if it is provided)
Sourcepub fn from_string(addr: impl Into<String>) -> Recipient
pub fn from_string(addr: impl Into<String>) -> Recipient
Creates a Recipient from the given string with no attached message
pub fn get_addr(&self) -> String
pub fn get_message(&self) -> Option<Binary>
Sourcepub fn generate_direct_msg(
&self,
deps: &Deps<'_>,
funds: Vec<Coin>,
) -> Result<SubMsg, ContractError>
pub fn generate_direct_msg( &self, deps: &Deps<'_>, funds: Vec<Coin>, ) -> Result<SubMsg, ContractError>
Generates a direct sub message for the given recipient.
Sourcepub fn generate_msg_cw20(
&self,
deps: &Deps<'_>,
cw20_coin: Cw20Coin,
) -> Result<SubMsg, ContractError>
pub fn generate_msg_cw20( &self, deps: &Deps<'_>, cw20_coin: Cw20Coin, ) -> Result<SubMsg, ContractError>
Generates a message to send a CW20 token to the recipient with the attached message.
Assumes the attached message is a valid CW20 Hook message for the receiving address.
Sourcepub fn generate_amp_msg(
&self,
deps: &Deps<'_>,
funds: Option<Vec<Coin>>,
) -> Result<AMPMsg, ContractError>
pub fn generate_amp_msg( &self, deps: &Deps<'_>, funds: Option<Vec<Coin>>, ) -> Result<AMPMsg, ContractError>
Generates an AMP message from the given Recipient.
This can be attached to an AMP Packet for execution via the aOS.
Sourcepub fn with_ibc_recovery(self, addr: impl Into<String>) -> Self
pub fn with_ibc_recovery(self, addr: impl Into<String>) -> Self
Adds an IBC recovery address to the recipient
This address can be used to recover any funds on failed IBC messages
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Recipient
impl<'de> Deserialize<'de> for Recipient
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 Recipient
impl JsonSchema for Recipient
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