47 releases (6 stable)

2.0.0 Mar 26, 2024
1.1.2 Nov 23, 2023
1.1.0 Jun 20, 2023
1.0.1 Dec 19, 2022
0.4.0 Dec 22, 2020

#1221 in Magic Beans

Download history 384/week @ 2023-12-18 119/week @ 2023-12-25 212/week @ 2024-01-01 212/week @ 2024-01-08 86/week @ 2024-01-15 175/week @ 2024-01-22 255/week @ 2024-01-29 339/week @ 2024-02-05 177/week @ 2024-02-12 188/week @ 2024-02-19 198/week @ 2024-02-26 187/week @ 2024-03-04 241/week @ 2024-03-11 457/week @ 2024-03-18 585/week @ 2024-03-25 1078/week @ 2024-04-01

2,390 downloads per month
Used in 12 crates (8 directly)

Apache-2.0

49KB
901 lines

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–5.5MB
~121K SLoC