grpc

package
v0.41.16 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: Apache-2.0 Imports: 14 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 TestnetHost = "access.devnet.nodes.onflow.org:9000"

Variables

This section is empty.

Functions

This section is empty.

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

func (c *BaseClient) SendTransaction(
	ctx context.Context,
	tx flow.Transaction,
	opts ...grpc.CallOption,
) error

func (*BaseClient) SetJSONOptions added in v0.26.3

func (c *BaseClient) SetJSONOptions(options []json.Option)

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 ...grpc.DialOption) (*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) 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) 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) 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) SendTransaction

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

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

Jump to

Keyboard shortcuts

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