requester

package
v1.0.0-rc.17 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoKeysAvailable = fmt.Errorf("no keys available")

Functions

This section is empty.

Types

type AccountKey added in v1.0.0

type AccountKey struct {
	flowsdk.AccountKey

	Address flowsdk.Address
	Signer  crypto.Signer
	// contains filtered or unexported fields
}

func (*AccountKey) Done added in v1.0.0

func (k *AccountKey) Done()

Done unlocks a key after use and puts it back into the pool.

func (*AccountKey) SetProposerPayerAndSign added in v1.0.0

func (k *AccountKey) SetProposerPayerAndSign(
	tx *flowsdk.Transaction,
	account *flowsdk.Account,
) error

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) Close added in v1.0.0

func (c *CrossSporkClient) Close() error

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) GetEventsForHeightRange added in v1.0.0

func (c *CrossSporkClient) GetEventsForHeightRange(
	ctx context.Context, eventType string, startHeight uint64, endHeight uint64,
) ([]flow.BlockEvents, 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(
	registerStore *pebble.RegisterStorage,
	blocksProvider *replayer.BlocksProvider,
	client *CrossSporkClient,
	config config.Config,
	logger zerolog.Logger,
	blocks storage.BlockIndexer,
	txPool *TxPool,
	collector metrics.Collector,
	keystore *KeyStore,
) (*EVM, error)

func (*EVM) Call

func (e *EVM) Call(
	tx *types.DynamicFeeTx,
	from common.Address,
	height uint64,
	stateOverrides *ethTypes.StateOverride,
) ([]byte, error)

func (*EVM) EstimateGas

func (e *EVM) EstimateGas(
	tx *types.DynamicFeeTx,
	from common.Address,
	height uint64,
	stateOverrides *ethTypes.StateOverride,
) (uint64, error)

func (*EVM) GetBalance

func (e *EVM) GetBalance(
	address common.Address,
	height uint64,
) (*big.Int, error)

func (*EVM) GetCode added in v0.2.0

func (e *EVM) GetCode(
	address common.Address,
	height uint64,
) ([]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(
	address common.Address,
	height uint64,
) (uint64, error)

func (*EVM) GetStorageAt added in v0.23.0

func (e *EVM) GetStorageAt(
	address common.Address,
	hash common.Hash,
	height uint64,
) (common.Hash, error)

func (*EVM) SendRawTransaction

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

type KMSKeySigner added in v1.0.0

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

KMSKeySigner is a crypto signer that contains a `crypto.Signer`[1] object, which is tied to a Cloud KMS asymmetric signing key.

[1](https://github.com/onflow/flow-go-sdk/blob/master/crypto/cloudkms/signer.go#L37)

func NewKMSKeySigner added in v1.0.0

func NewKMSKeySigner(
	ctx context.Context,
	key cloudkms.Key,
	logger zerolog.Logger,
) (*KMSKeySigner, error)

NewKMSKeySigner returns a new KMSKeySigner for the given Cloud KMS key.

func (*KMSKeySigner) PublicKey added in v1.0.0

func (s *KMSKeySigner) PublicKey() crypto.PublicKey

PublicKey returns the current public key of the Cloud KMS key.

func (*KMSKeySigner) Sign added in v1.0.0

func (s *KMSKeySigner) Sign(message []byte) ([]byte, error)

Sign signs the given message using the KMS signing key for this signer.

Reference: https://cloud.google.com/kms/docs/create-validate-signatures

type KeyLock added in v1.0.0

type KeyLock interface {
	LockKey(
		txID flowsdk.Identifier,
		referenceBlockHeight uint64,
		key *AccountKey,
	)
	UnlockKey(txID flowsdk.Identifier)
	Notify(blockHeight uint64)
}

type KeyStore added in v1.0.0

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

func NewKeyStore added in v1.0.0

func NewKeyStore(keys []*AccountKey) *KeyStore

func (*KeyStore) AvailableKeys added in v1.0.0

func (k *KeyStore) AvailableKeys() int

func (*KeyStore) LockKey added in v1.0.0

func (k *KeyStore) LockKey(
	txID flowsdk.Identifier,
	referenceBlockHeight uint64,
	key *AccountKey,
)

func (*KeyStore) Notify added in v1.0.0

func (k *KeyStore) Notify(blockHeight uint64)

func (*KeyStore) Take added in v1.0.0

func (k *KeyStore) Take() (*AccountKey, error)

func (*KeyStore) UnlockKey added in v1.0.0

func (k *KeyStore) UnlockKey(txID flowsdk.Identifier)

type RemoteCadenceArch added in v1.0.0

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

func NewRemoteCadenceArch added in v1.0.0

func NewRemoteCadenceArch(
	blockHeight uint64,
	client *CrossSporkClient,
	chainID flow.ChainID,
) *RemoteCadenceArch

func (*RemoteCadenceArch) Address added in v1.0.0

func (rca *RemoteCadenceArch) Address() evmTypes.Address

func (*RemoteCadenceArch) RequiredGas added in v1.0.0

func (rca *RemoteCadenceArch) RequiredGas(input []byte) uint64

func (*RemoteCadenceArch) Run added in v1.0.0

func (rca *RemoteCadenceArch) Run(input []byte) ([]byte, error)

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(address common.Address, height uint64) (*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(
		tx *types.DynamicFeeTx,
		from common.Address,
		height uint64,
		stateOverrides *ethTypes.StateOverride,
	) ([]byte, error)

	// EstimateGas executes the given signed transaction data on the state for the given EVM block height.
	// 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(
		tx *types.DynamicFeeTx,
		from common.Address,
		height uint64,
		stateOverrides *ethTypes.StateOverride,
	) (uint64, error)

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

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

	// GetStorageAt returns the storage from the state at the given address, key and block number.
	GetStorageAt(address common.Address, hash common.Hash, height uint64) (common.Hash, error)

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

type TxPool added in v0.21.0

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

func NewTxPool added in v0.21.0

func NewTxPool(
	client *CrossSporkClient,
	transactionsPublisher *models.Publisher[*gethTypes.Transaction],
	logger zerolog.Logger,
	config config.Config,
) *TxPool

func (*TxPool) Send added in v0.21.0

func (t *TxPool) Send(
	ctx context.Context,
	flowTx *flow.Transaction,
	evmTx *gethTypes.Transaction,
) error

Send flow transaction that executes EVM run function which takes in the encoded EVM transaction. The flow transaction status is awaited and an error is returned in case of a failure in submission, or an EVM validation error. Until the flow transaction is sealed the transaction will stay in the transaction pool marked as pending.

Jump to

Keyboard shortcuts

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