coreutil

package
v1.0.3-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Overview

package coreutil provides functions to describe interface of the core contract in a compact way

Index

Constants

View Source
const (
	CoreContractRoot            = "root"
	CoreContractAccounts        = "accounts"
	CoreContractBlob            = "blob"
	CoreContractBlocklog        = "blocklog"
	CoreContractGovernance      = "governance"
	CoreContractErrors          = "errors"
	CoreContractEVM             = "evm"
	CoreEPRotateStateController = "rotateStateController"
)

names of core contracts

View Source
const (
	StateVarTimestamp           = "T" // covered in TestGetEvents
	StateVarBlockIndex          = "I" // covered in TestGetEvents
	StateVarPrevL1Commitment    = "H" // covered in TestGetEvents
	ParamStateControllerAddress = "S"
)

the global names used in 'blocklog' contract and in 'state' package

Variables

View Source
var (
	CoreContractRootHname            = isc.Hn(CoreContractRoot)
	CoreContractAccountsHname        = isc.Hn(CoreContractAccounts)
	CoreContractBlobHname            = isc.Hn(CoreContractBlob)
	CoreContractBlocklogHname        = isc.Hn(CoreContractBlocklog)
	CoreContractGovernanceHname      = isc.Hn(CoreContractGovernance)
	CoreContractErrorsHname          = isc.Hn(CoreContractErrors)
	CoreContractEVMHname             = isc.Hn(CoreContractEVM)
	CoreEPRotateStateControllerHname = isc.Hn(CoreEPRotateStateController)
)
View Source
var (
	StatePrefixTimestamp        = string(CoreContractBlocklogHname.Bytes()) + StateVarTimestamp
	StatePrefixBlockIndex       = string(CoreContractBlocklogHname.Bytes()) + StateVarBlockIndex
	StatePrefixPrevL1Commitment = string(CoreContractBlocklogHname.Bytes()) + StateVarPrevL1Commitment
)

used in 'state' package as key for timestamp and block index

View Source
var FuncDefaultInitializer = Func("initializer")

Functions

func CoreContractProgramHash added in v1.0.3

func CoreContractProgramHash(name string) hashing.HashValue

func CoreHname

func CoreHname(name string) isc.Hname

Types

type ContractInfo

type ContractInfo struct {
	Name        string
	ProgramHash hashing.HashValue
}

ContractInfo holds basic information about a native smart contract

func NewContract

func NewContract(name string) *ContractInfo

func (*ContractInfo) FullKey

func (i *ContractInfo) FullKey(postfix []byte) []byte

FullKey concatenates 4 bytes of hname with postfix

func (*ContractInfo) Hname

func (i *ContractInfo) Hname() isc.Hname

func (*ContractInfo) Processor

func (i *ContractInfo) Processor(init Handler, eps ...isc.ProcessorEntryPoint) *ContractProcessor

Processor creates a ContractProcessor with the provided handlers

type ContractProcessor

type ContractProcessor struct {
	Contract *ContractInfo
	Handlers map[isc.Hname]isc.ProcessorEntryPoint
}

func (*ContractProcessor) Entrypoints added in v1.0.3

func (p *ContractProcessor) Entrypoints() map[isc.Hname]isc.ProcessorEntryPoint

func (*ContractProcessor) GetEntryPoint

func (p *ContractProcessor) GetEntryPoint(code isc.Hname) (isc.VMProcessorEntryPoint, bool)

func (*ContractProcessor) GetStateReadOnly

func (p *ContractProcessor) GetStateReadOnly(chainState kv.KVStoreReader) kv.KVStoreReader

type EntryPointHandler

type EntryPointHandler struct {
	Info    *EntryPointInfo
	Handler Handler
}

func (*EntryPointHandler) Call

func (h *EntryPointHandler) Call(ctx interface{}) dict.Dict

func (*EntryPointHandler) Hname

func (h *EntryPointHandler) Hname() isc.Hname

func (*EntryPointHandler) IsView

func (h *EntryPointHandler) IsView() bool

func (*EntryPointHandler) Name

func (h *EntryPointHandler) Name() string

type EntryPointInfo

type EntryPointInfo struct{ Name string }

EntryPointInfo holds basic information about a full entry point

func Func

func Func(name string) EntryPointInfo

Func declares a full entry point

func (*EntryPointInfo) Hname

func (ep *EntryPointInfo) Hname() isc.Hname

func (*EntryPointInfo) WithHandler

func (ep *EntryPointInfo) WithHandler(fn Handler) *EntryPointHandler

WithHandler specifies the handler function for the entry point

type Handler

type Handler func(ctx isc.Sandbox) dict.Dict

type ViewEntryPointHandler

type ViewEntryPointHandler struct {
	Info    *ViewEntryPointInfo
	Handler ViewHandler
}

func (*ViewEntryPointHandler) Call

func (h *ViewEntryPointHandler) Call(ctx interface{}) dict.Dict

func (*ViewEntryPointHandler) Hname

func (h *ViewEntryPointHandler) Hname() isc.Hname

func (*ViewEntryPointHandler) IsView

func (h *ViewEntryPointHandler) IsView() bool

func (*ViewEntryPointHandler) Name

func (h *ViewEntryPointHandler) Name() string

type ViewEntryPointInfo

type ViewEntryPointInfo struct {
	Name string
}

ViewEntryPointInfo holds basic information about a view entry point

func ViewFunc

func ViewFunc(name string) ViewEntryPointInfo

ViewFunc declares a view entry point

func (*ViewEntryPointInfo) Hname

func (ep *ViewEntryPointInfo) Hname() isc.Hname

func (*ViewEntryPointInfo) WithHandler

WithHandler specifies the handler function for the entry point

type ViewHandler

type ViewHandler func(ctx isc.SandboxView) dict.Dict

Jump to

Keyboard shortcuts

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