Documentation ¶
Index ¶
- Constants
- func GetPackingTypes(args []Argument) []interface{}
- func Pack(argSpec []Argument, args ...interface{}) ([]byte, error)
- func PackEvent(eventSpec *EventSpec, args ...interface{}) ([]binary.Word256, []byte, error)
- func Signature(name string, args []Argument) string
- func Unpack(argSpec []Argument, data []byte, args ...interface{}) error
- func UnpackEvent(eventSpec *EventSpec, topics []binary.Word256, data []byte, ...) error
- func UnpackRevert(data []byte) (message *string, err error)
- type Argument
- type EVMAddress
- type EVMBool
- type EVMBytes
- type EVMFixed
- type EVMInt
- type EVMString
- type EVMType
- type EVMUint
- type EventID
- type EventSpec
- type FunctionID
- type FunctionSpec
- func EncodeFunctionCall(abiData, funcName string, logger *logging.Logger, args ...interface{}) ([]byte, *FunctionSpec, error)
- func EncodeFunctionCallFromFile(abiFileName, abiPath, funcName string, logger *logging.Logger, ...) ([]byte, *FunctionSpec, error)
- func NewFunctionSpec(name string, inputs, outputs []Argument) *FunctionSpec
- func SpecFromFunctionReflect(fname string, v reflect.Value, skipIn, skipOut int) *FunctionSpec
- func SpecFromStructReflect(fname string, args reflect.Type, rets reflect.Type) *FunctionSpec
- type Spec
- func (spec *Spec) GetEventAbi(id EventID, addresses crypto.Address) (*EventSpec, error)
- func (spec *Spec) Pack(fname string, args ...interface{}) ([]byte, *FunctionSpec, error)
- func (spec *Spec) Unpack(data []byte, fname string, args ...interface{}) error
- func (spec *Spec) UnpackWithID(data []byte, args ...interface{}) error
- type Variable
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
Variables ¶
This section is empty.
Functions ¶
func PackEvent ¶
func UnpackEvent ¶
Types ¶
type Argument ¶
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 ¶
type EVMAddress struct { }
func (EVMAddress) Dynamic ¶
func (e EVMAddress) Dynamic() bool
func (EVMAddress) GetSignature ¶
func (e EVMAddress) GetSignature() string
func (EVMAddress) ImplicitCast ¶
func (e EVMAddress) ImplicitCast(o EVMType) bool
func (EVMAddress) String ¶
func (e EVMAddress) String() string
type EVMBool ¶
type EVMBool struct { }
type EVMString ¶
type EVMString struct { }
type EVMType ¶
type EventID ¶
type EventID [EventIDSize]byte
type EventSpec ¶
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 { Name string FunctionID FunctionID Constant bool Inputs []Argument Outputs []Argument }
func EncodeFunctionCall ¶
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 ¶
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 ¶
func NewFunctionSpec(name string, inputs, outputs []Argument) *FunctionSpec
func SpecFromFunctionReflect ¶
func SpecFromFunctionReflect(fname string, v reflect.Value, skipIn, skipOut int) *FunctionSpec
func SpecFromStructReflect ¶
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 ¶
func (f *FunctionSpec) SetConstant() *FunctionSpec
Sets this function as constant
func (*FunctionSpec) String ¶
func (f *FunctionSpec) String() string
type Spec ¶
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 ¶
LoadPath loads one abi file or finds all files in a directory
func MergeSpec ¶
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 ReadSpec ¶
ReadSpec takes an ABI and decodes it for futher use
func ReadSpecFile ¶
ReadSpecFile reads an ABI file from a file
func (*Spec) GetEventAbi ¶
func (*Spec) Pack ¶
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 ¶
Unpack decodes the return values from a function call