access

package
v0.33.35 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: AGPL-3.0 Imports: 16 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownReferenceBlock = errors.New("unknown reference block")

ErrUnknownReferenceBlock indicates that a transaction references an unknown block.

Functions

func TransactionResultToMessage

func TransactionResultToMessage(result *TransactionResult) *access.TransactionResultResponse

func TransactionResultsToMessage added in v0.24.11

func TransactionResultsToMessage(results []*TransactionResult) *access.TransactionResultsResponse

func WithBlockSignerDecoder added in v0.26.17

func WithBlockSignerDecoder(signerIndicesDecoder hotstuff.BlockSignerDecoder) func(*Handler)

WithBlockSignerDecoder configures the Handler to decode signer indices via the provided hotstuff.BlockSignerDecoder

Types

type API

type API interface {
	Ping(ctx context.Context) error
	GetNetworkParameters(ctx context.Context) NetworkParameters
	GetNodeVersionInfo(ctx context.Context) (*NodeVersionInfo, error)

	GetLatestBlockHeader(ctx context.Context, isSealed bool) (*flow.Header, flow.BlockStatus, error)
	GetBlockHeaderByHeight(ctx context.Context, height uint64) (*flow.Header, flow.BlockStatus, error)
	GetBlockHeaderByID(ctx context.Context, id flow.Identifier) (*flow.Header, flow.BlockStatus, error)

	GetLatestBlock(ctx context.Context, isSealed bool) (*flow.Block, flow.BlockStatus, error)
	GetBlockByHeight(ctx context.Context, height uint64) (*flow.Block, flow.BlockStatus, error)
	GetBlockByID(ctx context.Context, id flow.Identifier) (*flow.Block, flow.BlockStatus, error)

	GetCollectionByID(ctx context.Context, id flow.Identifier) (*flow.LightCollection, error)
	GetFullCollectionByID(ctx context.Context, id flow.Identifier) (*flow.Collection, error)

	SendTransaction(ctx context.Context, tx *flow.TransactionBody) error
	GetTransaction(ctx context.Context, id flow.Identifier) (*flow.TransactionBody, error)
	GetTransactionsByBlockID(ctx context.Context, blockID flow.Identifier) ([]*flow.TransactionBody, error)
	GetTransactionResult(ctx context.Context, id flow.Identifier, blockID flow.Identifier, collectionID flow.Identifier, requiredEventEncodingVersion entities.EventEncodingVersion) (*TransactionResult, error)
	GetTransactionResultByIndex(ctx context.Context, blockID flow.Identifier, index uint32, requiredEventEncodingVersion entities.EventEncodingVersion) (*TransactionResult, error)
	GetTransactionResultsByBlockID(ctx context.Context, blockID flow.Identifier, requiredEventEncodingVersion entities.EventEncodingVersion) ([]*TransactionResult, error)
	GetSystemTransaction(ctx context.Context, blockID flow.Identifier) (*flow.TransactionBody, error)
	GetSystemTransactionResult(ctx context.Context, blockID flow.Identifier, requiredEventEncodingVersion entities.EventEncodingVersion) (*TransactionResult, error)

	GetAccount(ctx context.Context, address flow.Address) (*flow.Account, error)
	GetAccountAtLatestBlock(ctx context.Context, address flow.Address) (*flow.Account, error)
	GetAccountAtBlockHeight(ctx context.Context, address flow.Address, height uint64) (*flow.Account, error)

	ExecuteScriptAtLatestBlock(ctx context.Context, script []byte, arguments [][]byte) ([]byte, error)
	ExecuteScriptAtBlockHeight(ctx context.Context, blockHeight uint64, script []byte, arguments [][]byte) ([]byte, error)
	ExecuteScriptAtBlockID(ctx context.Context, blockID flow.Identifier, script []byte, arguments [][]byte) ([]byte, error)

	GetEventsForHeightRange(ctx context.Context, eventType string, startHeight, endHeight uint64, requiredEventEncodingVersion entities.EventEncodingVersion) ([]flow.BlockEvents, error)
	GetEventsForBlockIDs(ctx context.Context, eventType string, blockIDs []flow.Identifier, requiredEventEncodingVersion entities.EventEncodingVersion) ([]flow.BlockEvents, error)

	GetLatestProtocolStateSnapshot(ctx context.Context) ([]byte, error)
	GetProtocolStateSnapshotByBlockID(ctx context.Context, blockID flow.Identifier) ([]byte, error)
	GetProtocolStateSnapshotByHeight(ctx context.Context, blockHeight uint64) ([]byte, error)

	GetExecutionResultForBlockID(ctx context.Context, blockID flow.Identifier) (*flow.ExecutionResult, error)
	GetExecutionResultByID(ctx context.Context, id flow.Identifier) (*flow.ExecutionResult, error)
}

