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

daoauth source pure

Package daoauth writes the arguments of a governed action as one typed, canonical string. memba\_gov stores that stri...

Overview

Package daoauth writes the arguments of a governed action as one typed, canonical string. memba_gov stores that string with the proposal and the target realm rebuilds it from its real arguments when it consumes the approval: the two must be equal byte for byte. Each value has exactly one spelling, so equal actions always encode to equal strings.

Fields are joined by "|":

Example
1u:<uint64>        decimal, no sign, no leading zero
2i:<int64>         decimal, "-" only when negative, no leading zero
3b:0 or b:1        bool
4a:<address>       the lowercase bech32 text the chain gives a caller
5s:<len>:<text>    length-prefixed printable ASCII (0x20-0x7E)

Strings are compared as raw bytes, with no Unicode normalisation; text is printable ASCII so that what a voter reads is exactly what executes.

Constants 1

const MaxArgs, MaxText

1const (
2	MaxArgs = 1024 // bytes of one encoded argument string
3	MaxText = 512  // bytes of one string field
4)
source

Variables 1

var ErrSyntax, ErrAddress, ErrText, ErrLength

1var (
2	ErrSyntax  = errors.New("daoauth: malformed argument string")
3	ErrAddress = errors.New("daoauth: address is not lowercase bech32")
4	ErrText    = errors.New("daoauth: text must be printable ASCII of at most 512 bytes")
5	ErrLength  = errors.New("daoauth: arguments exceed 1024 bytes")
6)
source

Functions 4

func ValidAddress

1func ValidAddress(a address) bool
source

ValidAddress reports whether a is "g1" and 38 lowercase bech32 characters whose checksum is the original bech32 one.

func ValidText

1func ValidText(s string) bool
source

ValidText reports whether s is at most MaxText bytes of printable ASCII (0x20 to 0x7E): no control, invisible, combining or direction-changing character can make a value read differently from what executes.

func Parse

1func Parse(s string) ([]Field, error)
source

Parse decodes s and refuses any text that is not the canonical encoding of its own fields. The empty string is the encoding of no fields.

Types 2

type Args

struct
1type Args struct{ fields []string }
source

Args accumulates fields in order. Methods panic on a value that has no canonical form, so a realm can never build an approval nobody can match.

Methods on Args

func Addr

method on Args
1func (a *Args) Addr(v address) *Args
source

func Bool

method on Args
1func (a *Args) Bool(v bool) *Args
source

func Int

method on Args
1func (a *Args) Int(v int64) *Args
source

func Str

method on Args
1func (a *Args) Str(v string) *Args
source

func String

method on Args
1func (a *Args) String() string
source

String returns the encoding. It panics past MaxArgs.

func Uint

method on Args
1func (a *Args) Uint(v uint64) *Args
source

type Field

struct
1type Field struct {
2	Tag   byte
3	Value string
4}
source

Field is one decoded value: Tag is 'u', 'i', 'b', 'a' or 's', and Value is its text, without the length prefix for strings.

Imports 3

  • errors stdlib
  • strconv stdlib
  • strings stdlib

Source Files 2