eth

package
v0.0.0-...-1bc71c5 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2021 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ERC20TokenType = "ERC20"
)

token types (should be all upper case)

Variables

View Source
var (
	LogAnyCallTopic = common.FromHex("0x3d1b3d059223895589208a5541dce543eab6d5942b3b1129231a942d1c47bc45")

	AnyCallFuncHash = common.FromHex("0x32f29022")
)

anycall lot topics and func hashes

View Source
var (

	// anySwapIn(bytes32 txs, address token, address to, uint amount, uint fromChainID)
	AnySwapInFuncHash = common.FromHex("0x825bb13c")
	// anySwapInUnderlying(bytes32 txs, address token, address to, uint amount, uint fromChainID)
	AnySwapInUnderlyingFuncHash = common.FromHex("0x3f88de89")
	// anySwapInAuto(bytes32 txs, address token, address to, uint amount, uint fromChainID)
	AnySwapInAutoFuncHash = common.FromHex("0x0175b1c4")
	// anySwapInExactTokensForTokens(bytes32 txs, uint amountIn, uint amountOutMin, address[] path, address to, uint deadline, uint fromChainID)
	AnySwapInExactTokensForTokensFuncHash = common.FromHex("0x2fc1e728")
	// anySwapInExactTokensForNative(bytes32 txs, uint amountIn, uint amountOutMin, address[] path, address to, uint deadline, uint fromChainID)
	AnySwapInExactTokensForNativeFuncHash = common.FromHex("0x52a397d5")
)

router contract's func hashs

View Source
var (
	// LogAnySwapOut(address token, address from, address to, uint amount, uint fromChainID, uint toChainID);
	LogAnySwapOutTopic = common.FromHex("0x97116cf6cd4f6412bb47914d6db18da9e16ab2142f543b86e207c24fbd16b23a")
	// LogAnySwapTradeTokensForTokens(address[] path, address from, address to, uint amountIn, uint amountOutMin, uint fromChainID, uint toChainID);
	LogAnySwapTradeTokensForTokensTopic = common.FromHex("0xfea6abdf4fd32f20966dff7619354cd82cd43dc78a3bee479f04c74dbfc585b3")
	// LogAnySwapTradeTokensForNative(address[] path, address from, address to, uint amountIn, uint amountOutMin, uint fromChainID, uint toChainID);
	LogAnySwapTradeTokensForNativeTopic = common.FromHex("0x278277e0209c347189add7bd92411973b5f6b8644f7ac62ea1be984ce993f8f4")
)

router contract's log topics

Functions

This section is empty.

Types

type Bridge

type Bridge struct {
	*tokens.CrossChainBridgeBase
	*NonceSetterBase
	Signer        types.Signer
	SignerChainID *big.Int
}

Bridge eth bridge

func NewCrossChainBridge

func NewCrossChainBridge() *Bridge

NewCrossChainBridge new bridge

func (*Bridge) AdjustNonce

func (b *Bridge) AdjustNonce(address string, value uint64) (nonce uint64)

AdjustNonce adjust account nonce (eth like chain)

func (*Bridge) BuildRawTransaction

func (b *Bridge) BuildRawTransaction(args *tokens.BuildTxArgs) (rawTx interface{}, err error)

BuildRawTransaction build raw tx

func (*Bridge) CallContract

func (b *Bridge) CallContract(contract string, data hexutil.Bytes, blockNumber string) (string, error)

CallContract call eth_call

func (*Bridge) ChainID

func (b *Bridge) ChainID() (*big.Int, error)

ChainID call eth_chainId Notice: eth_chainId return 0x0 for mainnet which is wrong (use net_version instead)

func (*Bridge) EstimateGas

func (b *Bridge) EstimateGas(from, to string, value *big.Int, data []byte) (uint64, error)

EstimateGas call eth_estimateGas

func (*Bridge) GetBalance

func (b *Bridge) GetBalance(account string) (*big.Int, error)

