client

package
v0.0.0-...-78810ce Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: Apache-2.0, MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_GAS_PRICE = 20_000_000_000
View Source
const DEFAULT_GAS_TIP = 3_000_000_000

Variables

View Source
var ERC20 abi.ABI

Functions

func ReplaceIncompatiableEvmResponses

func ReplaceIncompatiableEvmResponses(body []byte) []byte

Types

type Client

type Client struct {
	Asset       xc.ITask
	EthClient   *ethclient.Client
	ChainId     *big.Int
	Interceptor *utils.HttpInterceptor
}

Client for EVM

func NewClient

func NewClient(asset xc.ITask) (*Client, error)

NewClient returns a new EVM Client

func (*Client) DefaultGasLimit

func (client *Client) DefaultGasLimit() uint64

func (*Client) FetchBalance

func (client *Client) FetchBalance(ctx context.Context, addr xc.Address) (xc.AmountBlockchain, error)

Fetch the balance of the asset that this client is configured for

func (*Client) FetchDecimals

func (client *Client) FetchDecimals(ctx context.Context, contract xc.ContractAddress) (int, error)

func (*Client) FetchLegacyTxInfo

func (client *Client) FetchLegacyTxInfo(ctx context.Context, txHashStr xc.TxHash) (xc.LegacyTxInfo, error)

FetchLegacyTxInfo returns tx info for a EVM tx

func (*Client) FetchLegacyTxInput

func (client *Client) FetchLegacyTxInput(ctx context.Context, from xc.Address, to xc.Address) (xc.TxInput, error)

func (*Client) FetchNativeBalance

func (client *Client) FetchNativeBalance(ctx context.Context, addr xc.Address) (xc.AmountBlockchain, error)

Fetch the balance of the native asset that this client is configured for

func (*Client) FetchStakeBalance

func (cli *Client) FetchStakeBalance(ctx context.Context, args xcclient.StakedBalanceArgs) ([]*xcclient.StakedBalance, error)

func (*Client) FetchStakingInput

func (cli *Client) FetchStakingInput(ctx context.Context, args xcbuilder.StakeArgs) (xc.StakeTxInput, error)

func (*Client) FetchTransferInput

func (client *Client) FetchTransferInput(ctx context.Context, args xcbuilder.TransferArgs) (xc.TxInput, error)

func (*Client) FetchTxInfo

func (client *Client) FetchTxInfo(ctx context.Context, txHashStr xc.TxHash) (xclient.TxInfo, error)

func (*Client) FetchUnsimulatedInput

func (client *Client) FetchUnsimulatedInput(ctx context.Context, from xc.Address) (*tx_input.TxInput, error)

FetchLegacyTxInput returns tx input for a EVM tx

func (*Client) FetchUnstakingInput

func (cli *Client) FetchUnstakingInput(ctx context.Context, args xcbuilder.StakeArgs) (xc.UnstakeTxInput, error)

func (*Client) FetchValidator

func (client *Client) FetchValidator(ctx context.Context, validator string) (*GetValidatorResponse, error)

Fetch validator using beacon API

func (*Client) FetchValidatorBalance

func (client *Client) FetchValidatorBalance(ctx context.Context, validator string) (*xcclient.StakedBalance, error)

func (*Client) FetchWithdrawInput

func (cli *Client) FetchWithdrawInput(ctx context.Context, args xcbuilder.StakeArgs) (xc.WithdrawTxInput, error)

func (*Client) Get

func (cli *Client) Get(path string, response any) error

func (*Client) GetAndPrint

func (cli *Client) GetAndPrint(path string) error

func (*Client) GetNonce

func (client *Client) GetNonce(ctx context.Context, from xc.Address) (uint64, error)

func (*Client) Post

func (cli *Client) Post(path string, requestBody any, response any) error

func (*Client) Send

func (cli *Client) Send(method string, path string, requestBody any, response any) error

func (*Client) SimulateGasWithLimit

func (client *Client) SimulateGasWithLimit(ctx context.Context, from xc.Address, trans *tx.Tx) (uint64, error)

Simulate a transaction to get the estimated gas limit

