smart

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Apache-2.0 Imports: 46 Imported by: 3

Documentation

Overview

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

Index

Constants

View Source
const (
	CallDelayedContract = "@1CallDelayedContract"
	NewUserContract     = "@1NewUser"
	NewBadBlockContract = "@1NewBadBlock"
)
View Source
const (
	// AddressLength is the expected length of the address
	AddressLength = 20
)
View Source
const (
	// MaxPrice is a maximal value that price function can return
	MaxPrice = 100000000000000000
)
View Source
const (
	SysName = `@system`
)

Variables

View Source
var Arithmetic_name = map[int32]string{
	0: "NATIVE",
	3: "MUL",
	4: "DIV",
}
View Source
var Arithmetic_value = map[string]int32{
	"NATIVE": 0,
	"MUL":    3,
	"DIV":    4,
}
View Source
var BOM = []byte{0xEF, 0xBB, 0xBF}
View Source
var (
	ErrNotImplementedOnCLB = errors.New("Contract not implemented on CLB")
)
View Source
var FuelType_name = map[int32]string{
	0: "UNKNOWN",
	1: "vmCost_fee",
	2: "storage_fee",
	3: "expedite_fee",
}
View Source
var FuelType_value = map[string]int32{
	"UNKNOWN":      0,
	"vmCost_fee":   1,
	"storage_fee":  2,
	"expedite_fee": 3,
}
View Source
var GasPayAbleType_name = map[int32]string{
	0: "Invalid",
	1: "Unable",
	2: "Capable",
}
View Source
var GasPayAbleType_value = map[string]int32{
	"Invalid": 0,
	"Unable":  1,
	"Capable": 2,
}
View Source
var GasScenesType_name = map[int32]string{
	0:  "Unknown",
	1:  "Reward",
	2:  "Taxes",
	15: "Direct",
	16: "Combustion",
	24: "TransferSelf",
}
View Source
var GasScenesType_value = map[string]int32{
	"Unknown":      0,
	"Reward":       1,
	"Taxes":        2,
	"Direct":       15,
	"Combustion":   16,
	"TransferSelf": 24,
}
View Source
var PaymentType_name = map[int32]string{
	0: "INVALID",
	1: "ContractCaller",
	2: "ContractBinder",
	3: "EcosystemAddress",
}
View Source
var PaymentType_value = map[string]int32{
	"INVALID":          0,
	"ContractCaller":   1,
	"ContractBinder":   2,
	"EcosystemAddress": 3,
}

Functions

func ActivateContract

func ActivateContract(tblid, state int64, active bool)

ActivateContract sets Active status of the contract in script.GetVM()

func AllowChangeCondition

func AllowChangeCondition(sc *SmartContract, tblname string) error

AllowChangeCondition check access to change condition throught supper contract

func AppParam

func AppParam(sc *SmartContract, app int64, name string, ecosystem int64) (string, error)

AppParam returns the value of the specified app parameter for the ecosystem

func Append

func Append(slice []any, val any) []any

Append syn for golang 'append' function

func BlockTime

func BlockTime(sc *SmartContract) string

func BndWallet

func BndWallet(sc *SmartContract, tblid int64, state int64) error

BndWallet sets wallet_id to current wallet and updates value in vm

func BytesToString

func BytesToString(src []byte) string

BytesToString converts bytes to string

func CheckCondition

func CheckCondition(sc *SmartContract, condition string) (bool, error)

CheckCondition evaluates the condition

func CheckNumberChars

func CheckNumberChars(data string) bool

func CheckSign

func CheckSign(pub, data, sign string) (bool, error)

func CheckSignature

func CheckSignature(sc *SmartContract, i map[string]any, name string) error

CheckSignature checks the additional signatures for the contract

func ColumnCondition

func ColumnCondition(sc *SmartContract, tableName, name, coltype, permissions string) error

ColumnCondition is contract func

func CompileContract

