contract

package
v3.8.4 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2022 License: LGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_core_contract_contract_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type ABI

type ABI struct {
	Name        string    `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Args        []string  `protobuf:"bytes,2,rep,name=args,proto3" json:"args,omitempty"`
	AmountLimit []*Amount `protobuf:"bytes,3,rep,name=amountLimit,proto3" json:"amountLimit,omitempty"`
	// contains filtered or unexported fields
}

func (*ABI) Descriptor deprecated

func (*ABI) Descriptor() ([]byte, []int)

Deprecated: Use ABI.ProtoReflect.Descriptor instead.

func (*ABI) GetAmountLimit

func (x *ABI) GetAmountLimit() []*Amount

func (*ABI) GetArgs

func (x *ABI) GetArgs() []string

func (*ABI) GetName

func (x *ABI) GetName() string

func (*ABI) ProtoMessage

func (*ABI) ProtoMessage()

func (*ABI) ProtoReflect

func (x *ABI) ProtoReflect() protoreflect.Message

func (*ABI) Reset

func (x *ABI) Reset()

func (*ABI) String

func (x *ABI) String() string

type Amount

type Amount struct {
	Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`
	Val   string `protobuf:"bytes,2,opt,name=val,proto3" json:"val,omitempty"`
	// contains filtered or unexported fields
}

func (*Amount) Descriptor deprecated

func (*Amount) Descriptor() ([]byte, []int)

Deprecated: Use Amount.ProtoReflect.Descriptor instead.

func (*Amount) Equal

func (a *Amount) Equal(am *Amount) bool

Equal returns whether two amount are equal.

func (*Amount) GetToken

func (x *Amount) GetToken() string

func (*Amount) GetVal

func (x *Amount) GetVal() string

func (*Amount) ProtoMessage

func (*Amount) ProtoMessage()

func (*Amount) ProtoReflect

func (x *Amount) ProtoReflect() protoreflect.Message

func (*Amount) Reset

func (x *Amount) Reset()

func (*Amount) String

func (x *Amount) String() string

func (*Amount) ToBytes

func (a *Amount) ToBytes() []byte

ToBytes converts Amount to bytes.

type Compiler

type Compiler struct {
}

Compiler parse contract from json string

func (*Compiler) Parse

func (c *Compiler) Parse(id, code, abi string) (*Contract, error)

Parse parse contract from json abi string, set code and id

type Contract

type Contract struct {
	ID       string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"`
	Info     *Info  `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"`
	Code     string `protobuf:"bytes,3,opt,name=code,proto3" json:"code,omitempty"`
	OrigCode string `protobuf:"bytes,4,opt,name=origCode,proto3" json:"origCode,omitempty"`
	// contains filtered or unexported fields
}

func Compile

func Compile(id, src, abi string) (*Contract, error)

Compile read src and abi file, generate contract structure

func DecodeContract

func DecodeContract(str string) *Contract

DecodeContract static method to decode contract from string

func (*Contract) ABI

func (c *Contract) ABI(name string) *ABI

ABI get abi from contract with specific name

func (*Contract) B64Decode

func (c *Contract) B64Decode(str string) error

B64Decode decode contract from base64 string

func (*Contract) B64Encode

func (c *Contract) B64Encode() string

B64Encode encode contract to base64 string

func (*Contract) Decode

func (c *Contract) Decode(str string) error

Decode contract from string using proto buf

func (*Contract) Descriptor deprecated

func (*Contract) Descriptor() ([]byte, []int)

Deprecated: Use Contract.ProtoReflect.Descriptor instead.

func (*Contract) Encode

func (c *Contract) Encode() string

Encode contract to string using proto buf

func (*Contract) GetCode

func (x *Contract) GetCode() string

func (*Contract) GetID

func (x *Contract) GetID() string

func (*Contract) GetInfo

func (x *Contract) GetInfo() *Info

func (*Contract) GetOrigCode

func (x *Contract) GetOrigCode() string

func (*Contract) ProtoMessage

func (*Contract) ProtoMessage()

func (*Contract) ProtoReflect

func (x *Contract) ProtoReflect() protoreflect.Message

func (*Contract) Reset

func (x *Contract) Reset()

func (*Contract) String

func (x *Contract) String() string

func (*Contract) VerifySelf

func (c *Contract) VerifySelf() error

VerifySelf verify contract's size

type Cost

type Cost struct {
	Data     int64
	Net      int64
	CPU      int64
	DataList []DataItem
}

Cost ...

func Cost0

func Cost0() Cost

Cost0 construct zero cost

func NewCost

func NewCost(data, net, cpu int64, dataList ...DataItem) Cost

NewCost construct cost with specific data, net, cpu

func (*Cost) AddAssign

func (c *Cost) AddAssign(a Cost)

AddAssign add cost to self

func (Cost) IsOverflow

func (c Cost) IsOverflow(limit Cost) bool

IsOverflow decide if exceed limit

func (Cost) Multiply

func (c Cost) Multiply(i int64) Cost

Multiply a cost to int64, return new cost

func (Cost) ToGas

func (c Cost) ToGas() int64

ToGas convert cost to gas

type DataItem

type DataItem struct {
	Payer string
	Val   int64
}

DataItem describe ram cost with value and payer

type FixedAmount

type FixedAmount struct {
	Token string
	Val   *common.Decimal
}

FixedAmount the limit amount of token used by contract

type Info

type Info struct {
	Lang    string `protobuf:"bytes,1,opt,name=lang,proto3" json:"lang,omitempty"`
	Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"`
	Abi     []*ABI `protobuf:"bytes,3,rep,name=abi,proto3" json:"abi,omitempty"`
	// contains filtered or unexported fields
}

func (*Info) Descriptor deprecated

func (*Info) Descriptor() ([]byte, []int)

Deprecated: Use Info.ProtoReflect.Descriptor instead.

func (*Info) GetAbi

func (x *Info) GetAbi() []*ABI

func (*Info) GetLang

func (x *Info) GetLang() string

func (*Info) GetVersion

func (x *Info) GetVersion() string

func (*Info) ProtoMessage

func (*Info) ProtoMessage()

func (*Info) ProtoReflect

func (x *Info) ProtoReflect() protoreflect.Message

func (*Info) Reset

func (x *Info) Reset()

func (*Info) String

func (x *Info) String() string

type VersionCode

type VersionCode string

VersionCode version of contract

Jump to

Keyboard shortcuts

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