smartcontract

package
v0.91.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2020 License: MIT Imports: 21 Imported by: 21

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDefaultMultiSigRedeemScript added in v0.91.0

func CreateDefaultMultiSigRedeemScript(publicKeys keys.PublicKeys) ([]byte, error)

CreateDefaultMultiSigRedeemScript creates an "m out of n" type verification script using publicKeys length with the default BFT assumptions of (n - (n-1)/3) for m.

func CreateMultiSigRedeemScript

func CreateMultiSigRedeemScript(m int, publicKeys keys.PublicKeys) ([]byte, error)

CreateMultiSigRedeemScript creates an "m out of n" type verification script where n is the length of publicKeys.

Types

type CallFlag added in v0.90.0

type CallFlag byte

CallFlag represents call flag.

const (
	AllowStates CallFlag = 1 << iota
	AllowModifyStates
	AllowCall
	AllowNotify
	ReadOnly          = AllowStates | AllowCall | AllowNotify
	All               = ReadOnly | AllowModifyStates
	NoneFlag CallFlag = 0
)

Default flags.

func (CallFlag) Has added in v0.90.0

func (f CallFlag) Has(cf CallFlag) bool

Has returns true iff all bits set in cf are also set in f.

type ContractDetails added in v0.75.0

type ContractDetails struct {
	Author               string
	Email                string
	Version              string
	ProjectName          string `yaml:"name"`
	Description          string
	HasStorage           bool
	HasDynamicInvocation bool
	IsPayable            bool
	ReturnType           ParamType
	Parameters           []ParamType
}

ContractDetails contains contract metadata.

type ParamType

type ParamType int

ParamType represents the Type of the smart contract parameter.

const (
	UnknownType          ParamType = -1
	AnyType              ParamType = 0x00
	BoolType             ParamType = 0x10
	IntegerType          ParamType = 0x11
	ByteArrayType        ParamType = 0x12
	StringType           ParamType = 0x13
	Hash160Type          ParamType = 0x14
	Hash256Type          ParamType = 0x15
	PublicKeyType        ParamType = 0x16
	SignatureType        ParamType = 0x17
	ArrayType            ParamType = 0x20
	MapType              ParamType = 0x22
	InteropInterfaceType ParamType = 0x30
	VoidType             ParamType = 0xff
)

A list of supported smart contract parameter types.

func ParseParamType

func ParseParamType(typ string) (ParamType, error)

ParseParamType is a user-friendly string to ParamType converter, it's case-insensitive and makes the following conversions:

signature -> SignatureType
bool, boolean -> BoolType
int, integer -> IntegerType
hash160 -> Hash160Type
hash256 -> Hash256Type
bytes, bytearray -> ByteArrayType
key, publickey -> PublicKeyType
string -> StringType
array, struct -> ArrayType
map -> MapType
interopinterface -> InteropInterfaceType
void -> VoidType

anything else generates an error.

func (*ParamType) DecodeBinary

func (pt *ParamType) DecodeBinary(r *io.BinReader)

DecodeBinary implements io.Serializable interface.

func (ParamType) EncodeBinary

func (pt ParamType) EncodeBinary(w *io.BinWriter)

EncodeBinary implements io.Serializable interface.

func (ParamType) MarshalJSON

func (pt ParamType) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (ParamType) MarshalYAML

func (pt ParamType) MarshalYAML() (interface{}, error)

MarshalYAML implements the YAML Marshaler interface.

func (ParamType) String

func (pt ParamType) String() string

String implements the stringer interface.

func (*ParamType) UnmarshalJSON

func (pt *ParamType) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface.

func (*ParamType) UnmarshalYAML

func (pt *ParamType) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the YAML Unmarshaler interface.

type Parameter

type Parameter struct {
	// Type of the parameter.
	Type ParamType `json:"type"`
	// The actual value of the parameter.
	Value interface{} `json:"value"`
}

Parameter represents a smart contract parameter.

func NewParameter

func NewParameter(t ParamType) Parameter

NewParameter returns a Parameter with proper initialized Value of the given ParamType.

func NewParameterFromString

func NewParameterFromString(in string) (*Parameter, error)

NewParameterFromString returns a new Parameter initialized from the given string in neo-go-specific format. It is intended to be used in user-facing interfaces and has some heuristics in it to simplify parameter passing. Exact syntax is documented in the cli documentation.

func ParameterFromStackItem added in v0.90.0

func ParameterFromStackItem(i stackitem.Item, seen map[stackitem.Item]bool) Parameter

ParameterFromStackItem converts stackitem.Item to Parameter

func (*Parameter) DecodeBinary added in v0.75.0

func (p *Parameter) DecodeBinary(r *io.BinReader)

DecodeBinary implements io.Serializable interface.

func (*Parameter) EncodeBinary added in v0.75.0

func (p *Parameter) EncodeBinary(w *io.BinWriter)

EncodeBinary implements io.Serializable interface.

func (Parameter) MarshalJSON

func (p Parameter) MarshalJSON() ([]byte, error)

MarshalJSON implements Marshaler interface.

func (Parameter) TryParse

func (p Parameter) TryParse(dest interface{}) error

TryParse converts one Parameter into something more appropriate.

func (*Parameter) UnmarshalJSON

func (p *Parameter) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements Unmarshaler interface.

type ParameterPair added in v0.75.0

type ParameterPair struct {
	Key   Parameter `json:"key"`
	Value Parameter `json:"value"`
}

ParameterPair represents key-value pair, a slice of which is stored in MapType Parameter.

func (*ParameterPair) DecodeBinary added in v0.75.0

func (p *ParameterPair) DecodeBinary(r *io.BinReader)

DecodeBinary implements io.Serializable interface.

func (*ParameterPair) EncodeBinary added in v0.75.0

func (p *ParameterPair) EncodeBinary(w *io.BinWriter)

EncodeBinary implements io.Serializable interface.

type Params

type Params []Parameter

Params is an array of Parameter (TODO: drop it?).

func (Params) TryParseArray

func (p Params) TryParseArray(vals ...interface{}) error

TryParseArray converts an array of Parameter into an array of more appropriate things.

type PropertyState

type PropertyState byte

PropertyState represents contract properties (flags).

const (
	HasStorage   PropertyState = 1 << iota
	IsPayable    PropertyState = 1 << 2
	NoProperties               = 0
)

List of supported properties.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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