contract

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2020 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CTypeNone = iota
	CTypeTransfer
	CTypeDeploy
	CTypeCall
	CTypePatch
	CTypeDeposit
)
View Source
const (
	DepositActionAdd      = "add"
	DepositActionWithdraw = "withdraw"
)
View Source
const (
	PreparingContractError = iota + errors.CodeService + 200
	NoAvailableProxy
)
View Source
const (
	CID_CHAIN = "CID_CHAINSCORE"
)
View Source
const (
	FUNC_PREFIX = "Ex_"
)

Variables

This section is empty.

Functions

func CheckMethod

func CheckMethod(obj SystemScore) error

func DeployAndInstallSystemSCORE added in v0.9.1

func DeployAndInstallSystemSCORE(cc CallContext, contentID string, owner, to module.Address, param []byte, tid []byte) error

func Invoke

func Invoke(score SystemScore, method string, paramObj *codec.TypedObj) (status error, result *codec.TypedObj, steps *big.Int)

func NewContext

func NewContext(wc state.WorldContext, cm ContractManager, eem eeproxy.Manager, chain module.Chain, log log.Logger, ti *module.TraceInfo) *context

func NewDepositContext added in v0.9.3

func NewDepositContext(cc CallContext) state.DepositContext

func NewFrame

func NewFrame(p *callFrame, h ContractHandler, l *big.Int, q bool) *callFrame

func RegisterSystemScore added in v0.9.1

func RegisterSystemScore(id string, m *SystemScoreModule)

func RoundLimitFactorToRound

func RoundLimitFactorToRound(validator int, factor int64) int64

Types

type AcceptHandler

type AcceptHandler struct {
	*CommonHandler
	// contains filtered or unexported fields
}

func NewAcceptHandler added in v0.9.1

func NewAcceptHandler(ch *CommonHandler, txHash []byte, auditTxHash []byte) *AcceptHandler

func (*AcceptHandler) ExecuteSync

func (h *AcceptHandler) ExecuteSync(cc CallContext) (error, *codec.TypedObj, module.Address)

func (*AcceptHandler) Prepare

func (h *AcceptHandler) Prepare(ctx Context) (state.WorldContext, error)

It's never called

type AsyncContractHandler

type AsyncContractHandler interface {
	ContractHandler
	ExecuteAsync(cc CallContext) error
	SendResult(status error, steps *big.Int, result *codec.TypedObj) error
	Dispose()

	EEType() state.EEType
	eeproxy.CallContext
}

type CallContext

type CallContext interface {
	Context
	QueryMode() bool
	Call(handler ContractHandler, limit *big.Int) (error, *big.Int, *codec.TypedObj, module.Address)
	OnResult(status error, stepUsed *big.Int, result *codec.TypedObj, addr module.Address)
	OnCall(handler ContractHandler, limit *big.Int)
	OnEvent(addr module.Address, indexed, data [][]byte)
	GetBalance(module.Address) *big.Int
	ReserveExecutor() error
	GetProxy(eeType state.EEType) eeproxy.Proxy
	Dispose()
	StepUsed() *big.Int
	StepAvailable() *big.Int
	ApplySteps(t state.StepType, n int) bool
	DeductSteps(s *big.Int) bool
	ResetStepLimit(s *big.Int)
	GetEventLogs(r txresult.Receipt)
	EnterQueryMode()
	SetCodeID(code string)
	GetLastEIDOf(code string) int
	NewExecution() int
	GetReturnEID() int
	SetFeeProportion(addr module.Address, portion int)
	RedeemSteps(s *big.Int) (*big.Int, error)
	GetRedeemLogs(r txresult.Receipt) bool
	ClearRedeemLogs()
}

func NewCallContext

func NewCallContext(ctx Context, limit *big.Int, isQuery bool) CallContext

type CallHandler

type CallHandler struct {
	*CommonHandler
	// contains filtered or unexported fields
}

func (*CallHandler) DeleteValue

func (h *CallHandler) DeleteValue(key []byte) ([]byte, error)

func (*CallHandler) Dispose

func (h *CallHandler) Dispose()

func (*CallHandler) EEType

func (h *CallHandler) EEType() state.EEType

func (*CallHandler) ExecuteAsync

func (h *CallHandler) ExecuteAsync(cc CallContext) (err error)

func (*CallHandler) GetBalance

func (h *CallHandler) GetBalance(addr module.Address) *big.Int

func (*CallHandler) GetInfo

func (h *CallHandler) GetInfo() *codec.TypedObj

func (*CallHandler) GetObjGraph

func (h *CallHandler) GetObjGraph(flags bool) (int, []byte, []byte, error)

func (*CallHandler) GetValue

func (h *CallHandler) GetValue(key []byte) ([]byte, error)

func (*CallHandler) OnAPI

func (h *CallHandler) OnAPI(status error, info *scoreapi.Info)

func (*CallHandler) OnCall

func (h *CallHandler) OnCall(from, to module.Address, value,
	limit *big.Int, method string, params *codec.TypedObj,
)

func (*CallHandler) OnEvent

func (h *CallHandler) OnEvent(addr module.Address, indexed, data [][]byte)

func (*CallHandler) OnResult

func (h *CallHandler) OnResult(status error, steps *big.Int, result *codec.TypedObj)

func (*CallHandler) OnSetFeeProportion added in v0.9.3

func (h *CallHandler) OnSetFeeProportion(addr module.Address, portion int)

