1package rbac23const zeroAddress = address("")45// Role represents a role with a name and an assigned address.6type Role struct {7 // name represents the role's identifier8 name string9 address address10}1112// NewRole creates a new Role instance with roleName.13//14// Parameters:15// - roleName: Role identifier stored in the new Role without normalization.16// - addr: Address stored as the role's initial assignment without validation.17//18// Returns:19// - *Role: New role containing roleName and its initially assigned addr.20func NewRole(roleName string, addr address) *Role {21 return &Role{22 name: roleName,23 address: addr,24 }25}2627// Name returns the role's name.28//29// Returns:30// - string: Role identifier stored in the Role.31func (r *Role) Name() string { return r.name }3233// Address returns the address assigned to this role. Returns empty address if no address is assigned.34//35// Returns:36// - address: Address currently assigned to the role, or the empty address when unassigned.37func (r *Role) Address() address {38 return r.address39}4041// IsEmpty returns true if no address is assigned to this role.42//43// Returns:44// - bool: true when the stored role address equals the empty address; false when an address is assigned.45func (r *Role) IsEmpty() bool {46 return r.Address() == zeroAddress47}4849// IsAuthorized returns true if addr matches the role's assigned address.50//51// Parameters:52// - addr: Address to compare with the role's stored assignment.53//54// Returns:55// - bool: true when addr exactly equals the assigned address; false otherwise.56func (r *Role) IsAuthorized(addr address) bool {57 return r.Address() == addr58}5960// setAddress assigns addr to this role.61func (r *Role) setAddress(addr address) {62 r.address = addr63}64Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.