GetBalance call eth_getBalance

func (*Bridge) GetBlockByHash

func (b *Bridge) GetBlockByHash(blockHash string) (*types.RPCBlock, error)

GetBlockByHash call eth_getBlockByHash

func (*Bridge) GetBlockByNumber

func (b *Bridge) GetBlockByNumber(number *big.Int) (*types.RPCBlock, error)

GetBlockByNumber call eth_getBlockByNumber

func (*Bridge) GetCode

func (b *Bridge) GetCode(contract string) (code []byte, err error)

GetCode call eth_getCode

func (*Bridge) GetContractLogs

func (b *Bridge) GetContractLogs(contractAddresses []common.Address, logTopics [][]common.Hash, blockHeight uint64) ([]*types.RPCLog, error)

GetContractLogs get contract logs

func (*Bridge) GetErc20Balance

func (b *Bridge) GetErc20Balance(contract, address string) (*big.Int, error)

GetErc20Balance get erc20 balacne of address

func (*Bridge) GetErc20Decimals

func (b *Bridge) GetErc20Decimals(contract string) (uint8, error)

GetErc20Decimals get erc20 decimals

func (*Bridge) GetErc20TotalSupply

func (b *Bridge) GetErc20TotalSupply(contract string) (*big.Int, error)

GetErc20TotalSupply get erc20 total supply of address

func (*Bridge) GetFactoryAddress

func (b *Bridge) GetFactoryAddress(contractAddr string) (string, error)

GetFactoryAddress call "factory()"

func (*Bridge) GetLatestBlockNumber

func (b *Bridge) GetLatestBlockNumber() (uint64, error)

GetLatestBlockNumber call eth_blockNumber

func (*Bridge) GetLatestBlockNumberOf

func (b *Bridge) GetLatestBlockNumberOf(url string) (latest uint64, err error)

GetLatestBlockNumberOf call eth_blockNumber

func (*Bridge) GetLogs

func (b *Bridge) GetLogs(filterQuery *types.FilterQuery) (result []*types.RPCLog, err error)

GetLogs call eth_getLogs

func (*Bridge) GetMPCAddress

func (b *Bridge) GetMPCAddress(contractAddr string) (string, error)

GetMPCAddress call "mpc()"

func (*Bridge) GetOwnerAddress

func (b *Bridge) GetOwnerAddress(contractAddr string) (string, error)

GetOwnerAddress call "owner()"

func (*Bridge) GetPairFor

func (b *Bridge) GetPairFor(factory, token0, token1 string) (string, error)

GetPairFor call "getPair(address,address)"

func (*Bridge) GetPendingTransactions

func (b *Bridge) GetPendingTransactions() (result []*types.RPCTransaction, err error)

GetPendingTransactions call eth_pendingTransactions

func (*Bridge) GetPoolNonce

func (b *Bridge) GetPoolNonce(address, height string) (uint64, error)

GetPoolNonce call eth_getTransactionCount

func (*Bridge) GetSignerChainID

func (b *Bridge) GetSignerChainID() (*big.Int, error)

GetSignerChainID default way to get signer chain id use chain ID first, if missing then use network ID instead. normally this way works, but sometimes it failed (eg. ETC), then we should overwrite this function NOTE: call after chain config setted

func (*Bridge) GetTokenBalance

func (b *Bridge) GetTokenBalance(tokenType, tokenAddress, accountAddress string) (*big.Int, error)

GetTokenBalance api

func (*Bridge) GetTokenSupply

func (b *Bridge) GetTokenSupply(tokenType, tokenAddress string) (*big.Int, error)

GetTokenSupply impl

func (*Bridge) GetTransaction

func (b *Bridge) GetTransaction(txHash string) (interface{}, error)

GetTransaction impl

func (*Bridge) GetTransactionByHash

func (b *Bridge) GetTransactionByHash(txHash string) (tx *types.RPCTransaction, err error)

