Documentation
¶
Index ¶
- type Backend
- func NewBackend(chainName string, chainID uint64, blockPeriod time.Duration, ...) (*Backend, error)
- func NewDevBackend(chainName string, chainID uint64, blockPeriod time.Duration, ...) (*Backend, error)
- func NewFireBackend(ctx context.Context, chainName string, chainID uint64, ...) (*Backend, error)
- func (b *Backend) AddAccount(privkey *ecdsa.PrivateKey) (common.Address, error)
- func (b *Backend) BindOpts(ctx context.Context, from common.Address) (*bind.TransactOpts, error)
- func (b *Backend) Chain() (string, uint64)
- func (b *Backend) EnsureSynced(ctx context.Context) error
- func (b *Backend) PublicKey(from common.Address) (*ecdsa.PublicKey, error)
- func (b *Backend) Send(ctx context.Context, from common.Address, candidate txmgr.TxCandidate) (*ethtypes.Transaction, *ethclient.Receipt, error)
- func (b *Backend) SendTransaction(ctx context.Context, in *ethtypes.Transaction) error
- func (b *Backend) Sign(ctx context.Context, from common.Address, input [32]byte) ([65]byte, error)
- func (b *Backend) WaitConfirmed(ctx context.Context, tx *ethtypes.Transaction) (*ethclient.Receipt, error)
- func (b *Backend) WaitMined(ctx context.Context, tx *ethtypes.Transaction) (*ethclient.Receipt, error)
- type Backends
- func BackendsFrom(backends map[uint64]*Backend) Backends
- func BackendsFromClients(ethClients map[uint64]ethclient.Client, privkeys ...*ecdsa.PrivateKey) (Backends, error)
- func BackendsFromNetwork(ctx context.Context, network netconf.Network, endpoints xchain.RPCEndpoints, ...) (Backends, error)
- func BackendsFromTestnet(ctx context.Context, testnet types.Testnet) (Backends, error)
- func FireBackendsFromNetwork(ctx context.Context, network netconf.Network, endpoints xchain.RPCEndpoints, ...) (Backends, error)
- func NewFireBackends(ctx context.Context, testnet types.Testnet, fireCl fireblocks.Client) (Backends, error)
- func (b Backends) AddAccount(privkey *ecdsa.PrivateKey) (common.Address, error)
- func (b Backends) All() map[uint64]*Backend
- func (b Backends) Backend(sourceChainID uint64) (*Backend, error)
- func (b Backends) BindOpts(ctx context.Context, sourceChainID uint64, addr common.Address) (*bind.TransactOpts, *Backend, error)
- func (b Backends) Clients() map[uint64]ethclient.Client
- func (b Backends) NewWaiter() *Waiter
- func (b Backends) RPCClients() map[uint64]ethclient.Client
- func (b Backends) StartIdleConnectionClosing(ctx context.Context)
- type Waiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
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 NewDevBackend ¶ added in v0.11.0
func NewDevBackend(chainName string, chainID uint64, blockPeriod time.Duration, ethCl ethclient.Client) (*Backend, error)
NewDevBackend returns a backend with all pre-funded anvil dev accounts.
func NewFireBackend ¶
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 ¶
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 ¶
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) EnsureSynced ¶
EnsureSynced returns an error if the backend is not synced.
func (*Backend) SendTransaction ¶
SendTransaction intercepts the tx that bindings generates, extracts the from address (if the backendStubSigner was used), the strips fields, and passes it to the txmgr for reliable broadcasting.
func (*Backend) WaitConfirmed ¶ added in v0.15.0
func (b *Backend) WaitConfirmed(ctx context.Context, tx *ethtypes.Transaction) (*ethclient.Receipt, error)
WaitConfirmed is similar to WaitMined, except that it also waits for the (first) receipt block to be "confirmed". "Confirmed" depends on the evmchain.Reorgs value, if false, it is just calls WaitMined and returns the receipt. Otherwise, it also waits for "safe" confirmation (this is very slow up to 6min). It returns an error if the (first) receipt is reorged out (even though the tx may still be included in a different block).
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 BackendsFrom ¶ added in v0.13.0
func BackendsFromClients ¶ added in v0.14.1
func BackendsFromNetwork ¶ added in v0.12.0
func BackendsFromNetwork(ctx context.Context, network netconf.Network, endpoints xchain.RPCEndpoints, privKeys ...*ecdsa.PrivateKey) (Backends, error)
func BackendsFromTestnet ¶ added in v0.14.1
BackendsFromTestnet returns a multi-backends backed by in-memory keys that supports configured all chains.
func FireBackendsFromNetwork ¶ added in v0.15.0
func FireBackendsFromNetwork(ctx context.Context, network netconf.Network, endpoints xchain.RPCEndpoints, fireCl fireblocks.Client) (Backends, error)
func NewFireBackends ¶
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) AddAccount ¶ added in v0.12.0
AddAccount adds a in-memory private key account to all backends. Note this can be called even if other accounts are fireblocks based.
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) StartIdleConnectionClosing ¶ added in v0.14.1
StartIdleConnectionClosing starts a goroutine for each backend to close idle connections periodically. It returns immediately.