burrow: github.com/hyperledger/burrow/execution/evm/abi Index | Files

package abi

import "github.com/hyperledger/burrow/execution/evm/abi"

Index

Package Files

abi.go event_spec.go function_spec.go packing.go primitives.go spec.go

Constants

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)

const EventIDSize = 32

EventIDSize is the length of the event selector

const FallbackFunctionName = "()"

Token to use in deploy yaml in order to indicate call to the fallback function.

const FunctionIDSize = 4

FunctionIDSize is the length of the function selector

func GetPackingTypes Uses

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

func Pack Uses

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

func PackEvent Uses

func PackEvent(eventSpec *EventSpec, args ...interface{}) ([]binary.Word256, []byte, error)

func Signature Uses

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

func Unpack Uses

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

func UnpackEvent Uses

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

func UnpackRevert Uses

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

type Argument Uses

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

Argument is a decoded function parameter, return or event field

type EVMAddress Uses

type EVMAddress struct {
}

func (EVMAddress) Dynamic Uses

func (e EVMAddress) Dynamic() bool

func (EVMAddress) GetSignature Uses

func (e EVMAddress) GetSignature() string

func (EVMAddress) ImplicitCast Uses

func (e EVMAddress) ImplicitCast(o EVMType) bool

func (EVMAddress) String Uses

func (e EVMAddress) String() string

type EVMBool Uses

type EVMBool struct {
}

func (EVMBool) Dynamic Uses

func (e EVMBool) Dynamic() bool

func (EVMBool) GetSignature Uses

func (e EVMBool) GetSignature() string

func (EVMBool) ImplicitCast Uses

func (e EVMBool) ImplicitCast(o EVMType) bool

func (EVMBool) String Uses

func (e EVMBool) String() string

type EVMBytes Uses

type EVMBytes struct {
    M uint64
}

func (EVMBytes) Dynamic Uses

func (e EVMBytes) Dynamic() bool

func (EVMBytes) GetSignature Uses

func (e EVMBytes) GetSignature() string

func (EVMBytes) ImplicitCast Uses

func (e EVMBytes) ImplicitCast(o EVMType) bool

func (EVMBytes) String Uses

func (e EVMBytes) String() string

type EVMFixed Uses

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

func (EVMFixed) Dynamic Uses

func (e EVMFixed) Dynamic() bool

func (EVMFixed) GetSignature Uses

func (e EVMFixed) GetSignature() string

func (EVMFixed) ImplicitCast Uses

func (e EVMFixed) ImplicitCast(o EVMType) bool

type EVMInt Uses

type EVMInt struct {
    M uint64
}

func (EVMInt) Dynamic Uses

func (e EVMInt) Dynamic() bool

func (EVMInt) GetSignature Uses

func (e EVMInt) GetSignature() string

func (EVMInt) ImplicitCast Uses

func (e EVMInt) ImplicitCast(o EVMType) bool

func (EVMInt) String Uses

func (e EVMInt) String() string

type EVMString Uses

type EVMString struct {
}

func (EVMString) Dynamic Uses

func (e EVMString) Dynamic() bool

func (EVMString) GetSignature Uses

func (e EVMString) GetSignature() string

func (EVMString) ImplicitCast Uses

func (e EVMString) ImplicitCast(o EVMType) bool

func (EVMString) String Uses

func (e EVMString) String() string

type EVMType Uses

type EVMType interface {
    GetSignature() string

    Dynamic() bool
    ImplicitCast(o EVMType) bool
    // contains filtered or unexported methods
}

type EVMUint Uses

type EVMUint struct {
    M uint64
}

func (EVMUint) Dynamic Uses

func (e EVMUint) Dynamic() bool

func (EVMUint) GetSignature Uses

func (e EVMUint) GetSignature() string

func (EVMUint) ImplicitCast Uses

func (e EVMUint) ImplicitCast(o EVMType) bool

func (EVMUint) String Uses

func (e EVMUint) String() string

type EventID Uses

type EventID [EventIDSize]byte

func GetEventID Uses

func GetEventID(signature string) (id EventID)

func (EventID) Bytes Uses

func (id EventID) Bytes() []byte

func (EventID) String Uses

func (id EventID) String() string

type EventSpec Uses

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

func (*EventSpec) Get Uses

func (e *EventSpec) Get(key string) (interface{}, bool)

func (*EventSpec) String Uses

func (e *EventSpec) String() string

