access

package
v0.18.4 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: AGPL-3.0 Imports: 14 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

Types

type API

type API interface {
	Ping(ctx context.Context) error
	GetNetworkParameters(ctx context.Context) NetworkParameters

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

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

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

	SendTransaction(ctx context.Context, tx *flow.TransactionBody) error
	GetTransaction(ctx context.Context, id flow.Identifier) (*flow.TransactionBody, error)
	GetTransactionResult(ctx context.Context, id flow.Identifier) (*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) ([]flow.BlockEvents, error)
	GetEventsForBlockIDs(ctx context.Context, eventType string, blockIDs []flow.Identifier) ([]flow.BlockEvents, error)

	GetLatestProtocolStateSnapshot(ctx context.Context) ([]byte, 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 a key (combination of account and key index) is used for two signatures

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 {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(api API, chain flow.Chain) *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)

GetBlockByHeight 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) 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) 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) Ping

Ping the Access API server for a response.

func (*Handler) SendTransaction

SendTransaction submits a transaction to the network.

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

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
	// MaxAddressIndex is a simple spam prevention measure. It rejects any
	// transactions referencing an address with index newer than the specified
	// maximum. A zero value indicates no address checking.
	MaxAddressIndex        uint64
	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