nibiru-ownable-derive

Crates.ionibiru-ownable-derive
lib.rsnibiru-ownable-derive
version0.7.0
created_at2024-07-08 16:15:55.567363+00
updated_at2025-09-11 22:07:17.726453+00
descriptionMacros for generating code used by the `nibiru-ownable` crate
homepagehttps://github.com/NibiruChain/nibiru-wasm
repositoryhttps://github.com/NibiruChain/nibiru-wasm
max_upload_size
id1296123
size26,345
Matthias (matthiasmatt)

documentation

README

nibiru-ownable-derive

Macros for generating code used by the nibiru-ownable crate.

nibiru-ownable-derive provides procedural macros that automatically inject ownership-related message variants into your CosmWasm contract's ExecuteMsg and QueryMsg enums, eliminating boilerplate code.

Macros

#[ownable_execute]

Adds an UpdateOwnership(nibiru_ownable::Action) variant to your ExecuteMsg enum:

use cosmwasm_schema::cw_serde;
use nibiru_ownable::ownable_execute;

#[ownable_execute]  // Must be applied before #[cw_serde]
#[cw_serde]
enum ExecuteMsg {
    Foo {},
    Bar {},
}

Expands to:

#[cw_serde]
enum ExecuteMsg {
    UpdateOwnership(::nibiru_ownable::Action),
    Foo {},
    Bar {},
}

#[ownable_query]

Adds an Ownership {} variant to your QueryMsg enum:

use cosmwasm_schema::{cw_serde, QueryResponses};
use nibiru_ownable::ownable_query;

#[ownable_query]  // Must be applied before #[cw_serde]
#[cw_serde]
#[derive(QueryResponses)]
enum QueryMsg {
    #[returns(FooResponse)]
    Foo {},
}

Expands to:

#[cw_serde]
#[derive(QueryResponses)]
enum QueryMsg {
    #[returns(::nibiru_ownable::Ownership<String>)]
    Ownership {},
    #[returns(FooResponse)]
    Foo {},
}

Usage

Add both crates to your Cargo.toml:

[dependencies]
nibiru-ownable = "0.6.0"
nibiru-ownable-derive = "0.6.0"

Import the macros from nibiru-ownable (they are re-exported):

use nibiru_ownable::{ownable_execute, ownable_query};

Documentation

For detailed API documentation, visit docs.rs/nibiru-ownable-derive.

License

Contents of this crate at or prior to version 0.5.0 are published under GNU Affero General Public License v3 or later; contents after the said version are published under Apache-2.0 license.

Commit count: 379

cargo fmt