Crates.io | cw721-roles |
lib.rs | cw721-roles |
version | 2.6.0 |
source | src |
created_at | 2023-10-18 20:23:09.348671 |
updated_at | 2024-11-07 23:59:28.712869 |
description | Non-transferable CW721 NFT contract that incorporates voting weights and on-chain roles. |
homepage | |
repository | https://github.com/DA0-DA0/dao-contracts |
max_upload_size | |
id | 1007162 |
size | 132,644 |
This is a non-transferable NFT contract intended for use with DAOs. cw721-roles
has an extension that allows for each NFT to have a weight
associated with it, and also implements much of the functionality behind the cw4-group contract (credit to Confio for their work on that).
All methods of this contract are only callable via the configurable minter
when the contract is created. It is primarily intended for use with DAOs.
The mint
, burn
, send
, and transfer
methods have all been overriden from their default cw721-base
versions, but work roughly the same with the caveat being they are only callable via the minter
. All methods related to approvals are unsupported.
cw721-roles
contains the following extensions:
Token metadata has been extended with a weight and an optional human readable on-chain role which may be used in separate contracts for enforcing additional permissions.
pub struct MetadataExt {
/// Optional on-chain role for this member, can be used by other contracts to enforce permissions
pub role: Option<String>,
/// The voting weight of this role
pub weight: u64,
}
The contract has an additional execution extension that includes the ability to add and remove hooks for membership change events, as well as update a particular token's token_uri
, weight
, and role
. All of these are only callable by the configured minter
.
pub enum ExecuteExt {
/// Add a new hook to be informed of all membership changes.
/// Must be called by Admin
AddHook { addr: String },
/// Remove a hook. Must be called by Admin
RemoveHook { addr: String },
/// Update the token_uri for a particular NFT. Must be called by minter / admin
UpdateTokenUri {
token_id: String,
token_uri: Option<String>,
},
/// Updates the voting weight of a token. Must be called by minter / admin
UpdateTokenWeight { token_id: String, weight: u64 },
/// Udates the role of a token. Must be called by minter / admin
UpdateTokenRole {
token_id: String,
role: Option<String>,
},
}
The query extension implements queries that are compatible with the previously mentioned cw4-group contract.
pub enum QueryExt {
/// Total weight at a given height
#[returns(cw4::TotalWeightResponse)]
TotalWeight { at_height: Option<u64> },
/// Returns the weight of a certain member
#[returns(cw4::MemberResponse)]
Member {
addr: String,
at_height: Option<u64>,
},
/// Shows all registered hooks.
#[returns(cw_controllers::HooksResponse)]
Hooks {},
}