client

package
v0.0.0-...-f94ef0f Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func New

func New(ctx context.Context, endpoint string, opts Options) (*Client, error)

New returns a new Client ready to use. You should call Init method to initialize network magic the client is operating on.

func (*Client) Bridge_GetMinted

func (c *Client) Bridge_GetMinted(id int64) (common.Hash, error)

func (*Client) CalculateGas

func (c *Client) CalculateGas(tx *transaction.NeoTx) (uint64, error)

func (*Client) Eth_Accounts

func (c *Client) Eth_Accounts() ([]common.Address, error)

func (*Client) Eth_BlockNumber

func (c *Client) Eth_BlockNumber() (uint64, error)

func (*Client) Eth_Call

func (c *Client) Eth_Call(tx *result.TransactionObject) ([]byte, error)

func (*Client) Eth_ChainId

func (c *Client) Eth_ChainId() (uint64, error)

func (*Client) Eth_Coinbase

func (c *Client) Eth_Coinbase() (common.Address, error)

func (*Client) Eth_EstimateGas

func (c *Client) Eth_EstimateGas(tx *result.TransactionObject) (uint64, error)

func (*Client) Eth_GasPrice

func (c *Client) Eth_GasPrice() (*big.Int, error)

func (*Client) Eth_GetBalance

func (c *Client) Eth_GetBalance(addr common.Address) (*big.Int, error)

func (*Client) Eth_GetBlockByHash

func (c *Client) Eth_GetBlockByHash(blockHash common.Hash) (*result.Block, error)

func (*Client) Eth_GetBlockByNumber

func (c *Client) Eth_GetBlockByNumber(height uint32) (*result.Block, error)

func (*Client) Eth_GetBlockTransactionCountByHash

func (c *Client) Eth_GetBlockTransactionCountByHash(blockHash common.Hash) (uint64, error)

func (*Client) Eth_GetBlockTransactionCountByNumber

func (c *Client) Eth_GetBlockTransactionCountByNumber(height uint32) (uint64, error)

func (*Client) Eth_GetCode

func (c *Client) Eth_GetCode(address common.Address) ([]byte, error)

func (*Client) Eth_GetLogs

func (c *Client) Eth_GetLogs(filter *filters.LogFilter) ([]*types.Log, error)

func (*Client) Eth_GetStorageAt

func (c *Client) Eth_GetStorageAt(address common.Address, key common.Hash) (common.Hash, error)

func (*Client) Eth_GetTransactionByBlockHashAndIndex

func (c *Client) Eth_GetTransactionByBlockHashAndIndex(blockHash common.Hash, index int) (*result.TransactionOutputRaw, error)

func (*Client) Eth_GetTransactionByBlockNumberAndIndex

func (c *Client) Eth_GetTransactionByBlockNumberAndIndex(height uint32, index int) (*result.TransactionOutputRaw, error)

func (*Client) Eth_GetTransactionByHash

func (c *Client) Eth_GetTransactionByHash(txHash common.Hash) (*result.TransactionOutputRaw, error)

func (*Client) Eth_GetTransactionCount

func (c *Client) Eth_GetTransactionCount(address common.Address) (uint64, error)

func (*Client) Eth_GetTransactionReceipt

func (c *Client) Eth_GetTransactionReceipt(txHash common.Hash) (*types.Receipt, error)

func (*Client) Eth_ProtocolVersion

func (c *Client) Eth_ProtocolVersion() (string, error)

func (*Client) Eth_SendRawTransaction

func (c *Client) Eth_SendRawTransaction(raw []byte) (common.Hash, error)

func (*Client) Eth_SendTransaction

func (c *Client) Eth_SendTransaction(tx *result.TransactionObject) (common.Hash, error)

func (*Client) Eth_Sign

func (c *Client) Eth_Sign(address common.Address, msg []byte) ([]byte, error)

func (*Client) Eth_SignTransaction

func (c *Client) Eth_SignTransaction(tx *result.TransactionObject) ([]byte, error)

func (*Client) Eth_Syncing

func (c *Client) Eth_Syncing() (*result.Syncing, error)

func (*Client) FindStates

func (c *Client) FindStates(stateroot common.Hash, historicalContractHash common.Address, historicalPrefix []byte,
	start []byte, maxCount *int) (result.FindStates, error)