API provides all public-facing functionality of the Flow Access API.

type Blocks

type Blocks interface {
	HeaderByID(id flow.Identifier) (*flow.Header, error)
	FinalizedHeader() (*flow.Header, error)
}

type DuplicatedSignatureError added in v0.18.4

type DuplicatedSignatureError struct {
	Address  flow.Address
	KeyIndex uint64
}

DuplicatedSignatureError indicates that two signatures havs been provided for a key (combination of account and key index)

func (DuplicatedSignatureError) Error added in v0.18.4

func (e DuplicatedSignatureError) Error() string

type ExpiredTransactionError

type ExpiredTransactionError struct {
	RefHeight, FinalHeight uint64
}

ExpiredTransactionError indicates that a transaction has expired.

func (ExpiredTransactionError) Error

func (e ExpiredTransactionError) Error() string

type Handler

type Handler struct {
	// only for v0.33, to be backward compatible
	access.UnimplementedAccessAPIServer
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(api API, chain flow.Chain, finalizedHeader module.FinalizedHeaderCache, me module.Local, options ...HandlerOption) *Handler

func (*Handler) ExecuteScriptAtBlockHeight

func (h *Handler) ExecuteScriptAtBlockHeight(
	ctx context.Context,
	req *access.ExecuteScriptAtBlockHeightRequest,
) (*access.ExecuteScriptResponse, error)

ExecuteScriptAtBlockHeight executes a script at a specific block height.

func (*Handler) ExecuteScriptAtBlockID

func (h *Handler) ExecuteScriptAtBlockID(
	ctx context.Context,
	req *access.ExecuteScriptAtBlockIDRequest,
) (*access.ExecuteScriptResponse, error)

ExecuteScriptAtBlockID executes a script at a specific block ID.

func (*Handler) ExecuteScriptAtLatestBlock

func (h *Handler) ExecuteScriptAtLatestBlock(
	ctx context.Context,
	req *access.ExecuteScriptAtLatestBlockRequest,
) (*access.ExecuteScriptResponse, error)

ExecuteScriptAtLatestBlock executes a script at a the latest block.

func (*Handler) GetAccount

GetAccount returns an account by address at the latest sealed block.

func (*Handler) GetAccountAtBlockHeight

func (h *Handler) GetAccountAtBlockHeight(
	ctx context.Context,
	req *access.GetAccountAtBlockHeightRequest,
) (*access.AccountResponse, error)

func (*Handler) GetAccountAtLatestBlock

func (h *Handler) GetAccountAtLatestBlock(
	ctx context.Context,
	req *access.GetAccountAtLatestBlockRequest,
) (*access.AccountResponse, error)

GetAccountAtLatestBlock returns an account by address at the latest sealed block.

func (*Handler) GetBlockByHeight

func (h *Handler) GetBlockByHeight(
	ctx context.Context,
	req *access.GetBlockByHeightRequest,
) (*access.BlockResponse, error)

GetBlockByHeight gets a block by height.

func (*Handler) GetBlockByID

func (h *Handler) GetBlockByID(
	ctx context.Context,
	req *access.GetBlockByIDRequest,
) (*access.BlockResponse, error)

GetBlockByID gets a block by ID.

func (*Handler) GetBlockHeaderByHeight

func (h *Handler) GetBlockHeaderByHeight(
	ctx context.Context,
	req *access.GetBlockHeaderByHeightRequest,
) (*access.BlockHeaderResponse, error)

GetBlockHeaderByHeight gets a block header by height.

func (*Handler) GetBlockHeaderByID

func (h *Handler) GetBlockHeaderByID(
	ctx context.Context,
	req *access.GetBlockHeaderByIDRequest,
) (*access.BlockHeaderResponse, error)

GetBlockHeaderByID gets a block header by ID.

func (*Handler) GetCollectionByID

func (h *Handler) GetCollectionByID(
	ctx context.Context,
	req *access.GetCollectionByIDRequest,
) (*access.CollectionResponse, error)

GetCollectionByID gets a collection by ID.

func (*Handler) GetEventsForBlockIDs

func (h *Handler) GetEventsForBlockIDs(
	ctx context.Context,
	req *access.GetEventsForBlockIDsRequest,
) (*access.EventsResponse, error)

GetEventsForBlockIDs returns events matching a set of block IDs.

func (*Handler) GetEventsForHeightRange

func (h *Handler) GetEventsForHeightRange(
	ctx context.Context,
	req *access.GetEventsForHeightRangeRequest,
) (*access.EventsResponse, error)

GetEventsForHeightRange returns events matching a query.

func (*Handler) GetExecutionResultByID added in v0.32.0

GetExecutionResultByID returns the execution result for the given ID.

func (*Handler) GetExecutionResultForBlockID added in v0.21.0

GetExecutionResultForBlockID returns the latest received execution result for the given block ID. AN might receive multiple receipts with conflicting results for unsealed blocks. If this case happens, since AN is not able to determine which result is the correct one until the block is sealed, it has to pick one result to respond to this query. For now, we return the result from the latest received receipt.

func (*Handler) GetFullCollectionByID added in v0.33.26

func (h *Handler) GetFullCollectionByID(
	ctx context.Context,
	req *access.GetFullCollectionByIDRequest,
) (*access.FullCollectionResponse, error)

func (*Handler) GetLatestBlock

func (h *Handler) GetLatestBlock(
	ctx context.Context,
	req *access.GetLatestBlockRequest,
) (*access.BlockResponse, error)

GetLatestBlock gets the latest sealed block.

func (*Handler) GetLatestBlockHeader

func (h *Handler) GetLatestBlockHeader(
	ctx context.Context,
	req *access.GetLatestBlockHeaderRequest,
) (*access.BlockHeaderResponse, error)

GetLatestBlockHeader gets the latest sealed block header.

func (*Handler) GetLatestProtocolStateSnapshot added in v0.14.4

GetLatestProtocolStateSnapshot returns the latest serializable Snapshot

func (*Handler) GetNodeVersionInfo added in v0.31.0

GetNodeVersionInfo gets node version information such as semver, commit, sporkID, protocolVersion, etc

func (*Handler) GetProtocolStateSnapshotByBlockID added in v0.33.1

GetProtocolStateSnapshotByBlockID returns serializable Snapshot by blockID

func (*Handler) GetProtocolStateSnapshotByHeight added in v0.33.1

GetProtocolStateSnapshotByHeight returns serializable Snapshot by block height

func (*Handler) GetSystemTransaction added in v0.33.1

func (h *Handler) GetSystemTransaction(
	ctx context.Context,
	req *access.GetSystemTransactionRequest,
) (*access.TransactionResponse, error)

func (*Handler) GetSystemTransactionResult added in v0.33.1

func (h *Handler) GetSystemTransactionResult(
	ctx context.Context,
	req *access.GetSystemTransactionResultRequest,
) (*access.TransactionResultResponse, error)

func (*Handler) GetTransaction

func (h *Handler) GetTransaction(
	ctx context.Context,
	req *access.GetTransactionRequest,
) (*access.TransactionResponse, error)

GetTransaction gets a transaction by ID.

func (*Handler) GetTransactionResult

func (h *Handler) GetTransactionResult(
	ctx context.Context,
	req *access.GetTransactionRequest,
) (*access.TransactionResultResponse, error)

GetTransactionResult gets a transaction by ID.

func (*Handler) GetTransactionResultByIndex added in v0.24.8

func (h *Handler) GetTransactionResultByIndex(
	ctx context.Context,
	req *access.GetTransactionByIndexRequest,
) (*access.TransactionResultResponse, error)

GetTransactionResultByIndex gets a transaction at a specific index for in a block that is executed, pending or finalized transactions return errors

func (*Handler) GetTransactionResultsByBlockID added in v0.24.11

func (h *Handler) GetTransactionResultsByBlockID(
	ctx context.Context,
	req *access.GetTransactionsByBlockIDRequest,
) (*access.TransactionResultsResponse, error)

func (*Handler) GetTransactionsByBlockID added in v0.24.11

func (h *Handler) GetTransactionsByBlockID(
	ctx context.Context,
	req *access.GetTransactionsByBlockIDRequest,
) (*access.TransactionsResponse, error)

func (*Handler) Ping

Ping the Access API server for a response.

func (*Handler) SendTransaction

SendTransaction submits a transaction to the network.

type HandlerOption added in v0.26.17

type HandlerOption func(*Handler)

HandlerOption is used to hand over optional constructor parameters

type IncompleteTransactionError

type IncompleteTransactionError struct {
	MissingFields []string
}

IncompleteTransactionError indicates that a transaction is missing one or more required fields.

func (IncompleteTransactionError) Error

type InvalidAddressError added in v0.11.0

type InvalidAddressError struct {
	Address flow.Address
}

InvalidAddressError indicates that a transaction references an invalid flow Address in either the Authorizers or Payer field.

func (InvalidAddressError) Error added in v0.11.0

func (e InvalidAddressError) Error() string

type InvalidGasLimitError

type InvalidGasLimitError struct {
	Maximum uint64
	Actual  uint64
}

InvalidGasLimitError indicates that a transaction specifies a gas limit that exceeds the maximum.

func (InvalidGasLimitError) Error

func (e InvalidGasLimitError) Error() string

type InvalidScriptError

type InvalidScriptError struct {
	ParserErr error
}

InvalidScriptError indicates that a transaction contains an invalid Cadence script.

func (InvalidScriptError) Error

func (e InvalidScriptError) Error() string

func (InvalidScriptError) Unwrap

func (e InvalidScriptError) Unwrap() error

type InvalidSignatureError added in v0.12.0

type InvalidSignatureError struct {
	Signature flow.TransactionSignature
}

InvalidSignatureError indicates that a transaction contains a signature with a wrong format.

func (InvalidSignatureError) Error added in v0.12.0

func (e InvalidSignatureError) Error() string

type InvalidTxByteSizeError added in v0.11.0

type InvalidTxByteSizeError struct {
	Maximum uint64
	Actual  uint64
}

InvalidTxByteSizeError indicates that a transaction byte size exceeds the maximum.

func (InvalidTxByteSizeError) Error added in v0.11.0

func (e InvalidTxByteSizeError) Error() string

type NetworkParameters

type NetworkParameters struct {
	ChainID flow.ChainID
}

NetworkParameters contains the network-wide parameters for the Flow blockchain.

type NodeVersionInfo added in v0.31.0

type NodeVersionInfo struct {
	Semver               string
	Commit               string
	SporkId              flow.Identifier
	ProtocolVersion      uint64
	SporkRootBlockHeight uint64
	NodeRootBlockHeight  uint64
}

NodeVersionInfo contains information about node, such as semver, commit, sporkID, protocolVersion, etc

type ProtocolStateBlocks

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

func NewProtocolStateBlocks

func NewProtocolStateBlocks(state protocol.State) *ProtocolStateBlocks

func (*ProtocolStateBlocks) FinalizedHeader

func (b *ProtocolStateBlocks) FinalizedHeader() (*flow.Header, error)

func (*ProtocolStateBlocks) HeaderByID

func (b *ProtocolStateBlocks) HeaderByID(id flow.Identifier) (*flow.Header, error)

type TransactionResult

type TransactionResult struct {
	Status        flow.TransactionStatus
	StatusCode    uint
	Events        []flow.Event
	ErrorMessage  string
	BlockID       flow.Identifier
	TransactionID flow.Identifier
	CollectionID  flow.Identifier
	BlockHeight   uint64
}

TODO: Combine this with flow.TransactionResult?

func MessageToTransactionResult added in v0.12.5

func MessageToTransactionResult(message *access.TransactionResultResponse) *TransactionResult

type TransactionValidationOptions

type TransactionValidationOptions struct {
	Expiry                       uint
	ExpiryBuffer                 uint
	AllowEmptyReferenceBlockID   bool
	AllowUnknownReferenceBlockID bool
	MaxGasLimit                  uint64
	CheckScriptsParse            bool
	MaxTransactionByteSize       uint64
	MaxCollectionByteSize        uint64
}

type TransactionValidator

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

func NewTransactionValidator

func NewTransactionValidator(
	blocks Blocks,
	chain flow.Chain,
	options TransactionValidationOptions,
) *TransactionValidator

func (*TransactionValidator) Validate

func (v *TransactionValidator) Validate(tx *flow.TransactionBody) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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