| Crates.io | sov-modules-macros |
| lib.rs | sov-modules-macros |
| version | 0.3.0 |
| created_at | 2023-05-31 16:06:52.711462+00 |
| updated_at | 2023-10-20 17:03:17.883161+00 |
| description | Macros for use with the Sovereign SDK module system |
| homepage | https://www.sovereign.xyz |
| repository | https://github.com/sovereign-labs/sovereign-sdk |
| max_upload_size | |
| id | 878937 |
| size | 167,679 |
sov-modules-macrosThis crate provides Rust macros specifically designed to be used with the Module System. When developing a module, the developer's primary focus should be on implementing the business logic, without having to worry about low-level details such as message serialization/deserialization or how messages are dispatched to the appropriate module.
To alleviate the burden of writing repetitive and mechanical code, this crate offers a collection of macros that generate the necessary boilerplate code.
The following derive macros are supported:
ModuleInfo: Derives the sov-modules-api::ModuleInfo implementation for the underlying type.Genesis: Derives the sov-modules-api::Genesis implementation for the underlying type.DispatchCall: Derives the sov-modules-api::DispatchCall implementation for the underlying type.MessageCodec: Adds message serialization/deserialization functionality to the underlying type.The definitions of the traits mentioned above can be found in the sov-modules-api crate.
Example usage:
/// Runtime is a collection of sov modules defined in the rollup.
#[derive(Genesis, DispatchCall, MessageCodec)]
pub struct Runtime<C: Context> {
accounts: accounts::Accounts<C>,
bank: sov_bank::Bank<C>,
sequencer: sequencer::Sequencer<C>,
...
some other modules
}
/// `Genesis` allow initialization of the rollup in following way:
runtime.genesis(&configuration, working_set)
/// `DispatchCall & MessageCodec` allows dispatching serialized messages to the appropriate module.
let call_result = RT::decode_call(message_data)