FindStates returns historical contract storage item states by the given stateroot, historical contract hash and historical prefix. If `start` path is specified, then items starting from `start` path are being returned (excluding item located at the start path). If `maxCount` specified, then maximum number of items to be returned equals to `maxCount`.

func (*Client) GetBestBlockHash

func (c *Client) GetBestBlockHash() (common.Hash, error)

GetBestBlockHash returns the hash of the tallest block in the main chain.

func (*Client) GetBlockByHash

func (c *Client) GetBlockByHash(hash common.Hash) (*block.Block, error)

GetBlockByHash returns a block by its hash. You should initialize network magic with Init before calling GetBlockByHash.

func (*Client) GetBlockByHashVerbose

func (c *Client) GetBlockByHashVerbose(hash common.Hash) (*result.Block, error)

GetBlockByHashVerbose returns a block wrapper with additional metadata by its hash. You should initialize network magic with Init before calling GetBlockByHashVerbose.

func (*Client) GetBlockByIndex

func (c *Client) GetBlockByIndex(index uint32) (*block.Block, error)

GetBlockByIndex returns a block by its height. You should initialize network magic with Init before calling GetBlockByIndex.

func (*Client) GetBlockByIndexVerbose

func (c *Client) GetBlockByIndexVerbose(index uint32) (*result.Block, error)

GetBlockByIndexVerbose returns a block wrapper with additional metadata by its height. You should initialize network magic with Init before calling GetBlockByIndexVerbose. NOTE: to get transaction.ID and transaction.Size, use t.Hash() and io.GetVarSize(t) respectively.

func (*Client) GetBlockCount

func (c *Client) GetBlockCount() (uint32, error)

GetBlockCount returns the number of blocks in the main chain.

func (*Client) GetBlockGas

func (c *Client) GetBlockGas(index uint32) (uint64, error)

GetBlockSysFee returns the system fees of the block, based on the specified index.

func (*Client) GetBlockHash

func (c *Client) GetBlockHash(index uint32) (common.Hash, error)

GetBlockHash returns the hash value of the corresponding block, based on the specified index.

func (*Client) GetBlockHeader

func (c *Client) GetBlockHeader(hash common.Hash) (*block.Header, error)

GetBlockHeader returns the corresponding block header information from serialized hex string according to the specified script hash. You should initialize network magic // with Init before calling GetBlockHeader.

func (*Client) GetBlockHeaderCount

func (c *Client) GetBlockHeaderCount() (uint32, error)

GetBlockHeaderCount returns the number of headers in the main chain.

func (*Client) GetBlockHeaderVerbose

func (c *Client) GetBlockHeaderVerbose(hash common.Hash) (*result.Header, error)

GetBlockHeaderVerbose returns the corresponding block header information from Json format string according to the specified script hash.

func (*Client) GetConnectionCount

func (c *Client) GetConnectionCount() (int, error)

GetConnectionCount returns the current number of connections for the node.

func (*Client) GetConsensusAddress

func (c *Client) GetConsensusAddress() (common.Address, error)

func (*Client) GetContractStateByAddressOrName

func (c *Client) GetContractStateByAddressOrName(addressOrName string) (*state.Contract, error)

GetContractStateByAddressOrName queries contract information, according to the contract address or name.

func (*Client) GetContractStateByHash

func (c *Client) GetContractStateByHash(hash common.Address) (*state.Contract, error)

GetContractStateByHash queries contract information, according to the contract script hash.

func (*Client) GetContractStateByID

func (c *Client) GetContractStateByID(id int32) (*state.Contract, error)

GetContractStateByID queries contract information, according to the contract ID.

func (*Client) GetERC20Balances

func (c *Client) GetERC20Balances(address common.Address) (*result.ERC20Balances, error)

GetERC20Balances is a wrapper for getERC20balances RPC.

func (*Client) GetERC20Transfers

func (c *Client) GetERC20Transfers(address common.Address, start, stop *uint64, limit, page *int) (*result.ERC20Transfers, error)

func (*Client) GetERC721Balances

func (c *Client) GetERC721Balances(address common.Address) (*result.ERC721Balances, error)

GetERC721Balances is a wrapper for getERC721balances RPC.

func (*Client) GetERC721Properties

func (c *Client) GetERC721Properties(asset common.Address, token []byte) (map[string]interface{}, error)