func CompileContract(sc *SmartContract, code string, state, id, token int64) (any, error)

CompileContract is compiling contract

func ContractAccess

func ContractAccess(sc *SmartContract, names ...any) bool

ContractAccess checks whether the name of the executable contract matches one of the names listed in the parameters.

func ContractConditions

func ContractConditions(sc *SmartContract, names ...any) (bool, error)

ContractConditions calls the 'conditions' function for each of the contracts specified in the parameters

func CreateCLB

func CreateCLB(sc *SmartContract, name, dbUser, dbPassword string, port int64) error

CreateCLB allow create new CLB throught clbmanager

func CreateColumn

func CreateColumn(sc *SmartContract, tableName, name, colType, permissions string) (err error)

CreateColumn is creating column

func CreateContract

func CreateContract(sc *SmartContract, name, value, conditions string, tokenEcosystem, appID int64) (int64, error)

func CreateEcosystem

func CreateEcosystem(sc *SmartContract, wallet int64, name string) (int64, error)

CreateEcosystem creates a new ecosystem

func CreateLanguage

func CreateLanguage(sc *SmartContract, name, trans string) (id int64, err error)

NewLang creates new language

func CreateTable

func CreateTable(sc *SmartContract, name, columns, permissions string, applicationID int64) (err error)

CreateTable is creating smart contract table

func CreateView

func CreateView(sc *SmartContract, vname, columns, where string, applicationID int64) (err error)

CreateView is creating smart contract view table

func DBCollectMetrics

func DBCollectMetrics(sc *SmartContract) []any

DBCollectMetrics returns actual values of all metrics This function used to further store these values

func DBCount

func DBCount(sc *SmartContract, tableName string, inWhere *types.Map) (count int64, err error)

func DBInsert

func DBInsert(sc *SmartContract, tblname string, values *types.Map) (qcost int64, ret int64, err error)

DBInsert inserts a record into the specified database table

func DBSelect

func DBSelect(sc *SmartContract, tblname string, inColumns any, id int64, inOrder any,
	offset, limit int64, inWhere *types.Map, query any, group string, all bool) (int64, []any, error)

DBSelect returns an array of values of the specified columns when there is selection of data 'offset', 'limit', 'where'

func DBSelectMetrics

func DBSelectMetrics(sc *SmartContract, metric, timeInterval, aggregateFunc string) ([]any, error)

DBSelectMetrics returns list of metrics by name and time interval

func DBUpdate

func DBUpdate(sc *SmartContract, tblname string, id int64, values *types.Map) (qcost int64, err error)

DBUpdate updates the item with the specified id in the table

func DBUpdateExt

func DBUpdateExt(sc *SmartContract, tblname string, where *types.Map,
	values *types.Map) (qcost int64, err error)

DBUpdateExt updates the record in the specified table. You can specify 'where' query in params and then the values for this query

func Date

func Date(timeFormat string, timestamp int64) string

Date formats timestamp to specified date format

func DateTime

func DateTime(unix int64) string

func DateTimeLocation

func DateTimeLocation(unix int64, locationName string) (string, error)

func DecodeBase64

func DecodeBase64(input string) (out string, err error)

DecodeBase64 decodes base64 string

func DelColumn

func DelColumn(sc *SmartContract, tableName, name string) (err error)

func DelTable

func DelTable(sc *SmartContract, tableName string) (err error)

func DeleteCLB

func DeleteCLB(sc *SmartContract, name string) error

DeleteCLB delete clb

func EcosysParam

func EcosysParam(sc *SmartContract, name string) string

EcosysParam returns the value of the specified parameter for the ecosystem

func EditEcosysName

func EditEcosysName(sc *SmartContract, sysID int64, newName string) error

EditEcosysName set newName for ecosystem

func EditLanguage

func EditLanguage(sc *SmartContract, id int64, name, trans string) error

EditLanguage edits language

func EmbedFuncs

func EmbedFuncs(vt script.VMType) map[string]any

