Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add multi-owner cw-ownable with cosmwasm v2 #25

Merged
merged 7 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ A collection of [CosmWasm][1] utilities and helper libraries.
| [cw-address-like][2] | v1.0.4 | A trait that marks unchecked or checked address strings |
| [cw-item-set][3] | v0.7.1 | Set of non-duplicate items for storage |
| [cw-optional-indexes][4] | v0.1.1 | Index types for `IndexedMap` where an item may or may not have an index |
| [cw-ownable][5] | v0.5.1 | Utility for controlling contract ownership |
| [cw-ownable][5] | v0.6.0 | Utility for controlling contract ownership |
| [cw-paginate][6] | v0.2.1 | Helper function for interating maps |

## License
Expand Down
2 changes: 1 addition & 1 deletion packages/optional-indexes/src/unique.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct OptionalUniqueIndex<IK, T, PK = ()> {
phantom: PhantomData<PK>,
}

impl<'a, IK, T, PK> OptionalUniqueIndex<IK, T, PK> {
impl<IK, T, PK> OptionalUniqueIndex<IK, T, PK> {
pub const fn new(idx_fn: fn(&T) -> Option<IK>, idx_namespace: &'static str) -> Self {
Self {
index: idx_fn,
Expand Down
10 changes: 10 additions & 0 deletions packages/ownable/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,16 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
}
```

You can use ownership for other purposes:

```rust
use cw_ownable::OwnershipStore;

pub const CREATOR: OwnershipStore = OwnershipStore::new("creator");
```

`CREATOR` has all functions in place: `initialize_owner`, `is_owner`, `assert_owner`, and `get_ownership`.

## License

Contents of this crate at or prior to version `0.5.0` are published under [GNU Affero General Public License v3](https://github.com/steak-enjoyers/cw-plus-plus/blob/9c8fcf1c95b74dd415caf5602068c558e9d16ecc/LICENSE) or later; contents after the said version are published under [Apache-2.0](../../LICENSE) license.
8 changes: 5 additions & 3 deletions packages/ownable/derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ fn merge_variants(metadata: TokenStream, left: TokenStream, right: TokenStream)
let Enum(DataEnum {
variants,
..
}) = &mut left.data else {
}) = &mut left.data
else {
return syn::Error::new(left.ident.span(), "only enums can accept variants")
.to_compile_error()
.into();
Expand All @@ -33,14 +34,15 @@ fn merge_variants(metadata: TokenStream, left: TokenStream, right: TokenStream)
let Enum(DataEnum {
variants: to_add,
..
}) = right.data else {
}) = right.data
else {
return syn::Error::new(left.ident.span(), "only enums can provide variants")
.to_compile_error()
.into();
};

// insert variants from the right to the left
variants.extend(to_add.into_iter());
variants.extend(to_add);

quote! { #left }.into()
}
Expand Down
Loading