chain

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2022 License: AGPL-3.0 Imports: 18 Imported by: 2

Documentation

Index

Constants

View Source
const (
	TimePointFormat    = "2006-01-02T15:04:05.000" // shared with BlockTimestamp
	TimePointSecFormat = "2006-01-02T15:04:05"
)

Variables

View Source
var ErrInvalidAssetString = errors.New("invalid asset string")

Functions

func NewCustomDecoder

func NewCustomDecoder(r io.Reader, fn abi.DecodeFunc) *abi.Decoder

func NewCustomEncoder

func NewCustomEncoder(w io.Writer, fn abi.EncodeFunc) *abi.Encoder

func NewDecoder

func NewDecoder(r io.Reader) *abi.Decoder

func NewEncoder

func NewEncoder(w io.Writer) *abi.Encoder

Types

type Abi

type Abi struct {
	Version          string            `json:"version"`
	Types            []AbiType         `json:"types"`
	Structs          []AbiStruct       `json:"structs"`
	Actions          []AbiAction       `json:"actions"`
	Tables           []AbiTable        `json:"tables"`
	RicardianClauses []AbiClause       `json:"ricardian_clauses"`
	ErrorMessages    []AbiErrorMessage `json:"error_messages,omitempty"`
	Extensions       []*AbiExtension   `json:"abi_extensions,omitempty"`
	Variants         []AbiVariant      `json:"variants,omitempty" eosio:"extension"`
}

EOSIO ABI definition, describes the binary representation of a collection of types.

func (Abi) Decode

func (a Abi) Decode(r io.Reader, name string) (interface{}, error)

func (Abi) DecodeAction

func (a Abi) DecodeAction(r io.Reader, name Name) (interface{}, error)

func (Abi) Encode

func (a Abi) Encode(w io.Writer, name string, v interface{}) error

func (Abi) EncodeAction

func (a Abi) EncodeAction(w io.Writer, name Name, v interface{}) error

func (Abi) GetAction

func (a Abi) GetAction(name Name) *AbiAction

func (Abi) GetStruct

func (a Abi) GetStruct(name string) *AbiStruct

func (Abi) GetTable

func (a Abi) GetTable(name Name) *AbiTable

func (Abi) GetType

func (a Abi) GetType(name string) *AbiType

func (Abi) GetVariant

func (a Abi) GetVariant(name string) *AbiVariant

type AbiAction

type AbiAction struct {
	Name              Name   `json:"name"`
	Type              string `json:"type"`
	RicardianContract string `json:"ricardian_contract"`
}

type AbiClause

type AbiClause struct {
	Id   string `json:"id"`
	Body string `json:"body"`
}

type AbiErrorMessage

type AbiErrorMessage struct {
	Code    Uint64 `json:"error_code"`
	Message string `json:"error_msg"`
}

type AbiExtension

type AbiExtension struct {
	Type uint16 `json:"type"`
	Data Bytes  `json:"data"`
}

type AbiField

type AbiField struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type AbiStruct

type AbiStruct struct {
	Name   string     `json:"name"`
	Base   string     `json:"base"`
	Fields []AbiField `json:"fields"`
}

type AbiTable

type AbiTable struct {
	Name      Name     `json:"name"`
	IndexType string   `json:"index_type"`
	KeyNames  []string `json:"key_names"`
	KeyTypes  []string `json:"key_types"`
	Type      string   `json:"type"`
}

type AbiType

type AbiType struct {
	NewTypeName string `json:"new_type_name"`
	Type        string `json:"type"`
}

type AbiVariant

type AbiVariant struct {
	Name  string   `json:"name"`
	Types []string `json:"types"`
}

type Action

type Action struct {
	Account       Name              `json:"account"`
	Name          Name              `json:"name"`
	Authorization []PermissionLevel `json:"authorization"`
	Data          Bytes             `json:"data"`
}

func NewAction

func NewAction(account Name, name Name, authorization []PermissionLevel, data Bytes) *Action

func (Action) Decode

func (a Action) Decode(abi *Abi) (map[string]interface{}, error)

func (Action) DecodeInto

func (a Action) DecodeInto(v interface{}) error

func (Action) Digest

func (a Action) Digest() Checksum256

func (Action) MarshalABI

func (a Action) MarshalABI(e *abi.Encoder) error

func (*Action) UnmarshalABI