EmbedFuncs is extending vm with embedded functions

func EncodeBase64

func EncodeBase64(input string) (out string)

EncodeBase64 encodes string in base64

func EthereumAddress

func EthereumAddress(pub []byte) string

func Eval

func Eval(sc *SmartContract, condition string) error

Eval evaluates the condition

func EvalCondition

func EvalCondition(sc *SmartContract, table, name, condfield string) error

EvalCondition gets the condition and check it

func FillTxData

func FillTxData(fieldInfos []*script.FieldInfo, params map[string]any) (map[string]any, error)

func Float

func Float(v any) (ret float64)

Float converts the value to float64

func Floor

func Floor(x any) (int64, error)

Floor returns the greatest integer value less than or equal to x

func FlushContract

func FlushContract(sc *SmartContract, iroot any, id int64) error

FlushContract is flushing contract

func FormatMoney

func FormatMoney(sc *SmartContract, exp string, digit int64) (string, error)

func GetAllContracts

func GetAllContracts() (string, error)

func GetBlock

func GetBlock(blockID int64) (*types.Map, error)

func GetCLBList

func GetCLBList(sc *SmartContract) map[string]string

GetCLBList returns list CLB process with statuses

func GetColumnType

func GetColumnType(sc *SmartContract, tableName, columnName string) (string, error)

GetColumnType returns the type of the column

func GetContractById

func GetContractById(sc *SmartContract, id int64) string

GetContractById returns the name of the contract with this id

func GetContractByName

func GetContractByName(sc *SmartContract, name string) int64

GetContractByName returns id of the contract with this name

func GetDataFromXLSX

func GetDataFromXLSX(sc *SmartContract, binaryID, startLine, linesCount, sheetNum int64) (data []any, err error)

GetDataFromXLSX returns json by parameters range

func GetHistory

func GetHistory(sc *SmartContract, tableName string, id int64) ([]any, error)

func GetHistoryRaw

func GetHistoryRaw(dbTx *sqldb.DbTransaction, ecosystem int64, tableName string,
	id, idRollback int64) ([]any, error)

func GetHistoryRow

func GetHistoryRow(sc *SmartContract, tableName string, id, idRollback int64) (*types.Map,
	error)

func GetLogTxCount

func GetLogTxCount(sc *SmartContract, ecosystemID int64) (int64, error)

func GetMapKeys

func GetMapKeys(in *types.Map) []any

GetMapKeys returns the array of keys of the map

func GetRowsCountXLSX

func GetRowsCountXLSX(sc *SmartContract, binaryID, sheetNum int64) (int64, error)

GetRowsCountXLSX returns count of rows from excel file

func GetType

func GetType(val any) string

GetType returns the name of the type of the value

func GetUsedContracts

func GetUsedContracts(name string, state uint32, full bool) []string

GetUsedContracts returns the list of contracts which are called from the specified contract

func HMac

func HMac(key, data string, raw_output bool) (ret string, err error)

HMac returns HMAC hash as raw or hex string

func HTTPPostJSON

func HTTPPostJSON(requrl string, head *types.Map, json_str string) (string, error)

HTTPPostJSON sends post http request with json

func HTTPRequest

func HTTPRequest(requrl, method string, head *types.Map, params *types.Map) (string, error)

HTTPRequest sends http request

func Hash

func Hash(data any) (string, error)

Hash returns hash sum of data

func HexToBytes

func HexToBytes(hexdata string) ([]byte, error)

HexToBytes converts the hexadecimal representation to []byte

func InitVM

func InitVM()

func Int

func Int(v any) (int64, error)

Int converts the value to a number

func IsHonorNodeKey

func IsHonorNodeKey(id int64) bool

func IsObject

func IsObject(sc *SmartContract, name string, state int64) bool

IsObject returns true if there is the specified contract

func JSONDecode

func JSONDecode(input string) (ret any, err error)

JSONDecode converts json string to object

func JSONEncode

