requester

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const LatestBlockHeight uint64 = math.MaxUint64 - 1

Variables

View Source
var ErrOutOfRange = errors.New("height is out of range for provided spork clients")

Functions

This section is empty.

Types

type CrossSporkClient added in v0.12.0

type CrossSporkClient struct {
	access.Client
	// contains filtered or unexported fields
}

CrossSporkClient is a wrapper around the Flow AN client that can access different AN APIs based on the height boundaries of the sporks.

Each spork is defined with the last height included in that spork, based on the list we know which AN client to use when requesting the data.

Any API that supports cross-spork access must have a defined function that shadows the original access Client function.

func NewCrossSporkClient added in v0.12.0

func NewCrossSporkClient(
	currentSpork access.Client,
	pastSporks []access.Client,
	logger zerolog.Logger,
	chainID flowGo.ChainID,
) (*CrossSporkClient, error)

NewCrossSporkClient creates a new instance of the multi-spork client. It requires the current spork client and a slice of past spork clients.

func (*CrossSporkClient) ExecuteScriptAtBlockHeight added in v0.12.0

func (c *CrossSporkClient) ExecuteScriptAtBlockHeight(
	ctx context.Context,
	height uint64,
	script []byte,
	arguments []cadence.Value,
) (cadence.Value, error)

func (*CrossSporkClient) GetBlockHeaderByHeight added in v0.12.0

func (c *CrossSporkClient) GetBlockHeaderByHeight(
	ctx context.Context,
	height uint64,
) (*flow.BlockHeader, error)

func (*CrossSporkClient) GetLatestHeightForSpork added in v0.12.0

func (c *CrossSporkClient) GetLatestHeightForSpork(ctx context.Context, height uint64) (uint64, error)

GetLatestHeightForSpork will determine the spork client in which the provided height is contained and then find the latest height in that spork.

func (*CrossSporkClient) IsPastSpork added in v0.12.0

func (c *CrossSporkClient) IsPastSpork(height uint64) bool

IsPastSpork will check if the provided height is contained in the previous sporks.

func (*CrossSporkClient) SubscribeEventsByBlockHeight added in v0.12.0

func (c *CrossSporkClient) SubscribeEventsByBlockHeight(
	ctx context.Context,
	startHeight uint64,
	filter flow.EventFilter,
	opts ...access.SubscribeOption,
) (<-chan flow.BlockEvents, <-chan error, error)

type EVM

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

func NewEVM

func NewEVM(
	client *CrossSporkClient,
	config *config.Config,
	signer crypto.Signer,
	logger zerolog.Logger,
	blocks storage.BlockIndexer,
) (*EVM, error)

func (*EVM) Call

func (e *EVM) Call(
	ctx context.Context,
	data []byte,
	from common.Address,
	evmHeight int64,
) ([]byte, error)

func (*EVM) EstimateGas

func (e *EVM) EstimateGas(
	ctx context.Context,
	data []byte,
	from common.Address,
) (uint64, error)

func (*EVM) GetBalance

func (e *EVM) GetBalance(
	ctx context.Context,
	address common.Address,
	evmHeight int64,
) (*big.Int, error)

func (*EVM) GetCode added in v0.2.0

func (e *EVM) GetCode(
	ctx context.Context,
	address common.Address,
	evmHeight int64,
) ([]byte, error)

func (*EVM) GetLatestEVMHeight added in v0.6.0

func (e *EVM) GetLatestEVMHeight(ctx context.Context) (uint64, error)

func (*EVM) GetNonce added in v0.2.0

func (e *EVM) GetNonce(
	ctx context.Context,
	address common.Address,
	evmHeight int64,
) (uint64, error)

func (*EVM) SendRawTransaction

func (e *EVM) SendRawTransaction(ctx context.Context, data []byte) (common.Hash, error)

type KeyRotationSigner

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

KeyRotationSigner is a crypto signer that contains a pool of key pairs to sign with, and it rotates the key used for each signing request. This allows for faster submission of transactions to the network, due to a sequence number not being reused between different keys used. It also contains logic to queue up signature requests and in case there are more transactions pending than the keys in the pool it will wait for transactions to get executed so the new sequence key can be obtained. The signer is concurrency-safe.

func NewKeyRotationSigner

func NewKeyRotationSigner(keys []crypto.PrivateKey, hashAlgo crypto.HashAlgorithm) (*KeyRotationSigner, error)

func (*KeyRotationSigner) PublicKey

func (k *KeyRotationSigner) PublicKey() crypto.PublicKey

PublicKey returns the current public key which is available for signing.

func (*KeyRotationSigner) Sign

func (k *KeyRotationSigner) Sign(message []byte) ([]byte, error)

Sign signs the message and then rotates to the next key. note: if you want to get the public key pair, you should first call PublicKey and then Sign.

type Requester

type Requester interface {
	// SendRawTransaction will submit signed transaction data to the network.
	// The submitted EVM transaction hash is returned.
	SendRawTransaction(ctx context.Context, data []byte) (common.Hash, error)

	// GetBalance returns the amount of wei for the given address in the state of the
	// given EVM block height.
	GetBalance(ctx context.Context, address common.Address, evmHeight int64) (*big.Int, error)

	// Call executes the given signed transaction data on the state for the given EVM block height.
	// Note, this function doesn't make and changes in the state/blockchain and is
	// useful to execute and retrieve values.
	Call(ctx context.Context, data []byte, from common.Address, evmHeight int64) ([]byte, error)

	// EstimateGas executes the given signed transaction data on the state.
	// Note, this function doesn't make any changes in the state/blockchain and is
	// useful to executed and retrieve the gas consumption and possible failures.
	EstimateGas(ctx context.Context, data []byte, from common.Address) (uint64, error)

	// GetNonce gets nonce from the network at the given EVM block height.
	GetNonce(ctx context.Context, address common.Address, evmHeight int64) (uint64, error)

	// GetCode returns the code stored at the given address in
	// the state for the given EVM block height.
	GetCode(ctx context.Context, address common.Address, evmHeight int64) ([]byte, error)

	// GetLatestEVMHeight returns the latest EVM height of the network.
	GetLatestEVMHeight(ctx context.Context) (uint64, error)
}

Jump to

Keyboard shortcuts

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