GetERC721Properties is a wrapper for getERC721properties RPC. We recommend using ERC721Properties method instead of this to receive and work with proper VM types, this method is provided mostly for the sake of completeness. For well-known attributes like "description", "image", "name" and "tokenURI" it returns strings, while for all other ones []byte (which can be nil).

func (*Client) GetERC721Transfers

func (c *Client) GetERC721Transfers(address common.Address, start, stop *uint64, limit, page *int) (*result.ERC721Transfers, error)

func (*Client) GetFeePerByte

func (c *Client) GetFeePerByte() (uint64, error)

func (*Client) GetNativeContractHash

func (c *Client) GetNativeContractHash(name string) (common.Address, error)

GetNativeContractHash returns native contract hash by its name.

func (*Client) GetNativeContracts

func (c *Client) GetNativeContracts() ([]state.NativeContract, error)

GetNativeContracts queries information about native contracts.

func (*Client) GetNetwork

func (c *Client) GetNetwork() (uint64, error)

GetNetwork returns the network magic of the RPC node client connected to.

func (*Client) GetNextBlockValidators

func (c *Client) GetNextBlockValidators() ([]result.Validator, error)

func (*Client) GetNextValidators

func (c *Client) GetNextValidators() (keys.PublicKeys, error)

func (*Client) GetPeers

func (c *Client) GetPeers() (*result.GetPeers, error)

GetPeers returns the list of nodes that the node is currently connected/disconnected from.

func (*Client) GetRawMemPool

func (c *Client) GetRawMemPool() ([]common.Hash, error)

GetRawMemPool returns the list of unconfirmed transactions in memory.

func (*Client) GetRawTransaction

func (c *Client) GetRawTransaction(hash common.Hash) (*transaction.Transaction, error)

GetRawTransaction returns a transaction by hash.

func (*Client) GetRawTransactionVerbose

func (c *Client) GetRawTransactionVerbose(hash common.Hash) (*result.TransactionOutputRaw, error)

GetRawTransactionVerbose returns a transaction wrapper with additional metadata by transaction's hash. NOTE: to get transaction.ID and transaction.Size, use t.Hash() and io.GetVarSize(t) respectively.

func (*Client) GetState

func (c *Client) GetState(stateroot common.Hash, historicalContractHash common.Address, historicalKey []byte) ([]byte, error)

GetState returns historical contract storage item state by the given stateroot, historical contract hash and historical item key.

func (*Client) GetStateHeight

func (c *Client) GetStateHeight() (*result.StateHeight, error)

GetStateHeight returns current validated and local node state height.

func (*Client) GetStateRootByBlockHash

func (c *Client) GetStateRootByBlockHash(hash common.Hash) (*state.MPTRoot, error)

GetStateRootByBlockHash returns state root for block with specified hash.

func (*Client) GetStateRootByHeight

func (c *Client) GetStateRootByHeight(height uint32) (*state.MPTRoot, error)

GetStateRootByHeight returns state root for the specified height.

func (*Client) GetStorageByHash

func (c *Client) GetStorageByHash(hash common.Address, key []byte) ([]byte, error)

GetStorageByHash returns the stored value, according to the contract script hash and the stored key.

func (*Client) GetStorageByID

func (c *Client) GetStorageByID(id int32, key []byte) ([]byte, error)

GetStorageByID returns the stored value, according to the contract ID and the stored key.

func (*Client) GetTransactionHeight

func (c *Client) GetTransactionHeight(hash common.Hash) (uint32, error)

GetTransactionHeight returns the block index in which the transaction is found.

func (*Client) GetUnclaimedGas

func (c *Client) GetUnclaimedGas(address string) (result.UnclaimedGas, error)

GetUnclaimedGas returns unclaimed GAS amount for the specified address.

func (*Client) GetValidators

func (c *Client) GetValidators(index uint32) (keys.PublicKeys, error)

func (*Client) GetVersion

func (c *Client) GetVersion() (*result.Version, error)

GetVersion returns the version information about the queried node.

func (*Client) Init

func (c *Client) Init() error

func (*Client) IsBlocked

func (c *Client) IsBlocked(address common.Address) (bool, error)

func (*Client) Net_Listening

func (c *Client) Net_Listening() (bool, error)

func (*Client) Net_PeerCount

func (c *Client) Net_PeerCount() (uint64, error)

func (*Client) Net_Version

func (c *Client) Net_Version() (string, error)

func (*Client) Ping

func (c *Client) Ping() error