GetTransactionByHash call eth_getTransactionByHash

func (*Bridge) GetTransactionReceipt

func (b *Bridge) GetTransactionReceipt(txHash string) (receipt *types.RPCTxReceipt, url string, err error)

GetTransactionReceipt call eth_getTransactionReceipt

func (*Bridge) GetTransactionStatus

func (b *Bridge) GetTransactionStatus(txHash string) *tokens.TxStatus

GetTransactionStatus impl

func (*Bridge) GetUnderlyingAddress

func (b *Bridge) GetUnderlyingAddress(contractAddr string) (string, error)

GetUnderlyingAddress call "underlying()"

func (*Bridge) GetVaultAddress

func (b *Bridge) GetVaultAddress(contractAddr string) (string, error)

GetVaultAddress call "vault()"

func (*Bridge) InitChainConfig

func (b *Bridge) InitChainConfig(chainID *big.Int)

InitChainConfig impl

func (*Bridge) InitGatewayConfig

func (b *Bridge) InitGatewayConfig(chainID *big.Int)

InitGatewayConfig impl

func (*Bridge) InitTokenConfig

func (b *Bridge) InitTokenConfig(tokenID string, chainID *big.Int)

InitTokenConfig impl

func (*Bridge) IsContractAddress

func (b *Bridge) IsContractAddress(address string) (bool, error)

IsContractAddress is contract address

func (*Bridge) IsMinter

func (b *Bridge) IsMinter(contractAddr, minterAddr string) (bool, error)

IsMinter call "isMinter(address)"

func (*Bridge) IsValidAddress

func (b *Bridge) IsValidAddress(address string) bool

IsValidAddress check address

func (*Bridge) MPCSignTransaction

func (b *Bridge) MPCSignTransaction(rawTx interface{}, args *tokens.BuildTxArgs) (signTx interface{}, txHash string, err error)

MPCSignTransaction mpc sign raw tx

func (*Bridge) NetworkID

func (b *Bridge) NetworkID() (*big.Int, error)

NetworkID call net_version

func (*Bridge) RegisterSwap

func (b *Bridge) RegisterSwap(txHash string, args *tokens.RegisterArgs) ([]*tokens.SwapTxInfo, []error)

RegisterSwap api

func (*Bridge) ReloadChainConfig

func (b *Bridge) ReloadChainConfig(chainID *big.Int)

ReloadChainConfig reload chain config

func (*Bridge) ReloadTokenConfig

func (b *Bridge) ReloadTokenConfig(tokenID string, chainID *big.Int)

ReloadTokenConfig reload token config

func (*Bridge) SendSignedTransaction

func (b *Bridge) SendSignedTransaction(tx *types.Transaction) (txHash string, err error)

SendSignedTransaction call eth_sendRawTransaction

func (*Bridge) SendTransaction

func (b *Bridge) SendTransaction(signedTx interface{}) (txHash string, err error)

SendTransaction send signed tx

func (*Bridge) SetNonce

func (b *Bridge) SetNonce(address string, value uint64)

SetNonce set account nonce (eth like chain)

func (*Bridge) SuggestPrice

func (b *Bridge) SuggestPrice() (maxGasPrice *big.Int, err error)

SuggestPrice call eth_gasPrice

func (*Bridge) VerifyMsgHash

func (b *Bridge) VerifyMsgHash(rawTx interface{}, msgHashes []string) error

VerifyMsgHash verify msg hash

func (*Bridge) VerifyTransaction

func (b *Bridge) VerifyTransaction(txHash string, args *tokens.VerifyArgs) (*tokens.SwapTxInfo, error)

VerifyTransaction api

type NonceSetterBase

type NonceSetterBase struct {
	SwapNonce map[string]uint64 // key is sender address
}

NonceSetterBase base nonce setter

func NewNonceSetterBase

func NewNonceSetterBase() *NonceSetterBase

NewNonceSetterBase new base nonce setter

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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