Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

member.gno

0.76 Kb · 33 lines
 1package hub
 2
 3import (
 4	"gno.land/p/gnoland/boards"
 5)
 6
 7// Member defines a safe type for board members.
 8type Member struct {
 9	// address is the account address of the member.
10	address address
11
12	// roles contains the names of the roles assigned to the member.
13	roles []string
14}
15
16// Address returns the account address of the member.
17func (m Member) Address() address { return m.address }
18
19// Roles returns the names of the roles assigned to the member.
20func (m Member) Roles() []string { return append([]string(nil), m.roles...) }
21
22// NewSafeMember creates a safe board member.
23func NewSafeMember(ref boards.User) Member {
24	roles := make([]string, len(ref.Roles))
25	for i, r := range ref.Roles {
26		roles[i] = string(r)
27	}
28
29	return Member{
30		address: ref.Address,
31		roles:   roles,
32	}
33}