util

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2022 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AddressEmpty = Address{}
View Source
var DataIDEmpty = DataID{}
View Source
var DecMode, _ = DecOpts.DecMode()
View Source
var DecOpts = cbor.DecOptions{
	DupMapKey:        cbor.DupMapKeyQuiet,
	IndefLength:      cbor.IndefLengthForbidden,
	MaxArrayElements: 100_000,
	MaxMapPairs:      1_000_000,
	UTF8:             cbor.UTF8DecodeInvalid,
}
View Source
var EncMode, _ = EncOpts.EncMode()
View Source
var EncOpts = cbor.EncOptions{
	Sort:          cbor.SortLengthFirst,
	Time:          cbor.TimeRFC3339Nano,
	ShortestFloat: cbor.ShortestFloat16,
	NaNConvert:    cbor.NaNConvert7e00,
	InfConvert:    cbor.InfConvertFloat16,
	IndefLength:   cbor.IndefLengthForbidden,
	BigIntConvert: cbor.BigIntConvertNone,
}
View Source
var HashEmpty = Hash{}
View Source
var ModelIDEmpty = ModelID{}
View Source
var NativeToken = TokenSymbol{}
View Source
var StakeEmpty = StakeSymbol{}

Functions

func CheckSumHex

func CheckSumHex(data []byte) string

func DecodeQuoteString

func DecodeQuoteString(str string) ([]byte, error)

func DecodeQuoteStringWithLen

func DecodeQuoteStringWithLen(str string, expectedLen int) ([]byte, error)

func DecodeString

func DecodeString(str string) ([]byte, error)

DecodeString [str] to bytes from raw base64url.

func DecodeStringWithLen

func DecodeStringWithLen(str string, expectedLen int) ([]byte, error)

func EncodeToQuoteString

func EncodeToQuoteString(bytes []byte) string

func EncodeToString

func EncodeToString(bytes []byte) string

EncodeToString bytes to a string using raw base64url format.

func MarshalCBOR

func MarshalCBOR(v interface{}) ([]byte, error)

func MarshalJSONData

func MarshalJSONData(data []byte) json.RawMessage

func MustMarshalCBOR

func MustMarshalCBOR(v interface{}) []byte

func Sum256

func Sum256(msg []byte) []byte

Sum256 returns the SHA3-256 digest of the data.

func UnmarshalCBOR

func UnmarshalCBOR(data []byte, v interface{}) error

func UnmarshalCBORWithLen

func UnmarshalCBORWithLen(data []byte, expectedLen int) ([]byte, error)

func UnmarshalJSONData

func UnmarshalJSONData(data json.RawMessage) []byte

func ValidCBOR

func ValidCBOR(data []byte) error
func ValidLink(link string) bool

func ValidMessage

func ValidMessage(msg string) bool

func ValidName

func ValidName(name string) bool

Types

type Address

type Address [20]byte

Address ==========

func AddressFrom

func AddressFrom(str string) (Address, error)

func (Address) AsKey

func (id Address) AsKey() string

func (Address) Bytes

func (id Address) Bytes() []byte

func (Address) GoString

func (id Address) GoString() string

func (Address) MarshalCBOR

func (id Address) MarshalCBOR() ([]byte, error)

func (Address) MarshalJSON

func (id Address) MarshalJSON() ([]byte, error)

func (Address) MarshalText

func (id Address) MarshalText() ([]byte, error)

func (Address) Ptr

func (id Address) Ptr() *Address

func (Address) String

func (id Address) String() string

func (Address) ToStakeSymbol

func (id Address) ToStakeSymbol() (s StakeSymbol)

func (*Address) UnmarshalCBOR

func (id *Address) UnmarshalCBOR(data []byte) error

func (*Address) UnmarshalJSON

func (id *Address) UnmarshalJSON(b []byte) error

func (*Address) UnmarshalText

func (id *Address) UnmarshalText(b []byte) error

