Documentation ¶
Overview ¶
Package foundation server implementation of smartcontract functions
Index ¶
- Constants
- func ClearContext()
- func GetCostCenter() insolar.Reference
- func GetLogicalContext() *insolar.LogicCallContext
- func GetMigrationAdmin() insolar.Reference
- func GetMigrationAdminMember() insolar.Reference
- func GetMigrationDaemon(migrationMember insolar.Reference) (insolar.Reference, error)
- func GetPulseNumber() (insolar.PulseNumber, error)
- func GetRequestReference() insolar.Reference
- func GetRootDomain() insolar.Reference
- func GetRootMember() insolar.Reference
- func GetShardIndex(s string, mod int) int
- func IsEthereumAddress(s string) bool
- func IsMigrationDaemonMember(member insolar.Reference) bool
- func MarshalMethodErrorResult(err error) ([]byte, error)
- func MarshalMethodResult(returns ...interface{}) ([]byte, error)
- func SetLogicalContext(ctx *insolar.LogicCallContext)
- func TrimAddress(address string) string
- func TrimPublicKey(publicKey string) string
- func UnmarshalMethodResultSimplified(data []byte, returns ...interface{}) error
- func UnmarshalSig(b []byte) (r, s *big.Int, err error)
- func VerifySignature(rawRequest []byte, signature string, key string, rawpublicpem string, ...) error
- type BaseContract
- type BaseContractInterface
- type Error
- type ProxyInterface
- type Result
- type StableMap
- type VestingType
Constants ¶
const EthAddressLength = 20
Variables ¶
This section is empty.
Functions ¶
func GetLogicalContext ¶
func GetLogicalContext() *insolar.LogicCallContext
GetLogicalContext returns current calling context.
func GetMigrationAdmin ¶
Get reference on MigrationAdmin contract.
func GetMigrationAdminMember ¶
Get reference MigrationAdminMember contract.
func GetMigrationDaemon ¶ added in v0.9.1
Get reference on migrationdaemon contract by migration member.
func GetPulseNumber ¶
func GetPulseNumber() (insolar.PulseNumber, error)
GetPulseNumber returns current pulse from context.
func GetRequestReference ¶
GetRequestReference - Returns request reference from context.
func GetShardIndex ¶
GetShardIndex calculates hash from string and gets it by mod
func IsEthereumAddress ¶ added in v0.9.6
IsEthereumAddress Ethereum address format verifier
func IsMigrationDaemonMember ¶ added in v0.9.1
Check member is migration daemon member or not
func MarshalMethodErrorResult ¶
MarshalMethodErrorResult creates result data with logic error for any method.
func MarshalMethodResult ¶
MarshalMethodErrorResult creates result data with all `returns` returned by contract
func SetLogicalContext ¶
func SetLogicalContext(ctx *insolar.LogicCallContext)
SetLogicalContext saves current calling context
func UnmarshalMethodResultSimplified ¶
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 ¶
UnmarshalSig parses the two integer components of an ASN.1-encoded ECDSA signature.
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 ¶
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 ... } ...
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 ¶
StableMap is a `map[string]string` that can be deterministically serialized.
func NewStableMapFromInterface ¶
NewStableMapFromInterface tries to parse interface{} as [][]string and creates new StableMap.
func (StableMap) MarshalBinary ¶
func (StableMap) MarshalJSON ¶
func (*StableMap) UnmarshalBinary ¶
func (*StableMap) UnmarshalJSON ¶
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