abi

package
v0.0.0-...-54fe0b3 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBits       = errors.New("integer type bits out of range or is not a multiple of 8", errors.WithVendor(errVendor), errors.WithCode(-1))
	ErrValue      = errors.New("encode value type error", errors.WithVendor(errVendor), errors.WithCode(-2))
	ErrFixedBytes = errors.New("fixed bytes length mismatch", errors.WithVendor(errVendor), errors.WithCode(-3))
	ErrLength     = errors.New("length error", errors.WithVendor(errVendor), errors.WithCode(-4))
	ErrTag        = errors.New("generate tuple tag error", errors.WithVendor(errVendor), errors.WithCode(-5))
	ErrJSON       = errors.New("parse json abi error", errors.WithVendor(errVendor), errors.WithCode(-6))
)

errors

Functions

func Selector

func Selector(abi string) []byte

Selector function selector

Types

type CallOps

type CallOps struct {
	GasLimit *big.Int
	GasPrice *big.Int
	Nonce    *big.Int
	Amount   *big.Int
}

func MakeCallOps

func MakeCallOps(ctx context.Context, client client.Provider, signer signer.Signer, ops []Op) (*CallOps, error)

type Contract

type Contract interface {
	Select(selector string) (Func, bool)
}

type Encoder

type Encoder interface {
	Static() bool
	Marshal(value interface{}) ([]byte, error)
	Unmarshal(data []byte, v interface{}) (uint, error)
	fmt.Stringer
	Accept(visitor Visitor)
	GoTypeName() string
}

Encoder types encoder interface

func Address

func Address() (Encoder, error)

func Array

func Array(elem Encoder) (Encoder, error)

func Bool

func Bool() (Encoder, error)

func Builtin

func Builtin(name string) (Encoder, bool)

Get Builtin type encoder

func Bytes

func Bytes() (Encoder, error)

func Fixed

func Fixed(sign bool, M, N uint) (Encoder, error)

func FixedArray

func FixedArray(elem Encoder, len uint) (Encoder, error)

func FixedBytes

func FixedBytes(len uint) (Encoder, error)

func Integer

func Integer(sign bool, bits uint) (Encoder, error)

Integer create Integer encoder

func String

func String() (Encoder, error)

func Tuple

func Tuple(name string, elems ...Encoder) (Encoder, error)

type Func

type Func interface {
	Selector() []byte
	// Call generate call bytes
	Call(params ...interface{}) ([]byte, error)
	// Return unmarshal return bytes
	Return(data []byte, values interface{}) (uint, error)
}

func TryGetFunc

func TryGetFunc(contract Contract, signature string) (Func, bool)

type JSONField

type JSONField struct {
	Type JSONFieldType `json:"type"`
	Name string        `json:"name"`

	Inputs          []*JSONParam     `json:"inputs"`
	Outputs         []*JSONParam     `json:"outputs"`
	StateMutability *StateMutability `json:"stateMutability"`
	Anonymous       *bool            `json:"anonymous"`
}

type JSONFieldType

type JSONFieldType string
const (
	JSONTypeFunc        JSONFieldType = "function"
	JSONTypeConstructor JSONFieldType = "constructor"
	JSONTypeReceive     JSONFieldType = "receive"
	JSONTypeFallback    JSONFieldType = "fallback"
	JSONTypeEvent       JSONFieldType = "event"
	JSONTypeError       JSONFieldType = "error"
)

type JSONParam

type JSONParam struct {
	Name         string       `json:"name"`
	Type         string       `json:"type"`
	InternalType string       `json:"internalType"`
	Components   []*JSONParam `json:"components"`
	Indexed      *bool        `json:"indexed"`
}

type Op

type Op func(ops *CallOps)

func WithAmount

func WithAmount(value *fixed.Number) Op

func WithGasLimits

func WithGasLimits(value *big.Int) Op

func WithGasPrice

func WithGasPrice(value *fixed.Number) Op

func WithNonce

func WithNonce(value uint64) Op

type StateMutability

type StateMutability string
const (
	StateMutabilityPure       StateMutability = "pure"
	StateMutabilityView       StateMutability = "view"
	StateMutabilityNonpayable StateMutability = "nonpayable"
	StateMutabilityPayable    StateMutability = "payable"
)

type Transaction

type Transaction interface {
	Close()
	TX() string
	Receipt() <-chan *TransactionReceipt
}

Transaction

func MakeTransaction

func MakeTransaction(ctx context.Context, client client.Provider, s signer.Signer, callOpts *CallOps, recipient string, data []byte) (Transaction, error)

type TransactionReceipt

type TransactionReceipt struct {
	Error error
	Data  *client.TransactionReceipt
}

type Visitor

type Visitor interface {
	HandleInt(sign bool, bits uint)
	HandleBool()

	HandleFixedArray(len uint, elem Encoder)
	HandleBytes()
	HandleArray(elem Encoder)
	HandleString()
	HandleTuple(name string, elems []Encoder)
	// contains filtered or unexported methods
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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