manifest

package
v0.90.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2020 License: MIT Imports: 9 Imported by: 3

Documentation

Index

Constants

View Source
const MaxManifestSize = 2048

MaxManifestSize is a max length for a valid contract manifest.

Variables

This section is empty.

Functions

This section is empty.

Types

type ABI

type ABI struct {
	Hash       util.Uint160 `json:"hash"`
	EntryPoint Method       `json:"entryPoint"`
	Methods    []Method     `json:"methods"`
	Events     []Event      `json:"events"`
}

ABI represents a contract application binary interface.

type Event

type Event struct {
	Name       string      `json:"name"`
	Parameters []Parameter `json:"parameters"`
}

Event is a description of a single event.

type Group

type Group struct {
	PublicKey *keys.PublicKey `json:"pubKey"`
	Signature []byte          `json:"signature"`
}

Group represents a group of smartcontracts identified by a public key. Every SC in a group must provide signature of it's hash to prove it belongs to a group.

func (*Group) MarshalJSON

func (g *Group) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*Group) UnmarshalJSON

func (g *Group) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface.

type Manifest

type Manifest struct {
	// ABI is a contract's ABI.
	ABI ABI
	// Groups is a set of groups to which a contract belongs.
	Groups []Group
	// Features is a set of contract's features.
	Features    smartcontract.PropertyState
	Permissions []Permission
	// Trusts is a set of hashes to a which contract trusts.
	Trusts WildUint160s
	// SafeMethods is a set of names of safe methods.
	SafeMethods WildStrings
	// Extra is an implementation-defined user data.
	Extra interface{}
}

Manifest represens contract metadata.

func DefaultManifest

func DefaultManifest(h util.Uint160) *Manifest

DefaultManifest returns default contract manifest.

func NewManifest

func NewManifest(h util.Uint160) *Manifest

NewManifest returns new manifest with necessary fields initialized.

func (*Manifest) CanCall

func (m *Manifest) CanCall(toCall *Manifest, method string) bool

CanCall returns true is current contract is allowed to call method of another contract.

func (*Manifest) DecodeBinary

func (m *Manifest) DecodeBinary(r *io.BinReader)

DecodeBinary implements io.Serializable.

func (*Manifest) EncodeBinary

func (m *Manifest) EncodeBinary(w *io.BinWriter)

EncodeBinary implements io.Serializable.

func (*Manifest) MarshalJSON

func (m *Manifest) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*Manifest) UnmarshalJSON

func (m *Manifest) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface.

type Method

type Method struct {
	Name       string                  `json:"name"`
	Parameters []Parameter             `json:"parameters"`
	ReturnType smartcontract.ParamType `json:"returnType"`
}

Method represents method's metadata.

func DefaultEntryPoint

func DefaultEntryPoint() *Method

DefaultEntryPoint represents default entrypoint to a contract.

type Parameter

type Parameter struct {
	Name string                  `json:"name"`
	Type smartcontract.ParamType `json:"type"`
}

Parameter represents smartcontract's parameter's definition.

func NewParameter

func NewParameter(name string, typ smartcontract.ParamType) Parameter

NewParameter returns new paramter with the specified name and type.

type Permission

type Permission struct {
	Contract PermissionDesc `json:"contract"`
	Methods  WildStrings    `json:"methods"`
}

Permission describes which contracts may be invoked and which methods are called.

func NewPermission

func NewPermission(typ PermissionType, args ...interface{}) *Permission

NewPermission returns new permission of a given type.

func (*Permission) IsAllowed

func (p *Permission) IsAllowed(m *Manifest, method string) bool

IsAllowed checks if method is allowed to be executed.

func (*Permission) UnmarshalJSON

func (p *Permission) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface.

type PermissionDesc

type PermissionDesc struct {
	Type  PermissionType
	Value interface{}
}

PermissionDesc is a permission descriptor.

func (*PermissionDesc) Group

func (d *PermissionDesc) Group() *keys.PublicKey

Group returns group's public key for group-permission.

func (*PermissionDesc) Hash

func (d *PermissionDesc) Hash() util.Uint160

Hash returns hash for hash-permission.

func (*PermissionDesc) MarshalJSON

func (d *PermissionDesc) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*PermissionDesc) UnmarshalJSON

func (d *PermissionDesc) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface.

type PermissionType

type PermissionType uint8

PermissionType represents permission type.

const (
	// PermissionWildcard allows everything.
	PermissionWildcard PermissionType = 0
	// PermissionHash restricts called contracts based on hash.
	PermissionHash PermissionType = 1
	// PermissionGroup restricts called contracts based on public key.
	PermissionGroup PermissionType = 2
)

type WildStrings

type WildStrings struct {
	Value []string
}

WildStrings represents string set which can be wildcard.

func (*WildStrings) Add

func (c *WildStrings) Add(v string)

Add adds v to the container.

func (*WildStrings) Contains

func (c *WildStrings) Contains(v string) bool

Contains checks if v is in the container.

func (*WildStrings) IsWildcard

func (c *WildStrings) IsWildcard() bool

IsWildcard returns true iff container is wildcard.

func (*WildStrings) MarshalJSON

func (c *WildStrings) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*WildStrings) Restrict

func (c *WildStrings) Restrict()

Restrict transforms container into an empty one.

func (*WildStrings) UnmarshalJSON

func (c *WildStrings) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface.

type WildUint160s

type WildUint160s struct {
	Value []util.Uint160
}

WildUint160s represents Uint160 set which can be wildcard.

func (*WildUint160s) Add

func (c *WildUint160s) Add(v util.Uint160)

Add adds v to the container.

func (*WildUint160s) Contains

func (c *WildUint160s) Contains(v util.Uint160) bool

Contains checks if v is in the container.

func (*WildUint160s) IsWildcard

func (c *WildUint160s) IsWildcard() bool

IsWildcard returns true iff container is wildcard.

func (*WildUint160s) MarshalJSON

func (c *WildUint160s) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*WildUint160s) Restrict

func (c *WildUint160s) Restrict()

Restrict transforms container into an empty one.

func (*WildUint160s) UnmarshalJSON

func (c *WildUint160s) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface.

Jump to

Keyboard shortcuts

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