func JSONEncode(input any) (string, error)

JSONEncode converts object to json string

func JSONEncodeIndent

func JSONEncodeIndent(input any, indent string) (string, error)

JSONEncodeIndent converts object to json string

func Join

func Join(input []any, sep string) string

Join is joining input with separator

func LangRes

func LangRes(sc *SmartContract, idRes string) string

LangRes returns the language resource

func Len

func Len(in []any) int64

Len returns the length of the slice

func LoadContract

func LoadContract(transaction *sqldb.DbTransaction, ecosystem int64) (err error)

LoadContract reads and compiles contract of new state

func LoadContracts

func LoadContracts() error

LoadContracts reads and compiles contracts from smart_contracts tables

func Log

func Log(x any) (float64, error)

Log returns the natural logarithm of x

func Log10

func Log10(x any) (float64, error)

Log10 returns the decimal logarithm of x

func MathMod

func MathMod(x, y float64) float64

func MathModDecimal

func MathModDecimal(x, y decimal.Decimal) decimal.Decimal

func Money

func Money(v any) (decimal.Decimal, error)

Money converts the value into a numeric type for money

func PermColumn

func PermColumn(sc *SmartContract, tableName, name, permissions string) error

PermColumn is contract func

func PermTable

func PermTable(sc *SmartContract, name, permissions string) error

PermTable is changing permission of table

func Pow

func Pow(x, y any) (float64, error)

Pow returns x**y, the base-x exponential of y

func PrefixName

func PrefixName(table string) (prefix, name string)

func PrepareColumns

func PrepareColumns(columns []string) string

PrepareColumns replaces jsonb fields -> in the list of columns for db selecting For example, name,doc->title => name,doc::jsonb->>'title' as "doc.title"

func PubToHex

func PubToHex(in any) (ret string)

func PubToID

func PubToID(hexkey string) int64

PubToID returns a numeric identifier for the public key specified in the hexadecimal form.

func RandomDecimal

func RandomDecimal(sc *SmartContract, min decimal.Decimal, max decimal.Decimal) (decimal.Decimal, error)

func RandomFloat

func RandomFloat(sc *SmartContract, min float64, max float64) (float64, error)

func RandomInt

func RandomInt(sc *SmartContract, min int64, max int64) (int64, error)

RandomInt returns a random value between min and max

func RegexpMatch

func RegexpMatch(str, reg string) bool

RegexpMatch validates regexp

func Replace

func Replace(s, old, new string) string

Replace replaces old substrings to new substrings

func RoleAccess

func RoleAccess(sc *SmartContract, ids ...any) (bool, error)

RoleAccess checks whether the name of the role matches one of the names listed in the parameters.

func Round

func Round(x any) (int64, error)

Round returns the nearest integer, rounding half away from zero

func RowConditions

func RowConditions(sc *SmartContract, tblname string, id int64, conditionOnly bool) error

RowConditions checks conditions for table row by id

func SendExternalTransaction

func SendExternalTransaction(sc *SmartContract, uid, url, externalContract string,
	params *types.Map, resultContract string) (err error)

func SetContractWallet

func SetContractWallet(sc *SmartContract, tblid, state int64, wallet int64) error

SetContractWallet changes WalletID of the contract in script.GetVM()

func Size

func Size(s string) int64

Size returns the length of the string

func SortedKeys

func SortedKeys(m *types.Map) []any

SortedKeys returns the sorted array of keys of the map

func Split

func Split(input, sep string) []any

Split splits the input string to array

func Sqrt

func Sqrt(x any) (float64, error)

Sqrt returns the square root of x

func StartCLB

func StartCLB(sc *SmartContract, name string) error

StartCLB run CLB process

func StopCLBProcess

func StopCLBProcess(sc *SmartContract, name string) error

StopCLBProcess stops CLB process

func Str

func Str(v any) (ret string)

Str converts the value to a string

func StringToBytes

func StringToBytes(src string) []byte