func (a *Action) UnmarshalABI(d *abi.Decoder) error

type Asset

type Asset struct {
	Value int64
	Symbol
}

func A

func A(s string) *Asset

Convenience for NewAssetFromString, panics for invalid assets.

func NewAsset

func NewAsset(value int64, symbol Symbol) *Asset

Create new asset from value (number of symbol units) and symbol.

func NewAssetFromString

func NewAssetFromString(s string) (*Asset, error)

Create new asset from string, e.g. "1.0000 EOS"

func (*Asset) FloatValue

func (a *Asset) FloatValue() float64

func (*Asset) MarshalABI

func (a *Asset) MarshalABI(e *abi.Encoder) error

func (Asset) MarshalText

func (a Asset) MarshalText() (text []byte, err error)

func (*Asset) String

func (a *Asset) String() string

String representation of asset, e.g. "1.0000 EOS"

func (*Asset) UnmarshalABI

func (a *Asset) UnmarshalABI(d *abi.Decoder) error

func (*Asset) UnmarshalText

func (a *Asset) UnmarshalText(text []byte) error

type Blob

type Blob []byte

Exactly like Bytes but serializes as Base64 instead of Base16 (hex) when encoded as JSON Worth noting is that this version encodes to valid Base64 while the eosio variant does not see https://github.com/EOSIO/eos/issues/8161

func (Blob) Base64

func (b Blob) Base64() string

func (Blob) MarshalABI

func (b Blob) MarshalABI(e *abi.Encoder) error

func (Blob) MarshalText

func (b Blob) MarshalText() (text []byte, err error)

func (*Blob) UnmarshalABI

func (b *Blob) UnmarshalABI(d *abi.Decoder) error

func (*Blob) UnmarshalText

func (b *Blob) UnmarshalText(text []byte) error

type BlockNum

type BlockNum uint32

Type representing a block number, EOSIO chains are only expected to live for 68 years, sorry kids!

func (BlockNum) MarshalABI

func (bn BlockNum) MarshalABI(e *abi.Encoder) error

func (BlockNum) MarshalJSON

func (bn BlockNum) MarshalJSON() ([]byte, error)

func (BlockNum) String

func (bn BlockNum) String() string

func (*BlockNum) UnmarshalABI

func (bn *BlockNum) UnmarshalABI(d *abi.Decoder) error

func (*BlockNum) UnmarshalJSON

func (bn *BlockNum) UnmarshalJSON(b []byte) error

type BlockTimestamp

type BlockTimestamp uint32

func NewBlockTimestamp

func NewBlockTimestamp(t time.Time) BlockTimestamp

func NewBlockTimestampFromString

func NewBlockTimestampFromString(s string) (BlockTimestamp, error)

func (BlockTimestamp) MarshalABI

func (bts BlockTimestamp) MarshalABI(e *abi.Encoder) error

func (BlockTimestamp) MarshalText

func (bts BlockTimestamp) MarshalText() (text []byte, err error)

func (BlockTimestamp) String

func (bts BlockTimestamp) String() string

func (BlockTimestamp) Time

func (bts BlockTimestamp) Time() time.Time

func (*BlockTimestamp) UnmarshalABI

func (bts *BlockTimestamp) UnmarshalABI(d *abi.Decoder) error

func (*BlockTimestamp) UnmarshalText

func (bts *BlockTimestamp) UnmarshalText(text []byte) error

type Bytes

type Bytes []byte

Binary data type, encodes to hex string in JSON. Use the Blob type instead where possible since it encodes to base64.

func (Bytes) Hex

func (b Bytes) Hex() string

func (Bytes) MarshalABI

func (b Bytes) MarshalABI(e *abi.Encoder) error

func (Bytes) MarshalText

func (b Bytes) MarshalText() (text []byte, err error)

func (*Bytes) UnmarshalABI

func (b *Bytes) UnmarshalABI(d *abi.Decoder) error

func (*Bytes) UnmarshalText

func (b *Bytes) UnmarshalText(text []byte) error

type Checksum160

type Checksum160 [20]byte

ripemd160 checksum type

func Checksum160Digest

func Checksum160Digest(message []byte) Checksum160

Return ripemd160 hash of message

func (*Checksum160) MarshalABI

func (c160 *Checksum160) MarshalABI(e *abi.Encoder) error

func (Checksum160) MarshalText