Ping attempts to create a connection to the endpoint. and returns an error if there is one.

func (*Client) SendRawTransaction

func (c *Client) SendRawTransaction(rawTX []byte) (common.Hash, error)

func (*Client) SignAndPushTx

func (c *Client) SignAndPushTx(tx *transaction.Transaction, acc *wallet.Account) (common.Hash, error)

SignAndPushTx signs given transaction using given wif and cosigners and pushes it to the chain. It returns a hash of the transaction and an error. If one of the cosigners accounts is neither contract-based nor unlocked an error is returned.

func (*Client) SubmitBlock

func (c *Client) SubmitBlock(b block.Block) (common.Hash, error)

func (*Client) ValidateAddress

func (c *Client) ValidateAddress(address string) error

func (*Client) Web3_ClientVersion

func (c *Client) Web3_ClientVersion() (string, error)

func (*Client) Web3_Sha3

func (c *Client) Web3_Sha3(data []byte) (common.Hash, error)

type Notification

type Notification struct {
	Type  response.EventID
	Value interface{}
}

Notification represents server-generated notification for client subscriptions. Value can be one of block.Block, state.AppExecResult, subscriptions.NotificationEvent transaction.Transaction or subscriptions.NotaryRequestEvent based on Type.

type Options

type Options struct {
	// Cert is a client-side certificate, it doesn't work at the moment along
	// with the other two options below.
	Cert           string
	Key            string
	CACert         string
	DialTimeout    time.Duration
	RequestTimeout time.Duration
	// Limit total number of connections per host. No limit by default.
	MaxConnsPerHost int
}

Options defines options for the RPC client. All values are optional. If any duration is not specified a default of 4 seconds will be used.

type WSClient

type WSClient struct {
	Client
	// Notifications is a channel that is used to send events received from
	// server. Client's code is supposed to be reading from this channel if
	// it wants to use subscription mechanism, failing to do so will cause
	// WSClient to block even regular requests. This channel is not buffered.
	// In case of protocol error or upon connection closure this channel will
	// be closed, so make sure to handle this.
	Notifications chan Notification
	// contains filtered or unexported fields
}

WSClient is a websocket-enabled RPC client that can be used with appropriate servers. It's supposed to be faster than Client because it has persistent connection to the server and at the same time is exposes some functionality that is only provided via websockets (like event subscription mechanism). WSClient is thread-safe and can be used from multiple goroutines to perform RPC requests.

func NewWS

func NewWS(ctx context.Context, endpoint string, opts Options) (*WSClient, error)

NewWS returns a new WSClient ready to use (with established websocket connection). You need to use websocket URL for it like `ws://1.2.3.4/ws`. You should call Init method to initialize network magic the client is operating on.

func (*WSClient) Close

func (c *WSClient) Close()

Close closes connection to the remote side rendering this client instance unusable.

func (*WSClient) SubscribeForExecutionNotifications

func (c *WSClient) SubscribeForExecutionNotifications(contract *common.Address, name *string) (string, error)

SubscribeForExecutionNotifications adds subscription for notifications generated during transaction execution to this instance of client. It can be filtered by contract's hash (that emits notifications), nil value puts no such restrictions.

func (*WSClient) SubscribeForNewBlocks

func (c *WSClient) SubscribeForNewBlocks(primary *int) (string, error)

SubscribeForNewBlocks adds subscription for new block events to this instance of client. It can filtered by primary consensus node index, nil value doesn't add any filters.

func (*WSClient) SubscribeForNewTransactions

func (c *WSClient) SubscribeForNewTransactions(sender *common.Address) (string, error)

SubscribeForNewTransactions adds subscription for new transaction events to this instance of client. It can be filtered by sender and/or signer, nil value is treated as missing filter.

func (*WSClient) SubscribeForTransactionExecutions

func (c *WSClient) SubscribeForTransactionExecutions(state uint64) (string, error)

SubscribeForTransactionExecutions adds subscription for application execution results generated during transaction execution to this instance of client. Can be filtered by state (HALT/FAULT) to check for successful or failing transactions, nil value means no filtering.

func (*WSClient) Unsubscribe

func (c *WSClient) Unsubscribe(id string) error

Unsubscribe removes subscription for given event stream.

func (*WSClient) UnsubscribeAll

func (c *WSClient) UnsubscribeAll() error

UnsubscribeAll removes all active subscriptions of current client.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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