contract

package
v0.0.0-...-5fdeb2f Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2020 License: LGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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"`
	XXX_NoUnkeyedLiteral struct{}  `json:"-"`
	XXX_unrecognized     []byte    `json:"-"`
	XXX_sizecache        int32     `json:"-"`
}

func (*ABI) Descriptor

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

func (*ABI) GetAmountLimit

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

func (*ABI) GetArgs

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

func (*ABI) GetName

func (m *ABI) GetName() string

func (*ABI) ProtoMessage

func (*ABI) ProtoMessage()

func (*ABI) Reset

func (m *ABI) Reset()

func (*ABI) String

func (m *ABI) String() string

func (*ABI) XXX_DiscardUnknown

func (m *ABI) XXX_DiscardUnknown()

func (*ABI) XXX_Marshal

func (m *ABI) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ABI) XXX_Merge

func (m *ABI) XXX_Merge(src proto.Message)

func (*ABI) XXX_Size

func (m *ABI) XXX_Size() int

func (*ABI) XXX_Unmarshal

func (m *ABI) XXX_Unmarshal(b []byte) error

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"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Amount) Descriptor

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

func (*Amount) Equal

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

Equal returns whether two amount are equal.

func (*Amount) GetToken

func (m *Amount) GetToken() string

func (*Amount) GetVal

func (m *Amount) GetVal() string

func (*Amount) ProtoMessage

func (*Amount) ProtoMessage()

func (*Amount) Reset

func (m *Amount) Reset()

func (*Amount) String

func (m *Amount) String() string

func (*Amount) ToBytes

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

ToBytes converts Amount to bytes.

func (*Amount) XXX_DiscardUnknown

func (m *Amount) XXX_DiscardUnknown()

func (*Amount) XXX_Marshal

func (m *Amount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Amount) XXX_Merge

func (m *Amount) XXX_Merge(src proto.Message)

func (*Amount) XXX_Size

func (m *Amount) XXX_Size() int

func (*Amount) XXX_Unmarshal

func (m *Amount) XXX_Unmarshal(b []byte) error

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"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

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

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

func (*Contract) Encode

func (c *Contract) Encode() string

Encode contract to string using proto buf

func (*Contract) GetCode

func (m *Contract) GetCode() string

func (*Contract) GetID

func (m *Contract) GetID() string

func (*Contract) GetInfo

func (m *Contract) GetInfo() *Info

func (*Contract) ProtoMessage

func (*Contract) ProtoMessage()

func (*Contract) Reset

func (m *Contract) Reset()

func (*Contract) String

func (m *Contract) String() string

func (*Contract) VerifySelf

func (c *Contract) VerifySelf() error

VerifySelf verify contract's size

func (*Contract) XXX_DiscardUnknown

func (m *Contract) XXX_DiscardUnknown()

func (*Contract) XXX_Marshal

func (m *Contract) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Contract) XXX_Merge

func (m *Contract) XXX_Merge(src proto.Message)

func (*Contract) XXX_Size

func (m *Contract) XXX_Size() int

func (*Contract) XXX_Unmarshal

func (m *Contract) XXX_Unmarshal(b []byte) error

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.Fixed
}

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"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Info) Descriptor

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

func (*Info) GetAbi

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

func (*Info) GetLang

func (m *Info) GetLang() string

func (*Info) GetVersion

func (m *Info) GetVersion() string

func (*Info) ProtoMessage

func (*Info) ProtoMessage()

func (*Info) Reset

func (m *Info) Reset()

func (*Info) String

func (m *Info) String() string

func (*Info) XXX_DiscardUnknown

func (m *Info) XXX_DiscardUnknown()

func (*Info) XXX_Marshal

func (m *Info) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Info) XXX_Merge

func (m *Info) XXX_Merge(src proto.Message)

func (*Info) XXX_Size

func (m *Info) XXX_Size() int

func (*Info) XXX_Unmarshal

func (m *Info) XXX_Unmarshal(b []byte) error

type PaymentCode

type PaymentCode int32

PaymentCode payment mode of contract

const (
	SelfPay PaymentCode = iota
	ContractPay
)

Payment mode

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