ethbackend

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2024 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	ethclient.Client
	// contains filtered or unexported fields
}

func NewAnvilBackend added in v0.1.2

func NewAnvilBackend(chainName string, chainID uint64, blockPeriod time.Duration, ethCl ethclient.Client) (*Backend, error)

NewAnvilBackend returns a backend with all pre-funded anvil dev accounts.

func NewBackend

func NewBackend(chainName string, chainID uint64, blockPeriod time.Duration, ethCl ethclient.Client, privateKeys ...*ecdsa.PrivateKey) (*Backend, error)

NewBackend returns a new backend backed by in-memory private keys.

func NewFireBackend added in v0.1.2

func NewFireBackend(ctx context.Context, chainName string, chainID uint64, blockPeriod time.Duration, ethCl ethclient.Client, fireCl fireblocks.Client) (*Backend, error)

NewFireBackend returns a backend that supports all accounts supported by the configured fireblocks client. Note that private keys can still be added via AddAccount.

func (*Backend) AddAccount

func (b *Backend) AddAccount(privkey *ecdsa.PrivateKey) (common.Address, error)

AddAccount adds a in-memory private key account to the backend. Note this can be called even if other accounts are fireblocks based.

func (*Backend) BindOpts

func (b *Backend) BindOpts(ctx context.Context, from common.Address) (*bind.TransactOpts, error)

BindOpts returns a new TransactOpts for interacting with bindings based contracts for the provided account. The TransactOpts are partially stubbed, since txmgr handles nonces and signing.

Do not cache or store the TransactOpts, as they are not safe for concurrent use (pointer). Rather create a new TransactOpts for each transaction.

func (*Backend) Chain

func (b *Backend) Chain() (string, uint64)

func (*Backend) PublicKey added in v0.1.2

func (b *Backend) PublicKey(from common.Address) (*ecdsa.PublicKey, error)

func (*Backend) Send

func (*Backend) SendTransaction

func (b *Backend) SendTransaction(ctx context.Context, in *ethtypes.Transaction) error

SendTransaction intercepts the tx that bindings generates, extracts the from address (assuming the backendStubSigner was used), the strips fields, and passes it to the txmgr for reliable broadcasting.

func (*Backend) Sign

func (b *Backend) Sign(ctx context.Context, from common.Address, input [32]byte) ([65]byte, error)

func (*Backend) WaitMined

func (b *Backend) WaitMined(ctx context.Context, tx *ethtypes.Transaction) (*ethtypes.Receipt, error)

WaitMined waits for the transaction to be mined and asserts the receipt is successful.

type Backends

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

Backends is a wrapper around a set of Backends, one for each chain. At this point, it only supports "a single account for all Backends".

See Backends godoc for more information.

func NewBackends

func NewBackends(testnet types.Testnet, deployKeyFile string) (Backends, error)

NewBackends returns a multi-backends backed by in-memory keys that supports configured all chains.

func NewFireBackends added in v0.1.2

func NewFireBackends(ctx context.Context, testnet types.Testnet, fireCl fireblocks.Client) (Backends, error)

NewFireBackends returns a multi-backends backed by fireblocks keys that supports configured all chains.

func (Backends) All added in v0.1.2

func (b Backends) All() map[uint64]*Backend

func (Backends) Backend added in v0.1.2

func (b Backends) Backend(sourceChainID uint64) (*Backend, error)

func (Backends) BindOpts

func (b Backends) BindOpts(ctx context.Context, sourceChainID uint64, addr common.Address) (*bind.TransactOpts, *Backend, error)

BindOpts is a convenience function that an accounts' bind.TransactOpts and Backend for a given chain.

func (Backends) NewWaiter

func (b Backends) NewWaiter() *Waiter

NewWaiter returns a new Waiter.

func (Backends) RPCClients

func (b Backends) RPCClients() map[uint64]ethclient.Client

type Waiter

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

Waiter is a convenience struct to easily wait for multiple transactions to be mined. Adding is thread safe, but it panics if Add is called after Wait.

func (*Waiter) Add

func (w *Waiter) Add(chainID uint64, tx *ethtypes.Transaction)

func (*Waiter) Wait

func (w *Waiter) Wait(ctx context.Context) error

Jump to

Keyboard shortcuts

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