ethereum

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2022 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAccountNotFound  = errors.New("could not find specified account")
	ErrKeysNotFound     = errors.New("account either not found or not unlocked")
	ErrPassCodeNotFound = errors.New("could not find specified passCode")
)

Ethereum specific errors.

View Source
var ETH_MAX_PRIORITY_FEE_PER_GAS_NOT_FOUND string = "Method eth_maxPriorityFeePerGas not found"

Functions

func ComputeGasFeeCap

func ComputeGasFeeCap(eth layer1.Client, baseFee, tipCap *big.Int) (*big.Int, error)

Function to compute the gas fee that will be valid for the next 8 full blocks before we are priced out.

func GetValidators

func GetValidators(eth layer1.Client, contracts layer1.EthereumContracts, logger *logrus.Logger, ctx context.Context) ([]common.Address, error)

Get the current validators.

func TransferEther

func TransferEther(eth layer1.Client, logger *logrus.Entry, from, to common.Address, wei *big.Int) (*types.Transaction, error)

TransferEther transfer's ether from one account to another, assumes from is unlocked.

Types

type Client

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

func NewClient

func NewClient(
	endpoint string,
	pathKeystore string,
	pathPassCodes string,
	defaultAccount string,
	unlockAdditionalAccounts bool,
	finalityDelay uint64,
	txMaxGasFeeAllowedInGwei uint64,
	endpointMinimumPeers uint64,
) (*Client, error)

NewClient creates a new Ethereum abstraction.

func (*Client) Close

func (eth *Client) Close()

close the ethereum client.

func (*Client) CreateSecp256k1Signer

func (eth *Client) CreateSecp256k1Signer() (*crypto.Secp256k1Signer, error)

create a new signer for ETH accounts.

func (*Client) EndpointInSync

func (eth *Client) EndpointInSync(ctx context.Context) (bool, uint32, error)

EndpointInSync Checks if our endpoint is good to use -- This function is different. Because we need to be aware of errors, State is always updated.

func (*Client) ExtractTransactionSender

func (eth *Client) ExtractTransactionSender(tx *types.Transaction) (common.Address, error)

Extracts the sender of a transaction.

func (*Client) GetAccount

func (eth *Client) GetAccount(addr common.Address) (accounts.Account, error)

GetAccount returns the account specified.

func (*Client) GetBalance

func (eth *Client) GetBalance(addr common.Address) (*big.Int, error)

GetBalance returns the ETHER balance of account specified.

func (*Client) GetBlockBaseFeeAndSuggestedGasTip

func (eth *Client) GetBlockBaseFeeAndSuggestedGasTip(ctx context.Context) (*big.Int, *big.Int, error)

Get the base fee and suggestedGasTip for the latest ethereum block.

func (*Client) GetBlockByNumber

func (eth *Client) GetBlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)

wrapper around ethclient.BlockByNumber.

func (*Client) GetCallOpts

func (eth *Client) GetCallOpts(ctx context.Context, account accounts.Account) (*bind.CallOpts, error)

Safe function to call the smart contract state at the finalized block (block that we judge safe).

func (*Client) GetCallOptsLatestBlock

func (eth *Client) GetCallOptsLatestBlock(ctx context.Context, account accounts.Account) *bind.CallOpts

Function to call the smart contract state at the latest block seen by the ethereum node. USE THIS FUNCTION CAREFULLY, THE LATEST BLOCK IS SUSCEPTIBLE TO CHAIN RE-ORGS AND SHOULD NEVER BE USED AS TEST IF SOMETHING WAS COMMITTED TO OUR CONTRACTS. IDEALLY, ONLY USE THIS FUNCTION FOR MONITORING FUNCTIONS THAT DEPENDS ON THE LATEST BLOCK. Otherwise use GetCallOpts!!!

func (*Client) GetChainID

func (eth *Client) GetChainID() *big.Int

ChainID returns the ID used to build ethereum client.

func (*Client) GetCurrentHeight

func (eth *Client) GetCurrentHeight(ctx context.Context) (uint64, error)

GetCurrentHeight gets the height of the endpoints chain.

func (*Client) GetDefaultAccount

func (eth *Client) GetDefaultAccount() accounts.Account

GetDefaultAccount returns the default account.

func (*Client) GetEndpoint

func (eth *Client) GetEndpoint() string

Get ip address where are connected to the ethereum node.

func (*Client) GetEvents

func (eth *Client) GetEvents(ctx context.Context, firstBlock, lastBlock uint64, addresses []common.Address) ([]types.Log, error)

Get ethereum events from a block range.

func (*Client) GetFinalityDelay

func (eth *Client) GetFinalityDelay() uint64

Get finality delay.

func (*Client) GetFinalizedHeight

func (eth *Client) GetFinalizedHeight(ctx context.Context) (uint64, error)

GetFinalizedHeight gets the height of the endpoints chain at which is is considered finalized.

func (*Client) GetHeaderByNumber

func (eth *Client) GetHeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)

wrapper around ethclient.HeaderByNumber.

func (*Client) GetKnownAccounts

func (eth *Client) GetKnownAccounts() []accounts.Account

Get all ethereum accounts that we have access in the keystore.

func (*Client) GetPeerCount

func (eth *Client) GetPeerCount(ctx context.Context) (uint64, error)

func (*Client) GetPendingNonce

func (eth *Client) GetPendingNonce(ctx context.Context, account common.Address) (uint64, error)

