Documentation ¶
Overview ¶
Package grpc client provides a Go client for the Flow Access gRPC API.
The Access API provides a set of methods that can be used to submit transactions and read state from Flow. This client is compatible with the Access API implemented by the Access Node role, as well as the mock Access API exposed by the Flow Emulator.
The full Access API specification is here: https://docs.onflow.org/access-api/
Index ¶
- Constants
- func DefaultClientOptions() *options
- type BaseClient
- func (c *BaseClient) Close() error
- func (c *BaseClient) ExecuteScriptAtBlockHeight(ctx context.Context, height uint64, script []byte, arguments []cadence.Value, ...) (cadence.Value, error)
- func (c *BaseClient) ExecuteScriptAtBlockID(ctx context.Context, blockID flow.Identifier, script []byte, ...) (cadence.Value, error)
- func (c *BaseClient) ExecuteScriptAtLatestBlock(ctx context.Context, script []byte, arguments []cadence.Value, ...) (cadence.Value, error)
- func (c *BaseClient) ExecutionDataRPCClient() ExecutionDataRPCClient
- func (c *BaseClient) GetAccount(ctx context.Context, address flow.Address, opts ...grpc.CallOption) (*flow.Account, error)
- func (c *BaseClient) GetAccountAtBlockHeight(ctx context.Context, address flow.Address, blockHeight uint64, ...) (*flow.Account, error)
- func (c *BaseClient) GetAccountAtLatestBlock(ctx context.Context, address flow.Address, opts ...grpc.CallOption) (*flow.Account, error)
- func (c *BaseClient) GetBlockByHeight(ctx context.Context, height uint64, opts ...grpc.CallOption) (*flow.Block, error)
- func (c *BaseClient) GetBlockByID(ctx context.Context, blockID flow.Identifier, opts ...grpc.CallOption) (*flow.Block, error)
- func (c *BaseClient) GetBlockHeaderByHeight(ctx context.Context, height uint64, opts ...grpc.CallOption) (*flow.BlockHeader, error)
- func (c *BaseClient) GetBlockHeaderByID(ctx context.Context, blockID flow.Identifier, opts ...grpc.CallOption) (*flow.BlockHeader, error)
- func (c *BaseClient) GetCollection(ctx context.Context, colID flow.Identifier, opts ...grpc.CallOption) (*flow.Collection, error)
- func (c *BaseClient) GetEventsForBlockIDs(ctx context.Context, eventType string, blockIDs []flow.Identifier, ...) ([]flow.BlockEvents, error)
- func (c *BaseClient) GetEventsForHeightRange(ctx context.Context, query EventRangeQuery, opts ...grpc.CallOption) ([]flow.BlockEvents, error)
- func (c *BaseClient) GetExecutionDataByBlockID(ctx context.Context, blockID flow.Identifier, opts ...grpc.CallOption) (*flow.ExecutionData, error)
- func (c *BaseClient) GetExecutionResultForBlockID(ctx context.Context, blockID flow.Identifier, opts ...grpc.CallOption) (*flow.ExecutionResult, error)
- func (c *BaseClient) GetLatestBlock(ctx context.Context, isSealed bool, opts ...grpc.CallOption) (*flow.Block, error)
- func (c *BaseClient) GetLatestBlockHeader(ctx context.Context, isSealed bool, opts ...grpc.CallOption) (*flow.BlockHeader, error)
- func (c *BaseClient) GetLatestProtocolStateSnapshot(ctx context.Context, opts ...grpc.CallOption) ([]byte, error)
- func (c *BaseClient) GetNetworkParameters(ctx context.Context, opts ...grpc.CallOption) (*flow.NetworkParameters, error)
- func (c *BaseClient) GetNodeVersionInfo(ctx context.Context, opts ...grpc.CallOption) (*flow.NodeVersionInfo, error)
- func (c *BaseClient) GetTransaction(ctx context.Context, txID flow.Identifier, opts ...grpc.CallOption) (*flow.Transaction, error)
- func (c *BaseClient) GetTransactionResult(ctx context.Context, txID flow.Identifier, opts ...grpc.CallOption) (*flow.TransactionResult, error)
- func (c *BaseClient) GetTransactionResultByIndex(ctx context.Context, blockID flow.Identifier, index uint32, ...) (*flow.TransactionResult, error)
- func (c *BaseClient) GetTransactionResultsByBlockID(ctx context.Context, blockID flow.Identifier, opts ...grpc.CallOption) ([]*flow.TransactionResult, error)
- func (c *BaseClient) GetTransactionsByBlockID(ctx context.Context, blockID flow.Identifier, opts ...grpc.CallOption) ([]*flow.Transaction, error)
- func (c *BaseClient) Ping(ctx context.Context, opts ...grpc.CallOption) error
- func (c *BaseClient) RPCClient() RPCClient
- func (c *BaseClient) SendTransaction(ctx context.Context, tx flow.Transaction, opts ...grpc.CallOption) error
- func (c *BaseClient) SetEventEncoding(version flow.EventEncodingVersion)
- func (c *BaseClient) SetJSONOptions(options []json.Option)
- func (c *BaseClient) SubscribeEventsByBlockHeight(ctx context.Context, startHeight uint64, filter flow.EventFilter, ...) (<-chan flow.BlockEvents, <-chan error, error)
- func (c *BaseClient) SubscribeEventsByBlockID(ctx context.Context, startBlockID flow.Identifier, filter flow.EventFilter, ...) (<-chan flow.BlockEvents, <-chan error, error)
- func (c *BaseClient) SubscribeExecutionDataByBlockHeight(ctx context.Context, startHeight uint64, opts ...grpc.CallOption) (<-chan flow.ExecutionDataStreamResponse, <-chan error, error)
- func (c *BaseClient) SubscribeExecutionDataByBlockID(ctx context.Context, startBlockID flow.Identifier, opts ...grpc.CallOption) (<-chan flow.ExecutionDataStreamResponse, <-chan error, error)
- type Client
- func (c *Client) Close() error
- func (c *Client) ExecuteScriptAtBlockHeight(ctx context.Context, height uint64, script []byte, arguments []cadence.Value) (cadence.Value, error)
- func (c *Client) ExecuteScriptAtBlockID(ctx context.Context, blockID flow.Identifier, script []byte, ...) (cadence.Value, error)
- func (c *Client) ExecuteScriptAtLatestBlock(ctx context.Context, script []byte, arguments []cadence.Value) (cadence.Value, error)
- func (c *Client) ExecutionDataRPCClient() ExecutionDataRPCClient
- func (c *Client) GetAccount(ctx context.Context, address flow.Address) (*flow.Account, error)
- func (c *Client) GetAccountAtBlockHeight(ctx context.Context, address flow.Address, blockHeight uint64) (*flow.Account, error)
- func (c *Client) GetAccountAtLatestBlock(ctx context.Context, address flow.Address) (*flow.Account, error)
- func (c *Client) GetBlockByHeight(ctx context.Context, height uint64) (*flow.Block, error)
- func (c *Client) GetBlockByID(ctx context.Context, blockID flow.Identifier) (*flow.Block, error)
- func (c *Client) GetBlockHeaderByHeight(ctx context.Context, height uint64) (*flow.BlockHeader, error)
- func (c *Client) GetBlockHeaderByID(ctx context.Context, blockID flow.Identifier) (*flow.BlockHeader, error)
- func (c *Client) GetCollection(ctx context.Context, colID flow.Identifier) (*flow.Collection, error)
- func (c *Client) GetEventsForBlockIDs(ctx context.Context, eventType string, blockIDs []flow.Identifier) ([]flow.BlockEvents, error)
- func (c *Client) GetEventsForHeightRange(ctx context.Context, eventType string, startHeight uint64, endHeight uint64) ([]flow.BlockEvents, error)
- func (c *Client) GetExecutionDataByBlockID(ctx context.Context, blockID flow.Identifier) (*flow.ExecutionData, error)
- func (c *Client) GetExecutionResultForBlockID(ctx context.Context, blockID flow.Identifier) (*flow.ExecutionResult, error)
- func (c *Client) GetLatestBlock(ctx context.Context, isSealed bool) (*flow.Block, error)
- func (c *Client) GetLatestBlockHeader(ctx context.Context, isSealed bool) (*flow.BlockHeader, error)
- func (c *Client) GetLatestProtocolStateSnapshot(ctx context.Context) ([]byte, error)
- func (c *Client) GetNetworkParameters(ctx context.Context) (*flow.NetworkParameters, error)
- func (c *Client) GetNodeVersionInfo(ctx context.Context) (*flow.NodeVersionInfo, error)
- func (c *Client) GetTransaction(ctx context.Context, txID flow.Identifier) (*flow.Transaction, error)
- func (c *Client) GetTransactionResult(ctx context.Context, txID flow.Identifier) (*flow.TransactionResult, error)
- func (c *Client) GetTransactionResultByIndex(ctx context.Context, blockID flow.Identifier, index uint32) (*flow.TransactionResult, error)
- func (c *Client) GetTransactionResultsByBlockID(ctx context.Context, blockID flow.Identifier) ([]*flow.TransactionResult, error)
- func (c *Client) GetTransactionsByBlockID(ctx context.Context, blockID flow.Identifier) ([]*flow.Transaction, error)
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) RPCClient() RPCClient
- func (c *Client) SendTransaction(ctx context.Context, tx flow.Transaction) error
- func (c *Client) SubscribeEventsByBlockHeight(ctx context.Context, startHeight uint64, filter flow.EventFilter, ...) (<-chan flow.BlockEvents, <-chan error, error)
- func (c *Client) SubscribeEventsByBlockID(ctx context.Context, startBlockID flow.Identifier, filter flow.EventFilter, ...) (<-chan flow.BlockEvents, <-chan error, error)
- func (c *Client) SubscribeExecutionDataByBlockHeight(ctx context.Context, startHeight uint64) (<-chan flow.ExecutionDataStreamResponse, <-chan error, error)
- func (c *Client) SubscribeExecutionDataByBlockID(ctx context.Context, startBlockID flow.Identifier) (<-chan flow.ExecutionDataStreamResponse, <-chan error, error)
- func (c *Client) WaitServer(ctx context.Context) error
- type ClientOption
- type EntityToMessageError
- type EventRangeQuery
- type ExecutionDataRPCClient
- type MessageToEntityError
- type RPCClient
- type RPCError
- type SubscribeConfig
- type SubscribeOption
Constants ¶
const CanarynetHost = "access.canary.nodes.onflow.org:9000"
const EmulatorHost = "127.0.0.1:3569"
const MainnetHost = "access.mainnet.nodes.onflow.org:9000"
const TestnetHost = "access.devnet.nodes.onflow.org:9000"
Variables ¶
This section is empty.
Functions ¶
func DefaultClientOptions ¶ added in v1.0.0
func DefaultClientOptions() *options
Types ¶
type BaseClient ¶
type BaseClient struct {
// contains filtered or unexported fields
}
BaseClient is a gRPC client for the Flow Access API exposing all grpc specific methods.
Use this client if you need advance access to the HTTP API. If you don't require special methods use the Client instead.
func NewBaseClient ¶
func NewBaseClient(url string, opts ...grpc.DialOption) (*BaseClient, error)
NewBaseClient creates a new gRPC handler for network communication.
func NewFromExecutionDataRPCClient ¶ added in v0.41.19
func NewFromExecutionDataRPCClient(rpcClient ExecutionDataRPCClient) *BaseClient
NewFromExecutionDataRPCClient initializes a Flow client using a pre-configured gRPC provider.
func NewFromRPCClient ¶
func NewFromRPCClient(rpcClient RPCClient) *BaseClient
NewFromRPCClient initializes a Flow client using a pre-configured gRPC provider.
func (*BaseClient) ExecuteScriptAtBlockHeight ¶
func (*BaseClient) ExecuteScriptAtBlockID ¶
func (*BaseClient) ExecuteScriptAtLatestBlock ¶
func (*BaseClient) ExecutionDataRPCClient ¶ added in v1.0.0
func (c *BaseClient) ExecutionDataRPCClient() ExecutionDataRPCClient
func (*BaseClient) GetAccount ¶
func (c *BaseClient) GetAccount(ctx context.Context, address flow.Address, opts ...grpc.CallOption) (*flow.Account, error)
func (*BaseClient) GetAccountAtBlockHeight ¶
func (c *BaseClient) GetAccountAtBlockHeight( ctx context.Context, address flow.Address, blockHeight uint64, opts ...grpc.CallOption, ) (*flow.Account, error)
func (*BaseClient) GetAccountAtLatestBlock ¶
func (c *BaseClient) GetAccountAtLatestBlock( ctx context.Context, address flow.Address, opts ...grpc.CallOption, ) (*flow.Account, error)
func (*BaseClient) GetBlockByHeight ¶
func (c *BaseClient) GetBlockByHeight( ctx context.Context, height uint64, opts ...grpc.CallOption, ) (*flow.Block, error)
func (*BaseClient) GetBlockByID ¶
func (c *BaseClient) GetBlockByID( ctx context.Context, blockID flow.Identifier, opts ...grpc.CallOption, ) (*flow.Block, error)
func (*BaseClient) GetBlockHeaderByHeight ¶
func (c *BaseClient) GetBlockHeaderByHeight( ctx context.Context, height uint64, opts ...grpc.CallOption, ) (*flow.BlockHeader, error)
func (*BaseClient) GetBlockHeaderByID ¶
func (c *BaseClient) GetBlockHeaderByID( ctx context.Context, blockID flow.Identifier, opts ...grpc.CallOption, ) (*flow.BlockHeader, error)
func (*BaseClient) GetCollection ¶
func (c *BaseClient) GetCollection( ctx context.Context, colID flow.Identifier, opts ...grpc.CallOption, ) (*flow.Collection, error)
func (*BaseClient) GetEventsForBlockIDs ¶
func (c *BaseClient) GetEventsForBlockIDs( ctx context.Context, eventType string, blockIDs []flow.Identifier, opts ...grpc.CallOption, ) ([]flow.BlockEvents, error)
func (*BaseClient) GetEventsForHeightRange ¶
func (c *BaseClient) GetEventsForHeightRange( ctx context.Context, query EventRangeQuery, opts ...grpc.CallOption, ) ([]flow.BlockEvents, error)
func (*BaseClient) GetExecutionDataByBlockID ¶ added in v0.41.19
func (c *BaseClient) GetExecutionDataByBlockID( ctx context.Context, blockID flow.Identifier, opts ...grpc.CallOption, ) (*flow.ExecutionData, error)
func (*BaseClient) GetExecutionResultForBlockID ¶
func (c *BaseClient) GetExecutionResultForBlockID(ctx context.Context, blockID flow.Identifier, opts ...grpc.CallOption) (*flow.ExecutionResult, error)
func (*BaseClient) GetLatestBlock ¶
func (c *BaseClient) GetLatestBlock( ctx context.Context, isSealed bool, opts ...grpc.CallOption, ) (*flow.Block, error)
func (*BaseClient) GetLatestBlockHeader ¶
func (c *BaseClient) GetLatestBlockHeader( ctx context.Context, isSealed bool, opts ...grpc.CallOption, ) (*flow.BlockHeader, error)
func (*BaseClient) GetLatestProtocolStateSnapshot ¶
func (c *BaseClient) GetLatestProtocolStateSnapshot(ctx context.Context, opts ...grpc.CallOption) ([]byte, error)
func (*BaseClient) GetNetworkParameters ¶ added in v0.41.15
func (c *BaseClient) GetNetworkParameters(ctx context.Context, opts ...grpc.CallOption) (*flow.NetworkParameters, error)
func (*BaseClient) GetNodeVersionInfo ¶ added in v1.0.0
func (c *BaseClient) GetNodeVersionInfo(ctx context.Context, opts ...grpc.CallOption) (*flow.NodeVersionInfo, error)
func (*BaseClient) GetTransaction ¶
func (c *BaseClient) GetTransaction( ctx context.Context, txID flow.Identifier, opts ...grpc.CallOption, ) (*flow.Transaction, error)
func (*BaseClient) GetTransactionResult ¶
func (c *BaseClient) GetTransactionResult( ctx context.Context, txID flow.Identifier, opts ...grpc.CallOption, ) (*flow.TransactionResult, error)
func (*BaseClient) GetTransactionResultByIndex ¶ added in v0.41.15
func (c *BaseClient) GetTransactionResultByIndex( ctx context.Context, blockID flow.Identifier, index uint32, opts ...grpc.CallOption, ) (*flow.TransactionResult, error)
func (*BaseClient) GetTransactionResultsByBlockID ¶ added in v0.31.0
func (c *BaseClient) GetTransactionResultsByBlockID( ctx context.Context, blockID flow.Identifier, opts ...grpc.CallOption, ) ([]*flow.TransactionResult, error)
func (*BaseClient) GetTransactionsByBlockID ¶ added in v0.31.0
func (c *BaseClient) GetTransactionsByBlockID( ctx context.Context, blockID flow.Identifier, opts ...grpc.CallOption, ) ([]*flow.Transaction, error)
func (*BaseClient) Ping ¶
func (c *BaseClient) Ping(ctx context.Context, opts ...grpc.CallOption) error
func (*BaseClient) RPCClient ¶ added in v1.0.0
func (c *BaseClient) RPCClient() RPCClient
func (*BaseClient) SendTransaction ¶
func (c *BaseClient) SendTransaction( ctx context.Context, tx flow.Transaction, opts ...grpc.CallOption, ) error
func (*BaseClient) SetEventEncoding ¶ added in v1.0.0
func (c *BaseClient) SetEventEncoding(version flow.EventEncodingVersion)
func (*BaseClient) SetJSONOptions ¶ added in v0.26.3
func (c *BaseClient) SetJSONOptions(options []json.Option)
func (*BaseClient) SubscribeEventsByBlockHeight ¶ added in v0.41.19
func (c *BaseClient) SubscribeEventsByBlockHeight( ctx context.Context, startHeight uint64, filter flow.EventFilter, opts ...SubscribeOption, ) (<-chan flow.BlockEvents, <-chan error, error)
func (*BaseClient) SubscribeEventsByBlockID ¶ added in v0.41.19
func (c *BaseClient) SubscribeEventsByBlockID( ctx context.Context, startBlockID flow.Identifier, filter flow.EventFilter, opts ...SubscribeOption, ) (<-chan flow.BlockEvents, <-chan error, error)
func (*BaseClient) SubscribeExecutionDataByBlockHeight ¶ added in v0.41.19
func (c *BaseClient) SubscribeExecutionDataByBlockHeight( ctx context.Context, startHeight uint64, opts ...grpc.CallOption, ) (<-chan flow.ExecutionDataStreamResponse, <-chan error, error)
func (*BaseClient) SubscribeExecutionDataByBlockID ¶ added in v0.41.19
func (c *BaseClient) SubscribeExecutionDataByBlockID( ctx context.Context, startBlockID flow.Identifier, opts ...grpc.CallOption, ) (<-chan flow.ExecutionDataStreamResponse, <-chan error, error)
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements all common gRPC methods providing a network agnostic API.
func NewClient ¶
func NewClient(host string, opts ...ClientOption) (*Client, error)
NewClient creates an gRPC client exposing all the common access APIs. Client will use provided host for connection.
func (*Client) ExecuteScriptAtBlockHeight ¶
func (*Client) ExecuteScriptAtBlockID ¶
func (*Client) ExecuteScriptAtLatestBlock ¶
func (*Client) ExecutionDataRPCClient ¶ added in v1.0.0
func (c *Client) ExecutionDataRPCClient() ExecutionDataRPCClient
func (*Client) GetAccount ¶
func (*Client) GetAccountAtBlockHeight ¶
func (*Client) GetAccountAtLatestBlock ¶
func (*Client) GetBlockByHeight ¶
func (*Client) GetBlockByID ¶
func (*Client) GetBlockHeaderByHeight ¶
func (*Client) GetBlockHeaderByID ¶
func (*Client) GetCollection ¶
func (*Client) GetEventsForBlockIDs ¶
func (*Client) GetEventsForHeightRange ¶
func (*Client) GetExecutionDataByBlockID ¶ added in v0.41.19
func (*Client) GetExecutionResultForBlockID ¶
func (*Client) GetLatestBlock ¶
func (*Client) GetLatestBlockHeader ¶
func (*Client) GetLatestProtocolStateSnapshot ¶
func (*Client) GetNetworkParameters ¶ added in v0.41.15
func (*Client) GetNodeVersionInfo ¶ added in v1.0.0
func (*Client) GetTransaction ¶
func (*Client) GetTransactionResult ¶
func (*Client) GetTransactionResultByIndex ¶ added in v0.41.15
func (*Client) GetTransactionResultsByBlockID ¶ added in v0.31.0
func (*Client) GetTransactionsByBlockID ¶ added in v0.31.0
func (*Client) SendTransaction ¶
func (*Client) SubscribeEventsByBlockHeight ¶ added in v0.41.19
func (*Client) SubscribeEventsByBlockID ¶ added in v0.41.19
func (*Client) SubscribeExecutionDataByBlockHeight ¶ added in v0.41.19
func (*Client) SubscribeExecutionDataByBlockID ¶ added in v0.41.19
type ClientOption ¶ added in v1.0.0
type ClientOption func(*options)
ClientOption is a configuration option for the client.
func WithEventEncoding ¶ added in v1.0.0
func WithEventEncoding(version flow.EventEncodingVersion) ClientOption
WithEventEncoding sets the default event encoding to use when requesting events from the API
func WithGRPCDialOptions ¶ added in v1.0.0
func WithGRPCDialOptions(dialOpts ...grpc.DialOption) ClientOption
WithGRPCDialOptions wraps a grpc.DialOption into a ClientOption.
func WithJSONOptions ¶ added in v1.0.0
func WithJSONOptions(jsonOpts ...jsoncdc.Option) ClientOption
WithJSONOptions wraps a json.Option into a ClientOption.
type EntityToMessageError ¶
An EntityToMessageError indicates that an entity could not be converted to a protobuf message.
func (EntityToMessageError) Error ¶
func (e EntityToMessageError) Error() string
func (EntityToMessageError) Unwrap ¶
func (e EntityToMessageError) Unwrap() error
type EventRangeQuery ¶
type EventRangeQuery struct { // The event type to search for. Type string // The block height to begin looking for events (inclusive). StartHeight uint64 // The block height to end looking for events (inclusive). EndHeight uint64 }
EventRangeQuery defines a query for Flow events.
type ExecutionDataRPCClient ¶ added in v0.41.19
type ExecutionDataRPCClient interface { executiondata.ExecutionDataAPIClient }
ExecutionDataRPCClient is an RPC client for the Flow ExecutionData API.
type MessageToEntityError ¶
A MessageToEntityError indicates that a protobuf message could not be converted to an SDK entity.
func (MessageToEntityError) Error ¶
func (e MessageToEntityError) Error() string
func (MessageToEntityError) Unwrap ¶
func (e MessageToEntityError) Unwrap() error
type RPCClient ¶
type RPCClient interface { access.AccessAPIClient }
RPCClient is an RPC client for the Flow Access API.
type RPCError ¶
type RPCError struct {
GRPCErr error
}
An RPCError is an error returned by an RPC call to an Access API.
An RPC error can be unwrapped to produce the original gRPC error.
func (RPCError) GRPCStatus ¶
GRPCStatus returns the gRPC status for this error.
This function satisfies the interface defined in the status.FromError function.
type SubscribeConfig ¶ added in v0.41.19
type SubscribeConfig struct {
// contains filtered or unexported fields
}
func DefaultSubscribeConfig ¶ added in v0.41.19
func DefaultSubscribeConfig() *SubscribeConfig
type SubscribeOption ¶ added in v0.41.19
type SubscribeOption func(*SubscribeConfig)
func WithGRPCOptions ¶ added in v0.41.19
func WithGRPCOptions(grpcOpts ...grpc.CallOption) SubscribeOption
func WithHeartbeatInterval ¶ added in v0.41.19
func WithHeartbeatInterval(interval uint64) SubscribeOption