contract

package
v0.22.9-1 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCallDecoder added in v0.22.7

func NewCallDecoder(method *goethABI.Method) func(data []byte, res any) error

NewCallDecoder creates a new decoder for the given method and result.

It can be used to create a CallOpts.Decoder.

func NewCallEncoder added in v0.22.7

func NewCallEncoder(method *goethABI.Method, args ...any) func() ([]byte, error)

NewCallEncoder creates a new encoder for the given method and arguments.

It can be used to create a CallOpts.Encoder.

func NewContractErrorDecoder added in v0.22.7

func NewContractErrorDecoder(contract *goethABI.Contract) func(err error) error

NewContractErrorDecoder creates a new decoder that can handle errors defined in the given contract.

It can be used to create a CallOpts.ErrorDecoder.

Types

type Call added in v0.22.7

type Call struct {
	// contains filtered or unexported fields
}

Call is a contract call.

Using this type instead of performing the call directly allows to choose if the call should be executed immediately or passed as an argument to another function.

func NewCall added in v0.22.7

func NewCall(opts CallOpts) *Call

NewCall creates a new Call instance.

func (*Call) Address added in v0.22.7

func (c *Call) Address() types.Address

Address implements the Callable, Caller, TypedCaller, and Transactor interface.

func (*Call) Call added in v0.22.7

func (c *Call) Call(ctx context.Context, number types.BlockNumber, res any) error

Call executes the call and decodes the result into res.

func (*Call) CallData added in v0.22.7

func (c *Call) CallData() ([]byte, error)

CallData implements the Callable interface.

func (*Call) Client added in v0.22.7

func (c *Call) Client() rpc.RPC

Client implements the Caller, TypedCaller, and Transactor interface.

func (*Call) DecodeTo added in v0.22.7

func (c *Call) DecodeTo(data []byte, res any) error

DecodeTo implements the Decoder interface.

func (*Call) Gas added in v0.22.7

func (c *Call) Gas(ctx context.Context, number types.BlockNumber) (uint64, error)

Gas returns the estimated gas usage of the call.

type CallOpts added in v0.22.7

type CallOpts struct {
	// Client is the RPC client to use when performing the call or sending
	// the transaction.
	Client rpc.RPC

	// Address is the address of the contract to call or send a transaction to.
	Address types.Address

	// Encoder is an optional encoder that will be used to encode the
	// arguments of the contract call.
	Encoder func() ([]byte, error)

	// Decoder is an optional decoder that will be used to decode the result
	// returned by the contract call.
	Decoder func([]byte, any) error

	// ErrorDecoder is an optional decoder that will be used to decode the
	// error returned by the contract call.
	ErrorDecoder func(err error) error
}

CallOpts are the options for New*Call functions.

type Callable added in v0.22.7

type Callable interface {
	// Address returns the address of the contract to call.
	Address() types.Address

	// CallData returns the encoded call data.
	CallData() ([]byte, error)
}

Callable provides the data required to call a contract.

type Caller added in v0.22.7

type Caller interface {
	// Address returns the address of the contract to call.
	Address() types.Address

	// Client returns the RPC client to use when performing the call.
	Client() rpc.RPC

	// Call executes the call and decodes the result into res.
	Call(ctx context.Context, number types.BlockNumber, res any) error

	// Gas returns the estimated gas usage of the call.
	Gas(ctx context.Context, number types.BlockNumber) (uint64, error)
}

Caller can perform a call to a contract and decode the result.

type Decoder added in v0.22.7

type Decoder interface {
	DecodeTo([]byte, any) error
}

Decoder decodes the data returned by the contract call.

type SelfCaller added in v0.22.7

type SelfCaller interface {
	Callable
	Caller
	Decoder
}

SelfCaller is a Callable that can perform a call by itself.

type SelfTransactableCaller added in v0.22.7

type SelfTransactableCaller interface {
	Callable
	Caller
	Transactor
	Decoder
}

