nonce

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 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) (*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)
}

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.

Jump to

Keyboard shortcuts

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