rocketpool

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GasLimitMultiplier    float64 = 1.5
	MaxGasLimit           uint64  = 30000000
	NethermindRevertRegex string  = "Reverted 0x(?P<message>[0-9a-fA-F]+).*"
)

Transaction settings

View Source
const CacheTTL = 300 // 5 minutes

Cache settings

Variables

This section is empty.

Functions

func DecodeAbi

func DecodeAbi(abiEncoded string) (*abi.ABI, error)

Decode, decompress and parse a zlib-compressed, base64-encoded ABI

func EncodeAbiStr

func EncodeAbiStr(abiStr string) (string, error)

zlib-compress and base64-encode an ABI JSON string

func GetContractVersion

func GetContractVersion(rp *RocketPool, contractAddress common.Address, opts *bind.CallOpts) (uint8, error)

Get the version of the given contract

Types

type Contract

type Contract struct {
	Contract *bind.BoundContract
	Address  *common.Address
	ABI      *abi.ABI
	Client   ExecutionClient
}

Contract type wraps go-ethereum bound contract

func GetRocketVersionContractForAddress

func GetRocketVersionContractForAddress(rp *RocketPool, address common.Address) (*Contract, error)

Get the rocketVersion contract binding at the given address

func (*Contract) Call

func (c *Contract) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error

Call a contract method

func (*Contract) GetTransactionEvents

func (c *Contract) GetTransactionEvents(txReceipt *types.Receipt, eventName string, eventPrototype interface{}) ([]interface{}, error)

Get contract events from a transaction eventPrototype must be an event struct type Returns a slice of untyped values; assert returned events to event struct type

func (*Contract) GetTransactionGasInfo

func (c *Contract) GetTransactionGasInfo(opts *bind.TransactOpts, method string, params ...interface{}) (GasInfo, error)

Get Gas Limit for transaction

func (*Contract) GetTransferGasInfo

func (c *Contract) GetTransferGasInfo(opts *bind.TransactOpts) (GasInfo, error)

Get gas limit for a transfer call

func (*Contract) Transact

func (c *Contract) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error)

Transact on a contract method and wait for a receipt

func (*Contract) Transfer

func (c *Contract) Transfer(opts *bind.TransactOpts) (common.Hash, error)

Transfer ETH to a contract and wait for a receipt

type ExecutionClient

type ExecutionClient interface {

	// CodeAt returns the code of the given account. This is needed to differentiate
	// between contract internal errors and the local chain being out of sync.
	CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)

	// CallContract executes an Ethereum contract call with the specified data as the
	// input.
	CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)

	// HeaderByHash returns the block header with the given hash.
	HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)

	// HeaderByNumber returns a block header from the current canonical chain. If number is
	// nil, the latest known header is returned.
	HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)

	// PendingCodeAt returns the code of the given account in the pending state.
	PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)

	// PendingNonceAt retrieves the current pending nonce associated with an account.
	PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)

	// SuggestGasPrice retrieves the currently suggested gas price to allow a timely
	// execution of a transaction.
	SuggestGasPrice(ctx context.Context) (*big.Int, error)

	// SuggestGasTipCap retrieves the currently suggested 1559 priority fee to allow
	// a timely execution of a transaction.
	SuggestGasTipCap(ctx context.Context) (*big.Int, error)

	// EstimateGas tries to estimate the gas needed to execute a specific
	// transaction based on the current pending state of the backend blockchain.
	// There is no guarantee that this is the true gas limit requirement as other
	// transactions may be added or removed by miners, but it should provide a basis
	// for setting a reasonable default.
	EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error)

	// SendTransaction injects the transaction into the pending pool for execution.
	SendTransaction(ctx context.Context, tx *types.Transaction) error

	// FilterLogs executes a log filter operation, blocking during execution and
	// returning all the results in one batch.
	//
	// TODO(karalabe): Deprecate when the subscription one can return past data too.
	FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error)

	// SubscribeFilterLogs creates a background log filtering operation, returning
	// a subscription immediately, which can be used to stream the found events.
	SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)

	// TransactionReceipt returns the receipt of a transaction by transaction hash.
	// Note that the receipt is not available for pending transactions.
	TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)

	// BlockNumber returns the most recent block number
	BlockNumber(ctx context.Context) (uint64, error)

	// BalanceAt returns the wei balance of the given account.
	// The block number can be nil, in which case the balance is taken from the latest known block.
	BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)

	// TransactionByHash returns the transaction with the given hash.
	TransactionByHash(ctx context.Context, hash common.Hash) (tx *types.Transaction, isPending bool, err error)

	// NonceAt returns the account nonce of the given account.
	// The block number can be nil, in which case the nonce is taken from the latest known block.
	NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)

	// SyncProgress retrieves the current progress of the sync algorithm. If there's
	// no sync currently running, it returns nil.
	SyncProgress(ctx context.Context) (*ethereum.SyncProgress, error)
}

This is the common interface for execution clients.

type GasInfo

type GasInfo struct {
	EstGasLimit  uint64 `json:"estGasLimit"`
	SafeGasLimit uint64 `json:"safeGasLimit"`
}

Response for gas limits from network and from user request

type LegacyVersionWrapper

type LegacyVersionWrapper interface {
	GetVersion() *version.Version
	GetVersionedContractName(contractName string) (string, bool)
	GetEncodedABI(contractName string) string
	GetContract(contractName string, opts *bind.CallOpts) (*Contract, error)
	GetContractWithAddress(contractName string, address common.Address) (*Contract, error)
}

Wrapper for legacy contract versions

type LegacyVersionWrapper_v1_0_0

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

A wrapper that holds the updated contract information for this version

