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

v0 source pure

Package role is a role held by one address and passed in two steps (offer, accept), which its holder can cancel or re...

Overview

Package role is a role held by one address and passed in two steps (offer, accept), which its holder can cancel or renounce. A Role is pinned to the realm that made it (its home): every method that acts takes that realm's live cur and refuses any other value, so a *Role that leaked out of its realm can do nothing anywhere else.

Functions 4

func Canonical

1func Canonical(a address) bool
source

Canonical reports whether a is a valid address in its one canonical spelling, lower case. The chain also takes the upper-case bech32 of an account, but realms compare and key addresses as strings, so every address argument that is stored, compared or paid to goes through this.

func Upper

1func Upper(a address) bool
source

Upper reports whether a is spelled in upper case. Bech32 is all upper or all lower case (mixed case is not IsValid), and an address starts with its letter prefix "g", so the first byte tells: a scan of the 40 bytes costs far more gas, strings.ToLower more still.

func Adopt

1func Adopt(r *Role, name, h string, ok bool) *Role
source

Adopt is r once it agrees with the mirror h: unchanged without a mirror (!ok) or when r already holds it, nil when the mirror says renounced, else a new role named name for h, pinned to the calling realm (New).

func New

1func New(name string, holder address) *Role
source

New makes a role held by holder and pinned to the calling realm. Call it from the realm's init.

Types 1

type Role

struct
1type Role struct {
2	home    string  // the realm that made it, the only one it answers
3	name    string  // for events and messages ("owner", "guardian")
4	holder  address // "" once renounced
5	pending address // offered, "" if none
6}
source

Role is kept by its home realm in an unexported variable.

Methods on Role

func Accept

method on Role
1func (r *Role) Accept(_ int, rlm realm)
source

Accept takes the role offered to the caller.

func Holder

method on Role
1func (r *Role) Holder() address
source

Holder is who holds the role ("" once renounced).

func Is

method on Role
1func (r *Role) Is(_ int, rlm realm) bool
source

Is reports whether the immediate caller of the home realm holds the role.

func Must

method on Role
1func (r *Role) Must(_ int, rlm realm)
source

Must panics unless the immediate caller holds the role.

func Offer

method on Role
1func (r *Role) Offer(_ int, rlm realm, to address)
source

Offer offers the role to to. Offering it to the holder cancels an offer.

func Pending

method on Role
1func (r *Role) Pending() address
source

Pending is who was offered the role ("" if nobody).

func Renounce

method on Role
1func (r *Role) Renounce(_ int, rlm realm)
source

Renounce gives the role up for good.

Imports 2

  • chain stdlib
  • chain/runtime/unsafe stdlib

Source Files 2