abi

package
v0.0.0-...-25a45d7 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2019 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const ElementSize = 32

EVM Solidity calls and return values are packed into pieces of 32 bytes, including a bool (wasting 255 out of 256 bits)

View Source
const EventIDSize = 32
View Source
const FunctionIDSize = 4

Variables

This section is empty.

Functions

func GetPackingTypes

func GetPackingTypes(args []Argument) []interface{}

func Pack

func Pack(argSpec []Argument, args ...interface{}) ([]byte, error)

func PackIntoStruct

func PackIntoStruct(argSpec []Argument, st interface{}) ([]byte, error)

func Packer

func Packer(abiData, funcName string, args ...string) ([]byte, error)

Convenience Packing Functions

func ReadAbiFormulateCall

func ReadAbiFormulateCall(abiSpecBytes []byte, funcName string, args []string) ([]byte, error)

func ReadAbiFormulateCallFile

func ReadAbiFormulateCallFile(abiLocation, binPath, funcName string, args []string) ([]byte, error)

func Signature

func Signature(name string, args []Argument) (sig string)

func Unpack

func Unpack(argSpec []Argument, data []byte, args ...interface{}) error

func UnpackEvent

func UnpackEvent(eventSpec *EventSpec, topics []burrow_binary.Word256, data []byte, args ...interface{}) error

* Given a eventSpec, get all the fields (topic fields or not)

func UnpackIntoStruct

func UnpackIntoStruct(argSpec []Argument, data []byte, st interface{}) error

func UnpackRevert

func UnpackRevert(data []byte) (message *string, err error)

UnpackRevert decodes the revert reason if a contract called revert. If no reason was given, message will be nil else it will point to the string

Types

type AbiSpec

type AbiSpec struct {
	Constructor FunctionSpec
	Fallback    FunctionSpec
	Functions   map[string]FunctionSpec
	Events      map[string]EventSpec
	EventsById  map[EventID]EventSpec
}
var RevertAbi *AbiSpec

func MergeAbiSpec

func MergeAbiSpec(abiSpec []*AbiSpec) *AbiSpec

MergeAbiSpec takes multiple AbiSpecs and merges them into once structure. Note that the same function name or event name can occur in different abis, so there might be some information loss.

func ReadAbiSpec

func ReadAbiSpec(specBytes []byte) (*AbiSpec, error)

func ReadAbiSpecFile

func ReadAbiSpecFile(filename string) (*AbiSpec, error)

func (*AbiSpec) Pack

func (abiSpec *AbiSpec) Pack(fname string, args ...interface{}) ([]byte, error)

func (*AbiSpec) Unpack

func (abiSpec *AbiSpec) Unpack(data []byte, fname string, args ...interface{}) error

func (*AbiSpec) UnpackWithID

func (abiSpec *AbiSpec) UnpackWithID(data []byte, args ...interface{}) error

type AbiSpecJSON

type AbiSpecJSON struct {
	Name            string
	Type            string
	Inputs          []ArgumentJSON
	Outputs         []ArgumentJSON
	Constant        bool
	Payable         bool
	StateMutability string
	Anonymous       bool
}

type Argument

type Argument struct {
	Name        string
	EVM         EVMType
	IsArray     bool
	Indexed     bool
	Hashed      bool
	ArrayLength uint64
}

func EVMTypeFromReflect

func EVMTypeFromReflect(v reflect.Type) Argument

type ArgumentJSON

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

type EVMAddress

type EVMAddress struct {
}

func (EVMAddress) GetSignature

func (e EVMAddress) GetSignature() string

type EVMBool

type EVMBool struct {
}

func (EVMBool) GetSignature

func (e EVMBool) GetSignature() string

type EVMBytes

type EVMBytes struct {
	M uint64
}

func (EVMBytes) GetSignature

func (e EVMBytes) GetSignature() string

type EVMFixed

type EVMFixed struct {
	N, M uint64
	// contains filtered or unexported fields
}

func (EVMFixed) GetSignature

func (e EVMFixed) GetSignature() string

type EVMInt

type EVMInt struct {
	M uint64
}

func (EVMInt) GetSignature

func (e EVMInt) GetSignature() string

type EVMString

type EVMString struct {
}

func (EVMString) GetSignature

func (e EVMString) GetSignature() string

type EVMType

type EVMType interface {
	GetSignature() string
	// contains filtered or unexported methods
}

type EVMUint

type EVMUint struct {
	M uint64
}

func (EVMUint) GetSignature

func (e EVMUint) GetSignature() string

type EventID

type EventID [EventIDSize]byte

func GetEventID

func GetEventID(signature string) (id EventID)

func (EventID) Bytes

func (fs EventID) Bytes() []byte

type EventSpec

type EventSpec struct {
	EventID   EventID
	Inputs    []Argument
	Name      string
	Anonymous bool
}

func FindEventSpec

func FindEventSpec(abiDir string, eventID EventID) (evAbi *EventSpec, err error)

FindEventSpec helps when you have an event but you do not know what contract it came from. Events can be emitted from contracts called from other contracts, so you are not likely to know what abi to use. Therefore, this will go through all the files in the directory and see if a matching event spec can be found.

type FunctionID

type FunctionID [FunctionIDSize]byte

func GetFunctionID

func GetFunctionID(signature string) (id FunctionID)

func (FunctionID) Bytes

func (fs FunctionID) Bytes() []byte

type FunctionSpec

type FunctionSpec struct {
	FunctionID FunctionID
	Inputs     []Argument
	Outputs    []Argument
}

func SpecFromFunctionReflect

func SpecFromFunctionReflect(fname string, v reflect.Value, skipIn, skipOut int) *FunctionSpec

func SpecFromStructReflect

func SpecFromStructReflect(fname string, args reflect.Type, rets reflect.Type) *FunctionSpec

SpecFromStructReflect generates a FunctionSpec where the arguments and return values are described a struct. Both args and rets should be set to the return value of reflect.TypeOf() with the respective struct as an argument.

func (*FunctionSpec) SetFunctionID

func (functionSpec *FunctionSpec) SetFunctionID(functionName string)

type Variable

type Variable struct {
	Name  string
	Value string
}

func ReadAndDecodeContractReturn

func ReadAndDecodeContractReturn(abiLocation, binPath, funcName string, resultRaw []byte) ([]*Variable, error)

func Unpacker

func Unpacker(abiData, name string, data []byte) ([]*Variable, error)

Jump to

Keyboard shortcuts

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