evm

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: Apache-2.0 Imports: 23 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 CheckError added in v0.3.0

func CheckError(err error) xc.ClientError

func HexToAddress added in v0.3.0

func HexToAddress(address xc.Address) (common.Address, error)

HexToAddress returns a go-ethereum Address decoded Crosschain address (hex string).

func NewAddressBuilder

func NewAddressBuilder(asset xc.ITask) (xc.AddressBuilder, error)

NewAddressBuilder creates a new EVM AddressBuilder

func NewLegacyTxBuilder added in v0.3.0

func NewLegacyTxBuilder(asset xc.ITask) (xc.TxBuilder, error)

NewTxBuilder creates a new EVM TxBuilder for legacy tx

func NewSigner

func NewSigner(asset xc.ITask) (xc.Signer, error)

NewSigner creates a new EVM Signer

func NewTxBuilder

func NewTxBuilder(asset xc.ITask) (xc.TxBuilder, error)

NewTxBuilder creates a new EVM TxBuilder

func TrimPrefixes added in v0.3.0

func TrimPrefixes(addressOrTxHash string) string

Types

type AddressBuilder

type AddressBuilder struct {
}

AddressBuilder for EVM

func (AddressBuilder) GetAddressFromPublicKey

func (ab AddressBuilder) GetAddressFromPublicKey(publicKeyBytes []byte) (xc.Address, error)

GetAddressFromPublicKey returns an Address given a public key

func (AddressBuilder) GetAllPossibleAddressesFromPublicKey

func (ab AddressBuilder) GetAllPossibleAddressesFromPublicKey(publicKeyBytes []byte) ([]xc.PossibleAddress, error)

GetAllPossibleAddressesFromPublicKey returns all PossubleAddress(es) given a public key

type Client

type Client struct {
	Asset           *xc.AssetConfig
	EthClient       *ethclient.Client
	RpcClient       *rpc.Client
	ChainId         *big.Int
	Interceptor     *HttpInterceptor
	EstimateGasFunc xc.EstimateGasFunc
	Legacy          bool
}

Client for EVM

func NewClient

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

NewClient returns a new EVM Client

func NewLegacyClient

func NewLegacyClient(cfg xc.ITask) (*Client, error)

NewLegacyClient returns a new EVM Client for legacy tx

func (*Client) ChainID added in v0.3.0

func (client *Client) ChainID() (*big.Int, error)

ChainID returns the ChainID

func (*Client) EstimateGas added in v0.3.0

func (client *Client) EstimateGas(ctx context.Context) (xc.AmountBlockchain, error)

EstimateGas estimates gas price for a Cosmos chain

func (*Client) FetchBalance added in v0.3.0

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

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

func (*Client) FetchNativeBalance added in v0.3.0

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

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

func (*Client) FetchTxInfo

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

FetchTxInfo returns tx info for a EVM tx

func (*Client) FetchTxInput

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

FetchTxInput returns tx input for a EVM tx

func (*Client) RegisterEstimateGasCallback added in v0.3.0

func (client *Client) RegisterEstimateGasCallback(fn xc.EstimateGasFunc)

RegisterEstimateGasCallback registers a callback to get gas price

func (*Client) SubmitTx

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

SubmitTx submits a EVM tx

type HttpInterceptor added in v0.3.0

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

Interceptor

func (*HttpInterceptor) Disable added in v0.3.0

func (i *HttpInterceptor) Disable()

func (*HttpInterceptor) Enable added in v0.3.0

func (i *HttpInterceptor) Enable()

func (HttpInterceptor) RoundTrip added in v0.3.0

func (i HttpInterceptor) RoundTrip(req *http.Request) (*http.Response, error)

type Signer

type Signer struct {
}

Signer for EVM

func (Signer) ImportPrivateKey added in v0.2.0

func (signer Signer) ImportPrivateKey(privateKey string) (xc.PrivateKey, error)

ImportPrivateKey imports an EVM private key