StringToBytes converts string to bytes

func Substr

func Substr(s string, off int64, slen int64) string

Substr returns the substring of the string

func SysFlushContract

func SysFlushContract(iroot any, id int64, active bool) error

SysFlushContract is flushing contract

func SysFuel

func SysFuel(state int64) string

SysFuel returns the fuel rate

func SysParamInt

func SysParamInt(name string) int64

SysParamInt returns the value of the system parameter

func SysParamString

func SysParamString(name string) string

SysParamString returns the value of the system parameter

func SysRollback

func SysRollback(sc *SmartContract, data SysRollData) error

func SysRollbackActivate

func SysRollbackActivate(sysData SysRollData) error

SysRollbackActivate sets Deactive status of the contract in smartVM

func SysRollbackColumn

func SysRollbackColumn(dbTx *sqldb.DbTransaction, sysData SysRollData) error

SysRollbackColumn is rolling back column

func SysRollbackContract

func SysRollbackContract(name string, EcosystemID int64) error

SysRollbackContract performs rollback for the contract

func SysRollbackDeactivate

func SysRollbackDeactivate(sysData SysRollData) error

SysRollbackDeactivate sets Active status of the contract in smartVM

func SysRollbackDeleteColumn

func SysRollbackDeleteColumn(dbTx *sqldb.DbTransaction, sysData SysRollData) error

SysRollbackDeleteColumn is rolling back delete column

func SysRollbackDeleteTable

func SysRollbackDeleteTable(dbTx *sqldb.DbTransaction, sysData SysRollData) error

SysRollbackDeleteTable is rolling back delete table

func SysRollbackEcosystem

func SysRollbackEcosystem(dbTx *sqldb.DbTransaction, sysData SysRollData) error

SysRollbackEcosystem is rolling back ecosystem

func SysRollbackEditContract

func SysRollbackEditContract(transaction *sqldb.DbTransaction, sysData SysRollData,
	EcosystemID string) error

SysRollbackEditContract rollbacks the contract

func SysRollbackNewContract

func SysRollbackNewContract(sysData SysRollData, EcosystemID string) error

func SysRollbackTable

func SysRollbackTable(dbTx *sqldb.DbTransaction, sysData SysRollData) error

SysRollbackTable is rolling back table

func SysRollbackView

func SysRollbackView(DbTransaction *sqldb.DbTransaction, sysData SysRollData) error

SysRollbackView is rolling back table

func SysSetContractWallet

func SysSetContractWallet(tblid, state int64, wallet int64) error

SysSetContractWallet changes WalletID of the contract in smartVM

func TableConditions

func TableConditions(sc *SmartContract, name, columns, permissions string) (err error)

TableConditions is contract func

func TransferSelf

func TransferSelf(sc *SmartContract, value string, source string, target string) (flag bool, err error)

func UnbndWallet

func UnbndWallet(sc *SmartContract, tblid int64, state int64) error

UnbndWallet sets Active status of the contract in smartVM

func UnixDateTime

func UnixDateTime(value string) int64

func UnixDateTimeLocation

func UnixDateTimeLocation(value, locationName string) (int64, error)

func UpdateContract

func UpdateContract(sc *SmartContract, id int64, value, conditions string, recipient int64, tokenID string) error

func UpdateCron

func UpdateCron(sc *SmartContract, id int64) error

func UpdateNodesBan

func UpdateNodesBan(smartContract *SmartContract, timestamp int64) error

func UpdateNotifications

func UpdateNotifications(sc *SmartContract, ecosystemID int64, accounts ...any)

func UpdatePlatformParam

func UpdatePlatformParam(sc *SmartContract, name, value, conditions string) (int64, error)

UpdatePlatformParam updates the system parameter

func UpdateRolesNotifications

func UpdateRolesNotifications(sc *SmartContract, ecosystemID int64, roles ...any)

func UtxoToken