func (*CallHandler) Prepare

func (h *CallHandler) Prepare(ctx Context) (state.WorldContext, error)

func (*CallHandler) SendResult

func (h *CallHandler) SendResult(status error, steps *big.Int, result *codec.TypedObj) error

func (*CallHandler) SetCode

func (h *CallHandler) SetCode(code []byte) error

func (*CallHandler) SetObjGraph

func (h *CallHandler) SetObjGraph(flags bool, nextHash int, objGraph []byte) error

func (*CallHandler) SetValue

func (h *CallHandler) SetValue(key []byte, value []byte) ([]byte, error)

type CommonHandler

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

func NewCommonHandler added in v0.9.1

func NewCommonHandler(from, to module.Address, value *big.Int, log log.Logger) *CommonHandler

func (*CommonHandler) Logger

func (h *CommonHandler) Logger() log.Logger

func (*CommonHandler) Prepare

func (h *CommonHandler) Prepare(ctx Context) (state.WorldContext, error)

func (*CommonHandler) ResetLogger

func (h *CommonHandler) ResetLogger(logger log.Logger)

type Context

type Context interface {
	state.WorldContext
	ContractManager() ContractManager
	EEManager() eeproxy.Manager
	GetPreInstalledScore(id string) ([]byte, error)
	Logger() log.Logger
	PatchDecoder() module.PatchDecoder
	TraceInfo() *module.TraceInfo
	ChainID() int
}

type ContractHandler

type ContractHandler interface {
	Prepare(ctx Context) (state.WorldContext, error)
	ResetLogger(logger log.Logger)
}

type ContractManager

type ContractManager interface {
	GetHandler(from, to module.Address, value *big.Int, ctype int, data []byte) (ContractHandler, error)
	GetCallHandler(from, to module.Address, value *big.Int, method string, paramObj *codec.TypedObj) ContractHandler
	PrepareContractStore(ws state.WorldState, contract state.Contract) (ContractStore, error)
	GetSystemScore(contentID string, cc CallContext, from module.Address) (SystemScore, error)
}

func NewContractManager

func NewContractManager(db db.Database, contractDir string, log log.Logger) (ContractManager, error)

type ContractStore

type ContractStore interface {
	WaitResult() (string, error)
	Dispose()
}

type DataCallJSON

type DataCallJSON struct {
	Method string          `json:"method"`
	Params json.RawMessage `json:"params"`
}

func ParseCallData

func ParseCallData(data []byte) (*DataCallJSON, error)

type DeployData

type DeployData struct {
	ContentType string          `json:"contentType"`
	Content     common.HexBytes `json:"content"`
	Params      json.RawMessage `json:"params"`
}

func ParseDeployData

func ParseDeployData(data []byte) (*DeployData, error)

type DeployHandler

type DeployHandler struct {
	*CommonHandler
	// contains filtered or unexported fields
}

func NewDeployHandlerForPreInstall

func NewDeployHandlerForPreInstall(owner, scoreAddr module.Address, contentType string,
	content []byte, params *json.RawMessage, log log.Logger,
) *DeployHandler

func (*DeployHandler) ExecuteSync

func (h *DeployHandler) ExecuteSync(cc CallContext) (error, *codec.TypedObj, module.Address)

func (*DeployHandler) Prepare

func (h *DeployHandler) Prepare(ctx Context) (state.WorldContext, error)

type DepositHandler added in v0.9.3

type DepositHandler struct {
	*CommonHandler
	// contains filtered or unexported fields
}

func (*DepositHandler) ExecuteSync added in v0.9.3

func (h *DepositHandler) ExecuteSync(cc CallContext) (err error, ro *codec.TypedObj, addr module.Address)

func (*DepositHandler) Prepare added in v0.9.3

func (h *DepositHandler) Prepare(ctx Context) (state.WorldContext, error)

type DepositJSON added in v0.9.3

type DepositJSON struct {
	Action string           `json:"action"`
	ID     *common.HexBytes `json:"id,omitempty"`
}

func ParseDepositData added in v0.9.3

func ParseDepositData(data []byte) (*DepositJSON, error)

type Patch

type Patch struct {
	Type string `json:"type"`
	Data []byte `json:"data"`
}

func ParsePatchData

func ParsePatchData(data []byte) (*Patch, error)

type SyncContractHandler

type SyncContractHandler interface {
	ContractHandler
	ExecuteSync(cc CallContext) (error, *codec.TypedObj, module.Address)
}

type SystemScore

type SystemScore interface {
	Install(param []byte) error
	Update(param []byte) error
	GetAPI() *scoreapi.Info
}

type SystemScoreModule

type SystemScoreModule struct {
	New func(cid string, cc CallContext, from module.Address) (SystemScore, error)
}

type TransferAndCallHandler

type TransferAndCallHandler struct {
	*CallHandler
	// contains filtered or unexported fields
}

func (*TransferAndCallHandler) ExecuteAsync

func (h *TransferAndCallHandler) ExecuteAsync(cc CallContext) error

func (*TransferAndCallHandler) Prepare

type TransferAndMessageHandler

type TransferAndMessageHandler struct {
	*TransferHandler
	// contains filtered or unexported fields
}

type TransferHandler

type TransferHandler struct {
	*CommonHandler
}

func (*TransferHandler) ExecuteSync

func (h *TransferHandler) ExecuteSync(cc CallContext) (error, *codec.TypedObj, module.Address)

Jump to

Keyboard shortcuts

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