func (Signer) Sign

func (signer Signer) Sign(privateKey xc.PrivateKey, data xc.TxDataToSign) (xc.TxSignature, error)

Sign an EVM tx

type Tx

type Tx struct {
	EthTx  *types.Transaction
	Signer types.Signer
}

Tx for EVM

func (*Tx) AddSignatures added in v0.3.0

func (tx *Tx) AddSignatures(signatures ...xc.TxSignature) error

AddSignatures adds a signature to Tx

func (Tx) Amount added in v0.3.0

func (tx Tx) Amount() xc.AmountBlockchain

Amount returns the tx amount

func (Tx) ContractAddress added in v0.3.0

func (tx Tx) ContractAddress() xc.ContractAddress

ContractAddress returns the contract address for a token transfer

func (Tx) Fee added in v0.3.0

func (tx Tx) Fee(baseFeeUint uint64, gasUsedUint uint64) xc.AmountBlockchain

Fee returns the fee associated to the tx

func (Tx) From added in v0.3.0

func (tx Tx) From() xc.Address

From is the sender of a transfer

func (Tx) Hash

func (tx Tx) Hash() xc.TxHash

Hash returns the tx hash or id

func (Tx) IsContract added in v0.3.0

func (tx Tx) IsContract() bool

IsContract returns whether a tx is a contract or native transfer

func (Tx) ParseERC20TransferTx added in v0.3.0

func (tx Tx) ParseERC20TransferTx() (parsedTxInfo, error)

ParseERC20TransferTx parses the tx payload as ERC20 transfer

func (Tx) ParseMultisendTransferTx added in v0.3.0

func (tx Tx) ParseMultisendTransferTx() (parsedTxInfo, error)

ParseMultisendTransferTx parses the tx payload as multi-send transfer

func (*Tx) ParseTransfer added in v0.3.0

func (tx *Tx) ParseTransfer(receipt *types.Receipt, nativeAsset xc.NativeAsset) parsedTxInfo

ParseTransfer parses a tx and extracts higher-level transfer information

func (Tx) Serialize added in v0.3.0

func (tx Tx) Serialize() ([]byte, error)

Serialize returns the serialized tx

func (Tx) Sighashes added in v0.3.0

func (tx Tx) Sighashes() ([]xc.TxDataToSign, error)

Sighashes returns the tx payload to sign, aka sighash

func (Tx) To added in v0.3.0

func (tx Tx) To() xc.Address

To is the account receiving a transfer

type TxBuilder

type TxBuilder struct {
	Asset  xc.AssetConfig
	Legacy bool
}

TxBuilder for EVM

func (TxBuilder) NewNativeTransfer

func (txBuilder TxBuilder) NewNativeTransfer(from xc.Address, to xc.Address, amount xc.AmountBlockchain, input xc.TxInput) (xc.Tx, error)

NewNativeTransfer creates a new transfer for a native asset

func (TxBuilder) NewTokenTransfer

func (txBuilder TxBuilder) NewTokenTransfer(from xc.Address, to xc.Address, amount xc.AmountBlockchain, input xc.TxInput) (xc.Tx, error)

NewTokenTransfer creates a new transfer for a token asset

func (TxBuilder) NewTransfer

func (txBuilder TxBuilder) NewTransfer(from xc.Address, to xc.Address, amount xc.AmountBlockchain, input xc.TxInput) (xc.Tx, error)

NewTransfer creates a new transfer for an Asset, either native or token

type TxInput

type TxInput struct {
	xc.TxInputEnvelope
	Nonce    uint64
	GasLimit uint64
	// DynamicFeeTx
	GasTipCap xc.AmountBlockchain // maxPriorityFeePerGas
	GasFeeCap xc.AmountBlockchain // maxFeePerGas
	// LegacyTx
	GasPrice xc.AmountBlockchain // wei per gas
}

TxInput for EVM

func NewTxInput added in v0.3.0

func NewTxInput() *TxInput

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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