func UtxoToken(sc *SmartContract, toID int64, value string) (flag bool, err error)

func ValidateCondition

func ValidateCondition(sc *SmartContract, condition string, state int64) error

ValidateCondition checks if the condition can be compiled

func ValidateCron

func ValidateCron(cronSpec string) (err error)

func ValidateEditContractNewValue

func ValidateEditContractNewValue(sc *SmartContract, newValue, oldValue string) error

Types

type Address

type Address [AddressLength]byte

func (Address) Hex

func (a Address) Hex() string

type Arithmetic

type Arithmetic int32
const (
	Arithmetic_NATIVE Arithmetic = 0
	Arithmetic_MUL    Arithmetic = 3
	Arithmetic_DIV    Arithmetic = 4
)

func (Arithmetic) EnumDescriptor

func (Arithmetic) EnumDescriptor() ([]byte, []int)

func (Arithmetic) String

func (x Arithmetic) String() string

type Combustion

type Combustion struct {
	Flag    int64
	Percent int64
}

func (Combustion) Detail

func (c Combustion) Detail(sum decimal.Decimal) any

func (Combustion) Fees

type Contract

type Contract struct {
	Name          string
	Called        uint32
	FreeRequest   bool
	TxGovAccount  int64   // state wallet
	Rate          float64 // money rate
	TableAccounts string
	StackCont     []any // Stack of called contracts
	Extend        map[string]any
	Block         *script.CodeBlock
}

Contract contains the information about the contract.

func GetContract

func GetContract(name string, state uint32) *Contract

GetContract returns true if the contract exists in smartVM

func GetContractByID

func GetContractByID(id int32) *Contract

GetContractByID returns true if the contract exists

func VMGetContract

func VMGetContract(vm *script.VM, name string, state uint32) *Contract

func VMGetContractByID

func VMGetContractByID(vm *script.VM, id int32) *Contract

func (*Contract) GetFunc

func (contract *Contract) GetFunc(name string) *script.CodeBlock

GetFunc returns the block of the specified function in the contract

func (*Contract) Info

func (c *Contract) Info() *script.ContractInfo

type FlushInfo

type FlushInfo struct {
	ID   uint32            // id
	Prev *script.CodeBlock // previous item, nil if the new item has been appended
	Info *script.ObjInfo
	Name string // the name
}

func (*FlushInfo) FlushVM

func (finfo *FlushInfo) FlushVM()

type FuelCategory

type FuelCategory struct {
	FuelType       FuelType
	Decimal        decimal.Decimal
	ConversionRate float64
	Flag           GasPayAbleType
	Arithmetic     Arithmetic
}

func NewFuelCategory

func NewFuelCategory(fuelType FuelType, decimal decimal.Decimal, flag GasPayAbleType, convert float64) FuelCategory

func (*FuelCategory) Detail

func (f *FuelCategory) Detail() (string, any)

func (*FuelCategory) Fees

func (f *FuelCategory) Fees() decimal.Decimal

func (*FuelCategory) FeesInfo

func (f *FuelCategory) FeesInfo() any

type FuelType

type FuelType int32
const (
	FuelType_UNKNOWN      FuelType = 0
	FuelType_vmCost_fee   FuelType = 1
	FuelType_storage_fee  FuelType = 2
	FuelType_expedite_fee FuelType = 3
)

func (FuelType) EnumDescriptor

func (FuelType) EnumDescriptor() ([]byte, []int)

func (FuelType) String

func (x FuelType) String() string

type GasPayAbleType

type GasPayAbleType int32
const (
	GasPayAbleType_Invalid GasPayAbleType = 0
	GasPayAbleType_Unable  GasPayAbleType = 1
	GasPayAbleType_Capable GasPayAbleType = 2
)

func (GasPayAbleType) EnumDescriptor

func (GasPayAbleType) EnumDescriptor() ([]byte, []int)

func (GasPayAbleType) String

func (x GasPayAbleType) String() string

type GasScenesType

type GasScenesType int32
const (
	GasScenesType_Unknown      GasScenesType = 0
	GasScenesType_Reward       GasScenesType = 1
	GasScenesType_Taxes        GasScenesType = 2
	GasScenesType_Direct       GasScenesType = 15
	GasScenesType_Combustion   GasScenesType = 16
	GasScenesType_TransferSelf GasScenesType = 24
)

func (GasScenesType) EnumDescriptor

func (GasScenesType) EnumDescriptor() ([]byte, []int)

func (GasScenesType) String

func (x GasScenesType) String() string

type NotifyInfo

type NotifyInfo struct {
	Roles       bool // if true then UpdateRolesNotifications, otherwise UpdateNotifications
	EcosystemID int64
	List        []string
}

NotifyInfo is used for sending delayed notifications

type PaymentInfo

type PaymentInfo struct {
	TokenEco       int64
	ToID           int64
	TaxesID        int64
	FromID         int64
	PaymentType    PaymentType
	FuelRate       decimal.Decimal
	FuelCategories []FuelCategory
	PayWallet      *sqldb.Key
	Ecosystem      *sqldb.Ecosystem
	TaxesSize      int64
	Indirect       bool
	Combustion     *Combustion
	Penalty        bool
}

func (*PaymentInfo) Detail

func (pay *PaymentInfo) Detail() any

func (*PaymentInfo) DetailCombustion

func (pay *PaymentInfo) DetailCombustion() any

func (*PaymentInfo) GetEstimate

func (pay *PaymentInfo) GetEstimate() decimal.Decimal

func (*PaymentInfo) GetPayMoney

func (pay *PaymentInfo) GetPayMoney() decimal.Decimal

func (*PaymentInfo) PushFuelCategories

func (pay *PaymentInfo) PushFuelCategories(fes ...FuelCategory)

func (*PaymentInfo) SetDecimalByType

func (pay *PaymentInfo) SetDecimalByType(fuelType FuelType, decimal decimal.Decimal)

type PaymentType

type PaymentType int32
const (
	PaymentType_INVALID          PaymentType = 0
	PaymentType_ContractCaller   PaymentType = 1
	PaymentType_ContractBinder   PaymentType = 2
	PaymentType_EcosystemAddress PaymentType = 3
)

func (PaymentType) EnumDescriptor

func (PaymentType) EnumDescriptor() ([]byte, []int)

func (PaymentType) String

func (x PaymentType) String() string

type SignRes

type SignRes struct {
	Param string `json:"name"`
	Text  string `json:"text"`
}

SignRes contains the data of the signature

type SmartContract

type SmartContract struct {
	CLB            bool
	Rollback       bool
	FullAccess     bool
	SysUpdate      bool
	VM             *script.VM
	TxSmart        *types.SmartTransaction
	TxData         map[string]any
	TxContract     *Contract
	TxFuel         int64           // The fuel of executing contract
	TxCost         int64           // Maximum cost of executing contract
	TxUsedCost     decimal.Decimal // Used cost of CPU resources
	TXBlockFuel    decimal.Decimal
	BlockHeader    *types.BlockHeader
	PreBlockHeader *types.BlockHeader
	Loop           map[string]bool
	Hash           []byte
	Payload        []byte
	Timestamp      int64
	TxSignature    []byte
	TxSize         int64
	Size           common.StorageSize
	PublicKeys     [][]byte
	DbTransaction  *sqldb.DbTransaction
	Rand           *rand.Rand
	FlushRollback  []*FlushInfo
	Notifications  types.Notifications
	GenBlock       bool
	TimeLimit      int64
	Key            *sqldb.Key
	RollBackTx     []*types.RollbackTx

	Penalty         bool
	TokenEcosystems map[int64]any
	OutputsMap      map[sqldb.KeyUTXO][]sqldb.SpentInfo
	TxInputsMap     map[sqldb.KeyUTXO][]sqldb.SpentInfo
	TxOutputsMap    map[sqldb.KeyUTXO][]sqldb.SpentInfo
	PrevSysPar      map[string]string
	EcoParams       []sqldb.EcoParam
	// contains filtered or unexported fields
}

