helper

package
v0.43.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: GPL-3.0 Imports: 64 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTooManyAlphabetNodes = fmt.Errorf("too many alphabet nodes (maximum allowed is %d)", constants.MaxAlphabetNodes)

Functions

func AddManifestGroup

func AddManifestGroup(cw *wallet.Wallet, h util.Uint160, cs *ContractState) error

func AwaitTx

func AwaitTx(cmd *cobra.Command, c Client, txs []HashVUBPair) error

func CheckNotaryEnabled

func CheckNotaryEnabled(c Client) error

func DeployNNS

func DeployNNS(c *InitializeContext, method string) error

func DomainOf

func DomainOf(contract string) string

func EmitNewEpochCall

func EmitNewEpochCall(bw *io.BufBinWriter, wCtx *InitializeContext, nmHash util.Uint160, countEpoch int64) error

func GetAlphabetNNSDomain

func GetAlphabetNNSDomain(i int) string

func GetAlphabetWallets

func GetAlphabetWallets(v *viper.Viper, walletDir string) ([]*wallet.Wallet, error)

func GetComitteAcc

func GetComitteAcc(cmd *cobra.Command, v *viper.Viper) *wallet.Account

func GetContractByID added in v0.42.0

func GetContractByID(r *management.ContractReader, id int32) (*state.Contract, error)

GetContractByID retrieves a contract by its ID using the standard GetContractByID method. However, if the returned state.Contract is nil, it returns an error indicating that the contract was not found. See https://git.frostfs.info/TrueCloudLab/frostfs-node/issues/1210

func GetContractDeployData

func GetContractDeployData(c *InitializeContext, ctrName string, keysParam []any, method string) ([]any, error)

func GetContractDeployParameters

func GetContractDeployParameters(cs *ContractState, deployData []any) []any

func GetDefaultNetmapContractConfigMap

func GetDefaultNetmapContractConfigMap() map[string]any

func GetDesignatedByRole

func GetDesignatedByRole(inv *invoker.Invoker, h util.Uint160, role noderoles.Role, u uint32) (keys.PublicKeys, error)

func GetFrostfsIDAdmin

func GetFrostfsIDAdmin(v *viper.Viper) (util.Uint160, bool, error)

func GetNetConfigFromNetmapContract

func GetNetConfigFromNetmapContract(roInvoker *invoker.Invoker) ([]stackitem.Item, error)

func GetWalletAccount

func GetWalletAccount(w *wallet.Wallet, typ string) (*wallet.Account, error)

func InitializeContractWallet

func InitializeContractWallet(v *viper.Viper, walletDir string) (*wallet.Wallet, error)

func InvalidConfigValueErr

func InvalidConfigValueErr(key string) error

func InvokeFunction

func InvokeFunction(c Client, h util.Uint160, method string, parameters []any, signers []transaction.Signer) (*result.Invoke, error)

func MergeNetmapConfig

func MergeNetmapConfig(roInvoker *invoker.Invoker, md map[string]any) error

func NNSIsAvailable

func NNSIsAvailable(c Client, nnsHash util.Uint160, name string) (bool, error)

func NNSResolve

func NNSResolve(inv *invoker.Invoker, nnsHash util.Uint160, domain string) (stackitem.Item, error)

func NNSResolveHash

func NNSResolveHash(inv *invoker.Invoker, nnsHash util.Uint160, domain string) (util.Uint160, error)

NNSResolveHash Returns errMissingNNSRecord if invocation fault exception contains "token not found".

func NNSResolveKey

func NNSResolveKey(inv *invoker.Invoker, nnsHash util.Uint160, domain string) (*keys.PublicKey, error)

func NewActor

func NewActor(c actor.RPCActor, committeeAcc *wallet.Account) (*actor.Actor, error)

func NextPollInterval

func NextPollInterval(it int, previous time.Duration) (time.Duration, bool)

func ParseConfigFromNetmapContract

func ParseConfigFromNetmapContract(arr []stackitem.Item) (map[string][]byte, error)

func ParseGASAmount

func ParseGASAmount(s string) (fixedn.Fixed8, error)

func ParseNNSResolveResult

func ParseNNSResolveResult(res stackitem.Item) (util.Uint160, error)

ParseNNSResolveResult parses the result of resolving NNS record. It works with multiple formats (corresponding to multiple NNS versions). If array of hashes is provided, it returns only the first one.

Types

type Cache

type Cache struct {
	NNSCs    *state.Contract
	GroupKey *keys.PublicKey
}

type Client

type Client interface {
	invoker.RPCInvoke

	GetBlockCount() (uint32, error)
	GetNativeContracts() ([]state.Contract, error)
	GetApplicationLog(util.Uint256, *trigger.Type) (*result.ApplicationLog, error)
	GetVersion() (*result.Version, error)
	SendRawTransaction(*transaction.Transaction) (util.Uint256, error)
	GetCommittee() (keys.PublicKeys, error)
	CalculateNetworkFee(tx *transaction.Transaction) (int64, error)
}

