Documentation ¶
Index ¶
- Constants
- func GetPackingTypes(args []Argument) []interface{}
- func Pack(argSpec []Argument, args ...interface{}) ([]byte, error)
- func PackIntoStruct(argSpec []Argument, st interface{}) ([]byte, error)
- func Signature(name string, args []Argument) (sig string)
- func Unpack(argSpec []Argument, data []byte, args ...interface{}) error
- func UnpackEvent(eventSpec *EventSpec, topics []burrowBinary.Word256, data []byte, ...) error
- func UnpackIntoStruct(argSpec []Argument, data []byte, st interface{}) error
- func UnpackRevert(data []byte) (message *string, err error)
- type AbiSpec
- func (abiSpec *AbiSpec) EventByID(topic []byte) (*EventSpec, error)
- func (abiSpec *AbiSpec) Pack(fname string, args ...interface{}) ([]byte, *FunctionSpec, error)
- func (abiSpec *AbiSpec) Unpack(data []byte, fname string, args ...interface{}) error
- func (abiSpec *AbiSpec) UnpackWithID(data []byte, args ...interface{}) error
- type AbiSpecJSON
- type Argument
- type ArgumentJSON
- type BVMAddress
- type BVMBool
- type BVMBytes
- type BVMFixed
- type BVMInt
- type BVMString
- type BVMType
- type BVMUint
- type EventID
- type EventSpec
- type FunctionID
- type FunctionSpec
- type Variable
Constants ¶
const ElementSize = 32
BVM Solidity calls and return values are packed into pieces of 32 bytes, including a bool (wasting 255 out of 256 bits)
const EventIDSize = 32
const FunctionIDSize = 4
Variables ¶
This section is empty.
Functions ¶
func GetPackingTypes ¶
func GetPackingTypes(args []Argument) []interface{}
func PackIntoStruct ¶
func UnpackEvent ¶
func UnpackEvent(eventSpec *EventSpec, topics []burrowBinary.Word256, data []byte, args ...interface{}) error
* Given a eventSpec, get all the fields (topic fields or not)
func UnpackIntoStruct ¶
func UnpackRevert ¶
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
RevertAbi exists to decode reverts. Any contract function call fail using revert(), assert() or require(). If a function exits this way, the this hardcoded ABI will be used.
func MergeAbiSpec ¶
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 ReadAbiSpecFile ¶
func (*AbiSpec) EventByID ¶
EventByID looks an event up by its topic hash in the ABI and returns nil if none found.
func (*AbiSpec) Pack ¶
func (abiSpec *AbiSpec) 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 (*AbiSpec) UnpackWithID ¶
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 BVM BVMType IsArray bool Indexed bool Hashed bool ArrayLength uint64 }
func BVMTypeFromReflect ¶
type ArgumentJSON ¶
type ArgumentJSON struct { Name string Type string Components []ArgumentJSON Indexed bool }
type BVMAddress ¶
type BVMAddress struct { }
func (BVMAddress) Dynamic ¶
func (e BVMAddress) Dynamic() bool
func (BVMAddress) GetSignature ¶
func (e BVMAddress) GetSignature() string
func (BVMAddress) ImplicitCast ¶
func (e BVMAddress) ImplicitCast(o BVMType) bool
func (BVMAddress) String ¶
func (e BVMAddress) String() string
type BVMFixed ¶
type BVMFixed struct {
N, M uint64
// contains filtered or unexported fields
}
func (BVMFixed) GetSignature ¶
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 Constant bool Inputs []Argument Outputs []Argument }
func EncodeFunctionCall ¶
func EncodeFunctionCall(abiData, funcName string, 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 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) SetFunctionID ¶
func (functionSpec *FunctionSpec) SetFunctionID(functionName string)