func (c160 Checksum160) MarshalText() (text []byte, err error)

func (Checksum160) String

func (c Checksum160) String() string

func (*Checksum160) UnmarshalABI

func (c160 *Checksum160) UnmarshalABI(d *abi.Decoder) error

func (*Checksum160) UnmarshalText

func (c160 *Checksum160) UnmarshalText(text []byte) error

type Checksum256

type Checksum256 [32]byte

sha256 checksum type

func Checksum256Digest

func Checksum256Digest(message []byte) Checksum256

Return sha256 hash of message

func (*Checksum256) MarshalABI

func (c256 *Checksum256) MarshalABI(e *abi.Encoder) error

func (Checksum256) MarshalText

func (c256 Checksum256) MarshalText() (text []byte, err error)

func (Checksum256) String

func (c Checksum256) String() string

func (*Checksum256) UnmarshalABI

func (c256 *Checksum256) UnmarshalABI(d *abi.Decoder) error

func (*Checksum256) UnmarshalText

func (c256 *Checksum256) UnmarshalText(text []byte) error

type Checksum512

type Checksum512 [64]byte

sha512 checksum type

func Checksum512Digest

func Checksum512Digest(message []byte) Checksum512

Return sha512 hash of message

func (*Checksum512) MarshalABI

func (c512 *Checksum512) MarshalABI(e *abi.Encoder) error

func (Checksum512) MarshalText

func (c512 Checksum512) MarshalText() (text []byte, err error)

func (Checksum512) String

func (c Checksum512) String() string

func (*Checksum512) UnmarshalABI

func (c512 *Checksum512) UnmarshalABI(d *abi.Decoder) error

func (*Checksum512) UnmarshalText

func (c512 *Checksum512) UnmarshalText(text []byte) error

type ExtendedAsset

type ExtendedAsset struct {
	Quantity Asset `json:"quantity"`
	Contract Name  `json:"contract"`
}

func (*ExtendedAsset) MarshalABI

func (ea *ExtendedAsset) MarshalABI(e *abi.Encoder) error

func (*ExtendedAsset) UnmarshalABI

func (ea *ExtendedAsset) UnmarshalABI(d *abi.Decoder) error

type Float128

type Float128 struct {
	Data [16]byte // not sure what the best way to represent this is, abieos seems to use a hex string ¯\_(ツ)_/¯
}

func (Float128) MarshalABI

func (f128 Float128) MarshalABI(e *abi.Encoder) error

func (Float128) MarshalText

func (f128 Float128) MarshalText() (text []byte, err error)

func (*Float128) UnmarshalABI

func (f128 *Float128) UnmarshalABI(d *abi.Decoder) error

func (*Float128) UnmarshalText

func (f128 *Float128) UnmarshalText(text []byte) error

type Int128

type Int128 Uint128

func NewInt128

func NewInt128(i *big.Int) Int128

Create new Int128 from big.Int, panics if big.Int is too large.

func NewInt128FromString

func NewInt128FromString(s string) (Int128, error)

func (Int128) BigInt

func (i128 Int128) BigInt() *big.Int

func (Int128) Bytes

func (i128 Int128) Bytes(o binary.ByteOrder) []byte

func (Int128) MarshalABI

func (i128 Int128) MarshalABI(e *abi.Encoder) error

func (Int128) MarshalText

func (i128 Int128) MarshalText() (text []byte, err error)

func (Int128) String

func (i128 Int128) String() string

func (*Int128) UnmarshalABI

func (i128 *Int128) UnmarshalABI(d *abi.Decoder) error

func (*Int128) UnmarshalText

func (i128 *Int128) UnmarshalText(text []byte) error

type KeyType

type KeyType byte
const (
	K1 KeyType = 0
	P1 KeyType = 1
	WA KeyType = 2
)

func (KeyType) String

func (t KeyType) String() string

type Name

type Name uint64

Type representing an EOSIO name.

func N

func N(s string) Name

Convenience for NewName.

func NewName

func NewName(s string) Name

Create a new name from a string, e.g. "teamgreymass".

func (Name) MarshalABI

func (n Name) MarshalABI(e *abi.Encoder) error

func (Name) MarshalText

func (n Name) MarshalText() (text []byte, err error)

func (Name) String

func (n Name) String() string

Returns string representation of the name.

func (*Name) UnmarshalABI

