Documentation ¶
Overview ¶
Package 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://github.com/onflow/flow/blob/master/docs/access-api-spec.md
Index ¶
- type BlockEvents
- 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) GetAccount(ctx context.Context, address flow.Address, opts ...grpc.CallOption) (*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, opts ...grpc.CallOption) (*flow.Account, error)
- func (c *Client) GetBlockByHeight(ctx context.Context, height uint64, opts ...grpc.CallOption) (*flow.Block, error)
- func (c *Client) GetBlockByID(ctx context.Context, blockID flow.Identifier, opts ...grpc.CallOption) (*flow.Block, error)
- func (c *Client) GetBlockHeaderByHeight(ctx context.Context, height uint64, opts ...grpc.CallOption) (*flow.BlockHeader, error)
- func (c *Client) GetBlockHeaderByID(ctx context.Context, blockID flow.Identifier, opts ...grpc.CallOption) (*flow.BlockHeader, error)
- func (c *Client) GetCollection(ctx context.Context, colID flow.Identifier, opts ...grpc.CallOption) (*flow.Collection, error)
- func (c *Client) GetEventsForBlockIDs(ctx context.Context, eventType string, blockIDs []flow.Identifier, ...) ([]BlockEvents, error)
- func (c *Client) GetEventsForHeightRange(ctx context.Context, query EventRangeQuery, opts ...grpc.CallOption) ([]BlockEvents, error)
- func (c *Client) GetLatestBlock(ctx context.Context, isSealed bool, opts ...grpc.CallOption) (*flow.Block, error)
- func (c *Client) GetLatestBlockHeader(ctx context.Context, isSealed bool, opts ...grpc.CallOption) (*flow.BlockHeader, error)
- func (c *Client) GetLatestProtocolStateSnapshot(ctx context.Context, opts ...grpc.CallOption) ([]byte, error)
- func (c *Client) GetTransaction(ctx context.Context, txID flow.Identifier, opts ...grpc.CallOption) (*flow.Transaction, error)
- func (c *Client) GetTransactionResult(ctx context.Context, txID flow.Identifier, opts ...grpc.CallOption) (*flow.TransactionResult, error)
- func (c *Client) Ping(ctx context.Context, opts ...grpc.CallOption) error
- func (c *Client) SendTransaction(ctx context.Context, tx flow.Transaction, opts ...grpc.CallOption) error
- type EntityToMessageError
- type EventRangeQuery
- type MessageToEntityError
- type RPCClient
- type RPCError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockEvents ¶
type BlockEvents struct { BlockID flow.Identifier Height uint64 BlockTimestamp time.Time Events []flow.Event }
BlockEvents are the events that occurred in a specific block.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client is a gRPC Client for the Flow Access API.
func New ¶
func New(addr string, opts ...grpc.DialOption) (*Client, error)
New initializes a Flow client with the default gRPC provider.
An error will be returned if the host is unreachable.
func NewFromRPCClient ¶
NewFromRPCClient initializes a Flow client using a pre-configured gRPC provider.
func (*Client) ExecuteScriptAtBlockHeight ¶
func (c *Client) ExecuteScriptAtBlockHeight( ctx context.Context, height uint64, script []byte, arguments []cadence.Value, opts ...grpc.CallOption, ) (cadence.Value, error)
ExecuteScriptAtBlockHeight executes a ready-only Cadence script against the execution state at the given block height.
func (*Client) ExecuteScriptAtBlockID ¶
func (c *Client) ExecuteScriptAtBlockID( ctx context.Context, blockID flow.Identifier, script []byte, arguments []cadence.Value, opts ...grpc.CallOption, ) (cadence.Value, error)
ExecuteScriptAtBlockID executes a ready-only Cadence script against the execution state at the block with the given ID.
func (*Client) ExecuteScriptAtLatestBlock ¶
func (c *Client) ExecuteScriptAtLatestBlock( ctx context.Context, script []byte, arguments []cadence.Value, opts ...grpc.CallOption, ) (cadence.Value, error)
ExecuteScriptAtLatestBlock executes a read-only Cadence script against the latest sealed execution state.
func (*Client) GetAccount ¶
func (c *Client) GetAccount(ctx context.Context, address flow.Address, opts ...grpc.CallOption) (*flow.Account, error)
GetAccount is an alias for GetAccountAtLatestBlock.
func (*Client) GetAccountAtBlockHeight ¶ added in v0.14.1
func (c *Client) GetAccountAtBlockHeight( ctx context.Context, address flow.Address, blockHeight uint64, opts ...grpc.CallOption, ) (*flow.Account, error)
GetAccountAtBlockHeight gets an account by address at the given block height
func (*Client) GetAccountAtLatestBlock ¶ added in v0.8.0
func (c *Client) GetAccountAtLatestBlock( ctx context.Context, address flow.Address, opts ...grpc.CallOption, ) (*flow.Account, error)
GetAccountAtLatestBlock gets an account by address at the latest sealed block.
func (*Client) GetBlockByHeight ¶
func (c *Client) GetBlockByHeight( ctx context.Context, height uint64, opts ...grpc.CallOption, ) (*flow.Block, error)
GetBlockByHeight gets a full block by height.
func (*Client) GetBlockByID ¶
func (c *Client) GetBlockByID( ctx context.Context, blockID flow.Identifier, opts ...grpc.CallOption, ) (*flow.Block, error)
GetBlockByID gets a full block by ID.
func (*Client) GetBlockHeaderByHeight ¶
func (c *Client) GetBlockHeaderByHeight( ctx context.Context, height uint64, opts ...grpc.CallOption, ) (*flow.BlockHeader, error)
GetBlockHeaderByHeight gets a block header by height.
func (*Client) GetBlockHeaderByID ¶
func (c *Client) GetBlockHeaderByID( ctx context.Context, blockID flow.Identifier, opts ...grpc.CallOption, ) (*flow.BlockHeader, error)
GetBlockHeaderByID gets a block header by ID.
func (*Client) GetCollection ¶
func (c *Client) GetCollection( ctx context.Context, colID flow.Identifier, opts ...grpc.CallOption, ) (*flow.Collection, error)
GetCollection gets a collection by ID.
func (*Client) GetEventsForBlockIDs ¶
func (c *Client) GetEventsForBlockIDs( ctx context.Context, eventType string, blockIDs []flow.Identifier, opts ...grpc.CallOption, ) ([]BlockEvents, error)
GetEventsForBlockIDs retrieves events with the given type from the specified block IDs.
func (*Client) GetEventsForHeightRange ¶
func (c *Client) GetEventsForHeightRange( ctx context.Context, query EventRangeQuery, opts ...grpc.CallOption, ) ([]BlockEvents, error)
GetEventsForHeightRange retrieves events for all sealed blocks between the start and end block heights (inclusive) with the given type.
func (*Client) GetLatestBlock ¶
func (c *Client) GetLatestBlock( ctx context.Context, isSealed bool, opts ...grpc.CallOption, ) (*flow.Block, error)
GetLatestBlock gets the full payload of the latest sealed or unsealed block.
func (*Client) GetLatestBlockHeader ¶
func (c *Client) GetLatestBlockHeader( ctx context.Context, isSealed bool, opts ...grpc.CallOption, ) (*flow.BlockHeader, error)
GetLatestBlockHeader gets the latest sealed or unsealed block header.
func (*Client) GetLatestProtocolStateSnapshot ¶ added in v0.14.4
func (c *Client) GetLatestProtocolStateSnapshot(ctx context.Context, opts ...grpc.CallOption) ([]byte, error)
GetLatestProtocolStateSnapshot retrieves the latest snapshot of the protocol state in serialized form. This is used to generate a root snapshot file used by Flow nodes to bootstrap their local protocol state database.
func (*Client) GetTransaction ¶
func (c *Client) GetTransaction( ctx context.Context, txID flow.Identifier, opts ...grpc.CallOption, ) (*flow.Transaction, error)
GetTransaction gets a transaction by ID.
func (*Client) GetTransactionResult ¶
func (c *Client) GetTransactionResult( ctx context.Context, txID flow.Identifier, opts ...grpc.CallOption, ) (*flow.TransactionResult, error)
GetTransactionResult gets the result of a transaction.
func (*Client) SendTransaction ¶
func (c *Client) SendTransaction( ctx context.Context, tx flow.Transaction, opts ...grpc.CallOption, ) error
SendTransaction submits a transaction to the network.
type EntityToMessageError ¶ added in v0.6.0
An EntityToMessageError indicates that an entity could not be converted to a protobuf message.
func (EntityToMessageError) Error ¶ added in v0.6.0
func (e EntityToMessageError) Error() string
func (EntityToMessageError) Unwrap ¶ added in v0.6.0
func (e EntityToMessageError) Unwrap() error
type EventRangeQuery ¶
type EventRangeQuery struct { // The event type to search for. If empty, no filtering by type is done. Type string // The block height to begin looking for events StartHeight uint64 // The block height to end looking for events (inclusive) EndHeight uint64 }
EventRangeQuery defines a query for Flow events.
type MessageToEntityError ¶ added in v0.6.0
A MessageToEntityError indicates that a protobuf message could not be converted to an SDK entity.
func (MessageToEntityError) Error ¶ added in v0.6.0
func (e MessageToEntityError) Error() string
func (MessageToEntityError) Unwrap ¶ added in v0.6.0
func (e MessageToEntityError) Unwrap() error
type RPCClient ¶
type RPCClient interface { access.AccessAPIClient }
An RPCClient is an RPC client for the Flow Access API.
type RPCError ¶ added in v0.6.0
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 ¶ added in v0.6.0
GRPCStatus returns the gRPC status for this error.
This function satisfies the interface defined in the status.FromError function.