grpc

package
v1.0.0-preview.50 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: Apache-2.0 Imports: 13 Imported by: 78

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

View Source
const CanarynetHost = "access.canary.nodes.onflow.org:9000"
View Source
const EmulatorHost = "127.0.0.1:3569"
View Source
const MainnetHost = "access.mainnet.nodes.onflow.org:9000"
View Source
const PreviewnetHost = "access.previewnet.nodes.onflow.org:9000"
View Source
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) Close

func (c *BaseClient) Close() error

Close closes the client connection.

func (*BaseClient) ExecuteScriptAtBlockHeight

func (c *BaseClient) ExecuteScriptAtBlockHeight(
	ctx context.Context,
	height uint64,
	script []byte,
	arguments []cadence.Value,
	opts ...grpc.CallOption,
) (cadence.Value, error)

func (*BaseClient) ExecuteScriptAtBlockID

func (c *BaseClient) ExecuteScriptAtBlockID(
	ctx context.Context,
	blockID flow.Identifier,
	script []byte,
	arguments []cadence.Value,
	opts ...grpc.CallOption,
) (cadence.Value, error)

func (*BaseClient) ExecuteScriptAtLatestBlock

func (c *BaseClient) ExecuteScriptAtLatestBlock(
	ctx context.Context,
	script []byte,
	arguments []cadence.Value,
	opts ...grpc.CallOption,
) (cadence.Value, error)

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) Close

func (c *Client) Close() error

func (*Client) ExecuteScriptAtBlockHeight

func (c *Client) ExecuteScriptAtBlockHeight(ctx context.Context, height uint64, script []byte, arguments []cadence.Value) (cadence.Value, error)

func (*Client) ExecuteScriptAtBlockID

func (c *Client) ExecuteScriptAtBlockID(ctx context.Context, blockID flow.Identifier, script []byte, arguments []cadence.Value) (cadence.Value, error)

func (*Client) ExecuteScriptAtLatestBlock

func (c *Client) ExecuteScriptAtLatestBlock(ctx context.Context, script []byte, arguments []cadence.Value) (cadence.Value, error)

func (*Client) GetAccount

func (c *Client) GetAccount(ctx context.Context, address flow.Address) (*flow.Account, error)

func (*Client) GetAccountAtBlockHeight

func (c *Client) GetAccountAtBlockHeight(ctx context.Context, address flow.Address, blockHeight uint64) (*flow.Account, error)

func (*Client) GetAccountAtLatestBlock

func (c *Client) GetAccountAtLatestBlock(ctx context.Context, address flow.Address) (*flow.Account, error)

func (*Client) GetBlockByHeight

func (c *Client) GetBlockByHeight(ctx context.Context, height uint64) (*flow.Block, error)

func (*Client) GetBlockByID

func (c *Client) GetBlockByID(ctx context.Context, blockID flow.Identifier) (*flow.Block, error)

func (*Client) GetBlockHeaderByHeight

func (c *Client) GetBlockHeaderByHeight(ctx context.Context, height uint64) (*flow.BlockHeader, error)

func (*Client) GetBlockHeaderByID

func (c *Client) GetBlockHeaderByID(ctx context.Context, blockID flow.Identifier) (*flow.BlockHeader, error)

func (*Client) GetCollection

func (c *Client) GetCollection(ctx context.Context, colID flow.Identifier) (*flow.Collection, error)

func (*Client) GetEventsForBlockIDs

func (c *Client) GetEventsForBlockIDs(ctx context.Context, eventType string, blockIDs []flow.Identifier) ([]flow.BlockEvents, error)

func (*Client) GetEventsForHeightRange

func (c *Client) GetEventsForHeightRange(ctx context.Context, eventType string, startHeight uint64, endHeight uint64) ([]flow.BlockEvents, error)

func (*Client) GetExecutionDataByBlockID added in v0.41.19

func (c *Client) GetExecutionDataByBlockID(ctx context.Context, blockID flow.Identifier) (*flow.ExecutionData, error)