func (Address) Valid

func (id Address) Valid() bool

type DataID

type DataID [32]byte

DataID ==========

func DataIDFrom

func DataIDFrom(str string) (DataID, error)

func (DataID) Bytes

func (id DataID) Bytes() []byte

func (DataID) GoString

func (id DataID) GoString() string

func (DataID) MarshalCBOR

func (id DataID) MarshalCBOR() ([]byte, error)

func (DataID) MarshalJSON

func (id DataID) MarshalJSON() ([]byte, error)

func (DataID) MarshalText

func (id DataID) MarshalText() ([]byte, error)

func (DataID) String

func (id DataID) String() string

func (*DataID) UnmarshalCBOR

func (id *DataID) UnmarshalCBOR(data []byte) error

func (*DataID) UnmarshalJSON

func (id *DataID) UnmarshalJSON(b []byte) error

func (*DataID) UnmarshalText

func (id *DataID) UnmarshalText(b []byte) error

func (DataID) Valid

func (id DataID) Valid() bool

func (DataID) VersionKey

func (id DataID) VersionKey(version uint64) []byte

type ErrPrefix

type ErrPrefix string

func (ErrPrefix) ErrorIf

func (p ErrPrefix) ErrorIf(err error) error

func (ErrPrefix) ErrorMap

func (p ErrPrefix) ErrorMap(data []byte, err error) ([]byte, error)

func (ErrPrefix) Errorf

func (p ErrPrefix) Errorf(format string, a ...any) error

type Hash

type Hash [32]byte

Hash ==========

func HashFrom

func HashFrom(str string) (Hash, error)

func HashFromBytes

func HashFromBytes(data []byte) (Hash, error)

func HashFromData

func HashFromData(data []byte) Hash

func (Hash) Bytes

func (id Hash) Bytes() []byte

func (Hash) GoString

func (id Hash) GoString() string

func (Hash) MarshalCBOR

func (id Hash) MarshalCBOR() ([]byte, error)

func (Hash) MarshalJSON

func (id Hash) MarshalJSON() ([]byte, error)

func (Hash) MarshalText

func (id Hash) MarshalText() ([]byte, error)

func (Hash) String

func (id Hash) String() string

func (*Hash) UnmarshalCBOR

func (id *Hash) UnmarshalCBOR(data []byte) error

func (*Hash) UnmarshalJSON

func (id *Hash) UnmarshalJSON(b []byte) error

func (*Hash) UnmarshalText

func (id *Hash) UnmarshalText(b []byte) error

func (Hash) Valid

func (id Hash) Valid() bool

type IDList

type IDList[T IDg] []T

func AddressToStakeSymbol

func AddressToStakeSymbol(ids ...Address) IDList[StakeSymbol]

func NewIDList

func NewIDList[T IDg](cap int) IDList[T]

func (IDList[T]) CheckDuplicate

func (list IDList[T]) CheckDuplicate() error

func (IDList[T]) CheckValid

func (list IDList[T]) CheckValid() error

func (IDList[T]) Equal

func (list IDList[T]) Equal(target IDList[T]) bool

func (IDList[T]) Has

func (list IDList[T]) Has(id T) bool

func (IDList[T]) Valid

func (list IDList[T]) Valid() error

type IDg

type IDg interface {
	~[20]byte | ~[32]byte

	String() string
	Valid() bool
}

type ModelID

type ModelID [20]byte

ModelID ==========

func ModelIDFrom

func ModelIDFrom(str string) (ModelID, error)

func ModelIDFromHash

func ModelIDFromHash(id Hash) ModelID

func (ModelID) Bytes

func (id ModelID) Bytes() []byte

func (ModelID) GoString

func (id ModelID) GoString() string

func (ModelID) MarshalCBOR

func (id ModelID) MarshalCBOR() ([]byte, error)

func (ModelID) MarshalJSON

func (id ModelID) MarshalJSON() ([]byte, error)

