tg4-group

Crates.iotg4-group
lib.rstg4-group
version0.17.1
sourcesrc
created_at2022-02-16 11:55:12.395537
updated_at2023-01-26 12:24:49.43601
descriptionSimple tg4 implementation of group membership controlled by admin
homepagehttps://cosmwasm.com
repositoryhttps://github.com/confio/poe-contracts
max_upload_size
id533286
size48,665
Developers (github:confio:developers)

documentation

https://docs.cosmwasm.com

README

TG4 Group

This is a basic implementation of the tg4 spec. It fulfills all elements of the spec, including the raw query lookups, and it is designed to be used as a backing storage for tg3 compliant contracts.

It stores a set of members along with an admin, and allows the admin to update the state. Raw queries (intended for cross-contract queries) can check a given member address and the total points. Smart queries (designed for client API) can do the same, and also query the admin address as well as paginate over all members.

Init

To create it, you must pass in a list of members, as well as an optional admin, if you wish it to be mutable.

pub struct InitMsg {
    pub admin: Option<HumanAddr>,
    pub members: Vec<Member>,
}

pub struct Member {
    pub addr: HumanAddr,
    pub points: u64,
    pub start_height: Option<u64>
}

Members are defined by an address, a number of points and an optional start height. This is transformed and stored under their Addr, in a format defined in tg4 raw queries.

Note that 0 is an allowed number of points. This doesn't give any voting rights, but it does define this address is part of the group. This could be used in e.g. a KYC whitelist to say they are allowed, but cannot participate in decision-making.

Messages

Basic update messages, queries, and hooks are defined by the tg4 spec. Please refer to it for more info.

tg4-group adds one message to control the group membership:

UpdateMembers{add, remove} - takes a membership diff and adds/updates the members, as well as removing any provided addresses. If an address is on both lists, it will be removed. If it appears multiple times in add, only the last occurrence will be used.

Commit count: 698

cargo fmt