func (*Client) GetExecutionResultForBlockID

func (c *Client) GetExecutionResultForBlockID(ctx context.Context, blockID flow.Identifier) (*flow.ExecutionResult, error)

func (*Client) GetLatestBlock

func (c *Client) GetLatestBlock(ctx context.Context, isSealed bool) (*flow.Block, error)

func (*Client) GetLatestBlockHeader

func (c *Client) GetLatestBlockHeader(ctx context.Context, isSealed bool) (*flow.BlockHeader, error)

func (*Client) GetLatestProtocolStateSnapshot

func (c *Client) GetLatestProtocolStateSnapshot(ctx context.Context) ([]byte, error)

func (*Client) GetNetworkParameters added in v0.41.15

func (c *Client) GetNetworkParameters(ctx context.Context) (*flow.NetworkParameters, error)

func (*Client) GetNodeVersionInfo added in v1.0.0

func (c *Client) GetNodeVersionInfo(ctx context.Context) (*flow.NodeVersionInfo, error)

func (*Client) GetTransaction

func (c *Client) GetTransaction(ctx context.Context, txID flow.Identifier) (*flow.Transaction, error)

func (*Client) GetTransactionResult

func (c *Client) GetTransactionResult(ctx context.Context, txID flow.Identifier) (*flow.TransactionResult, error)

func (*Client) GetTransactionResultByIndex added in v0.41.15

func (c *Client) GetTransactionResultByIndex(ctx context.Context, blockID flow.Identifier, index uint32) (*flow.TransactionResult, error)

func (*Client) GetTransactionResultsByBlockID added in v0.31.0

func (c *Client) GetTransactionResultsByBlockID(ctx context.Context, blockID flow.Identifier) ([]*flow.TransactionResult, error)

func (*Client) GetTransactionsByBlockID added in v0.31.0

func (c *Client) GetTransactionsByBlockID(ctx context.Context, blockID flow.Identifier) ([]*flow.Transaction, error)

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) error

func (*Client) RPCClient added in v1.0.0

func (c *Client) RPCClient() RPCClient

RPCClient returns the underlying gRPC client.

func (*Client) SendTransaction

func (c *Client) SendTransaction(ctx context.Context, tx flow.Transaction) error

func (*Client) SubscribeEventsByBlockHeight added in v0.41.19

func (c *Client) SubscribeEventsByBlockHeight(
	ctx context.Context,
	startHeight uint64,
	filter flow.EventFilter,
	opts ...access.SubscribeOption,
) (<-chan flow.BlockEvents, <-chan error, error)

func (*Client) SubscribeEventsByBlockID added in v0.41.19

func (c *Client) SubscribeEventsByBlockID(
	ctx context.Context,
	startBlockID flow.Identifier,
	filter flow.EventFilter,
	opts ...access.SubscribeOption,
) (<-chan flow.BlockEvents, <-chan error, error)

func (*Client) SubscribeExecutionDataByBlockHeight added in v0.41.19

func (c *Client) SubscribeExecutionDataByBlockHeight(
	ctx context.Context,
	startHeight uint64,
) (<-chan flow.ExecutionDataStreamResponse, <-chan error, error)

func (*Client) SubscribeExecutionDataByBlockID added in v0.41.19

func (c *Client) SubscribeExecutionDataByBlockID(
	ctx context.Context,
	startBlockID flow.Identifier,
) (<-chan flow.ExecutionDataStreamResponse, <-chan error, error)

func (*Client) WaitServer added in v0.46.0

func (c *Client) WaitServer(ctx context.Context) error

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

type EntityToMessageError struct {
	Entity string
	Err    error
}

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

type MessageToEntityError struct {
	Entity string
	Err    error
}

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) Error

func (e RPCError) Error() string

func (RPCError) GRPCStatus

func (e RPCError) GRPCStatus() *status.Status

GRPCStatus returns the gRPC status for this error.

This function satisfies the interface defined in the status.FromError function.

func (RPCError) Unwrap

func (e RPCError) Unwrap() error

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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