func (*LegacyVersionWrapper_v1_0_0) GetContract

func (m *LegacyVersionWrapper_v1_0_0) GetContract(contractName string, opts *bind.CallOpts) (*Contract, error)

Get the contract with the provided name for this version of Rocket Pool

func (*LegacyVersionWrapper_v1_0_0) GetContractWithAddress

func (m *LegacyVersionWrapper_v1_0_0) GetContractWithAddress(contractName string, address common.Address) (*Contract, error)

func (*LegacyVersionWrapper_v1_0_0) GetEncodedABI

func (m *LegacyVersionWrapper_v1_0_0) GetEncodedABI(contractName string) string

Get the ABI for the provided contract

func (*LegacyVersionWrapper_v1_0_0) GetVersion

func (m *LegacyVersionWrapper_v1_0_0) GetVersion() *version.Version

Get the version for this manager

func (*LegacyVersionWrapper_v1_0_0) GetVersionedContractName

func (m *LegacyVersionWrapper_v1_0_0) GetVersionedContractName(contractName string) (string, bool)

Get the versioned name of the contract if it was upgraded as part of this deployment

type LegacyVersionWrapper_v1_1_0

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

A wrapper that holds the updated contract information for this version

func (*LegacyVersionWrapper_v1_1_0) GetContract

func (m *LegacyVersionWrapper_v1_1_0) GetContract(contractName string, opts *bind.CallOpts) (*Contract, error)

Get the contract with the provided name for this version of Rocket Pool

func (*LegacyVersionWrapper_v1_1_0) GetContractWithAddress

func (m *LegacyVersionWrapper_v1_1_0) GetContractWithAddress(contractName string, address common.Address) (*Contract, error)

func (*LegacyVersionWrapper_v1_1_0) GetEncodedABI

func (m *LegacyVersionWrapper_v1_1_0) GetEncodedABI(contractName string) string

Get the ABI for the provided contract

func (*LegacyVersionWrapper_v1_1_0) GetVersion

func (m *LegacyVersionWrapper_v1_1_0) GetVersion() *version.Version

Get the version for this manager

func (*LegacyVersionWrapper_v1_1_0) GetVersionedContractName

func (m *LegacyVersionWrapper_v1_1_0) GetVersionedContractName(contractName string) (string, bool)

Get the versioned name of the contract if it was upgraded as part of this deployment

type LegacyVersionWrapper_v1_1_0_rc1

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

A wrapper that holds the updated contract information for this version

func (*LegacyVersionWrapper_v1_1_0_rc1) GetContract

func (m *LegacyVersionWrapper_v1_1_0_rc1) GetContract(contractName string, opts *bind.CallOpts) (*Contract, error)

Get the contract with the provided name for this version of Rocket Pool

func (*LegacyVersionWrapper_v1_1_0_rc1) GetContractWithAddress

func (m *LegacyVersionWrapper_v1_1_0_rc1) GetContractWithAddress(contractName string, address common.Address) (*Contract, error)

func (*LegacyVersionWrapper_v1_1_0_rc1) GetEncodedABI

func (m *LegacyVersionWrapper_v1_1_0_rc1) GetEncodedABI(contractName string) string

Get the ABI for the provided contract

func (*LegacyVersionWrapper_v1_1_0_rc1) GetVersion

func (m *LegacyVersionWrapper_v1_1_0_rc1) GetVersion() *version.Version

Get the version for this manager

func (*LegacyVersionWrapper_v1_1_0_rc1) GetVersionedContractName

func (m *LegacyVersionWrapper_v1_1_0_rc1) GetVersionedContractName(contractName string) (string, bool)

Get the versioned name of the contract if it was upgraded as part of this deployment

type RocketPool

type RocketPool struct {
	Client                ExecutionClient
	RocketStorage         *contracts.RocketStorage
	RocketStorageContract *Contract
	VersionManager        *VersionManager
	// contains filtered or unexported fields
}

Rocket Pool contract manager

func NewRocketPool

func NewRocketPool(client ExecutionClient, rocketStorageAddress common.Address) (*RocketPool, error)

Create new contract manager

func (*RocketPool) GetABI

func (rp *RocketPool) GetABI(contractName string, opts *bind.CallOpts) (*abi.ABI, error)

Load Rocket Pool contract ABIs

func (*RocketPool) GetABIs

func (rp *RocketPool) GetABIs(opts *bind.CallOpts, contractNames ...string) ([]*abi.ABI, error)

func (*RocketPool) GetAddress

func (rp *RocketPool) GetAddress(contractName string, opts *bind.CallOpts) (*common.Address, error)

Load Rocket Pool contract addresses

func (*RocketPool) GetAddresses

func (rp *RocketPool) GetAddresses(opts *bind.CallOpts, contractNames ...string) ([]*common.Address, error)

func (*RocketPool) GetContract

func (rp *RocketPool) GetContract(contractName string, opts *bind.CallOpts) (*Contract, error)

Load Rocket Pool contracts

func (*RocketPool) GetContracts

func (rp *RocketPool) GetContracts(opts *bind.CallOpts, contractNames ...string) ([]*Contract, error)

func (*RocketPool) MakeContract

func (rp *RocketPool) MakeContract(contractName string, address common.Address, opts *bind.CallOpts) (*Contract, error)

Create a Rocket Pool contract instance

type VersionManager

type VersionManager struct {
	V1_0_0     LegacyVersionWrapper
	V1_1_0_RC1 LegacyVersionWrapper
	V1_1_0     LegacyVersionWrapper
	// contains filtered or unexported fields
}

func NewVersionManager

func NewVersionManager(rp *RocketPool) *VersionManager

Jump to

Keyboard shortcuts

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