func (n *Name) UnmarshalABI(d *abi.Decoder) error

func (*Name) UnmarshalText

func (n *Name) UnmarshalText(text []byte) error

type PermissionLevel

type PermissionLevel struct {
	Actor      Name `json:"actor"`
	Permission Name `json:"permission"`
}

func (PermissionLevel) MarshalABI

func (pl PermissionLevel) MarshalABI(e *abi.Encoder) error

func (*PermissionLevel) UnmarshalABI

func (pl *PermissionLevel) UnmarshalABI(d *abi.Decoder) error

type PublicKey

type PublicKey struct {
	Type KeyType
	Data []byte
}

func NewPublicKey

func NewPublicKey(t KeyType, d []byte) *PublicKey

func NewPublicKeyFromString

func NewPublicKeyFromString(s string) (*PublicKey, error)

func (*PublicKey) LegacyString

func (pk *PublicKey) LegacyString(prefix string) string

panics if key type isn't k1

func (PublicKey) MarshalABI

func (pk PublicKey) MarshalABI(e *abi.Encoder) error

func (PublicKey) MarshalText

func (pk PublicKey) MarshalText() (text []byte, err error)

func (*PublicKey) String

func (pk *PublicKey) String() string

func (*PublicKey) UnmarshalABI

func (pk *PublicKey) UnmarshalABI(d *abi.Decoder) error

func (*PublicKey) UnmarshalText

func (pk *PublicKey) UnmarshalText(text []byte) error

type Signature

type Signature struct {
	Type KeyType
	Data []byte
}

func NewSignature

func NewSignature(t KeyType, d []byte) *Signature

func NewSignatureString

func NewSignatureString(s string) (*Signature, error)

func (Signature) MarshalABI

func (s Signature) MarshalABI(e *abi.Encoder) error

func (*Signature) MarshalText

func (s *Signature) MarshalText() (text []byte, err error)

func (*Signature) String

func (pk *Signature) String() string

func (*Signature) UnmarshalABI

func (s *Signature) UnmarshalABI(d *abi.Decoder) error

func (*Signature) UnmarshalText

func (s *Signature) UnmarshalText(text []byte) error

type Symbol

type Symbol uint64

func NewSymbol

func NewSymbol(precision uint8, name string) (Symbol, error)

Create new symbol from precision and name.

func NewSymbolFromString

func NewSymbolFromString(s string) (Symbol, error)

Create new asset symbol from string, e.g. "4,EOS"

func (Symbol) Code

func (s Symbol) Code() SymbolCode

Asset symbol code.

func (Symbol) Decimals

func (s Symbol) Decimals() int

Number of decimals in symbol, e.g. 4 for EOS

func (Symbol) MarshalABI

func (s Symbol) MarshalABI(e *abi.Encoder) error

func (Symbol) MarshalText

func (s Symbol) MarshalText() (text []byte, err error)

func (Symbol) Name

func (s Symbol) Name() string

Asset symbol name, e.g. "EOS"

func (Symbol) Precision

func (s Symbol) Precision() int

Precision of asset symbol, 10^Decimals.

func (Symbol) String

func (s Symbol) String() string

String representation of asset symbol, e.g. "4,EOS"

func (*Symbol) UnmarshalABI

func (s *Symbol) UnmarshalABI(d *abi.Decoder) error

func (*Symbol) UnmarshalText

func (s *Symbol) UnmarshalText(text []byte) error

type SymbolCode

type SymbolCode uint64

func (SymbolCode) MarshalABI

func (sc SymbolCode) MarshalABI(e *abi.Encoder) error

func (SymbolCode) MarshalText

func (sc SymbolCode) MarshalText() (text []byte, err error)

func (*SymbolCode) UnmarshalABI

func (sc *SymbolCode) UnmarshalABI(d *abi.Decoder) error

func (*SymbolCode) UnmarshalText

func (sc *SymbolCode) UnmarshalText(text []byte) error

type TimePoint

type TimePoint int64

func NewTimePoint

func NewTimePoint(t time.Time) TimePoint

func NewTimePointFromString

func NewTimePointFromString(s string) (TimePoint, error)

func (TimePoint) MarshalABI

func (tp TimePoint) MarshalABI(e *abi.Encoder) error

func (TimePoint) MarshalText

func (tp TimePoint) MarshalText() (text []byte, err error)

