ethcall

package
v0.72.4 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyArgsToJson

func AnyArgsToJson(args []any) ([]string, error)

AnyArgsToJson does the inverse of the JsonArgsToAny; takes a list of arguments in go types and marshals them to a list of JSON strings.

func CanonicalizeJSON

func CanonicalizeJSON(in []byte) ([]byte, error)

func JsonArgsToAny

func JsonArgsToAny(methodName string, jsonArgs []string, abiJSON string) ([]any, error)

JsonArgsToAny takes a list of arguments marshalled as JSON strings. It then uses the ethereum ABI to convert each JSON argument into the go type which corresponds to the ethereum type defined in the ABI for that argument.

Types

type Call

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

func NewCall

func NewCall(method string, args []any, address string, abiJSON []byte) (Call, error)

func (Call) Args

func (c Call) Args() ([]any, error)

func (Call) Call

func (c Call) Call(ctx context.Context, caller ethereum.ContractCaller, blockNumber *big.Int) (Result, error)

func (Call) Hash

func (c Call) Hash() []byte

func (Call) UnpackResult

func (c Call) UnpackResult(bytes []byte) ([]any, error)

type Config

type Config struct {
	Level encoding.LogLevel `long:"log-level"`
}

type Engine

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

func NewEngine

func NewEngine(log *logging.Logger, cfg Config, client EthReaderCaller, forwarder Forwarder) (*Engine, error)

func (*Engine) AddSpec

func (e *Engine) AddSpec(s Spec) (string, error)

func (*Engine) GetSpec

func (e *Engine) GetSpec(id string) (Spec, bool)

func (*Engine) OnTick

func (e *Engine) OnTick(ctx context.Context, vegaTime time.Time)

type EthReaderCaller

type EthReaderCaller interface {
	ethereum.ContractCaller
	ethereum.ChainReader
}

Still TODO

  • listen for new data sources and add specs
  • on tick check every block since last tick not just current
  • submit some sort of error event if call fails
  • know when datasources stop being active and remove them -- because e.g. market is dead, or amended to have different source -- or because trigger will never fire again
  • what to do about catching up e.g. if node is restarted

type Forwarder

type Forwarder interface {
	ForwardFromSelf(*commandspb.ChainEvent)
}

type Result

type Result struct {
	*Call
	Bytes []byte
}

func (Result) Values

func (r Result) Values() ([]any, error)

type Spec

type Spec struct {
	Call
	Trigger
}

func NewSpec

func NewSpec(call Call, trigger Trigger) Spec

func NewSpecFromProto

func NewSpecFromProto(proto *vega.DataSourceDefinition) (Spec, error)

func (Spec) Hash

func (s Spec) Hash() []byte

func (Spec) HashHex

func (s Spec) HashHex() string

func (Spec) ToProto

func (s Spec) ToProto() (*vega.DataSourceDefinition, error)

type TimeTrigger

type TimeTrigger struct {
	Initial uint64
	Every   uint64 // 0 = don't repeat
	Until   uint64 // 0 = forever
}

func TimeTriggerFromProto

func TimeTriggerFromProto(proto *vega.EthTimeTrigger) TimeTrigger

func (TimeTrigger) Hash

func (t TimeTrigger) Hash() []byte

func (TimeTrigger) ToProto

func (t TimeTrigger) ToProto() *vega.EthCallTrigger

func (TimeTrigger) Trigger

func (t TimeTrigger) Trigger(prev blockish, current blockish) bool

type Trigger

type Trigger interface {
	Trigger(prev blockish, current blockish) bool
	ToProto() *vega.EthCallTrigger
	Hash() []byte
}

func TriggerFromProto

func TriggerFromProto(proto *vega.EthCallTrigger) (Trigger, error)

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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