Documentation
¶
Overview ¶
Copyright (C) 2025, Lux Industries Inc. All rights reserved. See the file LICENSE for licensing terms.
Copyright (C) 2025, Lux Industries Inc. All rights reserved. See the file LICENSE for licensing terms.
Copyright (C) 2025, Lux Industries Inc. All rights reserved. See the file LICENSE for licensing terms.
Copyright (C) 2025, Lux Industries Inc. All rights reserved. See the file LICENSE for licensing terms.
Index ¶
- Variables
- func CalculateEvmFeeInLux(gasUsed uint64, gasPrice *big.Int) float64
- func ConvertToNanoLux(balance *big.Int) *big.Int
- func ExtractWarpMessageFromLogs(logs []*types.Log) (*warp.UnsignedMessage, error)
- func ExtractWarpMessageFromReceipt(receipt *types.Receipt) (*warp.UnsignedMessage, error)
- func GetClientWithoutScheme(rpcURL string) (ethclient.Client, string, error)
- func GetErrorFromTrace(trace map[string]interface{}, functionSignatureToError map[string]error) (error, error)
- func GetEventFromLogs[T any](logs []*types.Log, parser func(log types.Log) (T, error)) (T, error)
- func GetFunctionSelector(functionSignature string) string
- func GetTxTrace(rpcURL string, txID string) (map[string]interface{}, error)
- func GetWarpMessagesFromLogs(logs []*types.Log) []*warp.UnsignedMessage
- func HasScheme(rpcURL string) (bool, error)
- func PrivateKeyToAddress(privateKey string) (common.Address, error)
- func TransactionError(tx *types.Transaction, err error, msg string, args ...interface{}) error
- func TxDump(description string, tx *types.Transaction) (string, error)
- type Client
- func (client Client) BlockByNumber(n *big.Int) (*types.Block, error)
- func (client Client) BlockNumber() (uint64, error)
- func (client Client) CalculateTxParams(address string) (*big.Int, *big.Int, uint64, error)
- func (client Client) ChainConfig() (*params.ChainConfigWithUpgradesJSON, error)
- func (client Client) Close()
- func (client Client) ContractAlreadyDeployed(contractAddress string) (bool, error)
- func (client Client) CreateDummyBlocks(numBlocks int, privKeyStr string) error
- func (client Client) EstimateBaseFee() (*big.Int, error)
- func (client Client) EstimateGasLimit(msg interfaces.CallMsg) (uint64, error)
- func (client Client) FilterLogs(query interfaces.FilterQuery) ([]types.Log, error)
- func (client Client) FundAddress(sourceAddressPrivateKeyStr string, targetAddressStr string, amount *big.Int) (*types.Receipt, error)
- func (client Client) GetAddressBalance(addressStr string) (*big.Int, error)
- func (client Client) GetChainID() (*big.Int, error)
- func (client Client) GetContractBytecode(contractAddressStr string) ([]byte, error)
- func (client Client) GetPrivateKeyBalance(privateKey string) (*big.Int, error)
- func (client Client) GetTxOptsWithSigner(prefundedPrivateKeyStr string) (*bind.TransactOpts, error)
- func (client Client) IssueTx(txStr string) error
- func (client Client) NonceAt(addressStr string) (uint64, error)
- func (client Client) SendTransaction(tx *types.Transaction) error
- func (client Client) SetupProposerVM(privKey string) error
- func (client Client) SuggestGasTipCap() (*big.Int, error)
- func (client Client) TransactWithWarpMessage(from common.Address, privateKeyStr string, warpMessage *luxWarp.Message, ...) (*types.Transaction, error)
- func (client Client) TransactionReceipt(hash common.Hash) (*types.Receipt, error)
- func (client Client) WaitForEVMBootstrapped(timeout time.Duration) error
- func (client Client) WaitForNewBlock(prevBlockNumber uint64, totalDuration time.Duration) error
- func (client Client) WaitForTransaction(tx *types.Transaction) (*types.Receipt, bool, error)
- type RawClient
Constants ¶
This section is empty.
Variables ¶
var ErrUnknownErrorSelector = fmt.Errorf("unknown error selector")
Functions ¶
func ConvertToNanoLux ¶
ConvertToNanoLux converts a balance in Lux to NanoLux. It adds 0.5 to the balance before dividing by 1e9 to round it to the nearest whole number.
func ExtractWarpMessageFromLogs ¶
func ExtractWarpMessageFromLogs( logs []*types.Log, ) (*warp.UnsignedMessage, error)
get first unsigned warp message contained in [logs]
func ExtractWarpMessageFromReceipt ¶
func ExtractWarpMessageFromReceipt( receipt *types.Receipt, ) (*warp.UnsignedMessage, error)
get first unsigned warp message contained in [receipt]
func GetClientWithoutScheme ¶
tries to connect an ethclient to a rpc url without scheme, by trying out different possible schemes: ws, wss, https, http
func GetErrorFromTrace ¶
func GetErrorFromTrace( trace map[string]interface{}, functionSignatureToError map[string]error, ) (error, error)
returns golang error associated with [trace] by using [functionSignatureToError] to map function signatures to evm function selectors in [trace], and then to golang errors first returned error is the mapped error, second error is for errors obtained executing this function
func GetEventFromLogs ¶
Returns the first log in 'logs' that is successfully parsed by 'parser'
func GetFunctionSelector ¶
returns evm function selector code for the given function signature evm maps function and error signatures into codes that are then used in traces
func GetTxTrace ¶
returns a trace for the given [txID] on [rpcURL] supports [repeatsOnFailure] failures
func GetWarpMessagesFromLogs ¶
func GetWarpMessagesFromLogs( logs []*types.Log, ) []*warp.UnsignedMessage
get all unsigned warp messages contained in [logs]
func PrivateKeyToAddress ¶
returns the public address associated with [privateKey]
func TransactionError ¶
func TransactionError(tx *types.Transaction, err error, msg string, args ...interface{}) error
transform a tx operation error into an error that contains: - the [err] itself - the [tx] hash (or information on the tx not being submitted) - another descriptive [msg], together with formated [args]
Types ¶
type Client ¶
wraps over ethclient for calls used by SDK. featues: - finds out url scheme in case it is missing, to connect to ws/wss/http/https - repeats to try to recover from failures, generating its own context for each call - logs rpc url in case of failure - receives addresses and private keys as strings
func (Client) BlockByNumber ¶
gets block [n] supports [repeatsOnFailure] failures
func (Client) BlockNumber ¶
gets current height supports [repeatsOnFailure] failures
func (Client) CalculateTxParams ¶
Returns gasFeeCap, gasTipCap, and nonce to be used when constructing a transaction supports [repeatsOnFailure] failures on each step
func (Client) ChainConfig ¶
func (client Client) ChainConfig() (*params.ChainConfigWithUpgradesJSON, error)
returns the chain conf supports [repeatsOnFailure] failures
func (Client) ContractAlreadyDeployed ¶
indicates wether a contract is deployed on [contractAddress] supports [repeatsOnFailure] failures
func (Client) CreateDummyBlocks ¶
issue dummy txs to create the given number of blocks
func (Client) EstimateBaseFee ¶
returns the estimated base fee supports [repeatsOnFailure] failures
func (Client) EstimateGasLimit ¶
func (client Client) EstimateGasLimit( msg interfaces.CallMsg, ) (uint64, error)
returns the estimated gas limit supports [repeatsOnFailure] failures
func (Client) FilterLogs ¶
func (client Client) FilterLogs(query interfaces.FilterQuery) ([]types.Log, error)
get logs as given by [query] supports [repeatsOnFailure] failures
func (Client) FundAddress ¶
func (client Client) FundAddress( sourceAddressPrivateKeyStr string, targetAddressStr string, amount *big.Int, ) (*types.Receipt, error)
transfers [amount] to [targetAddressStr] using [sourceAddressPrivateKeyStr] supports [repeatsOnFailure] failures on each step
func (Client) GetAddressBalance ¶
returns the balance for [address] supports [repeatsOnFailure] failures
func (Client) GetChainID ¶
returns the chain ID supports [repeatsOnFailure] failures
func (Client) GetContractBytecode ¶
returns the contract bytecode at [contractAddress] supports [repeatsOnFailure] failures
func (Client) GetPrivateKeyBalance ¶
returns the balance for [privateKey] supports [repeatsOnFailure] failures
func (Client) GetTxOptsWithSigner ¶
func (client Client) GetTxOptsWithSigner( prefundedPrivateKeyStr string, ) (*bind.TransactOpts, error)
returns tx options that include signer for [prefundedPrivateKeyStr] supports [repeatsOnFailure] failures when gathering chain info
func (Client) IssueTx ¶
encode [txStr] to binary, sends and waits for it supports [repeatsOnFailure] failures on each step
func (Client) SendTransaction ¶
func (client Client) SendTransaction( tx *types.Transaction, ) error
sends [tx] supports [repeatsOnFailure] failures
func (Client) SetupProposerVM ¶
issue transactions on [client] so as to activate Proposer VM Fork this should generate a PostForkBlock because its parent block (genesis) has a timestamp (0) that is greater than or equal to the fork activation time of 0. Therefore, subsequent blocks should be built with BuildBlockWithContext. the current timestamp should be after the ProposerVM activation time (aka ApricotPhase4). supports [repeatsOnFailure] failures on each step
func (Client) SuggestGasTipCap ¶
returns the suggested gas tip supports [repeatsOnFailure] failures
func (Client) TransactWithWarpMessage ¶
func (client Client) TransactWithWarpMessage( from common.Address, privateKeyStr string, warpMessage *luxWarp.Message, contract common.Address, callData []byte, value *big.Int, generateRawTxOnly bool, ) (*types.Transaction, error)
generates a transaction signed with [privateKeyStr], calling a [contract] method using [callData] including [warpMessage] in the tx accesslist if [generateRawTxOnly] is set, it generates a similar, unsigned tx, with given [from] address
func (Client) TransactionReceipt ¶
get tx receipt for hash supports [repeatsOnFailure] failures
func (Client) WaitForEVMBootstrapped ¶
waits for [timeout] until evm is bootstrapped considers evm is bootstrapped if it responds to an evm call (ChainID)
func (Client) WaitForNewBlock ¶
waits until current height is bigger than the given previous height at [prevBlockNumber] supports [repeatsOnFailure] failures on each step
func (Client) WaitForTransaction ¶
waits for [tx]'s receipt to have successful state supports [repeatsOnFailure] failures
type RawClient ¶
type RawClient struct {
RPCClient *rpc.Client
URL string
// also used at mocks
CallContext func(context.Context, interface{}, string, ...interface{}) error
}
wraps over rpc.Client for calls used by SDK. used to make evm calls not available in ethclient: - debug trace call - debug trace transaction features: - finds out url scheme in case it is missing, to connect to ws/wss/http/https - repeats to try to recover from failures, generating its own context for each call - logs rpc url in case of failure
func GetRawClient ¶
connects a raw evm rpc client to the given [rpcURL] supports [repeatsOnFailure] failures
func (RawClient) DebugTraceCall ¶
returns a trace for making a call on [client] with the given [data] supports [repeatsOnFailure] failures