abi

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2019 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(params ...interface{}) ([]byte, error)

Encode abi parameters

func Selector

func Selector(functionSignature string) []byte

Get function selector(4bytes) from string of function signature

Types

type ABI

type ABI struct {
	Methods []Method
}

func New

func New(abiJSON string) (ABI, error)

func (*ABI) UnmarshalJSON

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

UnmarshalJSON is implementation of json.Decoder's UnmarshalJSON

type Argument

type Argument struct {
	Name string
	Type Type
}

func (*Argument) UnmarshalJSON

func (argument *Argument) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface

type ArgumentMarshaling

type ArgumentMarshaling struct {
	Name string
	Type string
}

type Arguments

type Arguments []Argument

func (Arguments) Pack

func (arguments Arguments) Pack() string

Pack returns series of Arguments type Example function foo(int64 a, bool b) Pack() extract "int64,bool"

type Method

type Method struct {
	Name      string
	Arguments Arguments
	Output    Argument
}

func ExtractAbiFromFunction

func ExtractAbiFromFunction(f ast.FunctionLiteral) (Method, error)

Extract ABI from function of ast.

func (Method) ID

func (method Method) ID() []byte

ID return function's id using function selector

func (Method) Signature

func (method Method) Signature() string

Signature returns function's signature according to the ABI spec.

Example function foo(int64 a, int64 b) = "foo(int64,int64)"

type ParamType

type ParamType string
const (
	Integer   ParamType = "int"
	Integer64 ParamType = "int64"
	Boolean   ParamType = "bool"
	String    ParamType = "string"
)

type Pointer

type Pointer []byte

type Size

type Size []byte

type Type

type Type struct {
	Type ParamType
}

func NewType

func NewType(paramType string) (Type, error)

type Value

type Value []byte

Jump to

Keyboard shortcuts

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