func (ModelID) MarshalText

func (id ModelID) MarshalText() ([]byte, error)

func (ModelID) String

func (id ModelID) String() string

func (*ModelID) UnmarshalCBOR

func (id *ModelID) UnmarshalCBOR(data []byte) error

func (*ModelID) UnmarshalJSON

func (id *ModelID) UnmarshalJSON(b []byte) error

func (*ModelID) UnmarshalText

func (id *ModelID) UnmarshalText(b []byte) error

func (ModelID) Valid

func (id ModelID) Valid() bool

type RawData

type RawData []byte

func (RawData) MarshalJSON

func (r RawData) MarshalJSON() ([]byte, error)

func (*RawData) UnmarshalJSON

func (r *RawData) UnmarshalJSON(b []byte) error

type Set

type Set[T ordered] map[T]struct{}

func NewSet

func NewSet[T ordered](cap int) Set[T]

func (Set[T]) Add

func (s Set[T]) Add(vv ...T)

func (Set[T]) Has

func (s Set[T]) Has(v T) bool

func (Set[T]) List

func (s Set[T]) List() []T

type StakeSymbol

type StakeSymbol [20]byte

StakeSymbol

func StakeFrom

func StakeFrom(s string) (StakeSymbol, error)

func (StakeSymbol) Address

func (id StakeSymbol) Address() Address

func (StakeSymbol) Bytes

func (id StakeSymbol) Bytes() []byte

func (StakeSymbol) GoString

func (id StakeSymbol) GoString() string

func (StakeSymbol) MarshalCBOR

func (id StakeSymbol) MarshalCBOR() ([]byte, error)

func (StakeSymbol) MarshalJSON

func (id StakeSymbol) MarshalJSON() ([]byte, error)

func (StakeSymbol) MarshalText

func (id StakeSymbol) MarshalText() ([]byte, error)

func (StakeSymbol) Ptr

func (id StakeSymbol) Ptr() *StakeSymbol

func (StakeSymbol) String

func (id StakeSymbol) String() string

func (*StakeSymbol) UnmarshalCBOR

func (id *StakeSymbol) UnmarshalCBOR(data []byte) error

func (*StakeSymbol) UnmarshalJSON

func (id *StakeSymbol) UnmarshalJSON(b []byte) error

func (*StakeSymbol) UnmarshalText

func (id *StakeSymbol) UnmarshalText(b []byte) error

func (StakeSymbol) Valid

func (id StakeSymbol) Valid() bool

type TokenSymbol

type TokenSymbol [20]byte

TokenSymbol

func TokenFrom

func TokenFrom(s string) (TokenSymbol, error)

func (TokenSymbol) Address

func (id TokenSymbol) Address() Address

func (TokenSymbol) AsKey

func (id TokenSymbol) AsKey() string

func (TokenSymbol) Bytes

func (id TokenSymbol) Bytes() []byte

func (TokenSymbol) GoString

func (id TokenSymbol) GoString() string

func (TokenSymbol) MarshalCBOR

func (id TokenSymbol) MarshalCBOR() ([]byte, error)

func (TokenSymbol) MarshalJSON

func (id TokenSymbol) MarshalJSON() ([]byte, error)

func (TokenSymbol) MarshalText

func (id TokenSymbol) MarshalText() ([]byte, error)

func (TokenSymbol) Ptr

func (id TokenSymbol) Ptr() *TokenSymbol

func (TokenSymbol) String

func (id TokenSymbol) String() string

func (*TokenSymbol) UnmarshalCBOR

func (id *TokenSymbol) UnmarshalCBOR(data []byte) error

func (*TokenSymbol) UnmarshalJSON

func (id *TokenSymbol) UnmarshalJSON(b []byte) error

func (*TokenSymbol) UnmarshalText

func (id *TokenSymbol) UnmarshalText(b []byte) error

func (TokenSymbol) Valid

func (id TokenSymbol) Valid() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL