foundation

package
v0.9.15 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2019 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package foundation server implementation of smartcontract functions

Index

Constants

View Source
const EthAddressLength = 20

Variables

This section is empty.

Functions

func ClearContext

func ClearContext()

ClearContext clears underlying gls context

func GetCostCenter

func GetCostCenter() insolar.Reference

Get reference CostCenter contract.

func GetLogicalContext

func GetLogicalContext() *insolar.LogicCallContext

GetLogicalContext returns current calling context.

func GetMigrationAdmin

func GetMigrationAdmin() insolar.Reference

Get reference on MigrationAdmin contract.

func GetMigrationAdminMember

func GetMigrationAdminMember() insolar.Reference

Get reference MigrationAdminMember contract.

func GetMigrationDaemon added in v0.9.1

func GetMigrationDaemon(migrationMember insolar.Reference) (insolar.Reference, error)

Get reference on migrationdaemon contract by migration member.

func GetPulseNumber

func GetPulseNumber() (insolar.PulseNumber, error)

GetPulseNumber returns current pulse from context.

func GetRequestReference

func GetRequestReference() insolar.Reference

GetRequestReference - Returns request reference from context.

func GetRootDomain

func GetRootDomain() insolar.Reference

Get reference on RootDomain contract.

func GetRootMember

func GetRootMember() insolar.Reference

Get reference RootMember contract.

func GetShardIndex

func GetShardIndex(s string, mod int) int

GetShardIndex calculates hash from string and gets it by mod

func IsEthereumAddress added in v0.9.6

func IsEthereumAddress(s string) bool

IsEthereumAddress Ethereum address format verifier

func IsMigrationDaemonMember added in v0.9.1

func IsMigrationDaemonMember(member insolar.Reference) bool

Check member is migration daemon member or not

func MarshalMethodErrorResult

func MarshalMethodErrorResult(err error) ([]byte, error)

MarshalMethodErrorResult creates result data with logic error for any method.

func MarshalMethodResult

func MarshalMethodResult(returns ...interface{}) ([]byte, error)

MarshalMethodErrorResult creates result data with all `returns` returned by contract

func SetLogicalContext

func SetLogicalContext(ctx *insolar.LogicCallContext)

SetLogicalContext saves current calling context

func TrimAddress

func TrimAddress(address string) string

TrimPublicKey trim address

func TrimPublicKey

func TrimPublicKey(publicKey string) string

TrimPublicKey trim public key

func UnmarshalMethodResultSimplified

func UnmarshalMethodResultSimplified(data []byte, returns ...interface{}) error

UnmarshalMethodResultSimplified is simplified version of UnmarshalMethodResult that finds *foundation.Error in `returns` and saves there logicError in case it's not empty. This works as we force all methods in contracts to return error. Top level logic error has priority over error returned by contract. Example:

var i int
var contractError *foundation.Error
err := UnmarshalMethodResultSimplified(data, &i, &contractError)
if err != nil {
    ... system error ...
}
if contractError != nil {
    ... logic error set by system of returned by contract ...
}
...

func UnmarshalSig

func UnmarshalSig(b []byte) (r, s *big.Int, err error)

UnmarshalSig parses the two integer components of an ASN.1-encoded ECDSA signature.

func VerifySignature

func VerifySignature(rawRequest []byte, signature string, key string, rawpublicpem string, selfSigned bool) error

VerifySignature used for checking the signature using rawpublicpem and rawRequest. selfSigned flag need to compare public Keys.

Types

type BaseContract

type BaseContract struct {
}

BaseContract is a base class for all contracts.

func (*BaseContract) GetCode

func (bc *BaseContract) GetCode() insolar.Reference

GetCode - Returns prototype of contract

func (*BaseContract) GetContext

func (bc *BaseContract) GetContext() *insolar.LogicCallContext

GetContext returns current calling context OBSOLETED.

func (*BaseContract) GetPrototype

func (bc *BaseContract) GetPrototype() insolar.Reference

GetPrototype - Returns prototype of contract

func (*BaseContract) GetReference

func (bc *BaseContract) GetReference() insolar.Reference

GetReference - Returns public reference of contract

func (*BaseContract) SelfDestruct

func (bc *BaseContract) SelfDestruct() error

SelfDestruct contract will be marked as deleted

type BaseContractInterface

type BaseContractInterface interface {
	GetReference() insolar.Reference
	GetPrototype() insolar.Reference
	GetCode() insolar.Reference
}

BaseContractInterface is an interface to deal with any contract same way

type Error

type Error struct {
	S string
}

Error elementary string based error struct satisfying builtin error interface

foundation.Error{"some err"}

func UnmarshalMethodResult

func UnmarshalMethodResult(data []byte, returns ...interface{}) (*Error, error)

UnmarshalMethodResult extracts method result into provided pointers to existing variables. You should know what types method returns and number of returned variables. If result contains logic error that was created outside of contract then method returns this error *Error. Errors of serialized returned as second return value. Example:

var i int
var contractError *foundation.Error
logicError, err := UnmarshalMethodResult(data, &i, &contractError)
if err != nil {
    ... system error ...
}
if logicError != nil {
    ... logic error created with MarshalMethodErrorResult ...
}
if contractError != nil {
    ... contract returned error ...
}
...

func (*Error) Error

func (e *Error) Error() string

Error returns error in string format

type ProxyInterface

type ProxyInterface interface {
	GetReference() insolar.Reference
	GetPrototype() (insolar.Reference, error)
	GetCode() (insolar.Reference, error)
}

ProxyInterface interface any proxy of a contract implements

func GetObject

func GetObject(ref insolar.Reference) ProxyInterface

GetObject create proxy by address unimplemented

type Result

type Result struct {
	// Error - logic error, this field is not NIL if error is created outside
	// contract code, for example "object not found"
	Error *Error
	// Returns - all return values of contract's method, whatever it returns,
	// including errors
	Returns []interface{}
}

Result struct that serialized and saved on ledger as result of request

type StableMap

type StableMap map[string]string

StableMap is a `map[string]string` that can be deterministically serialized.

func NewStableMapFromInterface

func NewStableMapFromInterface(i interface{}) (StableMap, error)

NewStableMapFromInterface tries to parse interface{} as [][]string and creates new StableMap.

func (StableMap) MarshalBinary

func (m StableMap) MarshalBinary() ([]byte, error)

func (StableMap) MarshalJSON

func (m StableMap) MarshalJSON() ([]byte, error)

func (*StableMap) UnmarshalBinary

func (m *StableMap) UnmarshalBinary(data []byte) error

func (*StableMap) UnmarshalJSON

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

type VestingType added in v0.9.1

type VestingType int

VestingType type of vesting process

const (
	DefaultVesting VestingType = iota
	Vesting1
	Vesting2
	Vesting3
	Vesting4
)

func (VestingType) String added in v0.9.1

func (i VestingType) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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