3 releases (stable)

new 2.0.0-rc Apr 25, 2024
1.4.0 Apr 15, 2024
1.3.0 Feb 5, 2024
1.2.2 Jan 24, 2024

#2051 in Magic Beans

Download history 347/week @ 2024-01-23 257/week @ 2024-01-30 607/week @ 2024-02-06 933/week @ 2024-02-13 506/week @ 2024-02-20 405/week @ 2024-02-27 604/week @ 2024-03-05 582/week @ 2024-03-12 432/week @ 2024-03-19 369/week @ 2024-03-26 621/week @ 2024-04-02 509/week @ 2024-04-09 641/week @ 2024-04-16

2,230 downloads per month
Used in 3 crates (2 directly)

Apache-2.0 and GPL-3.0-only

60KB
1K SLoC

CW4 Group

This is a basic implementation of the cw4 spec. It fulfills all elements of the spec, including the raw query lookups, and it designed to be used as a backing storage for cw3 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 weight. 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 weight: u64,
}

Members are defined by an address and a weight. This is transformed and stored under their CanonicalAddr, in a format defined in cw4 raw queries.

Note that 0 is an allowed weight. 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 cw4 spec. Please refer to it for more info.

cw4-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.

Dependencies

~4–16MB
~200K SLoC