client

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleResponse

func HandleResponse[DataType any](context *RequesterContext, resp *http.Response, path string, err error) (*api.ApiResponse[DataType], error)

Processes a response to a request

func MakeBatchArg

func MakeBatchArg[DataType BatchInputType](input []DataType) string

Converts an array of inputs into a comma-delimited string

func RawGetRequest

func RawGetRequest[DataType any](context *RequesterContext, path string, params map[string]string) (*api.ApiResponse[DataType], error)

Submit a GET request to the API server

func RawPostRequest

func RawPostRequest[DataType any](context *RequesterContext, path string, body string) (*api.ApiResponse[DataType], error)

Submit a POST request to the API server

func SendGetRequest

func SendGetRequest[DataType any](r IRequester, method string, requestName string, args map[string]string) (*api.ApiResponse[DataType], error)

Submit a GET request to the API server

func SendPostRequest

func SendPostRequest[DataType any](r IRequester, method string, requestName string, body any) (*api.ApiResponse[DataType], error)

Submit a POST request to the API server

Types

type ApiClient

type ApiClient struct {
	Service *ServiceRequester
	Tx      *TxRequester
	Utils   *UtilsRequester
	Wallet  *WalletRequester
	// contains filtered or unexported fields
}

Binder for the Hyperdrive daemon API server

func NewApiClient

func NewApiClient(baseRoute string, socketPath string, debugMode bool) *ApiClient

Creates a new API client instance

func (*ApiClient) SetDebug

func (c *ApiClient) SetDebug(debug bool)

Set debug mode

type BatchInputType

type BatchInputType interface {
	uint64 | common.Address | beacon.ValidatorPubkey
}

Types that can be batched into a comma-delmited string

type IRequester

type IRequester interface {
	// The human-readable requester name (for logging)
	GetName() string

	// The name of the subroute to send requests to
	GetRoute() string

	// Context to hold settings and utilities the requester should use
	GetContext() *RequesterContext
}

IRequester is an interface for making HTTP requests to a specific subroute on the Hyperdrive Daemon

type RequesterContext

type RequesterContext struct {
	// The path to the socket to send requests to
	SocketPath string

	// An HTTP Client for sending requests
	Client *http.Client

	// Whether or not to print debug logs
	DebugMode bool

	// Logger to print debug messages to
	Log *log.ColorLogger

	// The base route for the client to send requests to (<http://<base>/<route>/<method>)
	Base string
}

The context passed into a requester

type ServiceRequester

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

func NewServiceRequester

func NewServiceRequester(context *RequesterContext) *ServiceRequester

func (*ServiceRequester) ClientStatus

Gets the status of the configured Execution and Beacon clients

func (*ServiceRequester) GetConfig

Gets the Hyperdrive configuration

func (*ServiceRequester) GetContext

func (r *ServiceRequester) GetContext() *RequesterContext

func (*ServiceRequester) GetName

func (r *ServiceRequester) GetName() string

func (*ServiceRequester) GetRoute

func (r *ServiceRequester) GetRoute() string

func (*ServiceRequester) RestartContainer

func (r *ServiceRequester) RestartContainer(container string) (*api.ApiResponse[api.SuccessData], error)

Restarts a Docker container

func (*ServiceRequester) TerminateDataFolder

Deletes the data folder including the wallet file, password file, and all validator keys. Don't use this unless you have a very good reason to do it (such as switching from Prater to Mainnet).

func (*ServiceRequester) Version

Gets the version of the daemon

type TxRequester

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

func NewTxRequester

func NewTxRequester(context *RequesterContext) *TxRequester

func (*TxRequester) GetContext

func (r *TxRequester) GetContext() *RequesterContext

func (*TxRequester) GetName

func (r *TxRequester) GetName() string

func (*TxRequester) GetRoute

func (r *TxRequester) GetRoute() string

func (*TxRequester) SignTx

func (r *TxRequester) SignTx(txSubmission *eth.TransactionSubmission, nonce *big.Int, maxFee *big.Int, maxPriorityFee *big.Int) (*api.ApiResponse[api.TxSignTxData], error)

Use the node private key to sign a transaction without submitting it

func (*TxRequester) SignTxBatch

func (r *TxRequester) SignTxBatch(txSubmissions []*eth.TransactionSubmission, firstNonce *big.Int, maxFee *big.Int, maxPriorityFee *big.Int) (*api.ApiResponse[api.TxBatchSignTxData], error)

Use the node private key to sign a batch of transactions without submitting them

func (*TxRequester) SubmitTx

func (r *TxRequester) SubmitTx(txSubmission *eth.TransactionSubmission, nonce *big.Int, maxFee *big.Int, maxPriorityFee *big.Int) (*api.ApiResponse[api.TxData], error)

Submit a transaction

func (*TxRequester) SubmitTxBatch