Client represents N3 client interface capable of test-invoking scripts and sending signed transactions to chain.

func GetN3Client

func GetN3Client(v *viper.Viper) (Client, error)

type ClientContext

type ClientContext struct {
	Client          Client           // a raw neo-go client OR a local chain implementation
	CommitteeAct    *actor.Actor     // committee actor with the Global witness scope
	ReadOnlyInvoker *invoker.Invoker // R/O contract invoker, does not contain any signer
	SentTxs         []HashVUBPair
}

func DefaultClientContext

func DefaultClientContext(c Client, committeeAcc *wallet.Account) (*ClientContext, error)

func (*ClientContext) AwaitTx

func (c *ClientContext) AwaitTx(cmd *cobra.Command) error

func (*ClientContext) SendTx

func (c *ClientContext) SendTx(tx *transaction.Transaction, cmd *cobra.Command, await bool) error

type ContractState

type ContractState struct {
	NEF         *nef.File
	RawNEF      []byte
	Manifest    *manifest.Manifest
	RawManifest []byte
	Hash        util.Uint160
}

func ReadContract

func ReadContract(ctrPath, ctrName string) (*ContractState, error)

func (*ContractState) Parse

func (cs *ContractState) Parse() error

type HashVUBPair

type HashVUBPair struct {
	Hash util.Uint256
	Vub  uint32
}

type InitializeContext

type InitializeContext struct {
	ClientContext
	Cache
	// CommitteeAcc is used for retrieving the committee address and the verification script.
	CommitteeAcc *wallet.Account
	// ConsensusAcc is used for retrieving the committee address and the verification script.
	ConsensusAcc *wallet.Account
	Wallets      []*wallet.Wallet
	// ContractWallet is a wallet for providing the contract group signature.
	ContractWallet *wallet.Wallet
	// Accounts contains simple signature accounts in the same order as in Wallets.
	Accounts     []*wallet.Account
	Contracts    map[string]*ContractState
	Command      *cobra.Command
	ContractPath string
	ContractURL  string
}

func NewInitializeContext

func NewInitializeContext(cmd *cobra.Command, v *viper.Viper) (*InitializeContext, error)

func (*InitializeContext) AwaitTx

func (c *InitializeContext) AwaitTx() error

func (*InitializeContext) Close

func (c *InitializeContext) Close()

func (*InitializeContext) EmitUpdateNNSGroupScript

func (c *InitializeContext) EmitUpdateNNSGroupScript(bw *io.BufBinWriter, nnsHash util.Uint160, pub *keys.PublicKey) (bool, bool, error)

EmitUpdateNNSGroupScript emits script for updating group key stored in NNS. First return value is true iff the key is already there and nothing should be done. Second return value is true iff a domain registration code was emitted.

func (*InitializeContext) GetAlphabetDeployItems

func (c *InitializeContext) GetAlphabetDeployItems(i, n int) []any

func (*InitializeContext) GetContract

func (c *InitializeContext) GetContract(ctrName string) *ContractState

func (*InitializeContext) GetSigner

func (c *InitializeContext) GetSigner(tryGroup bool, acc *wallet.Account) transaction.Signer

func (*InitializeContext) IsUpdated

func (c *InitializeContext) IsUpdated(ctrHash util.Uint160, cs *ContractState) bool

func (*InitializeContext) MultiSign

func (c *InitializeContext) MultiSign(tx *transaction.Transaction, accType string) error

func (*InitializeContext) MultiSignAndSend

func (c *InitializeContext) MultiSignAndSend(tx *transaction.Transaction, accType string) error

func (*InitializeContext) NNSContractState

func (c *InitializeContext) NNSContractState() (*state.Contract, error)

func (*InitializeContext) NNSRegisterDomainScript

func (c *InitializeContext) NNSRegisterDomainScript(nnsHash, expectedHash util.Uint160, domain string) ([]byte, bool, error)

func (*InitializeContext) NNSRootRegistered

func (c *InitializeContext) NNSRootRegistered(nnsHash util.Uint160, zone string) (bool, error)

func (*InitializeContext) SendCommitteeTx

func (c *InitializeContext) SendCommitteeTx(script []byte, tryGroup bool) error

SendCommitteeTx creates transaction from script, signs it by committee nodes and sends it to RPC. If tryGroup is false, global scope is used for the signer (useful when working with native contracts).

func (*InitializeContext) SendConsensusTx

func (c *InitializeContext) SendConsensusTx(script []byte) error

SendConsensusTx creates transaction from script, signs it by alphabet nodes and sends it to RPC. Not that because this is used only after the contracts were initialized and deployed, we always try to have a group scope.

