CW Ownable

Utility for controlling ownership of CosmWasm smart contracts.

How to use

Use the #[cw_ownable] macro to define your execute message:

```rust use cosmwasmschema::cwserde; use cwownable::{cwownable, Expiration};

[cw_ownable]

[cw_serde]

enum ExecuteMsg { Foo {}, Bar {}, } ```

The macro inserts three variants, {Transfer,Accept,Renounce}Ownership to the enum:

```rust

[cw_serde]

enum ExecuteMsg { TransferOwnership { new_owner: String, expiry: Option, }, AcceptOwnership {}, RenounceOwnership {}, Foo {}, Bar {}, } ```

Handle the messages using the functions provided by this crate:

```rust use cosmwasmstd::{entrypoint, DepsMut, Env, MessageInfo, Response}; use cwownable::{cwserde, OwnershipError};

[entry_point]

pub fn execute( deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg, ) -> Result { match msg { ExecuteMsg::TransferOwnership { newowner, expiry, } => { cwownable::transferownership(deps, &info.sender, &newowner, expiry)?; }, ExecuteMsg::AcceptOwnership {} => { cwownable::acceptownership(deps.storage, &env.block, info.sender)?; }, ExecuteMsg::RenounceOwnership {} => { cwownable::renounceownership(deps.storage, &info.sender)?; }, _ => unimplemneted!(), } Ok(Response::new()) } ```

License

Contents of this crate are open source under GNU Affero General Public License v3 or later.