func (*EventSpec) UnmarshalJSON Uses

func (e *EventSpec) UnmarshalJSON(data []byte) error

type FunctionID Uses

type FunctionID [FunctionIDSize]byte

func GetFunctionID Uses

func GetFunctionID(signature string) (id FunctionID)

func (FunctionID) Bytes Uses

func (fs FunctionID) Bytes() []byte

type FunctionSpec Uses

type FunctionSpec struct {
    Name       string
    FunctionID FunctionID
    Constant   bool
    Inputs     []Argument
    Outputs    []Argument
}

func EncodeFunctionCall Uses

func EncodeFunctionCall(abiData, funcName string, logger *logging.Logger, args ...interface{}) ([]byte, *FunctionSpec, error)

EncodeFunctionCall ABI encodes a function call based on ABI in string abiData and the arguments specified as strings. The fname specifies which function should called, if it doesn't exist exist the fallback function will be called. If fname is the empty string, the constructor is called. The arguments must be specified in args. The count must match the function being called. Returns the ABI encoded function call, whether the function is constant according to the ABI (which means it does not modified contract state)

func EncodeFunctionCallFromFile Uses

func EncodeFunctionCallFromFile(abiFileName, abiPath, funcName string, logger *logging.Logger, args ...interface{}) ([]byte, *FunctionSpec, error)

EncodeFunctionCallFromFile ABI encodes a function call based on ABI in file, and the arguments specified as strings. The abiFileName specifies the name of the ABI file, and abiPath the path where it can be found. The fname specifies which function should called, if it doesn't exist exist the fallback function will be called. If fname is the empty string, the constructor is called. The arguments must be specified in args. The count must match the function being called. Returns the ABI encoded function call, whether the function is constant according to the ABI (which means it does not modified contract state)

func NewFunctionSpec Uses

func NewFunctionSpec(name string, inputs, outputs []Argument) *FunctionSpec

func SpecFromFunctionReflect Uses

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

func SpecFromStructReflect Uses

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) SetConstant Uses

func (f *FunctionSpec) SetConstant() *FunctionSpec

Sets this function as constant

func (*FunctionSpec) String Uses

func (f *FunctionSpec) String() string

type Spec Uses

type Spec struct {
    Constructor  *FunctionSpec
    Fallback     *FunctionSpec
    Functions    map[string]*FunctionSpec
    EventsByName map[string]*EventSpec
    EventsByID   map[EventID]*EventSpec
}

Spec is the ABI for contract decoded.

func LoadPath Uses

func LoadPath(abiFileOrDirs ...string) (*Spec, error)

LoadPath loads one abi file or finds all files in a directory

func MergeSpec Uses

func MergeSpec(abiSpec []*Spec) *Spec

MergeSpec takes multiple Specs 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 NewSpec Uses

func NewSpec() *Spec

func ReadSpec Uses

func ReadSpec(specBytes []byte) (*Spec, error)

ReadSpec takes an ABI and decodes it for futher use

func ReadSpecFile Uses

func ReadSpecFile(filename string) (*Spec, error)

ReadSpecFile reads an ABI file from a file

func (*Spec) GetEventAbi Uses

func (spec *Spec) GetEventAbi(id EventID, addresses crypto.Address) (*EventSpec, error)

func (*Spec) Pack Uses

func (spec *Spec) Pack(fname string, args ...interface{}) ([]byte, *FunctionSpec, error)

Pack ABI encodes a function call. The fname specifies which function should called, if it doesn't exist exist the fallback function will be called. If fname is the empty string, the constructor is called. The arguments must be specified in args. The count must match the function being called. Returns the ABI encoded function call, whether the function is constant according to the ABI (which means it does not modified contract state)

func (*Spec) Unpack Uses

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

Unpack decodes the return values from a function call

func (*Spec) UnpackWithID Uses

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

type Variable Uses

type Variable struct {
    Name  string
    Value string
}

Variable exist to unpack return values into, so have both the return value and its name

func DecodeFunctionReturn Uses

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

func DecodeFunctionReturnFromFile Uses

func DecodeFunctionReturnFromFile(abiLocation, binPath, funcName string, resultRaw []byte, logger *logging.Logger) ([]*Variable, error)

DecodeFunctionReturnFromFile ABI decodes the return value from a contract function call.

Package abi imports 20 packages (graph) and is imported by 35 packages. Updated 2020-07-01. Refresh now. Tools for package owners.