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

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

v1 source pure

Package core holds the shared Remix Lab contracts: error categories, roles, inert view records and the small read int...

Overview

Package core holds the shared Remix Lab contracts: error categories, roles, inert view records and the small read interfaces that blocks and adapters implement.

Nothing in this package holds state. View records are plain values that never alias a block's internal storage, so returning them from a realm does not hand out mutation capability.

Constants 5

const ViewSchemaVersion

1const ViewSchemaVersion = 1
source

ViewSchemaVersion is the version of the view/action shapes defined here. Bump it whenever an exported view struct changes shape.

Variables 1

var ErrUnauthorized, ErrNotFound, ErrInvalidInput, ErrLimitExceeded, ErrInvalidState, ErrConflict

1var (
2	ErrUnauthorized  = errors.New("remix: unauthorized")
3	ErrNotFound      = errors.New("remix: not found")
4	ErrInvalidInput  = errors.New("remix: invalid input")
5	ErrLimitExceeded = errors.New("remix: limit exceeded")
6	ErrInvalidState  = errors.New("remix: invalid state")
7	ErrConflict      = errors.New("remix: conflict")
8)
source

Error categories. Blocks wrap these so that clients can classify failures by prefix without parsing free-form text.

Functions 5

func CheckText

1func CheckText(field, s string, minBytes, maxBytes int, multiline bool) error
source

CheckText validates user-supplied text: valid UTF-8, between minBytes and maxBytes long, not blank when minBytes > 0, and free of control characters (other than newline when multiline is set) and of invisible or direction-changing format characters (see IsHiddenFormat). It does not escape; rendering is the render block's job.

func Errorf

1func Errorf(category error, detail string) error
source

Errorf returns an error whose message starts with the category's message, e.g. "remix: invalid input: title is empty".

func Is

1func Is(err, category error) bool
source

Is reports whether err belongs to category.

func IsHiddenFormat

1func IsHiddenFormat(r rune) bool
source

IsHiddenFormat reports whether r is an invisible or direction-changing format character that could make text display differently from its content: soft hyphen, Arabic letter mark, Mongolian vowel separator, zero-width space, LRM/RLM, bidi embeddings, overrides and isolates, invisible operators, the byte order mark and interlinear annotations. ZWNJ and ZWJ (U+200C, U+200D) are allowed because several scripts and emoji sequences need them.

func ParseRole

1func ParseRole(s string) (Role, error)
source

ParseRole converts the canonical role name to a Role.

Types 12

type AppDescriptor

struct
1type AppDescriptor struct {
2	Recipe            string
3	RecipeVersion     string
4	Components        []string // "<component-id>@<catalog-version>"
5	ConfigDigest      string
6	ViewSchemaVersion int
7	Bindings          []string // "<interface>=<pkgpath>"
8}
source

AppDescriptor identifies how a realm was composed. Generated realms expose one so the Lab can show an app's ingredients from the chain itself.

type AuthorizationPolicy

interface
1type AuthorizationPolicy interface {
2	Authorize(op string, actor address) error
3}
source

AuthorizationPolicy decides whether an authenticated actor may perform a named operation. The actor must come from the realm's authenticated context, never from a caller-supplied argument.

type BallotOutcome

ident
1type BallotOutcome int
source

BallotOutcome is the committed result of a finalized ballot.

Methods on BallotOutcome

func String

method on BallotOutcome
1func (o BallotOutcome) String() string
source

type BallotReader

interface
1type BallotReader interface {
2	Ballot(id uint64) (BallotView, bool)
3}
source

BallotReader is the read side of a ballot box.

type BallotStatus

ident
1type BallotStatus int
source

BallotStatus is the lifecycle stage of a ballot.

Methods on BallotStatus

func String

method on BallotStatus
1func (s BallotStatus) String() string
source

type BallotView

struct
 1type BallotView struct {
 2	ID             uint64
 3	Title          string
 4	Options        []string
 5	Status         BallotStatus
 6	Public         bool  // anyone may vote; no electorate snapshot
 7	ElectorateSize int   // 0 for public ballots
 8	QuorumPercent  int   // of the captured electorate
 9	OpenedAt       int64 // unix seconds, 0 while draft
10	Deadline       int64 // unix seconds, 0 while draft
11	Counts         []int // per option, same order as Options
12	Abstentions    int
13	Turnout        int // ballots cast, including abstentions
14	Outcome        BallotOutcome
15	Winner         int // option index when Outcome == OutcomeWinner, else -1
16}
source

BallotView is an inert summary of a ballot and its current tally.

type MemberView

struct
1type MemberView struct {
2	Address address
3	Role    Role
4}
source

MemberView is an inert membership record.

type MembershipReader

interface
 1type MembershipReader interface {
 2	// RoleOf returns addr's role, RoleNone for non-members.
 3	RoleOf(addr address) Role
 4	// Size returns the number of members.
 5	Size() int
 6	// Snapshot returns every member whose role is at least minRole, in a
 7	// stable order. ok is false (and the slice nil) when more than max
 8	// members qualify, so callers never act on a truncated electorate.
 9	// A negative max or an invalid minRole also yields (nil, false).
10	Snapshot(minRole Role, max int) (addrs []address, ok bool)
11}
source

MembershipReader is the read side of a membership set, implemented by the membership block and by adapters to shared membership realms.

type Role

ident
1type Role int
source

Role is an address's standing inside a membership set. Roles are ordered: a higher role satisfies any requirement for a lower one.

Methods on Role

func AtLeast

method on Role
1func (r Role) AtLeast(min Role) bool
source

AtLeast reports whether r satisfies a requirement of min.

func String

method on Role
1func (r Role) String() string
source

func Valid

method on Role
1func (r Role) Valid() bool
source

Valid reports whether r is one of the defined roles.

type SubmissionReader

interface
1type SubmissionReader interface {
2	Submission(id uint64) (SubmissionView, bool)
3	// Submissions pages through submissions, optionally filtered by status
4	// (pass -1 for all), in submission order.
5	Submissions(status int, offset, limit int) []SubmissionView
6	Count() int
7}
source

SubmissionReader is the read side of a form.

type SubmissionStatus

ident
1type SubmissionStatus int
source

SubmissionStatus is the review state of a form submission.

Methods on SubmissionStatus

func String

method on SubmissionStatus
1func (s SubmissionStatus) String() string
source

type SubmissionView

struct
1type SubmissionView struct {
2	ID        uint64
3	Submitter address
4	Answers   []string // in form field order
5	Status    SubmissionStatus
6}
source

SubmissionView is an inert copy of a submission.

Dependencies

Imports 3

/p/g1lnkytfqcjwllws63gvf0mv9yt04aswy4y9amhm/remixlab/core/v1

Imported by indexer

Source Files 3