Skip to main content

Module roles

Module roles 

Source
Expand description

CORD-04 Roles: v2 wire content for the Role (vsk 1), Grant (vsk 3), and Banlist (vsk 4) control entities.

The authority ALGEBRA is shared, not copied: these types convert to/from crate::community::roles’s Role/MemberGrant/Permissions, and the fold feeds the shared authorize_delegation + is_authorized. Only the SERIALIZATION is v2-native, because CORD-04 §3 rides permissions as a decimal STRING (the shared Permissions serializes as a bare u64 for v1’s storage), and a reader MUST accept either form (a number from an older edition, a string henceforth) and always write the string.

Structs§

GrantContent
CORD-04 §2 Grant content (vsk 3), eid == grant_locator(community_id, member). Empty role_ids is a revoke.
RoleContent
CORD-04 §2 Role content (vsk 1), eid == role_id. permissions rides as a decimal string (§3); unknown fields round-trip (CORD-02 §6).

Constants§

MAX_BANLIST
MAX_ROLES_PER_COMMUNITY
MAX_ROLES_PER_MEMBER
A member holds at most this many Roles (CORD-04 §2); a Community folds at most MAX_ROLES_PER_COMMUNITY Roles (the lowest role_ids win, the same deterministic cap the member list uses). A Banlist edition holds at most MAX_BANLIST npubs (the practical NIP-44-envelope ceiling, CORD-04 §4).
MAX_ROLE_NAME_BYTES
A role name shares the protocol-wide 64-byte cap (CORD-04 §2/§3).

Functions§

banlist_content_json
Serialize a banlist to its CORD-04 §4 wire JSON (a flat array of lowercase-hex npubs, replaced entire on every edit).
grant_content_json
Serialize a Grant’s content to its CORD-04 §2 wire JSON.
parse_banlist_content
Parse a vsk-4 edition’s content into the banned set (lowercase hex). Non-array or malformed content yields None (dropped, never a partial ban).
parse_grant_content
Parse a vsk-3 edition’s content into a shared MemberGrant.
parse_role_content
Parse a vsk-1 edition’s content into a shared Role. Accepts permissions as a string or a legacy number.
role_content_json
Serialize a Role’s content to its CORD-04 §2 wire JSON (permissions as a string).
validate_banlist
A Banlist edition fits its ceiling (CORD-04 §4): refuse an over-cap edit rather than publish one a strict reader drops.
validate_role
A Role’s content byte-fits its cap discipline: name ≤ 64 bytes. (The 100-per- community and 64-per-member caps are fold-side, applied on read.)