http

package
v0.26.4 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: Apache-2.0 Imports: 18 Imported by: 27

Documentation

Index

Constants

View Source
const (
	EmulatorHost  = "http://127.0.0.1:8888/v1"
	TestnetHost   = "https://rest-testnet.onflow.org/v1/"
	MainnetHost   = "https://rest-mainnet.onflow.org/v1/"
	CanarynetHost = "https://rest-canary.onflow.org/v1/"
)
View Source
const (
	// FINAL points to latest finalised block height.
	FINAL uint64 = math.MaxUint64 - 1
	// SEALED points to latest sealed block height.
	SEALED uint64 = math.MaxUint64 - 2
)

special height values definition.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseClient

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

BaseClient provides an API specific to the HTTP.

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(host string) (*BaseClient, error)

NewBaseClient creates a new BaseClient. BaseClient provides an API specific to the HTTP.

Use this client if you need advance access to the HTTP API. If you don't require special methods use the Client instead.

func (*BaseClient) ExecuteScriptAtBlockHeight

func (c *BaseClient) ExecuteScriptAtBlockHeight(
	ctx context.Context,
	blockQuery HeightQuery,
	script []byte,
	arguments []cadence.Value,
	opts ...queryOpts,
) (cadence.Value, error)

func (*BaseClient) ExecuteScriptAtBlockID

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

func (*BaseClient) GetAccountAtBlockHeight

func (c *BaseClient) GetAccountAtBlockHeight(
	ctx context.Context,
	address flow.Address,
	blockQuery HeightQuery,
	opts ...queryOpts,
) (*flow.Account, error)

func (*BaseClient) GetBlockByID

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

func (*BaseClient) GetBlocksByHeights

func (c *BaseClient) GetBlocksByHeights(
	ctx context.Context,
	heightQuery HeightQuery,
	opts ...queryOpts,
) ([]*flow.Block, error)

GetBlocksByHeights requests the blocks by the specified block query.

func (*BaseClient) GetCollection

func (c *BaseClient) GetCollection(
	ctx context.Context,
	ID flow.Identifier,
	opts ...queryOpts,
) (*flow.Collection, error)

func (*BaseClient) GetEventsForBlockIDs

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

func (*BaseClient) GetEventsForHeightRange

func (c *BaseClient) GetEventsForHeightRange(
	ctx context.Context,
	eventType string,
	heightQuery HeightQuery,
) ([]flow.BlockEvents, error)

func (*BaseClient) GetExecutionResultForBlockID

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

func (*BaseClient) GetLatestProtocolStateSnapshot

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

func (*BaseClient) GetTransaction

func (c *BaseClient) GetTransaction(
	ctx context.Context,
	ID flow.Identifier,
	opts ...queryOpts,
) (*flow.Transaction, error)

func (*BaseClient) GetTransactionResult

func (c *BaseClient) GetTransactionResult(
	ctx context.Context,
	ID flow.Identifier,
	opts ...queryOpts,
) (*flow.TransactionResult, error)

func (*BaseClient) Ping

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

func (*BaseClient) SendTransaction

func (c *BaseClient) SendTransaction(
	ctx context.Context,
	tx flow.Transaction,
	opts ...queryOpts,
) 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 HTTP methods providing a network agnostic API.

func NewClient

func NewClient(host string) (*Client, error)

NewClient creates an HTTP 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)

GetAccount is an alias for GetAccountAtLatestBlock.

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, ID 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, ID flow.Identifier) (*flow.Transaction, error)

func (*Client) GetTransactionResult

func (c *Client) GetTransactionResult(ctx context.Context, ID flow.Identifier) (*flow.TransactionResult, 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 ExpandOpts

type ExpandOpts struct {
	Expands []string
}

ExpandOpts allows you to define a list of fields that you want to retrieve as extra data in the response.

Be sure to follow the documentation for allowed values found here https://docs.onflow.org/http-api/

type HTTPError

type HTTPError struct {
	Url     string
	Code    int
	Message string
}

func (HTTPError) Error

func (h HTTPError) Error() string

type HeightQuery

type HeightQuery struct {
	Heights []uint64
	Start   uint64
	End     uint64
}

HeightQuery defines all the possible heights you can pass when fetching blocks.

Make sure you only pass either heights or special heights or start and end height else an error will be returned. You can refer to the docs for querying blocks found here https://docs.onflow.org/http-api/#tag/Blocks/paths/~1blocks/get

type SelectOpts

type SelectOpts struct {
	Selects []string
}

SelectOpts allows you to define a list of fields that you only want to fetch in the response filtering out any other data.

Be sure to follow the documentation for allowed values found here https://docs.onflow.org/http-api/

Directories

Path Synopsis
* Access API * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0.0 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
* Access API * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0.0 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)

Jump to

Keyboard shortcuts

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