type LocalActor

type LocalActor struct {
	Invoker *invoker.Invoker
	// contains filtered or unexported fields
}

LocalActor is a kludge, do not use it outside of the morph commands.

func NewLocalActor

func NewLocalActor(cmd *cobra.Command, c actor.RPCActor) (*LocalActor, error)

NewLocalActor create LocalActor with accounts form provided wallets. In case of empty wallets provided created actor with dummy account only for read operation.

func (*LocalActor) Call

func (a *LocalActor) Call(contract util.Uint160, operation string, params ...any) (*result.Invoke, error)

func (*LocalActor) CallAndExpandIterator

func (a *LocalActor) CallAndExpandIterator(_ util.Uint160, _ string, _ int, _ ...any) (*result.Invoke, error)

func (*LocalActor) GetRPCInvoker added in v0.38.6

func (a *LocalActor) GetRPCInvoker() invoker.RPCInvoke

func (*LocalActor) MakeCall

func (a *LocalActor) MakeCall(_ util.Uint160, _ string, _ ...any) (*transaction.Transaction, error)

func (*LocalActor) MakeRun

func (a *LocalActor) MakeRun(_ []byte) (*transaction.Transaction, error)

func (*LocalActor) MakeUnsignedCall

func (a *LocalActor) MakeUnsignedCall(_ util.Uint160, _ string, _ []transaction.Attribute, _ ...any) (*transaction.Transaction, error)

func (*LocalActor) MakeUnsignedRun

func (a *LocalActor) MakeUnsignedRun(_ []byte, _ []transaction.Attribute) (*transaction.Transaction, error)

func (*LocalActor) SendCall

func (a *LocalActor) SendCall(contract util.Uint160, method string, params ...any) (util.Uint256, uint32, error)

func (*LocalActor) SendRun

func (a *LocalActor) SendRun(script []byte) (util.Uint256, uint32, error)

func (*LocalActor) Sender

func (a *LocalActor) Sender() util.Uint160

func (*LocalActor) TerminateSession

func (a *LocalActor) TerminateSession(_ uuid.UUID) error

func (*LocalActor) TraverseIterator

func (a *LocalActor) TraverseIterator(sessionID uuid.UUID, iterator *result.Iterator, num int) ([]stackitem.Item, error)

func (*LocalActor) Wait

func (a *LocalActor) Wait(h util.Uint256, vub uint32, err error) (*state.AppExecResult, error)

type LocalClient

type LocalClient struct {
	// contains filtered or unexported fields
}

func NewLocalClient

func NewLocalClient(cmd *cobra.Command, v *viper.Viper, wallets []*wallet.Wallet, dumpPath string) (*LocalClient, error)

func (*LocalClient) CalculateNetworkFee

func (l *LocalClient) CalculateNetworkFee(tx *transaction.Transaction) (int64, error)

CalculateNetworkFee calculates network fee for the given transaction. Copied from neo-go with minor corrections (no need to support non-notary mode): https://github.com/nspcc-dev/neo-go/blob/v0.103.0/pkg/services/rpcsrv/server.go#L911

func (*LocalClient) Dump

func (l *LocalClient) Dump() (err error)

func (*LocalClient) GetApplicationLog

func (l *LocalClient) GetApplicationLog(h util.Uint256, t *trigger.Type) (*result.ApplicationLog, error)

func (*LocalClient) GetBlockCount

func (l *LocalClient) GetBlockCount() (uint32, error)

func (*LocalClient) GetCommittee

func (l *LocalClient) GetCommittee() (keys.PublicKeys, error)

func (*LocalClient) GetNativeContracts

func (l *LocalClient) GetNativeContracts() ([]state.Contract, error)

func (*LocalClient) GetVersion

func (l *LocalClient) GetVersion() (*result.Version, error)

GetVersion return default version.

func (*LocalClient) InvokeContractVerify

func (*LocalClient) InvokeFunction

func (l *LocalClient) InvokeFunction(h util.Uint160, method string, sPrm []smartcontract.Parameter, ss []transaction.Signer) (*result.Invoke, error)

InvokeFunction is implemented via `InvokeScript`.

func (*LocalClient) InvokeScript

func (l *LocalClient) InvokeScript(script []byte, signers []transaction.Signer) (*result.Invoke, error)

func (*LocalClient) SendRawTransaction

func (l *LocalClient) SendRawTransaction(tx *transaction.Transaction) (util.Uint256, error)

func (*LocalClient) TerminateSession

func (l *LocalClient) TerminateSession(_ uuid.UUID) (bool, error)

func (*LocalClient) TraverseIterator

func (l *LocalClient) TraverseIterator(_, _ uuid.UUID, _ int) ([]stackitem.Item, error)

Jump to

Keyboard shortcuts

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