eggtypes

package
v0.0.0-...-3acd70f Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSchema

func AddSchema(schema MessageSchema) error

Add a message schema to the schemas managed by EggRoll.

func Decode

func Decode(data []byte) (any, error)

Decode binary data into a Go value.

func DecodeIntoMap

func DecodeIntoMap(m map[string]any, data []byte) (string, error)

Decode the binary data into a map. Return the schema kind.

func EncodeError

func EncodeError(Message string) []byte

Encode the error into binary data.

func EncodeFromMap

func EncodeFromMap(kind string, m map[string]any) ([]byte, error)

Encode the JSON message into an ABI payload.

func EncodeLog

func EncodeLog(Message string) []byte

Encode the log into binary data.

func FilterReports

func FilterReports[T any](reports []Report, id [4]byte) []T

Filter the reports with the given id and unpack it into T.

func FindReport

func FindReport[T any](reports []Report, id [4]byte) (empty T, found bool)

Find the report with the given id and unpack it into T.

func MustAddSchema

func MustAddSchema(schema MessageSchema)

Add a message schema to the schemas managed by EggRoll. Panic if an error occurs.

Types

type AdvanceResult

type AdvanceResult struct {
	Result

	// Advance input index.
	Index int

	// Payload of the input.
	Payload []byte

	// Input sender.
	Sender common.Address

	// Number of the block the input was mined.
	BlockNumber int64

	// Time of the block the input was mined.
	BlockTimestamp time.Time

	// Resulting vouchers of the request.
	Vouchers []Voucher

	// Resulting notices of the request.
	Notices []Notice
}

Result of an advance request.

type CompletionStatus

type CompletionStatus int

Completion of an advance or inspect request.

const (
	CompletionStatusUnprocessed CompletionStatus = iota
	CompletionStatusAccepted
	CompletionStatusRejected
	CompletionStatusException
	CompletionStatusMachineHalted
	CompletionStatusCycleLimitExceeded
	CompletionStatusTimeLimitExceeded
	CompletionStatusPayloadLengthLimitExceeded
)

type Decoder

type Decoder func([]any) (any, error)

Decode binary data into a Go value.

type Encoder

type Encoder interface {

	// Encode a Go value into binary data.
	Encode() []byte
}

The Go types for message schema implement this interface.

type Error

type Error struct {
	Message string
}

Error message from the DApp contract.

func (Error) Encode

func (v Error) Encode() []byte

Encode the error into binary data.

type ID

type ID [4]byte

EggRoll uses 4 bytes to identify the message kind when decoding it. This is based on the function selector of the Solidity ABI.

var ErrorID ID

ID for the error message

var LogID ID

ID for the log message type.

type InspectResult

type InspectResult struct {
	Result

	// Number of processed advance inputs when the inspect was made.
	ProcessedInputCount int
}

Result of an inspect request.

type Log

type Log struct {
	Message string
}

Log message from a DApp contract.

func (Log) Encode

func (v Log) Encode() []byte

Encode the log to into binary data.

type MessageSchema

type MessageSchema struct {
	ID
	Kind string
	abi.Arguments
	Decoder
}

Schema for a message.

func GetSchemas

func GetSchemas() (result []MessageSchema)

Get all schemas managed by EggRoll. The schemas are sorted by Kind.

type Notice

type Notice struct {
	InputIndex  int
	OutputIndex int
	Payload     []byte
}

type Report

type Report struct {
	InputIndex  int
	OutputIndex int
	Payload     []byte
}

type Result

type Result struct {

	// Completion status of the request.
	Status CompletionStatus

	// Resulting reports of the request.
	Reports []Report
}

Result of an request.

func (*Result) Logs

func (r *Result) Logs() []Log

Get logs from the result.

type Voucher

type Voucher struct {
	InputIndex  int
	OutputIndex int
	Destination common.Address
	Payload     []byte
}

Jump to

Keyboard shortcuts

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