func (*Client) SubmitTx

func (client *Client) SubmitTx(ctx context.Context, trans xc.Tx) error

SubmitTx submits a EVM tx

func (*Client) TraceEthMovements

func (client *Client) TraceEthMovements(ctx context.Context, txHash common.Hash) (tx.SourcesAndDests, error)

func (*Client) TraceTransaction

func (client *Client) TraceTransaction(ctx context.Context, txHash common.Hash) (*TraceTransactionResult, error)

Implements debug_traceTransaction, which is supported on GETH and most RPC providers, but likely not implemented on public nodes. This will reveal ETH transfers in internal transactions and removes the need for us to manually parse "multi transfers".

func (*Client) TxPoolContentFrom

func (client *Client) TxPoolContentFrom(ctx context.Context, from common.Address) (*TxPoolResult, error)

Get current pending transaction queue for a given address

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type GetValidatorResponse

type GetValidatorResponse struct {
	ExecutionOptimistic bool      `json:"execution_optimistic"`
	Finalized           bool      `json:"finalized"`
	Data                Validator `json:"data"`
}

type TraceTransactionArgs

type TraceTransactionArgs struct {
	Tracer string `json:"tracer"`
}

type TraceTransactionResult

type TraceTransactionResult struct {
	Gas     hexutil.Uint              `json:"gas"`
	GasUsed hexutil.Uint              `json:"gasUsed"`
	To      common.Address            `json:"to"`
	From    common.Address            `json:"from"`
	Input   hexutil.Bytes             `json:"input"`
	Value   hexutil.Big               `json:"value"`
	Type    TraceTransactionType      `json:"type"`
	Calls   []*TraceTransactionResult `json:"calls"`
}

func FlattenTraceResult

func FlattenTraceResult(result *TraceTransactionResult, traces []*TraceTransactionResult) []*TraceTransactionResult

Recurse through all of the traces and provide them as a linear set of traces.

type TraceTransactionType

type TraceTransactionType string
var CALL TraceTransactionType = "CALL"
var DELEGATE_CALL TraceTransactionType = "DELEGATECALL"

type TxPoolPendingMap

type TxPoolPendingMap struct {
}

type TxPoolResult

type TxPoolResult struct {
	// map of nonce to txinfo
	Pending map[string]*TxPoolTxInfo `json:"pending"`
}

func (*TxPoolResult) InfoFor

func (result *TxPoolResult) InfoFor(address string) (*TxPoolTxInfo, bool)

return first pending tx for a given address (should only be 1 entry..)

func (*TxPoolResult) PendingCount

func (result *TxPoolResult) PendingCount() int

type TxPoolTxInfo

type TxPoolTxInfo struct {
	From                 string      `json:"from"`
	Gas                  hexutil.Big `json:"gas"`
	GasPrice             hexutil.Big `json:"gasPrice"`
	MaxFeePerGas         hexutil.Big `json:"maxFeePerGas"`
	MaxPriorityFeePerGas hexutil.Big `json:"maxPriorityFeePerGas"`
	Hash                 string      `json:"hash"`
}

type Validator

type Validator struct {
	Index     string           `json:"index"`
	Balance   string           `json:"balance"`
	Status    ValidatorStatus  `json:"status"`
	Validator ValidatorDetails `json:"validator"`
}

type ValidatorDetails

type ValidatorDetails struct {
	Pubkey                     string `json:"pubkey"`
	WithdrawalCredentials      string `json:"withdrawal_credentials"`
	EffectiveBalance           string `json:"effective_balance"`
	Slashed                    bool   `json:"slashed"`
	ActivationEligibilityEpoch string `json:"activation_eligibility_epoch"`
	ActivationEpoch            string `json:"activation_epoch"`
	ExitEpoch                  string `json:"exit_epoch"`
	WithdrawableEpoch          string `json:"withdrawable_epoch"`
}

type ValidatorStatus

type ValidatorStatus string

func (ValidatorStatus) ToState

func (s ValidatorStatus) ToState() (xcclient.StakeState, bool)

Directories

Path Synopsis
staking

Jump to

Keyboard shortcuts

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