func (r *TxRequester) SubmitTxBatch(txSubmissions []*eth.TransactionSubmission, firstNonce *big.Int, maxFee *big.Int, maxPriorityFee *big.Int) (*api.ApiResponse[api.BatchTxData], error)

Submit a batch of transactions

func (*TxRequester) WaitForTransaction

func (r *TxRequester) WaitForTransaction(txHash common.Hash) (*api.ApiResponse[api.SuccessData], error)

Wait for a transaction

type UtilsRequester

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

func NewUtilsRequester

func NewUtilsRequester(context *RequesterContext) *UtilsRequester

func (*UtilsRequester) Balance

Get the node's ETH balance

func (*UtilsRequester) GetContext

func (r *UtilsRequester) GetContext() *RequesterContext

func (*UtilsRequester) GetName

func (r *UtilsRequester) GetName() string

func (*UtilsRequester) GetRoute

func (r *UtilsRequester) GetRoute() string

func (*UtilsRequester) ResolveEns

func (r *UtilsRequester) ResolveEns(address common.Address, name string) (*api.ApiResponse[api.UtilsResolveEnsData], error)

Resolves an ENS name or reserve resolves an address

type WalletRequester

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

func NewWalletRequester

func NewWalletRequester(context *RequesterContext) *WalletRequester

func (*WalletRequester) DeletePassword

func (r *WalletRequester) DeletePassword() (*api.ApiResponse[api.SuccessData], error)

Delete the wallet keystore's password from disk

func (*WalletRequester) Export

Export wallet

func (*WalletRequester) ExportEthKey

Export the wallet in encrypted ETH key format

func (*WalletRequester) GenerateValidatorKey

func (r *WalletRequester) GenerateValidatorKey(path string) (*api.ApiResponse[api.WalletGenerateValidatorKeyData], error)

Generate a validator key derived from the node wallet's seed

func (*WalletRequester) GetContext

func (r *WalletRequester) GetContext() *RequesterContext

func (*WalletRequester) GetName

func (r *WalletRequester) GetName() string

func (*WalletRequester) GetRoute

func (r *WalletRequester) GetRoute() string

func (*WalletRequester) Initialize

func (r *WalletRequester) Initialize(derivationPath *string, index *uint64, saveWallet bool, password string, savePassword bool) (*api.ApiResponse[api.WalletInitializeData], error)

Initialize the wallet with a new key

func (*WalletRequester) Masquerade

func (r *WalletRequester) Masquerade(address common.Address) (*api.ApiResponse[api.SuccessData], error)

Set the node address to an arbitrary address

func (*WalletRequester) Rebuild

Rebuild the validator keys associated with the wallet

func (*WalletRequester) Recover

func (r *WalletRequester) Recover(derivationPath *string, mnemonic *string, index *uint64, password string, save bool) (*api.ApiResponse[api.WalletRecoverData], error)

Recover wallet

func (*WalletRequester) RestoreAddress

func (r *WalletRequester) RestoreAddress() (*api.ApiResponse[api.SuccessData], error)

Set the node address back to the wallet address

func (*WalletRequester) SearchAndRecover

func (r *WalletRequester) SearchAndRecover(mnemonic string, address common.Address, password string, save bool) (*api.ApiResponse[api.WalletSearchAndRecoverData], error)

Search and recover wallet

func (*WalletRequester) SendMessage

func (r *WalletRequester) SendMessage(message []byte, address common.Address) (*api.ApiResponse[api.TxInfoData], error)

Sends a zero-value message with a payload

func (*WalletRequester) SetEnsName

Set an ENS reverse record to a name

func (*WalletRequester) SetPassword

func (r *WalletRequester) SetPassword(password string, save bool) (*api.ApiResponse[api.SuccessData], error)

Sets the wallet keystore's password

func (*WalletRequester) SignMessage

func (r *WalletRequester) SignMessage(message []byte) (*api.ApiResponse[api.WalletSignMessageData], error)

Use the node private key to sign an arbitrary message

func (*WalletRequester) SignTx added in v0.2.3

func (r *WalletRequester) SignTx(message []byte) (*api.ApiResponse[api.WalletSignTxData], error)

Use the node private key to sign a transaction

func (*WalletRequester) Status

Get wallet status

func (*WalletRequester) TestRecover

func (r *WalletRequester) TestRecover(derivationPath *string, mnemonic string, index *uint64) (*api.ApiResponse[api.WalletRecoverData], error)

Recover wallet in test-mode so none of the artifacts are saved

func (*WalletRequester) TestSearchAndRecover

func (r *WalletRequester) TestSearchAndRecover(mnemonic string, address common.Address) (*api.ApiResponse[api.WalletSearchAndRecoverData], error)

Search for and recover the wallet in test-mode so none of the artifacts are saved

Jump to

Keyboard shortcuts

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