pub trait TokenTransferValidationContext {
type AccountId;
// Required methods
fn sender_account(
&self,
sender: &Signer,
) -> Result<Self::AccountId, HostError>;
fn receiver_account(
&self,
receiver: &Signer,
) -> Result<Self::AccountId, HostError>;
fn get_port(&self) -> Result<PortId, HostError>;
fn can_send_coins(&self) -> Result<(), HostError>;
fn can_receive_coins(&self) -> Result<(), HostError>;
fn escrow_coins_validate(
&self,
from_account: &Self::AccountId,
port_id: &PortId,
channel_id: &ChannelId,
coin: &PrefixedCoin,
memo: &Memo,
) -> Result<(), HostError>;
fn unescrow_coins_validate(
&self,
to_account: &Self::AccountId,
port_id: &PortId,
channel_id: &ChannelId,
coin: &PrefixedCoin,
) -> Result<(), HostError>;
fn mint_coins_validate(
&self,
account: &Self::AccountId,
coin: &PrefixedCoin,
) -> Result<(), HostError>;
fn burn_coins_validate(
&self,
account: &Self::AccountId,
coin: &PrefixedCoin,
memo: &Memo,
) -> Result<(), HostError>;
// Provided method
fn denom_hash_string(&self, _denom: &PrefixedDenom) -> Option<String> { ... }
}
Expand description
Methods required in token transfer validation, to be implemented by the host
Required Associated Types§
Required Methods§
Sourcefn sender_account(&self, sender: &Signer) -> Result<Self::AccountId, HostError>
fn sender_account(&self, sender: &Signer) -> Result<Self::AccountId, HostError>
Attempt to convert a Signer
to a native chain sender account.
Sourcefn receiver_account(
&self,
receiver: &Signer,
) -> Result<Self::AccountId, HostError>
fn receiver_account( &self, receiver: &Signer, ) -> Result<Self::AccountId, HostError>
Attempt to convert a Signer
to a native chain receiver account.
Sourcefn get_port(&self) -> Result<PortId, HostError>
fn get_port(&self) -> Result<PortId, HostError>
get_port returns the portID for the transfer module.
Sourcefn can_send_coins(&self) -> Result<(), HostError>
fn can_send_coins(&self) -> Result<(), HostError>
Returns Ok() if the host chain supports sending coins.
Sourcefn can_receive_coins(&self) -> Result<(), HostError>
fn can_receive_coins(&self) -> Result<(), HostError>
Returns Ok() if the host chain supports receiving coins.
Sourcefn escrow_coins_validate(
&self,
from_account: &Self::AccountId,
port_id: &PortId,
channel_id: &ChannelId,
coin: &PrefixedCoin,
memo: &Memo,
) -> Result<(), HostError>
fn escrow_coins_validate( &self, from_account: &Self::AccountId, port_id: &PortId, channel_id: &ChannelId, coin: &PrefixedCoin, memo: &Memo, ) -> Result<(), HostError>
Validates that the tokens can be escrowed successfully.
memo
field allows incorporating additional contextual details in the
escrow validation.
Sourcefn unescrow_coins_validate(
&self,
to_account: &Self::AccountId,
port_id: &PortId,
channel_id: &ChannelId,
coin: &PrefixedCoin,
) -> Result<(), HostError>
fn unescrow_coins_validate( &self, to_account: &Self::AccountId, port_id: &PortId, channel_id: &ChannelId, coin: &PrefixedCoin, ) -> Result<(), HostError>
Validates that the tokens can be unescrowed successfully.
Sourcefn mint_coins_validate(
&self,
account: &Self::AccountId,
coin: &PrefixedCoin,
) -> Result<(), HostError>
fn mint_coins_validate( &self, account: &Self::AccountId, coin: &PrefixedCoin, ) -> Result<(), HostError>
Validates the receiver account and the coin input
Sourcefn burn_coins_validate(
&self,
account: &Self::AccountId,
coin: &PrefixedCoin,
memo: &Memo,
) -> Result<(), HostError>
fn burn_coins_validate( &self, account: &Self::AccountId, coin: &PrefixedCoin, memo: &Memo, ) -> Result<(), HostError>
Validates the sender account and the coin input before burning.
memo
field allows incorporating additional contextual details in the
burn validation.
Provided Methods§
Sourcefn denom_hash_string(&self, _denom: &PrefixedDenom) -> Option<String>
fn denom_hash_string(&self, _denom: &PrefixedDenom) -> Option<String>
Returns a hash of the prefixed denom. Implement only if the host chain supports hashed denominations.