Sylvia 0.7.0

Introducing Sylvia.

Jan Woźniak
Confio
2 min readAug 21, 2023

--

What is Sylvia?

I introduce the Sylvia framework. Its purpose is to make smart contract development using cosmwasm as user-friendly as possible.

Based on methods defined by the user, Sylvia will:
- generate entry points,
- generate messages with dispatch logic,
- generate a Remote type for better communication with the contract,
- generate Querier helpers for more intuitive querying of the contract,
- generate multitest helpers for more intuitive testing.

Sylvia exposes three procedural attribute macros:
- entry_points — it will generate entry points, gateways to each cosmwasm smart contract,
- interface — Used as an attribute for a trait. Its aim is to allow users to divide the code into semantical parts. It supports execute and query messages,
- contract — Main Sylvia macro. Defines the structure of your contract by generating all of the messages and helpers. Users can implement methods defined on interfaces using the messages attribute. Sylvia generates message wrappers called ContractExecMsg and ContractQueryMsg, allowing dispatch to proper logic and exposing all of the messages in schema API.

How to get started with Sylvia?

The best way to learn Sylvia is to go through the Sylvia book. It goes step by step through development with Sylvia.
To learn about the cosmwasm, please refer to the cosmwasm book.

Release 0.7.0

Since 0.7.0, it is possible to override the entry points.

First, define your custom entry point:

#[entry_point]
pub fn sudo(deps: DepsMut, _env: Env, _msg: SudoMsg) -> StdResult<Response> {
CounterContract::new().counter.save(deps.storage, &3)?;
Ok(Response::new())
}

Then add a new attribute sv::override_entry_point() to your contract.

#[cfg_attr(not(feature = “library”), entry_points)]
#[contract]
#[sv::override_entry_point(sudo=crate::entry_points::sudo(crate::messages::SudoMsg))]
#[sv::override_entry_point(exec=crate::entry_points::execute(crate::messages::CustomExecMsg))]
impl CounterContract {

Single attribute overrides single entry point. Next to the entry point path you have to provide the message type.
This will tell Sylvia not to generate the entry points for overridden ones and will use them in generated multitest helpers.

What’s next?

Release 0.8.0 will bring support to define CustomQuery on your contract.

--

--