abi

package
v0.0.0-...-e4f0010 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2021 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(t *Type, input []byte) (interface{}, error)

Decode decodes the input with a given type

func DecodeStruct

func DecodeStruct(t *Type, input []byte, out interface{}) error

DecodeStruct decodes the input with a type to a struct

func Encode

func Encode(v interface{}, t *Type) ([]byte, error)

Encode encodes a value

func EncodeTopic

func EncodeTopic(t *Type, val interface{}) (web3.Hash, error)

EncodeTopic encodes a topic

func ParseLog

func ParseLog(args *Type, log *web3.Log) (map[string]interface{}, error)

ParseLog parses an event log

func ParseTopic

func ParseTopic(t *Type, topic web3.Hash) (interface{}, error)

ParseTopic parses an individual topic

func ParseTopics

func ParseTopics(args *Type, topics []web3.Hash) ([]interface{}, error)

ParseTopics parses topics from a log event

Types

type ABI

type ABI struct {
	Constructor *Method
	Methods     map[string]*Method
	Events      map[string]*Event
}

ABI represents the ethereum abi format

func MustNewABI

func MustNewABI(s string) *ABI

MustNewABI returns a parsed ABI contract or panics if fails

func NewABI

func NewABI(s string) (*ABI, error)

NewABI returns a parsed ABI struct

func NewABIFromList

func NewABIFromList(humanReadableAbi []string) (*ABI, error)

func NewABIFromReader

func NewABIFromReader(r io.Reader) (*ABI, error)

NewABIFromReader returns an ABI object from a reader

func (*ABI) UnmarshalJSON

func (a *ABI) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface

type ArgumentStr

type ArgumentStr struct {
	Name       string
	Type       string
	Indexed    bool
	Components []*ArgumentStr
}

ArgumentStr encodes a type object

type Event

type Event struct {
	Name      string
	Anonymous bool
	Inputs    *Type
}

Event is a triggered log mechanism

func MustNewEvent

func MustNewEvent(name string) *Event

MustNewEvent creates a new solidity event object or fails

func NewEvent

func NewEvent(name string) (*Event, error)

NewEvent creates a new solidity event object using the signature

func NewEventFromType

func NewEventFromType(name string, typ *Type) *Event

NewEventFromType creates a new solidity event object using the name and type

func (*Event) ID

func (e *Event) ID() (res web3.Hash)

ID returns the id of the event used during logs

func (*Event) Match

func (e *Event) Match(log *web3.Log) bool

Match checks wheter the log is from this event

func (*Event) ParseLog

func (e *Event) ParseLog(log *web3.Log) (map[string]interface{}, error)

ParseLog parses a log with this event

func (*Event) Sig

func (e *Event) Sig() string

Sig returns the signature of the event

type Kind

type Kind int

Kind represents the kind of abi type

const (
	// KindBool is a boolean
	KindBool Kind = iota

	// KindUInt is an uint
	KindUInt

	// KindInt is an int
	KindInt

	// KindString is a string
	KindString

	// KindArray is an array
	KindArray

	// KindSlice is a slice
	KindSlice

	// KindAddress is an address
	KindAddress

	// KindBytes is a bytes array
	KindBytes

	// KindFixedBytes is a fixed bytes
	KindFixedBytes

	// KindFixedPoint is a fixed point
	KindFixedPoint

	// KindTuple is a tuple
	KindTuple

	// KindFunction is a function
	KindFunction
)

func (Kind) String

func (k Kind) String() string

type Method

type Method struct {
	Name    string
	Const   bool
	Inputs  *Type
	Outputs *Type
}

Method is a callable function in the contract

func NewMethod

func NewMethod(name string) (*Method, error)

func (*Method) ID

func (m *Method) ID() []byte

ID returns the id of the method

func (*Method) Sig

func (m *Method) Sig() string

Sig returns the signature of the method

type TupleElem

type TupleElem struct {
	Name    string
	Elem    *Type
	Indexed bool
}

TupleElem is an element of a tuple

type Type

type Type struct {
	// contains filtered or unexported fields
}

Type is an ABI type

func MustNewType

func MustNewType(s string) *Type

MustNewType parses a type in string format or panics if its invalid

func NewTupleType

func NewTupleType(inputs []*TupleElem) *Type

func NewType

func NewType(s string) (*Type, error)

NewType parses a type in string format

func NewTypeFromArgument

func NewTypeFromArgument(arg *ArgumentStr) (*Type, error)

NewTypeFromArgument parses an abi type from an argument

func (*Type) Decode

func (t *Type) Decode(input []byte) (interface{}, error)

Decode decodes an object using this type

func (*Type) DecodeStruct

func (t *Type) DecodeStruct(input []byte, out interface{}) error

DecodeStruct decodes an object using this type to the out param

func (*Type) Elem

func (t *Type) Elem() *Type

Elem returns the elem value for slice and arrays

func (*Type) Encode

func (t *Type) Encode(v interface{}) ([]byte, error)

Encode encodes an object using this type

func (*Type) GoType

func (t *Type) GoType() reflect.Type

GoType returns the go type

func (*Type) Kind

func (t *Type) Kind() Kind

Kind returns the kind of the type

func (*Type) ParseLog

func (t *Type) ParseLog(log *web3.Log) (map[string]interface{}, error)

ParseLog parses a log using this type

func (*Type) Size

func (t *Type) Size() int

Size returns the size of the type

func (*Type) String

func (t *Type) String() string

String returns the raw representation of the type

func (*Type) TupleElems

func (t *Type) TupleElems() []*TupleElem

TupleElems returns the elems of the tuple

Jump to

Keyboard shortcuts

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