func (TimePoint) String

func (tp TimePoint) String() string

func (TimePoint) Time

func (tp TimePoint) Time() time.Time

func (*TimePoint) UnmarshalABI

func (tp *TimePoint) UnmarshalABI(d *abi.Decoder) error

func (*TimePoint) UnmarshalText

func (tp *TimePoint) UnmarshalText(text []byte) error

type TimePointSec

type TimePointSec uint32

func NewTimePointSec

func NewTimePointSec(t time.Time) TimePointSec

func NewTimePointSecFromString

func NewTimePointSecFromString(s string) (TimePointSec, error)

func (TimePointSec) MarshalABI

func (tps TimePointSec) MarshalABI(e *abi.Encoder) error

func (TimePointSec) MarshalText

func (tps TimePointSec) MarshalText() (text []byte, err error)

func (TimePointSec) String

func (tps TimePointSec) String() string

func (TimePointSec) Time

func (tps TimePointSec) Time() time.Time

func (*TimePointSec) UnmarshalABI

func (tps *TimePointSec) UnmarshalABI(d *abi.Decoder) error

func (*TimePointSec) UnmarshalText

func (tps *TimePointSec) UnmarshalText(text []byte) error

type Transaction

type Transaction struct {
	TransactionHeader
	ContextFreeActions []Action               `json:"context_free_actions"`
	Actions            []Action               `json:"actions"`
	Extensions         []TransactionExtension `json:"transaction_extensions"`
}

func (Transaction) MarshalABI

func (tx Transaction) MarshalABI(e *abi.Encoder) error

func (*Transaction) UnmarshalABI

func (tx *Transaction) UnmarshalABI(d *abi.Decoder) error

type TransactionExtension

type TransactionExtension struct {
	Type uint16 `json:"type"`
	Data Bytes  `json:"data"`
}

func (TransactionExtension) MarshalABI

func (txe TransactionExtension) MarshalABI(e *abi.Encoder) error

func (*TransactionExtension) UnmarshalABI

func (txe *TransactionExtension) UnmarshalABI(d *abi.Decoder) error

type TransactionHeader

type TransactionHeader struct {
	Expiration       TimePointSec `json:"expiration"`
	RefBlockNum      uint16       `json:"ref_block_num"`
	RefBlockPrefix   uint32       `json:"ref_block_prefix"`
	MaxNetUsageWords uint         `json:"max_net_usage_words"`
	MaxCpuUsageMs    uint8        `json:"max_cpu_usage_ms"`
	DelaySec         uint         `json:"delay_sec"`
}

func (TransactionHeader) MarshalABI

func (txh TransactionHeader) MarshalABI(e *abi.Encoder) error

func (*TransactionHeader) UnmarshalABI

func (txh *TransactionHeader) UnmarshalABI(d *abi.Decoder) error

type Uint128

type Uint128 struct {
	Lo uint64
	Hi uint64
}

func NewUint128

func NewUint128(i *big.Int) Uint128

Create new Uint128 from big.Int, panics if big.Int is too large.

func NewUint128FromString

func NewUint128FromString(s string) (Uint128, error)

func (Uint128) BigInt

func (u128 Uint128) BigInt() *big.Int

func (Uint128) Bytes

func (u128 Uint128) Bytes(o binary.ByteOrder) []byte

func (Uint128) MarshalABI

func (u128 Uint128) MarshalABI(e *abi.Encoder) error

func (Uint128) MarshalText

func (u128 Uint128) MarshalText() (text []byte, err error)

func (Uint128) String

func (u128 Uint128) String() string

func (*Uint128) UnmarshalABI

func (u128 *Uint128) UnmarshalABI(d *abi.Decoder) error

func (*Uint128) UnmarshalText

func (u128 *Uint128) UnmarshalText(text []byte) error

type Uint64

type Uint64 uint64

uint64 alias that encodes to string for values above 32bit instead of scientific notation in JSON

func (Uint64) MarshalABI

func (u64 Uint64) MarshalABI(e *abi.Encoder) error

func (Uint64) MarshalJSON

func (u64 Uint64) MarshalJSON() ([]byte, error)

func (*Uint64) UnmarshalABI

func (u64 *Uint64) UnmarshalABI(d *abi.Decoder) error

func (*Uint64) UnmarshalJSON

func (u64 *Uint64) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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