wrapper around ethclient.PendingNonceAt.

func (*Client) GetTimeoutContext

func (eth *Client) GetTimeoutContext() (context.Context, context.CancelFunc)

Get timeout context.

func (*Client) GetTransactionByHash

func (eth *Client) GetTransactionByHash(ctx context.Context, txHash common.Hash) (tx *types.Transaction, isPending bool, err error)

wrapper around ethclient.TransactionByHash.

func (*Client) GetTransactionOpts

func (eth *Client) GetTransactionOpts(ctx context.Context, account accounts.Account) (*bind.TransactOpts, error)

Get transaction options in order to do a transaction.

func (*Client) GetTransactionReceipt

func (eth *Client) GetTransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)

wrapper around ethclient.TransactionReceipt.

func (*Client) GetTxMaxGasFeeAllowed

func (eth *Client) GetTxMaxGasFeeAllowed() *big.Int

Get the max gas fee allowed to perform transactions in WEI.

func (*Client) GetTxMaxStaleBlocks

func (eth *Client) GetTxMaxStaleBlocks() uint64

Number of blocks to wait for a tx in the memory pool w/o returning to the caller asking for retry.

func (*Client) GetTxNotFoundMaxBlocks

func (eth *Client) GetTxNotFoundMaxBlocks() uint64

How many blocks we should wait for removing a tx in case we don't find it in the layer1 chain.

func (*Client) IsAccessible

func (eth *Client) IsAccessible() bool

IsAccessible checks against endpoint to confirm server responds.

func (*Client) RetryTransaction

func (eth *Client) RetryTransaction(ctx context.Context, tx *types.Transaction, baseFee, gasTipCap *big.Int) (*types.Transaction, error)

Retry a transaction done by any of the known ethereum accounts.

func (*Client) SendTransaction

func (eth *Client) SendTransaction(ctx context.Context, tx *types.Transaction) error

wrapper around ethclient.SendTransaction.

func (*Client) SignTransaction

func (eth *Client) SignTransaction(tx types.TxData, signerAddress common.Address) (*types.Transaction, error)

Sign an ethereum transaction.

type Contracts

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

Contracts contains bindings to smart contract system.

func NewContracts

func NewContracts(eth *Client, contractFactoryAddress common.Address) *Contracts

Set the contractFactoryAddress and looks up for all the contracts that we need that were deployed via the factory. It's only executed once. Other call to this functions are no-op.

func (*Contracts) ALCA added in v0.0.8

func (c *Contracts) ALCA() bindings.IALCA

func (*Contracts) ALCAAddress added in v0.0.8

func (c *Contracts) ALCAAddress() common.Address

func (*Contracts) ALCB added in v0.0.8

func (c *Contracts) ALCB() bindings.IALCB

func (*Contracts) ALCBAddress added in v0.0.8

func (c *Contracts) ALCBAddress() common.Address

func (*Contracts) ContractFactory

func (c *Contracts) ContractFactory() bindings.IAliceNetFactory

func (*Contracts) ContractFactoryAddress

func (c *Contracts) ContractFactoryAddress() common.Address

func (*Contracts) Dynamics added in v0.0.5

func (c *Contracts) Dynamics() bindings.IDynamics

func (*Contracts) DynamicsAddress added in v0.0.5

func (c *Contracts) DynamicsAddress() common.Address

func (*Contracts) Ethdkg

func (c *Contracts) Ethdkg() bindings.IETHDKG

func (*Contracts) EthdkgAddress

func (c *Contracts) EthdkgAddress() common.Address

func (*Contracts) GetAllAddresses

func (c *Contracts) GetAllAddresses() []common.Address

return all addresses from all contracts in the contract struct.

func (*Contracts) Governance

func (c *Contracts) Governance() bindings.IGovernance

func (*Contracts) GovernanceAddress

func (c *Contracts) GovernanceAddress() common.Address

func (*Contracts) PublicStaking

func (c *Contracts) PublicStaking() bindings.IPublicStaking

func (*Contracts) PublicStakingAddress

func (c *Contracts) PublicStakingAddress() common.Address

func (*Contracts) Snapshots

func (c *Contracts) Snapshots() bindings.ISnapshots

func (*Contracts) SnapshotsAddress

func (c *Contracts) SnapshotsAddress() common.Address

func (*Contracts) ValidatorPool

func (c *Contracts) ValidatorPool() bindings.IValidatorPool

func (*Contracts) ValidatorPoolAddress

func (c *Contracts) ValidatorPoolAddress() common.Address

func (*Contracts) ValidatorStaking

func (c *Contracts) ValidatorStaking() bindings.IValidatorStaking

func (*Contracts) ValidatorStakingAddress

func (c *Contracts) ValidatorStakingAddress() common.Address

type ErrTxTooExpensive

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

func (*ErrTxTooExpensive) Error

func (e *ErrTxTooExpensive) Error() string

type JsonRPCMessage

type JsonRPCMessage struct {
	Version string          `json:"jsonrpc,omitempty"`
	ID      json.RawMessage `json:"id,omitempty"`
	Method  string          `json:"method,omitempty"`
	Params  json.RawMessage `json:"params,omitempty"`
	Error   *jsonError      `json:"error,omitempty"`
	Result  json.RawMessage `json:"result,omitempty"`
}

A value of this type can a JSON-RPC request, notification, successful response or error response. Which one it is depends on the fields.

Jump to

Keyboard shortcuts

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