Attribute Macro sylvia_derive::entry_points
source · #[entry_points]
Expand description
Procedural macro generating cosmwasm entry points from contract impl block.
By default generates execute
, instantiate
, sudo
, query
entry points.
§Example usage
pub struct SvContract;
#[sylvia::entry_points]
#[sylvia::contract]
impl SvContract {
pub const fn new() -> Self {
Self
}
#[sv::msg(instantiate)]
fn instantiate(&self, ctx: InstantiateCtx, admin: Option<String>) -> StdResult<Response> {
}
}
§Generics
Cosmwasm
entry point has to be implemented with concrete types.
In case your contract uses some generic types you have to specify concrete types
used in their place in the entry_points
macro attribute generics
.
pub struct SvContract<InstantiateT, DataT> {
data: Item<DataT>,
_phantom: PhantomData<InstantiateT>,
}
#[sylvia::entry_points(generics<SvCustomMsg, SvCustomMsg>)]
#[sylvia::contract]
impl<InstantiateT, DataT> SvContract<InstantiateT, DataT>
where InstantiateT: sylvia::types::CustomMsg + 'static,
DataT: 'static
{
pub const fn new() -> Self {
Self {
data: Item::new("data"),
_phantom: PhantomData,
}
}
#[sv::msg(instantiate)]
fn instantiate(&self, ctx: InstantiateCtx, instantiate_data: InstantiateT) -> StdResult<Response> {
}
}