Trait cw_iper_test::IbcApplication
source · pub trait IbcApplication: IbcPortInterface {
// Required methods
fn handle_outgoing_packet(
&self,
api: &dyn Api,
block: &BlockInfo,
sender: Addr,
router: &RouterWrapper<'_>,
storage: Rc<RefCell<&mut dyn Storage>>,
msg: IbcMsg,
channel: IbcChannelWrapper
) -> Result<AppResponse, Error>;
fn packet_receive(
&self,
api: &dyn Api,
block: &BlockInfo,
router: &RouterWrapper<'_>,
storage: Rc<RefCell<&mut dyn Storage>>,
msg: IbcPacketReceiveMsg
) -> InfallibleResult<PacketReceiveOk, PacketReceiveFailing>;
fn packet_ack(
&self,
api: &dyn Api,
block: &BlockInfo,
router: &RouterWrapper<'_>,
storage: Rc<RefCell<&mut dyn Storage>>,
msg: AckPacket
) -> Result<AppResponse, Error>;
fn packet_timeout(
&self,
api: &dyn Api,
block: &BlockInfo,
router: &RouterWrapper<'_>,
storage: Rc<RefCell<&mut dyn Storage>>,
msg: TimeoutPacket
) -> Result<AppResponse, Error>;
fn open_channel(
&self,
api: &dyn Api,
block: &BlockInfo,
router: &RouterWrapper<'_>,
storage: Rc<RefCell<&mut dyn Storage>>,
msg: IbcChannelOpenMsg
) -> Result<AppResponse, Error>;
fn channel_connect(
&self,
api: &dyn Api,
block: &BlockInfo,
router: &RouterWrapper<'_>,
storage: Rc<RefCell<&mut dyn Storage>>,
msg: IbcChannelConnectMsg
) -> Result<AppResponse, Error>;
fn init(&self, api: &MockApiBech32, storage: &mut dyn Storage);
}
Expand description
This trait identifies a generic IBC application
(e.g., IC20
, ICA
, etc.) that is managed by the IperIbcModule
.
The IperIbcModule
is a structure implementing both Ibc
and Module
traits and serves as the IBC module
for the App
class of an IperApp
.
IperIbcModule
will invoke a function implemented by this trait under the following conditions:
- handle_outgoing_packet: An
IBC packet
is emitted and the sourcechannel-id
is thisIbcApplication
. - packet_receive: An
IBC packet
is received and the destinationchannel-id
is thisIbcApplication
. - packet_ack: An
acknowledgment packet
returns and the sourcechannel-id
was thisIbcApplication
. - packet_timeout: A
timeout packet
returns and the sourcechannel-id
was thisIbcApplication
. - open_channel: An
IBC channel
is being opened that carries thisIbcApplication
. - channel_connect: An
IBC channel
is being connected that carries thisIbcApplication
.
§Implementation of the trait:
In order to be implemented, the struct has to implement also IbcPortInterface
Use the derive macro IbcPort
from cw-iper-test-macros
§Example:
#[derive(IbcPort)]
#[ibc_port = "transfer"]
pub struct Ics20;
Required Methods§
sourcefn handle_outgoing_packet(
&self,
api: &dyn Api,
block: &BlockInfo,
sender: Addr,
router: &RouterWrapper<'_>,
storage: Rc<RefCell<&mut dyn Storage>>,
msg: IbcMsg,
channel: IbcChannelWrapper
) -> Result<AppResponse, Error>
fn handle_outgoing_packet( &self, api: &dyn Api, block: &BlockInfo, sender: Addr, router: &RouterWrapper<'_>, storage: Rc<RefCell<&mut dyn Storage>>, msg: IbcMsg, channel: IbcChannelWrapper ) -> Result<AppResponse, Error>
An IBC packet
is emitted and the source channel-id
is this IbcApplication
.
For example. on Ics20
the transfer amount has to be burned/locked from the sender address
sourcefn packet_receive(
&self,
api: &dyn Api,
block: &BlockInfo,
router: &RouterWrapper<'_>,
storage: Rc<RefCell<&mut dyn Storage>>,
msg: IbcPacketReceiveMsg
) -> InfallibleResult<PacketReceiveOk, PacketReceiveFailing>
fn packet_receive( &self, api: &dyn Api, block: &BlockInfo, router: &RouterWrapper<'_>, storage: Rc<RefCell<&mut dyn Storage>>, msg: IbcPacketReceiveMsg ) -> InfallibleResult<PacketReceiveOk, PacketReceiveFailing>
An IBC packet
is received and the destination channel-id
is this [IbcApplication
].
The return type is [InfallibleResult
], allowing to revert any Storage changes without raising errors.
sourcefn packet_ack(
&self,
api: &dyn Api,
block: &BlockInfo,
router: &RouterWrapper<'_>,
storage: Rc<RefCell<&mut dyn Storage>>,
msg: AckPacket
) -> Result<AppResponse, Error>
fn packet_ack( &self, api: &dyn Api, block: &BlockInfo, router: &RouterWrapper<'_>, storage: Rc<RefCell<&mut dyn Storage>>, msg: AckPacket ) -> Result<AppResponse, Error>
An acknowledgment packet
returns and the source channel-id
was this IbcApplication
.
sourcefn packet_timeout(
&self,
api: &dyn Api,
block: &BlockInfo,
router: &RouterWrapper<'_>,
storage: Rc<RefCell<&mut dyn Storage>>,
msg: TimeoutPacket
) -> Result<AppResponse, Error>
fn packet_timeout( &self, api: &dyn Api, block: &BlockInfo, router: &RouterWrapper<'_>, storage: Rc<RefCell<&mut dyn Storage>>, msg: TimeoutPacket ) -> Result<AppResponse, Error>
A timeout packet
returns and the source channel-id
was this IbcApplication
.
sourcefn open_channel(
&self,
api: &dyn Api,
block: &BlockInfo,
router: &RouterWrapper<'_>,
storage: Rc<RefCell<&mut dyn Storage>>,
msg: IbcChannelOpenMsg
) -> Result<AppResponse, Error>
fn open_channel( &self, api: &dyn Api, block: &BlockInfo, router: &RouterWrapper<'_>, storage: Rc<RefCell<&mut dyn Storage>>, msg: IbcChannelOpenMsg ) -> Result<AppResponse, Error>
An IBC channel
is being opened that carries this IbcApplication
.
sourcefn channel_connect(
&self,
api: &dyn Api,
block: &BlockInfo,
router: &RouterWrapper<'_>,
storage: Rc<RefCell<&mut dyn Storage>>,
msg: IbcChannelConnectMsg
) -> Result<AppResponse, Error>
fn channel_connect( &self, api: &dyn Api, block: &BlockInfo, router: &RouterWrapper<'_>, storage: Rc<RefCell<&mut dyn Storage>>, msg: IbcChannelConnectMsg ) -> Result<AppResponse, Error>
An IBC channel
is being connected that carries this IbcApplication
.