common

package
v0.0.0-...-4f3c08f Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version = major*1_000_000 + minor*1_000 + patch

	PrevVersion = prevMajor*1_000_000 + prevMinor*1_000 + prevPatch

	// ErrVersionMismatch is thrown by CheckVersion in case of error.
	ErrVersionMismatch = "previous version mismatch"

	// ErrAlreadyUpdated is thrown by CheckVersion if current version equals to version contract
	// is being updated from.
	ErrAlreadyUpdated = "contract is already of the latest version"
)
View Source
const LegacyOwnerKey = "contractOwner"

LegacyOwnerKey is storage key used to store contract owner.

Variables

View Source
var (
	// ErrAlphabetWitnessFailed appears when the method must be
	// called by the Alphabet but was not.
	ErrAlphabetWitnessFailed = "alphabet witness check failed"
	// ErrOwnerWitnessFailed appears when the method must be called
	// by an owner of some assets but was not.
	ErrOwnerWitnessFailed = "owner witness check failed"
	// ErrWitnessFailed appears when the method must be called
	// using certain public key but was not.
	ErrWitnessFailed = "witness check failed"
)

Functions

func AbortWithMessage

func AbortWithMessage(msg string)

AbortWithMessage calls `runtime.Log` with the passed message and calls `ABORT` opcode.

func AlphabetAddress

func AlphabetAddress() []byte

AlphabetAddress returns multi address of alphabet public keys.

func AlphabetNodes

func AlphabetNodes() []interop.PublicKey

AlphabetNodes returns a list of alphabet nodes from committee in the sidechain.

func AppendVersion

func AppendVersion(data interface{}) []interface{}

AppendVersion appends current contract version to the list of deploy arguments.

func BurnTransferDetails

func BurnTransferDetails(txDetails []byte) []byte

func BytesEqual

func BytesEqual(a []byte, b []byte) bool

BytesEqual compares two slices of bytes by wrapping them into strings, which is necessary with new util.Equals interop behaviour, see neo-go#1176.

func CheckAlphabetWitness

func CheckAlphabetWitness(caller []byte)

CheckAlphabetWitness checks witness of the passed caller. It panics with ErrAlphabetWitnessFailed message on fail.

func CheckOwnerWitness

func CheckOwnerWitness(caller []byte)

CheckOwnerWitness checks witness of the passed caller. It panics with ErrOwnerWitnessFailed message on fail.

func CheckVersion

func CheckVersion(from int)

CheckVersion checks that previous version is more than PrevVersion to ensure migrating contract data was done successfully.

func CheckWitness

func CheckWitness(caller []byte)

CheckWitness checks witness of the passed caller. It panics with ErrWitnessFailed message on fail.

func CommitteeAddress

func CommitteeAddress() []byte

CommitteeAddress returns multi address of committee.

func ContainerFeeTransferDetails

func ContainerFeeTransferDetails(cid []byte) []byte

func FromKnownContract

func FromKnownContract(ctx storage.Context, caller interop.Hash160, key string) bool

func GetList

func GetList(ctx storage.Context, key interface{}) [][]byte

func HasUpdateAccess

func HasUpdateAccess() bool

HasUpdateAccess returns true if contract can be updated.

func InitVote

func InitVote(ctx storage.Context)

func InnerRingInvoker

func InnerRingInvoker(ir []interop.PublicKey) interop.PublicKey

InnerRingInvoker returns the public key of the inner ring node that has invoked the contract. Work around for environments without notary support.

func InnerRingNodes

func InnerRingNodes() []interop.PublicKey

InnerRingNodes return a list of inner ring nodes from state validator role in the sidechain.

func InnerRingNodesFromNetmap

func InnerRingNodesFromNetmap(sc interop.Hash160) []interop.PublicKey

InnerRingNodesFromNetmap gets a list of inner ring nodes through calling "innerRingList" method of smart contract. Work around for environments without notary support.

func InvokeID

func InvokeID(args []interface{}, prefix []byte) []byte

InvokeID returns hashed value of prefix and args concatenation. Iy is used to identify different ballots.

func LockTransferDetails

func LockTransferDetails(txDetails []byte) []byte

func MintTransferDetails

func MintTransferDetails(txDetails []byte) []byte

func Multiaddress

func Multiaddress(n []interop.PublicKey, committee bool) []byte

Multiaddress returns default multisignature account address for N keys. If committee set to true, it is `M = N/2+1` committee account.

func RemoveVotes

func RemoveVotes(ctx storage.Context, id []byte)

RemoveVotes clears ballots of the decision that has been accepted by inner ring nodes.

func SetSerialized

func SetSerialized(ctx storage.Context, key interface{}, value interface{})

SetSerialized serializes data and puts it into contract storage.

func UnlockTransferDetails

func UnlockTransferDetails(epoch int) []byte

func Vote

func Vote(ctx storage.Context, id, from []byte) int

Vote adds ballot for the decision with a specific 'id' and returns the amount of unique voters for that decision.

func WalletToScriptHash

func WalletToScriptHash(wallet []byte) []byte

Types

type Ballot

type Ballot struct {
	// ID of the voting decision.
	ID []byte

	// Public keys of the already voted inner ring nodes.
	Voters []interop.PublicKey

	// Height of block with the last vote.
	Height int
}

type IRNode

type IRNode struct {
	PublicKey interop.PublicKey
}

Jump to

Keyboard shortcuts

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