Documentation
¶
Index ¶
- Constants
- Variables
- func BuildERC20Payload(to xc.Address, amount xc.AmountBlockchain) ([]byte, error)
- func CheckError(err error) xclient.ClientError
- func GweiToWei(gwei uint64) xc.AmountBlockchain
- func HexToAddress(address xc.Address) (common.Address, error)
- func NewAddressBuilder(asset xc.ITask) (xc.AddressBuilder, error)
- func NewSigner(asset xc.ITask) (xc.Signer, error)
- func NewTxBuilder(asset xc.ITask) (xc.TxBuilder, error)
- func ReplaceIncompatiableEvmResponses(body []byte) []byte
- func TrimPrefixes(addressOrTxHash string) string
- type AddressBuilder
- type Client
- func (client *Client) DefaultMaxGasLimit() uint64
- func (client *Client) FetchBalance(ctx context.Context, address xc.Address) (xc.AmountBlockchain, error)
- func (client *Client) FetchLegacyTxInfo(ctx context.Context, txHashStr xc.TxHash) (xc.LegacyTxInfo, error)
- func (client *Client) FetchNativeBalance(ctx context.Context, address xc.Address) (xc.AmountBlockchain, error)
- func (client *Client) FetchTxInfo(ctx context.Context, txHashStr xc.TxHash) (xclient.TxInfo, error)
- func (client *Client) FetchTxInput(ctx context.Context, from xc.Address, to xc.Address) (xc.TxInput, error)
- func (client *Client) GetNonce(ctx context.Context, from xc.Address) (uint64, error)
- func (client *Client) SimulateGasWithLimit(ctx context.Context, txBuilder xc.TxBuilder, from xc.Address, to xc.Address, ...) (uint64, error)
- func (client *Client) SubmitTx(ctx context.Context, tx xc.Tx) error
- func (client *Client) TraceEthMovements(ctx context.Context, txHash common.Hash) (SourcesAndDests, error)
- func (client *Client) TraceTransaction(ctx context.Context, txHash common.Hash) (*TraceTransactionResult, error)
- func (client *Client) TxPoolContentFrom(ctx context.Context, from common.Address) (*TxPoolResult, error)
- type EvmTxBuilder
- type GethTxBuilder
- type Signer
- type SourcesAndDests
- type TraceTransactionArgs
- type TraceTransactionResult
- type TraceTransactionType
- 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) GetSignatures() []xc.TxSignature
- func (tx Tx) Hash() xc.TxHash
- func (tx Tx) IsContract() bool
- func (tx Tx) ParseERC20TransferTx(nativeAsset xc.NativeAsset) (SourcesAndDests, error)
- func (tx *Tx) ParseTokenLogs(receipt *types.Receipt, nativeAsset xc.NativeAsset) SourcesAndDests
- func (tx Tx) Serialize() ([]byte, error)
- func (tx Tx) Sighashes() ([]xc.TxDataToSign, error)
- func (tx Tx) To() xc.Address
- type TxBuilder
- func (txBuilder TxBuilder) BuildProxyPayload(contract xc.ContractAddress, to xc.Address, amount xc.AmountBlockchain) ([]byte, error)
- func (txBuilder TxBuilder) BuildTaskPayload(taskFrom xc.Address, taskTo xc.Address, taskAmount xc.AmountBlockchain, ...) (string, xc.AmountBlockchain, []byte, error)
- func (txBuilder TxBuilder) BuildTaskTx(from xc.Address, to xc.Address, amount xc.AmountBlockchain, input xc.TxInput) (xc.Tx, error)
- func (txBuilder TxBuilder) BuildWormholePayload(taskFrom xc.Address, taskTo xc.Address, taskAmount xc.AmountBlockchain, ...) (string, xc.AmountBlockchain, []byte, error)
- func (txBuilder TxBuilder) BuildWormholeTransferTx(from xc.Address, to xc.Address, amount xc.AmountBlockchain, input xc.TxInput) (xc.Tx, error)
- func (txBuilder TxBuilder) NewNativeTransfer(from xc.Address, to xc.Address, amount xc.AmountBlockchain, input xc.TxInput) (xc.Tx, error)
- func (txBuilder TxBuilder) NewTask(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)
- func (txBuilder TxBuilder) WithTxBuilder(buider GethTxBuilder) xc.TxBuilder
- type TxInput
- type TxPoolPendingMap
- type TxPoolResult
- type TxPoolTxInfo
Constants ¶
const DEFAULT_GAS_PRICE = 20_000_000_000
const DEFAULT_GAS_TIP = 3_000_000_000
Variables ¶
var DefaultMaxTipCapGwei uint64 = 5
var ERC20 abi.ABI
Functions ¶
func BuildERC20Payload ¶
func CheckError ¶
func CheckError(err error) xclient.ClientError
func GweiToWei ¶
func GweiToWei(gwei uint64) xc.AmountBlockchain
func HexToAddress ¶
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 NewTxBuilder ¶
NewTxBuilder creates a new EVM TxBuilder
func TrimPrefixes ¶
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.ITask EthClient *ethclient.Client ChainId *big.Int Interceptor *utils.HttpInterceptor }
Client for EVM
func (*Client) DefaultMaxGasLimit ¶
func (*Client) FetchBalance ¶
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) FetchLegacyTxInfo ¶
func (client *Client) FetchLegacyTxInfo(ctx context.Context, txHashStr xc.TxHash) (xc.LegacyTxInfo, error)
FetchLegacyTxInfo returns tx info for a EVM tx
func (*Client) FetchNativeBalance ¶
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) FetchTxInput ¶
func (client *Client) FetchTxInput(ctx context.Context, from xc.Address, to xc.Address) (xc.TxInput, error)
FetchTxInput returns tx input for a EVM tx
func (*Client) SimulateGasWithLimit ¶
func (client *Client) SimulateGasWithLimit(ctx context.Context, txBuilder xc.TxBuilder, from xc.Address, to xc.Address, txInput xc.TxInput) (uint64, error)
Simulate a transaction to get the estimated gas limit
func (*Client) TraceEthMovements ¶
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 EvmTxBuilder ¶
type EvmTxBuilder struct { }
supports evm after london merge
func (*EvmTxBuilder) BuildTxWithPayload ¶
func (*EvmTxBuilder) BuildTxWithPayload(chain *xc.ChainConfig, to xc.Address, value xc.AmountBlockchain, data []byte, inputRaw xc.TxInput) (xc.Tx, error)
type GethTxBuilder ¶
type Signer ¶
type Signer struct { }
Signer for EVM
func (Signer) ImportPrivateKey ¶
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 SourcesAndDests ¶
type SourcesAndDests struct { Sources []*xc.LegacyTxInfoEndpoint Destinations []*xc.LegacyTxInfoEndpoint }
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 Tx ¶
type Tx struct { EthTx *types.Transaction Signer types.Signer Signatures []xc.TxSignature }
Tx for EVM
func (*Tx) AddSignatures ¶
func (tx *Tx) AddSignatures(signatures ...xc.TxSignature) error
AddSignatures adds a signature to Tx
func (Tx) ContractAddress ¶
func (tx Tx) ContractAddress() xc.ContractAddress
ContractAddress returns the contract address for a token transfer
func (Tx) Fee ¶
func (tx Tx) Fee(baseFeeUint uint64, gasUsedUint uint64) xc.AmountBlockchain
Fee returns the fee associated to the tx
func (Tx) GetSignatures ¶
func (tx Tx) GetSignatures() []xc.TxSignature
func (Tx) IsContract ¶
IsContract returns whether a tx is a contract or native transfer
func (Tx) ParseERC20TransferTx ¶
func (tx Tx) ParseERC20TransferTx(nativeAsset xc.NativeAsset) (SourcesAndDests, error)
ParseERC20TransferTx parses the tx payload as ERC20 transfer
func (*Tx) ParseTokenLogs ¶
func (tx *Tx) ParseTokenLogs(receipt *types.Receipt, nativeAsset xc.NativeAsset) SourcesAndDests
ParseTransfer parses a tx and extracts higher-level transfer information
type TxBuilder ¶
TxBuilder for EVM
func (TxBuilder) BuildProxyPayload ¶
func (txBuilder TxBuilder) BuildProxyPayload(contract xc.ContractAddress, to xc.Address, amount xc.AmountBlockchain) ([]byte, error)
func (TxBuilder) BuildTaskPayload ¶
func (TxBuilder) BuildTaskTx ¶
func (TxBuilder) BuildWormholePayload ¶
func (TxBuilder) BuildWormholeTransferTx ¶
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
func (TxBuilder) WithTxBuilder ¶
func (txBuilder TxBuilder) WithTxBuilder(buider GethTxBuilder) xc.TxBuilder
type TxInput ¶
type TxInput struct { xc.TxInputEnvelope utils.TxPriceInput Nonce uint64 `json:"nonce,omitempty"` GasLimit uint64 `json:"gas_limit,omitempty"` // DynamicFeeTx GasTipCap xc.AmountBlockchain `json:"gas_tip_cap,omitempty"` // maxPriorityFeePerGas GasFeeCap xc.AmountBlockchain `json:"gas_fee_cap,omitempty"` // maxFeePerGas // GasPrice xc.AmountBlockchain `json:"gas_price,omitempty"` // wei per gas // Task params Params []string `json:"params,omitempty"` // For legacy implementation only GasPrice xc.AmountBlockchain `json:"gas_price,omitempty"` // wei per gas ChainId xc.AmountBlockchain `json:"chain_id,omitempty"` }
TxInput for EVM
func NewTxInput ¶
func NewTxInput() *TxInput
func (*TxInput) IndependentOf ¶
func (*TxInput) SafeFromDoubleSend ¶
func (*TxInput) SetGasFeePriority ¶
func (input *TxInput) SetGasFeePriority(other xc.GasFeePriority) error
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