Documentation ¶
Index ¶
- Constants
- Variables
- func CheckError(err error) xc.ClientError
- func HexToAddress(address xc.Address) (common.Address, error)
- func NewAddressBuilder(asset xc.ITask) (xc.AddressBuilder, error)
- func NewLegacyTxBuilder(asset xc.ITask) (xc.TxBuilder, error)
- func NewSigner(asset xc.ITask) (xc.Signer, error)
- func NewTxBuilder(asset xc.ITask) (xc.TxBuilder, error)
- func TrimPrefixes(addressOrTxHash string) string
- type AddressBuilder
- type Client
- func (client *Client) ChainID() (*big.Int, error)
- func (client *Client) EstimateGas(ctx context.Context) (xc.AmountBlockchain, error)
- func (client *Client) FetchBalance(ctx context.Context, address xc.Address) (xc.AmountBlockchain, error)
- func (client *Client) FetchNativeBalance(ctx context.Context, address xc.Address) (xc.AmountBlockchain, error)
- func (client *Client) FetchTxInfo(ctx context.Context, txHashStr xc.TxHash) (xc.TxInfo, error)
- func (client *Client) FetchTxInput(ctx context.Context, from xc.Address, _ xc.Address) (xc.TxInput, error)
- func (client *Client) RegisterEstimateGasCallback(fn xc.EstimateGasFunc)
- func (client *Client) SubmitTx(ctx context.Context, tx xc.Tx) error
- type HttpInterceptor
- type Signer
- type Tx
- func (tx *Tx) AddSignatures(signatures ...xc.TxSignature) error
- func (tx Tx) Amount() xc.AmountBlockchain
- func (tx Tx) ContractAddress() xc.ContractAddress
- func (tx Tx) Fee(baseFeeUint uint64, gasUsedUint uint64) xc.AmountBlockchain
- func (tx Tx) From() xc.Address
- func (tx Tx) Hash() xc.TxHash
- func (tx Tx) IsContract() bool
- func (tx Tx) ParseERC20TransferTx() (parsedTxInfo, error)
- func (tx Tx) ParseMultisendTransferTx() (parsedTxInfo, error)
- func (tx *Tx) ParseTransfer(receipt *types.Receipt, nativeAsset xc.NativeAsset) parsedTxInfo
- func (tx Tx) Serialize() ([]byte, error)
- func (tx Tx) Sighashes() ([]xc.TxDataToSign, error)
- func (tx Tx) To() xc.Address
- type TxBuilder
- func (txBuilder TxBuilder) NewNativeTransfer(from xc.Address, to xc.Address, amount xc.AmountBlockchain, input xc.TxInput) (xc.Tx, error)
- func (txBuilder TxBuilder) NewTokenTransfer(from xc.Address, to xc.Address, amount xc.AmountBlockchain, input xc.TxInput) (xc.Tx, error)
- func (txBuilder TxBuilder) NewTransfer(from xc.Address, to xc.Address, amount xc.AmountBlockchain, input xc.TxInput) (xc.Tx, error)
- type TxInput
Constants ¶
const DEFAULT_GAS_PRICE = 20_000_000_000
const DEFAULT_GAS_TIP = 3_000_000_000
Variables ¶
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
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
NewTxBuilder creates a new EVM TxBuilder for legacy tx
func NewTxBuilder ¶
NewTxBuilder creates a new EVM TxBuilder
func TrimPrefixes ¶ added in v0.3.0
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 NewLegacyClient ¶
NewLegacyClient returns a new EVM Client for legacy tx
func (*Client) EstimateGas ¶ added in v0.3.0
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 ¶
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
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()
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) IsContract ¶ added in v0.3.0
IsContract returns whether a tx is a contract or native transfer
func (Tx) ParseERC20TransferTx ¶ added in v0.3.0
ParseERC20TransferTx parses the tx payload as ERC20 transfer
func (Tx) ParseMultisendTransferTx ¶ added in v0.3.0
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
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
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