nonce

package
v0.17.10 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2024 License: MIT Imports: 13 Imported by: 1

Documentation

Overview

Package nonce is the nonce manager

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainQuery

type ChainQuery interface {
	// PendingNonceAt returns the account nonce of the given account in the pending state.
	// This is the nonce that should be used for the next transaction.
	PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
}

ChainQuery is a chain used to generate a nonce.

type Manager

type Manager interface {
	// SignTx signs a legacy tx
	SignTx(ogTx *types.Transaction, signer types.Signer, prv *ecdsa.PrivateKey, options ...Option) (*types.Transaction, error)
	// NewKeyedTransactor wraps keyed transactor in a nonce manager.
	// right now, this only works if all txes are sent out (a safe assumption in test mode)
	// this can be obviated by signing at send time or loop + retrying on failure
	NewKeyedTransactor(realSigner *bind.TransactOpts) (*bind.TransactOpts, error)
	// NewKeyedTransactorFromKey creates a new keyed transactor from a private key.
	NewKeyedTransactorFromKey(key *ecdsa.PrivateKey) (*bind.TransactOpts, error)
	// GetNextNonce gets the next nonce for the address.
	GetNextNonce(address common.Address) (*big.Int, error)
	// ClearNonce clears the nonce for the address.
	ClearNonce(address common.Address)
}

Manager is a singleton used to generate a nonce. This can be explicitly overrided by setting a nonce manually (not recommended). The issue here is many of the deploy helper functions are called asynchronously and there's a gap between the tx.Sequence generation and the transactor. This solves that by wrapping the transactor in a nonce manager.

func NewNonceManager

func NewNonceManager(ctx context.Context, chain ChainQuery, chainID *big.Int) Manager

NewNonceManager generates a new nonce manager. This should be called once, as nonce storage is not global.

type Option added in v0.0.76

type Option func(*signTXConfig)

Option is a functional option for SignTX method.

func WithNoBump added in v0.0.76

func WithNoBump(noBump bool) Option

WithNoBump sets the skipNonceBump flag.

Jump to

Keyboard shortcuts

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