Trait cw_iper_test::StargateApplication
source · pub trait StargateApplication: StargateUrls + StargateName {
// Required methods
fn stargate_msg(
&self,
api: &dyn Api,
storage: Rc<RefCell<&mut dyn Storage>>,
router: &RouterWrapper<'_>,
block: &BlockInfo,
sender: Addr,
type_url: String,
data: Binary
) -> Result<AppResponse, Error>;
fn stargate_query(
&self,
api: &dyn Api,
storage: &dyn Storage,
querier: &dyn Querier,
block: &BlockInfo,
request: GrpcQuery
) -> Result<Binary, Error>;
}
Expand description
This trait identifies a generic Stargate application
(e.g., TokenFactory
, IC20
) that is managed by the IperStargateModule
.
The IperStargateModule
is a structure implementing both Stargate
and Module
traits and serves as the Stargate module
for the App
class of an IperApp
.
IperStargateModule
will invoke a function implemented by this trait under the following conditions:
- stargate_msg: A
AnyMsg
is targetting thisStargateApplication
for execution; - stargate_query: A
GrpcQuery
is targetting thisStargateApplication
for query.
§Implementation of the trait:
In order to be implemented, the struct has to implement both StargateUrls
+ StargateName
Use the derive macro
Stargate
and #[urls] proc_macro_attribute
from cw-iper-test-macros
§Example:
ⓘ
#[derive(Stargate)]
#[stargate(name = "ics20", query_urls = Ics20QueryUrls, msgs_urls = Ics20MsgUrls)]
pub struct Ics20;
#[urls]
pub enum Ics20MsgUrls {
#[strum(serialize = "/ibc.applications.transfer.v1.MsgTransfer")]
MsgTransfer,
}
#[urls]
pub enum Ics20QueryUrls {}
Required Methods§
sourcefn stargate_msg(
&self,
api: &dyn Api,
storage: Rc<RefCell<&mut dyn Storage>>,
router: &RouterWrapper<'_>,
block: &BlockInfo,
sender: Addr,
type_url: String,
data: Binary
) -> Result<AppResponse, Error>
fn stargate_msg( &self, api: &dyn Api, storage: Rc<RefCell<&mut dyn Storage>>, router: &RouterWrapper<'_>, block: &BlockInfo, sender: Addr, type_url: String, data: Binary ) -> Result<AppResponse, Error>
A AnyMsg
is targetting this StargateApplication
for execution;