SmartContract is storing smart contract data

func (*SmartContract) AccessColumns

func (sc *SmartContract) AccessColumns(table string, columns *[]string, update bool) error

AccessColumns checks access rights to the columns

func (*SmartContract) AccessRights

func (sc *SmartContract) AccessRights(condition string, iscondition bool) error

AccessRights checks the access right by executing the condition value

func (*SmartContract) AccessTable

func (sc *SmartContract) AccessTable(table, action string) error

AccessTable checks the access right to the table

func (*SmartContract) AccessTablePerm

func (sc *SmartContract) AccessTablePerm(table, action string) (map[string]string, error)

func (*SmartContract) AppendStack

func (sc *SmartContract) AppendStack(fn string) error

AppendStack adds an element to the stack of contract call or removes the top element when name is empty

func (*SmartContract) CallContract

func (sc *SmartContract) CallContract(point string) (string, error)

CallContract calls the contract functions according to the specified flags

func (*SmartContract) CheckAccess

func (sc *SmartContract) CheckAccess(tableName, columns string, ecosystem int64) (table string, perm map[string]string,
	cols string, err error)

func (*SmartContract) EvalIf

func (sc *SmartContract) EvalIf(conditions string) (bool, error)

EvalIf counts and returns the logical value of the specified expression

func (*SmartContract) GetContractLimit

func (sc *SmartContract) GetContractLimit() (ret int64)

GetContractLimit returns the default maximal cost of contract

func (*SmartContract) GetLogger

func (sc *SmartContract) GetLogger() *log.Entry

GetLogger is returning logger

func (*SmartContract) GetSignedBy

func (sc *SmartContract) GetSignedBy(public []byte) (int64, error)

func (*SmartContract) IsCustomTable

func (sc *SmartContract) IsCustomTable(table string) (isCustom bool, err error)

func (*SmartContract) PopStack

func (sc *SmartContract) PopStack(fn string)

type SysRollData

type SysRollData struct {
	Type        string `json:"type,omitempty"`
	EcosystemID int64  `json:"ecosystem,omitempty"`
	ID          int64  `json:"id,omitempty"`
	Data        string `json:"data,omitempty"`
	TableName   string `json:"table,omitempty"`
}

type TableInfo

type TableInfo struct {
	Columns map[string]string
	Table   *sqldb.Table
}

type TxInfo

type TxInfo struct {
	BlockId      int64          `json:"block_id"`
	BlockHash    string         `json:"block_hash"`
	Address      string         `json:"address"`
	Ecosystem    int64          `json:"ecosystem"`
	Hash         string         `json:"hash"`
	Expedite     string         `json:"expedite"`
	ContractName string         `json:"contract_name"`
	Params       map[string]any `json:"params"`
	CreatedAt    int64          `json:"created_at"`
	Size         string         `json:"size"`
	Status       int64          `json:"status"` //0:success 1:penalty
}

type TxSignJSON

type TxSignJSON struct {
	ForSign string    `json:"forsign"`
	Field   string    `json:"field"`
	Title   string    `json:"title"`
	Params  []SignRes `json:"params"`
}

TxSignJSON is a structure for additional signs of transaction

type ViewColSch

type ViewColSch struct {
	Table string `json:"table,omitempty"`
	Col   string `json:"col,omitempty"`
	Alias string `json:"alias,omitempty"`
}

type ViewWheSch

type ViewWheSch struct {
	TableOne string `json:"table1,omitempty"`
	TableTwo string `json:"table2,omitempty"`
	ColOne   string `json:"col1,omitempty"`
	ColTwo   string `json:"col2,omitempty"`
	Compare  string `json:"compare,omitempty"`
}

Jump to

Keyboard shortcuts

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