Documentation ¶
Index ¶
- Constants
- Variables
- func ArrayFromStackItem(param stackitem.Item) ([]stackitem.Item, error)
- func BigIntFromStackItem(param stackitem.Item) (*big.Int, error)
- func BoolFromStackItem(param stackitem.Item) (bool, error)
- func BytesFromStackItem(param stackitem.Item) ([]byte, error)
- func CalculateNotaryDepositAmount(c *Client, gasMul, gasDiv int64) (fixedn.Fixed8, error)
- func IntFromStackItem(param stackitem.Item) (int64, error)
- func NNSAlphabetContractName(index int) string
- func StringFromStackItem(param stackitem.Item) (string, error)
- type AlphabetKeys
- type Callback
- type Client
- func (c *Client) BatchTransferGas(receivers []util.Uint160, amount fixedn.Fixed8) error
- func (c *Client) BlockCount() (res uint32, err error)
- func (c *Client) CalculateNonceAndVUB(hash *util.Uint256) (nonce uint32, vub uint32, err error)
- func (c *Client) CalculateNonceAndVUBControl(hash *util.Uint256) (nonce uint32, vub uint32, err error)
- func (c *Client) Close()
- func (c *Client) Committee() (res keys.PublicKeys, err error)
- func (c *Client) DepositEndlessNotary(ctx context.Context, amount fixedn.Fixed8) (util.Uint256, uint32, error)
- func (c *Client) DepositNotary(ctx context.Context, amount fixedn.Fixed8, delta uint32) (util.Uint256, error)
- func (c *Client) EnableNotarySupport(opts ...NotaryOption) error
- func (c *Client) GasBalance() (res int64, err error)
- func (c *Client) GetActor() *actor.Actor
- func (c *Client) GetApplicationLog(hash util.Uint256, trig *trigger.Type) (*result.ApplicationLog, error)
- func (c *Client) GetDesignateHash() util.Uint160
- func (c *Client) GetNotaryDeposit() (res int64, err error)
- func (c *Client) GetRPCActor() actor.RPCActor
- func (c *Client) GetVersion() (*result.Version, error)
- func (c *Client) Invoke(ctx context.Context, contract util.Uint160, fee fixedn.Fixed8, method string, ...) (InvokeRes, error)
- func (c *Client) IsNotaryEnabled() bool
- func (c *Client) IsValidScript(script []byte, signers []transaction.Signer) (valid bool, err error)
- func (c *Client) MagicNumber() (uint64, error)
- func (c *Client) Metrics() morphmetrics.Register
- func (c *Client) MsPerBlock() (res int64, err error)
- func (c *Client) NNSContractAddress(name string) (sh util.Uint160, err error)
- func (c *Client) NNSHash() (util.Uint160, error)
- func (c *Client) NeoFSAlphabetList() (res keys.PublicKeys, err error)
- func (c *Client) NotaryInvoke(ctx context.Context, contract util.Uint160, fee fixedn.Fixed8, nonce uint32, ...) (InvokeRes, error)
- func (c *Client) NotaryInvokeNotAlpha(ctx context.Context, contract util.Uint160, fee fixedn.Fixed8, vubP *uint32, ...) (InvokeRes, error)
- func (c *Client) NotarySignAndInvokeTX(mainTx *transaction.Transaction) error
- func (c *Client) ProbeNotary() (res bool)
- func (c *Client) ReceiveBlocks(ch chan<- *block.Block) (string, error)
- func (c *Client) ReceiveExecutionNotifications(contract util.Uint160, ch chan<- *state.ContainedNotificationEvent) (string, error)
- func (c *Client) ReceiveNotaryRequests(txSigner util.Uint160, ch chan<- *result.NotaryRequestEvent) (string, error)
- func (c *Client) SetGroupSignerScope() error
- func (c *Client) SwitchRPC(ctx context.Context) bool
- func (c *Client) TestInvoke(contract util.Uint160, method string, args ...any) (res []stackitem.Item, err error)
- func (c *Client) TestInvokeIterator(cb func(stackitem.Item) error, batchSize int, contract util.Uint160, ...) error
- func (c *Client) TransferGas(receiver util.Uint160, amount fixedn.Fixed8) error
- func (c *Client) TxHalt(h util.Uint256) (res bool, err error)
- func (c *Client) TxHeight(h util.Uint256) (res uint32, err error)
- func (c *Client) Unsubscribe(subID string) error
- func (c *Client) UnsubscribeAll() error
- func (c *Client) UpdateNeoFSAlphabetList(ctx context.Context, prm UpdateAlphabetListPrm) error
- func (c *Client) UpdateNotaryList(ctx context.Context, prm UpdateNotaryListPrm) error
- func (c *Client) Wait(ctx context.Context, n uint32) error
- func (c *Client) WaitTxHalt(ctx context.Context, p InvokeRes) error
- type DialerSource
- type Endpoint
- type InvokePrm
- type InvokePrmOptional
- type InvokeRes
- type MTLSConfig
- type NotaryOption
- type Option
- func WithConnLostCallback(cb Callback) Option
- func WithDialTimeout(dur time.Duration) Option
- func WithDialerSource(ds DialerSource) Option
- func WithEndpoints(endpoints ...Endpoint) Option
- func WithLogger(logger *logger.Logger) Option
- func WithMetrics(metrics morphmetrics.Register) Option
- func WithMorphCacheMetrics(morphCacheMetrics metrics.MorphCacheMetrics) Option
- func WithSigner(signer *transaction.Signer) Option
- func WithSwitchInterval(i time.Duration) Option
- type StaticClient
- func (s StaticClient) ContractAddress() util.Uint160
- func (s StaticClient) Invoke(ctx context.Context, prm InvokePrm) (InvokeRes, error)
- func (s *StaticClient) IsAlpha() bool
- func (s StaticClient) Morph() *Client
- func (s StaticClient) TestInvoke(prm TestInvokePrm) ([]stackitem.Item, error)
- func (s *StaticClient) WithNotary() bool
- type StaticClientOption
- type SwitchRPCGuardedActor
- func (a *SwitchRPCGuardedActor) CalculateNetworkFee(tx *transaction.Transaction) (int64, error)
- func (a *SwitchRPCGuardedActor) CalculateValidUntilBlock() (uint32, error)
- func (a *SwitchRPCGuardedActor) Call(contract util.Uint160, operation string, params ...any) (*result.Invoke, error)
- func (a *SwitchRPCGuardedActor) CallAndExpandIterator(contract util.Uint160, method string, maxItems int, params ...any) (*result.Invoke, error)
- func (a *SwitchRPCGuardedActor) GetBlockCount() (uint32, error)
- func (a *SwitchRPCGuardedActor) GetNetwork() netmode.Magic
- func (a *SwitchRPCGuardedActor) GetRPCActor() actor.RPCActor
- func (a *SwitchRPCGuardedActor) GetRPCInvoker() invoker.RPCInvoke
- func (a *SwitchRPCGuardedActor) GetVersion() result.Version
- func (a *SwitchRPCGuardedActor) MakeCall(contract util.Uint160, method string, params ...any) (*transaction.Transaction, error)
- func (a *SwitchRPCGuardedActor) MakeRun(script []byte) (*transaction.Transaction, error)
- func (a *SwitchRPCGuardedActor) MakeTunedCall(contract util.Uint160, method string, attrs []transaction.Attribute, ...) (*transaction.Transaction, error)
- func (a *SwitchRPCGuardedActor) MakeTunedRun(script []byte, attrs []transaction.Attribute, ...) (*transaction.Transaction, error)
- func (a *SwitchRPCGuardedActor) MakeUncheckedRun(script []byte, sysfee int64, attrs []transaction.Attribute, ...) (*transaction.Transaction, error)
- func (a *SwitchRPCGuardedActor) MakeUnsignedCall(contract util.Uint160, method string, attrs []transaction.Attribute, ...) (*transaction.Transaction, error)
- func (a *SwitchRPCGuardedActor) MakeUnsignedRun(script []byte, attrs []transaction.Attribute) (*transaction.Transaction, error)
- func (a *SwitchRPCGuardedActor) MakeUnsignedUncheckedRun(script []byte, sysFee int64, attrs []transaction.Attribute) (*transaction.Transaction, error)
- func (a *SwitchRPCGuardedActor) Send(tx *transaction.Transaction) (util.Uint256, uint32, error)
- func (a *SwitchRPCGuardedActor) SendCall(contract util.Uint160, method string, params ...any) (util.Uint256, uint32, error)
- func (a *SwitchRPCGuardedActor) SendRun(script []byte) (util.Uint256, uint32, error)
- func (a *SwitchRPCGuardedActor) SendTunedCall(contract util.Uint160, method string, attrs []transaction.Attribute, ...) (util.Uint256, uint32, error)
- func (a *SwitchRPCGuardedActor) SendTunedRun(script []byte, attrs []transaction.Attribute, ...) (util.Uint256, uint32, error)
- func (a *SwitchRPCGuardedActor) SendUncheckedRun(script []byte, sysfee int64, attrs []transaction.Attribute, ...) (util.Uint256, uint32, error)
- func (a *SwitchRPCGuardedActor) Sender() util.Uint160
- func (a *SwitchRPCGuardedActor) Sign(tx *transaction.Transaction) error
- func (a *SwitchRPCGuardedActor) SignAndSend(tx *transaction.Transaction) (util.Uint256, uint32, error)
- func (a *SwitchRPCGuardedActor) TerminateSession(sessionID uuid.UUID) error
- func (a *SwitchRPCGuardedActor) TraverseIterator(sessionID uuid.UUID, iterator *result.Iterator, num int) ([]stackitem.Item, error)
- type TestInvokePrm
- type UpdateAlphabetListPrm
- type UpdateNotaryListPrm
Constants ¶
const ( // NNSBalanceContractName is a name of the balance contract in NNS. NNSBalanceContractName = "balance.frostfs" // NNSContainerContractName is a name of the container contract in NNS. NNSContainerContractName = "container.frostfs" // NNSFrostFSIDContractName is a name of the frostfsid contract in NNS. NNSFrostFSIDContractName = "frostfsid.frostfs" // NNSNetmapContractName is a name of the netmap contract in NNS. NNSNetmapContractName = "netmap.frostfs" // NNSProxyContractName is a name of the proxy contract in NNS. NNSProxyContractName = "proxy.frostfs" // NNSGroupKeyName is a name for the FrostFS group key record in NNS. NNSGroupKeyName = "group.frostfs" // NNSPolicyContractName is a name of the policy contract in NNS. NNSPolicyContractName = "policy.frostfs" )
const HaltState = "HALT"
HaltState returned if TestInvoke function processed without panic.
Variables ¶
var ( // ErrNilClient is returned by functions that expect // a non-nil Client pointer, but received nil. ErrNilClient = errors.New("client is nil") // ErrConnectionLost is returned when client lost web socket connection // to the RPC node and has not been able to establish a new one since. ErrConnectionLost = errors.New("connection to the RPC node has been lost") )
var ( // ErrNNSRecordNotFound means that there is no such record in NNS contract. ErrNNSRecordNotFound = errors.New("record has not been found in NNS contract") )
var ErrNoHealthyEndpoint = errors.New("no healthy endpoint")
Functions ¶
func ArrayFromStackItem ¶
ArrayFromStackItem returns the slice contract parameters from passed parameter.
If passed parameter carries boolean false value, returns (nil, nil).
func BigIntFromStackItem ¶
BigIntFromStackItem receives numerical value from the value of a smart contract parameter.
func BoolFromStackItem ¶
BoolFromStackItem receives boolean value from the value of a smart contract parameter.
func BytesFromStackItem ¶
BytesFromStackItem receives binary value from the value of a smart contract parameter.
func CalculateNotaryDepositAmount ¶
CalculateNotaryDepositAmount calculates notary deposit amount using the rule:
IF notaryBalance < gasBalance * gasMul { DEPOSIT gasBalance / gasDiv } ELSE { DEPOSIT 1 }
gasMul and gasDiv must be positive.
func IntFromStackItem ¶
IntFromStackItem receives numerical value from the value of a smart contract parameter.
func NNSAlphabetContractName ¶
NNSAlphabetContractName returns contract name of the alphabet contract in NNS based on alphabet index.
Types ¶
type AlphabetKeys ¶
type AlphabetKeys func() (keys.PublicKeys, error)
type Callback ¶
type Callback func()
Callback is a function that is going to be called on certain Client's state.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a wrapper over web socket neo-go client that provides smart-contract invocation interface and notification subscription functionality.
On connection lost tries establishing new connection to the next RPC (if any). If no RPC node available, switches to inactive mode: any RPC call leads to immediate return with ErrConnectionLost error, notification channel returned from Client.NotificationChannel is closed.
Working client must be created via constructor New. Using the Client that has been created with new(Client) expression (or just declaring a Client variable) is unsafe and can lead to panic.
func New ¶
New creates, initializes and returns the Client instance. Notary support should be enabled with EnableNotarySupport client method separately.
If private key is nil, it panics.
Other values are set according to provided options, or by default:
- client context: Background;
- dial timeout: 5s;
- blockchain network type: netmode.PrivNet;
- signer with the global scope;
- wait interval: 500ms;
- logger: &logger.Logger{Logger: zap.L()}.
- metrics: metrics.NoopRegister
If desired option satisfies the default value, it can be omitted. If multiple options of the same config value are supplied, the option with the highest index in the arguments will be used. If the list of endpoints provided - uses first alive. If there are no healthy endpoint - returns ErrNoHealthyEndpoint.
func (*Client) BatchTransferGas ¶
func (*Client) BlockCount ¶
BlockCount returns block count of the network to which the underlying RPC node client is connected.
func (*Client) CalculateNonceAndVUB ¶
CalculateNonceAndVUB calculates nonce and ValidUntilBlock values based on transaction hash.
func (*Client) CalculateNonceAndVUBControl ¶ added in v0.37.0
func (c *Client) CalculateNonceAndVUBControl(hash *util.Uint256) (nonce uint32, vub uint32, err error)
CalculateNonceAndVUBControl calculates nonce and rounded ValidUntilBlock values based on transaction hash for use in control transactions.
func (*Client) Close ¶
func (c *Client) Close()
Close closes connection to the remote side making this client instance unusable. Closes notification channel returned from Client.NotificationChannel(), Removes all subscription.
func (*Client) Committee ¶
func (c *Client) Committee() (res keys.PublicKeys, err error)
Committee returns keys of chain committee from neo native contract.
func (*Client) DepositEndlessNotary ¶
func (c *Client) DepositEndlessNotary(ctx context.Context, amount fixedn.Fixed8) (util.Uint256, uint32, error)
DepositEndlessNotary calls notary deposit method. Unlike `DepositNotary`, this method sets notary deposit till parameter to a maximum possible value. This allows to avoid ValidAfterDeposit failures.
This function must be invoked with notary enabled otherwise it throws panic.
func (*Client) DepositNotary ¶
func (c *Client) DepositNotary(ctx context.Context, amount fixedn.Fixed8, delta uint32) (util.Uint256, error)
DepositNotary calls notary deposit method. Deposit is required to operate with notary contract. It used by notary contract in to produce fallback tx if main tx failed to create. Deposit isn't last forever, so it should be called periodically. Notary support should be enabled in client to use this function.
This function must be invoked with notary enabled otherwise it throws panic.
func (*Client) EnableNotarySupport ¶
func (c *Client) EnableNotarySupport(opts ...NotaryOption) error
EnableNotarySupport creates notary structure in client that provides ability for client to get alphabet keys from committee or provided source and use proxy contract script hash to create tx for notary contract.
func (*Client) GasBalance ¶
GasBalance returns GAS amount in the client's wallet.
func (*Client) GetApplicationLog ¶
func (*Client) GetDesignateHash ¶
GetDesignateHash returns hash of the native `RoleManagement` contract.
func (*Client) GetNotaryDeposit ¶
GetNotaryDeposit returns deposit of client's account in notary contract. Notary support should be enabled in client to use this function.
This function must be invoked with notary enabled otherwise it throws panic.
func (*Client) GetRPCActor ¶ added in v0.38.6
func (*Client) Invoke ¶
func (c *Client) Invoke(ctx context.Context, contract util.Uint160, fee fixedn.Fixed8, method string, args ...any) (InvokeRes, error)
Invoke invokes contract method by sending transaction into blockchain. Returns valid until block value. Supported args types: int64, string, util.Uint160, []byte and bool.
func (*Client) IsNotaryEnabled ¶
IsNotaryEnabled returns true if EnableNotarySupport has been successfully called before.
func (*Client) IsValidScript ¶
IsValidScript returns true if invocation script executes with HALT state.
func (*Client) MagicNumber ¶
MagicNumber returns the magic number of the network to which the underlying RPC node client is connected.
func (*Client) Metrics ¶ added in v0.37.0
func (c *Client) Metrics() morphmetrics.Register
func (*Client) MsPerBlock ¶
MsPerBlock returns MillisecondsPerBlock network parameter.
func (*Client) NNSContractAddress ¶
NNSContractAddress returns contract address script hash based on its name in NNS contract. If script hash has not been found, returns ErrNNSRecordNotFound.
func (*Client) NeoFSAlphabetList ¶
func (c *Client) NeoFSAlphabetList() (res keys.PublicKeys, err error)
NeoFSAlphabetList returns keys that stored in NeoFS Alphabet role. Main chain stores alphabet node keys of inner ring there, however the sidechain stores both alphabet and non alphabet node keys of inner ring.
func (*Client) NotaryInvoke ¶
func (c *Client) NotaryInvoke(ctx context.Context, contract util.Uint160, fee fixedn.Fixed8, nonce uint32, vub *uint32, method string, args ...any) (InvokeRes, error)
NotaryInvoke invokes contract method by sending tx to notary contract in blockchain. Fallback tx is a `RET`. If Notary support is not enabled it fallbacks to a simple `Invoke()`.
Returns valid until block value.
`nonce` and `vub` are used only if notary is enabled.
func (*Client) NotaryInvokeNotAlpha ¶
func (c *Client) NotaryInvokeNotAlpha(ctx context.Context, contract util.Uint160, fee fixedn.Fixed8, vubP *uint32, method string, args ...any) (InvokeRes, error)
NotaryInvokeNotAlpha does the same as NotaryInvoke but does not use client's private key in Invocation script. It means that main TX of notary request is not expected to be signed by the current node.
Considered to be used by non-IR nodes.
func (*Client) NotarySignAndInvokeTX ¶
func (c *Client) NotarySignAndInvokeTX(mainTx *transaction.Transaction) error
NotarySignAndInvokeTX signs and sends notary request that was received from Notary service. NOTE: does not fallback to simple `Invoke()`. Expected to be used only for TXs retrieved from the received notary requests.
func (*Client) ProbeNotary ¶
ProbeNotary checks if native `Notary` contract is presented on chain.
func (*Client) ReceiveBlocks ¶
ReceiveBlocks performs subscription for new block events. Events are sent to the specified channel.
Returns ErrConnectionLost if client has not been able to establish connection to any of passed RPC endpoints.
func (*Client) ReceiveExecutionNotifications ¶
func (c *Client) ReceiveExecutionNotifications(contract util.Uint160, ch chan<- *state.ContainedNotificationEvent) (string, error)
ReceiveExecutionNotifications performs subscription for notifications generated during contract execution. Events are sent to the specified channel.
Returns ErrConnectionLost if client has not been able to establish connection to any of passed RPC endpoints.
func (*Client) ReceiveNotaryRequests ¶
func (c *Client) ReceiveNotaryRequests(txSigner util.Uint160, ch chan<- *result.NotaryRequestEvent) (string, error)
ReceiveNotaryRequests performsn subscription for notary request payloads addition or removal events to this instance of client. Passed txSigner is used as filter: subscription is only for the notary requests that must be signed by txSigner. Events are sent to the specified channel.
Returns ErrConnectionLost if client has not been able to establish connection to any of passed RPC endpoints.
func (*Client) SetGroupSignerScope ¶
SetGroupSignerScope makes the default signer scope include all FrostFS contracts. Should be called for side-chain client only.
func (*Client) TestInvoke ¶
func (c *Client) TestInvoke(contract util.Uint160, method string, args ...any) (res []stackitem.Item, err error)
TestInvoke invokes contract method locally in neo-go node. This method should be used to read data from smart-contract.
func (*Client) TestInvokeIterator ¶
func (c *Client) TestInvokeIterator(cb func(stackitem.Item) error, batchSize int, contract util.Uint160, method string, args ...interface{}) error
TestInvokeIterator invokes contract method returning an iterator and executes cb on each element. If cb returns an error, the session is closed and this error is returned as-is. If the remove neo-go node does not support sessions, `unwrap.ErrNoSessionID` is returned. batchSize is the number of items to prefetch: if the number of items in the iterator is less than batchSize, no session will be created. The default batchSize is 100, the default limit from neo-go.
func (*Client) TransferGas ¶
TransferGas to the receiver from local wallet.
func (*Client) TxHalt ¶
TxHalt returns true if transaction has been successfully executed and persisted.
func (*Client) TxHeight ¶
TxHeight returns true if transaction has been successfully executed and persisted.
func (*Client) Unsubscribe ¶
Unsubscribe performs unsubscription for the given subscription ID.
Returns ErrConnectionLost if client has not been able to establish connection to any of passed RPC endpoints.
func (*Client) UnsubscribeAll ¶
UnsubscribeAll removes all active subscriptions of current client.
Returns ErrConnectionLost if client has not been able to establish connection to any of passed RPC endpoints.
func (*Client) UpdateNeoFSAlphabetList ¶
func (c *Client) UpdateNeoFSAlphabetList(ctx context.Context, prm UpdateAlphabetListPrm) error
UpdateNeoFSAlphabetList updates list of alphabet nodes in designate contract. As for sidechain list should contain all inner ring nodes. Requires committee multi signature.
This function must be invoked with notary enabled otherwise it throws panic.
func (*Client) UpdateNotaryList ¶
func (c *Client) UpdateNotaryList(ctx context.Context, prm UpdateNotaryListPrm) error
UpdateNotaryList updates list of notary nodes in designate contract. Requires committee multi signature.
This function must be invoked with notary enabled otherwise it throws panic.
type DialerSource ¶
type Endpoint ¶
type Endpoint struct { Address string Priority int MTLSConfig *MTLSConfig }
Endpoint represents morph endpoint together with its priority.
type InvokePrm ¶
type InvokePrm struct { TestInvokePrm // optional parameters InvokePrmOptional }
InvokePrm groups parameters of the Invoke operation.
type InvokePrmOptional ¶
type InvokePrmOptional struct {
// contains filtered or unexported fields
}
InvokePrmOptional groups optional parameters of the Invoke operation.
func (*InvokePrmOptional) IsControl ¶ added in v0.37.0
func (i *InvokePrmOptional) IsControl() bool
IsControl gets whether a control transaction will be used.
func (*InvokePrmOptional) SetControlTX ¶ added in v0.37.0
func (i *InvokePrmOptional) SetControlTX(b bool)
SetControlTX sets whether a control transaction will be used.
func (*InvokePrmOptional) SetHash ¶
func (i *InvokePrmOptional) SetHash(hash util.Uint256)
SetHash sets optional hash of the transaction. If hash is set and notary is enabled, StaticClient uses it for notary nonce and `validUntilBlock` calculation.
func (*InvokePrmOptional) SetVUB ¶ added in v0.38.0
func (i *InvokePrmOptional) SetVUB(v uint32)
SetVUB sets valid until block value.
type MTLSConfig ¶ added in v0.41.0
MTLSConfig represents endpoint mTLS configuration.
type NotaryOption ¶
type NotaryOption func(*notaryCfg)
func WithAlphabetSource ¶
func WithAlphabetSource(t AlphabetKeys) NotaryOption
WithAlphabetSource returns a notary support option for client that specifies function to return list of alphabet node keys. By default notary subsystem uses committee as a source. This is valid for side chain but notary in main chain should override it.
func WithProxyContract ¶
func WithProxyContract(h util.Uint160) NotaryOption
WithProxyContract sets proxy contract hash.
func WithRoundTime ¶
func WithRoundTime(t uint32) NotaryOption
WithRoundTime returns a notary support option for client that specifies extra blocks to synchronize side chain height diff of inner ring nodes.
func WithTxValidTime ¶
func WithTxValidTime(t uint32) NotaryOption
WithTxValidTime returns a notary support option for client that specifies minimum amount of blocks when mainTx will be valid.
type Option ¶
type Option func(*cfg)
Option is a client configuration change function.
func WithConnLostCallback ¶
WithConnLostCallback return a client constructor option that specifies a callback that is called when Client unsuccessfully tried to connect to all the specified endpoints.
func WithDialTimeout ¶
WithDialTimeout returns a client constructor option that specifies neo-go client dial timeout duration.
Ignores non-positive value. Has no effect if WithSingleClient is provided.
If option not provided, 5s timeout is used.
func WithDialerSource ¶
func WithDialerSource(ds DialerSource) Option
func WithEndpoints ¶
WithEndpoints returns a client constructor option that specifies additional Neo rpc endpoints.
func WithLogger ¶
WithLogger returns a client constructor option that specifies the component for writing log messages.
Ignores nil value.
If option not provided, &logger.Logger{Logger: zap.L()} is used.
func WithMetrics ¶ added in v0.37.0
func WithMetrics(metrics morphmetrics.Register) Option
WithMetrics returns a client constructor option that specifies the component for reporting metrics.
Ignores nil value.
If option not provided, NoopMetrics is used.
func WithMorphCacheMetrics ¶ added in v0.37.0
func WithMorphCacheMetrics(morphCacheMetrics metrics.MorphCacheMetrics) Option
func WithSigner ¶
func WithSigner(signer *transaction.Signer) Option
WithSigner returns a client constructor option that specifies the signer and the scope of the transaction.
Ignores nil value.
If option not provided, signer with global scope is used.
func WithSwitchInterval ¶
WithSwitchInterval returns a client constructor option that specifies a wait interval b/w attempts to reconnect to an RPC node with the highest priority.
type StaticClient ¶
type StaticClient struct {
// contains filtered or unexported fields
}
StaticClient is a wrapper over Neo:Morph client that invokes single smart contract methods with fixed fee.
Working static client must be created via constructor NewStatic. Using the StaticClient that has been created with new(StaticClient) expression (or just declaring a StaticClient variable) is unsafe and can lead to panic.
func NewStatic ¶
func NewStatic(client *Client, scriptHash util.Uint160, fee fixedn.Fixed8, opts ...StaticClientOption) (*StaticClient, error)
NewStatic creates, initializes and returns the StaticClient instance.
If provided Client instance is nil, ErrNilClient is returned.
Specified fee is used by default. Per-operation fees can be customized via WithCustomFee option.
func (StaticClient) ContractAddress ¶
func (s StaticClient) ContractAddress() util.Uint160
ContractAddress returns the address of the associated contract.
func (StaticClient) Invoke ¶
Invoke calls Invoke method of Client with static internal script hash and fee. Supported args types are the same as in Client.
If TryNotary is provided:
- if AsAlphabet is provided, calls NotaryInvoke;
- otherwise, calls NotaryInvokeNotAlpha.
If fee for the operation executed using specified method is customized, then StaticClient uses it. Otherwise, default fee is used.
func (*StaticClient) IsAlpha ¶
func (s *StaticClient) IsAlpha() bool
IsAlpha returns Alphabet status of the client.
See also AsAlphabet.
func (StaticClient) Morph ¶
func (s StaticClient) Morph() *Client
Morph return wrapped raw morph client.
func (StaticClient) TestInvoke ¶
func (s StaticClient) TestInvoke(prm TestInvokePrm) ([]stackitem.Item, error)
TestInvoke calls TestInvoke method of Client with static internal script hash.
func (*StaticClient) WithNotary ¶
func (s *StaticClient) WithNotary() bool
WithNotary returns notary status of the client.
See also TryNotary.
type StaticClientOption ¶
type StaticClientOption func(*staticOpts)
StaticClientOption allows to set an optional parameter of StaticClient.
func AsAlphabet ¶
func AsAlphabet() StaticClientOption
AsAlphabet returns option to sign main TX of notary requests with client's private key.
Considered to be used by IR nodes only.
func TryNotary ¶
func TryNotary() StaticClientOption
TryNotary returns option to enable notary invocation tries.
type SwitchRPCGuardedActor ¶ added in v0.38.0
type SwitchRPCGuardedActor struct {
// contains filtered or unexported fields
}
SwitchRPCGuardedActor switches an established connection with neo-go if it is broken. This leads to an invalidation of an rpc actor within Client. That means the components that are initilized with the rpc actor may unintentionally use it when it is already invalidated. SwitchRPCGuardedActor is used to prevent this situation, getting the rpc actor from Client.
func NewSwitchRPCGuardedActor ¶ added in v0.38.0
func NewSwitchRPCGuardedActor(c *Client) *SwitchRPCGuardedActor
func (*SwitchRPCGuardedActor) CalculateNetworkFee ¶ added in v0.38.0
func (a *SwitchRPCGuardedActor) CalculateNetworkFee(tx *transaction.Transaction) (int64, error)
func (*SwitchRPCGuardedActor) CalculateValidUntilBlock ¶ added in v0.38.0
func (a *SwitchRPCGuardedActor) CalculateValidUntilBlock() (uint32, error)
func (*SwitchRPCGuardedActor) CallAndExpandIterator ¶ added in v0.38.0
func (*SwitchRPCGuardedActor) GetBlockCount ¶ added in v0.38.0
func (a *SwitchRPCGuardedActor) GetBlockCount() (uint32, error)
func (*SwitchRPCGuardedActor) GetNetwork ¶ added in v0.38.0
func (a *SwitchRPCGuardedActor) GetNetwork() netmode.Magic
func (*SwitchRPCGuardedActor) GetRPCActor ¶ added in v0.38.6
func (a *SwitchRPCGuardedActor) GetRPCActor() actor.RPCActor
func (*SwitchRPCGuardedActor) GetRPCInvoker ¶ added in v0.38.6
func (a *SwitchRPCGuardedActor) GetRPCInvoker() invoker.RPCInvoke
func (*SwitchRPCGuardedActor) GetVersion ¶ added in v0.38.0
func (a *SwitchRPCGuardedActor) GetVersion() result.Version
func (*SwitchRPCGuardedActor) MakeCall ¶ added in v0.38.0
func (a *SwitchRPCGuardedActor) MakeCall(contract util.Uint160, method string, params ...any) (*transaction.Transaction, error)
func (*SwitchRPCGuardedActor) MakeRun ¶ added in v0.38.0
func (a *SwitchRPCGuardedActor) MakeRun(script []byte) (*transaction.Transaction, error)
func (*SwitchRPCGuardedActor) MakeTunedCall ¶ added in v0.38.0
func (a *SwitchRPCGuardedActor) MakeTunedCall(contract util.Uint160, method string, attrs []transaction.Attribute, txHook actor.TransactionCheckerModifier, params ...any) (*transaction.Transaction, error)
func (*SwitchRPCGuardedActor) MakeTunedRun ¶ added in v0.38.0
func (a *SwitchRPCGuardedActor) MakeTunedRun(script []byte, attrs []transaction.Attribute, txHook actor.TransactionCheckerModifier) (*transaction.Transaction, error)
func (*SwitchRPCGuardedActor) MakeUncheckedRun ¶ added in v0.38.0
func (a *SwitchRPCGuardedActor) MakeUncheckedRun(script []byte, sysfee int64, attrs []transaction.Attribute, txHook actor.TransactionModifier) (*transaction.Transaction, error)
func (*SwitchRPCGuardedActor) MakeUnsignedCall ¶ added in v0.38.0
func (a *SwitchRPCGuardedActor) MakeUnsignedCall(contract util.Uint160, method string, attrs []transaction.Attribute, params ...any) (*transaction.Transaction, error)
func (*SwitchRPCGuardedActor) MakeUnsignedRun ¶ added in v0.38.0
func (a *SwitchRPCGuardedActor) MakeUnsignedRun(script []byte, attrs []transaction.Attribute) (*transaction.Transaction, error)
func (*SwitchRPCGuardedActor) MakeUnsignedUncheckedRun ¶ added in v0.38.0
func (a *SwitchRPCGuardedActor) MakeUnsignedUncheckedRun(script []byte, sysFee int64, attrs []transaction.Attribute) (*transaction.Transaction, error)
func (*SwitchRPCGuardedActor) Send ¶ added in v0.38.0
func (a *SwitchRPCGuardedActor) Send(tx *transaction.Transaction) (util.Uint256, uint32, error)
func (*SwitchRPCGuardedActor) SendTunedCall ¶ added in v0.38.0
func (a *SwitchRPCGuardedActor) SendTunedCall(contract util.Uint160, method string, attrs []transaction.Attribute, txHook actor.TransactionCheckerModifier, params ...any) (util.Uint256, uint32, error)
func (*SwitchRPCGuardedActor) SendTunedRun ¶ added in v0.38.0
func (a *SwitchRPCGuardedActor) SendTunedRun(script []byte, attrs []transaction.Attribute, txHook actor.TransactionCheckerModifier) (util.Uint256, uint32, error)
func (*SwitchRPCGuardedActor) SendUncheckedRun ¶ added in v0.38.0
func (a *SwitchRPCGuardedActor) SendUncheckedRun(script []byte, sysfee int64, attrs []transaction.Attribute, txHook actor.TransactionModifier) (util.Uint256, uint32, error)
func (*SwitchRPCGuardedActor) Sender ¶ added in v0.38.0
func (a *SwitchRPCGuardedActor) Sender() util.Uint160
func (*SwitchRPCGuardedActor) Sign ¶ added in v0.38.0
func (a *SwitchRPCGuardedActor) Sign(tx *transaction.Transaction) error
func (*SwitchRPCGuardedActor) SignAndSend ¶ added in v0.38.0
func (a *SwitchRPCGuardedActor) SignAndSend(tx *transaction.Transaction) (util.Uint256, uint32, error)
func (*SwitchRPCGuardedActor) TerminateSession ¶ added in v0.38.0
func (a *SwitchRPCGuardedActor) TerminateSession(sessionID uuid.UUID) error
type TestInvokePrm ¶
type TestInvokePrm struct {
// contains filtered or unexported fields
}
TestInvokePrm groups parameters of the TestInvoke operation.
func (*TestInvokePrm) SetArgs ¶
func (ti *TestInvokePrm) SetArgs(args ...any)
SetArgs sets arguments of the contact call.
func (*TestInvokePrm) SetMethod ¶
func (ti *TestInvokePrm) SetMethod(method string)
SetMethod sets method of the contract to call.
type UpdateAlphabetListPrm ¶
type UpdateAlphabetListPrm struct {
// contains filtered or unexported fields
}
UpdateAlphabetListPrm groups parameters of UpdateNeoFSAlphabetList operation.
func (*UpdateAlphabetListPrm) SetHash ¶
func (u *UpdateAlphabetListPrm) SetHash(hash util.Uint256)
SetHash sets hash of the transaction that led to the update of the alphabet role in the designate contract.
func (*UpdateAlphabetListPrm) SetList ¶
func (u *UpdateAlphabetListPrm) SetList(list keys.PublicKeys)
SetList sets a list of the new alphabet role keys.
type UpdateNotaryListPrm ¶
type UpdateNotaryListPrm struct {
// contains filtered or unexported fields
}
UpdateNotaryListPrm groups parameters of UpdateNotaryList operation.
func (*UpdateNotaryListPrm) SetHash ¶
func (u *UpdateNotaryListPrm) SetHash(hash util.Uint256)
SetHash sets hash of the transaction that led to the update of the notary role in the designate contract.
func (*UpdateNotaryListPrm) SetList ¶
func (u *UpdateNotaryListPrm) SetList(list keys.PublicKeys)
SetList sets a list of the new notary role keys.