SelfTransactableCaller is a Callable that can perform a call or send a transaction by itself.

type TransactableCall added in v0.22.7

type TransactableCall struct {
	// contains filtered or unexported fields
}

TransactableCall works like Call but can be also used to send a transaction.

func NewTransactableCall added in v0.22.7

func NewTransactableCall(opts CallOpts) *TransactableCall

NewTransactableCall creates a new TransactableCall instance.

func (*TransactableCall) SendTransaction added in v0.22.7

func (t *TransactableCall) SendTransaction(ctx context.Context) (*types.Hash, *types.Transaction, error)

SendTransaction sends a call as a transaction.

type Transactor added in v0.22.7

type Transactor interface {
	// Address returns the address of the contract to send a transaction to.
	Address() types.Address

	// Client returns the RPC client to use when sending the transaction.
	Client() rpc.RPC

	// SendTransaction sends a call as a transaction.
	SendTransaction(ctx context.Context) (*types.Hash, *types.Transaction, error)

	// Gas returns the estimated gas usage of the transaction.
	Gas(ctx context.Context, number types.BlockNumber) (uint64, error)
}

Transactor can send a transaction to a contract.

type TypedCall added in v0.22.7

type TypedCall[T any] struct {
	// contains filtered or unexported fields
}

TypedCall is a Call with a typed result.

func NewTypedCall added in v0.22.7

func NewTypedCall[T any](opts CallOpts) *TypedCall[T]

NewTypedCall creates a new TypedCall instance.

func (*TypedCall[T]) Call added in v0.22.7

func (t *TypedCall[T]) Call(ctx context.Context, number types.BlockNumber) (T, error)

Call executes the call and returns the decoded result.

func (*TypedCall[T]) Decode added in v0.22.7

func (t *TypedCall[T]) Decode(data []byte) (T, error)

Decode decodes the result of the call.

type TypedCaller added in v0.22.7

type TypedCaller[T any] interface {
	// Address returns the address of the contract to call.
	Address() types.Address

	// Client returns the RPC client to use when performing the call.
	Client() rpc.RPC

	// Call executes the call and decodes the result into res.
	Call(ctx context.Context, number types.BlockNumber) (T, error)

	// Gas returns the estimated gas usage of the call.
	Gas(ctx context.Context, number types.BlockNumber) (uint64, error)
}

TypedCaller can perform a call to a contract and decode the result.

type TypedDecoder added in v0.22.7

type TypedDecoder[T any] interface {
	Decode([]byte) (T, error)
}

TypedDecoder decodes the data returned by the contract call.

type TypedSelfCaller added in v0.22.7

type TypedSelfCaller[T any] interface {
	Callable
	TypedCaller[T]
	TypedDecoder[T]
	Decoder
}

TypedSelfCaller is a Callable that can perform a call by itself.

type TypedSelfTransactableCaller added in v0.22.7

type TypedSelfTransactableCaller[T any] interface {
	Callable
	TypedCaller[T]
	Transactor
	Decoder
}

TypedSelfTransactableCaller is a Callable that can perform a call or send a transaction by itself.

type TypedTransactableCall added in v0.22.7

type TypedTransactableCall[T any] struct {
	// contains filtered or unexported fields
}

TypedTransactableCall is a TransactableCall with a typed result.

func NewTypedTransactableCall added in v0.22.7

func NewTypedTransactableCall[T any](opts CallOpts) *TypedTransactableCall[T]

NewTypedTransactableCall creates a new TypedTransactableCall instance.

func (*TypedTransactableCall[T]) Call added in v0.22.7

func (t *TypedTransactableCall[T]) Call(ctx context.Context, number types.BlockNumber) (T, error)

Call executes the call and returns the decoded result.

func (*TypedTransactableCall[T]) Decode added in v0.22.7

func (t *TypedTransactableCall[T]) Decode(data []byte) (T, error)

Decode decodes the result of the call.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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