eth

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2020 License: GPL-3.0 Imports: 22 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ERC20TokenType = "ERC20"
)

token types (should be all upper case)

Variables

View Source
var (
	// ExtCodeParts extended func hashes and log topics
	ExtCodeParts map[string][]byte
)

Functions

func InitExtCodeParts

func InitExtCodeParts()

InitExtCodeParts init extended code parts

func InitExtCodePartsWithFlag added in v0.3.0

func InitExtCodePartsWithFlag(isMbtc bool)

InitExtCodePartsWithFlag init extended code parts with flag

func PackData

func PackData(args ...interface{}) []byte

PackData pack data

func PackDataWithFuncHash

func PackDataWithFuncHash(funcHash []byte, args ...interface{}) []byte

PackDataWithFuncHash pack data with func hash

func ParseErc20SwapinTxInput

func ParseErc20SwapinTxInput(input *[]byte, checkToAddress string) (from, to string, value *big.Int, err error)

ParseErc20SwapinTxInput parse erc20 swapin tx input

func ParseErc20SwapinTxLogs

func ParseErc20SwapinTxLogs(logs []*types.RPCLog, checkToAddress string) (from, to string, value *big.Int, err error)

ParseErc20SwapinTxLogs parse erc20 swapin tx logs

func ParseSwapoutTxInput

func ParseSwapoutTxInput(input *[]byte) (string, *big.Int, error)

ParseSwapoutTxInput parse swapout tx input

func VerifyContractCodeParts

func VerifyContractCodeParts(code []byte, codePartsSlice ...map[string][]byte) (err error)

VerifyContractCodeParts verify contract code parts

func VerifyErc20ContractCode

func VerifyErc20ContractCode(code []byte) (err error)

VerifyErc20ContractCode verify erc20 contract code

func VerifySwapContractCode

func VerifySwapContractCode(code []byte) (err error)

VerifySwapContractCode verify swap contract code

Types

type Bridge

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

Bridge eth bridge

func NewCrossChainBridge

func NewCrossChainBridge(isSrc bool) *Bridge

NewCrossChainBridge new bridge

func (*Bridge) AdjustNonce

func (b *Bridge) AdjustNonce(pairID 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) DcrmSignTransaction

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

DcrmSignTransaction dcrm sign raw tx

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) ([]byte, 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) GetLatestBlockNumber

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

GetLatestBlockNumber call eth_blockNumber

func (*Bridge) GetLatestBlockNumberOf

func (b *Bridge) GetLatestBlockNumberOf(apiAddress string) (uint64, 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) 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) 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) (*types.RPCTransaction, error)

GetTransactionByHash call eth_getTransactionByHash

func (*Bridge) GetTransactionReceipt

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

GetTransactionReceipt call eth_getTransactionReceipt

func (*Bridge) GetTransactionStatus

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

GetTransactionStatus impl

func (*Bridge) IncreaseNonce

func (b *Bridge) IncreaseNonce(pairID string, value uint64)

IncreaseNonce decrease account nonce (eth like chain)

func (*Bridge) Init

func (b *Bridge) Init()

Init init after verify

func (*Bridge) InitLatestBlockNumber

func (b *Bridge) InitLatestBlockNumber()

InitLatestBlockNumber init latest block number

func (*Bridge) IsContractAddress

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

IsContractAddress is contract address

func (*Bridge) IsValidAddress

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

IsValidAddress check address

func (*Bridge) NetworkID

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

NetworkID call net_version

func (*Bridge) SendSignedTransaction

func (b *Bridge) SendSignedTransaction(tx *types.Transaction) error

SendSignedTransaction call eth_sendRawTransaction

func (*Bridge) SendTransaction

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

SendTransaction send signed tx

func (*Bridge) SetChainAndGateway added in v0.3.0

func (b *Bridge) SetChainAndGateway(chainCfg *tokens.ChainConfig, gatewayCfg *tokens.GatewayConfig)

SetChainAndGateway set chain and gateway config

func (*Bridge) SetNonce

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

SetNonce set nonce directly

func (*Bridge) SignTransaction added in v0.3.0

func (b *Bridge) SignTransaction(rawTx interface{}, pairID string) (signTx interface{}, txHash string, err error)

SignTransaction sign tx with pairID

func (*Bridge) SignTransactionWithPrivateKey added in v0.3.0

func (b *Bridge) SignTransactionWithPrivateKey(rawTx interface{}, privKey *ecdsa.PrivateKey) (signTx interface{}, txHash string, err error)

SignTransactionWithPrivateKey sign tx with ECDSA private key

func (*Bridge) StartChainTransactionScanJob

func (b *Bridge) StartChainTransactionScanJob()

StartChainTransactionScanJob scan job

func (*Bridge) StartPoolTransactionScanJob

func (b *Bridge) StartPoolTransactionScanJob()

StartPoolTransactionScanJob scan job

func (*Bridge) SuggestPrice

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

SuggestPrice call eth_gasPrice

func (*Bridge) VerifyChainID

func (b *Bridge) VerifyChainID()

VerifyChainID verify chain id

func (*Bridge) VerifyContractCode

func (b *Bridge) VerifyContractCode(contract string, codePartsSlice ...map[string][]byte) (err error)

VerifyContractCode verify contract code

func (*Bridge) VerifyErc20ContractAddress

func (b *Bridge) VerifyErc20ContractAddress(contract, codeHash string, isProxy bool) (err error)

VerifyErc20ContractAddress verify erc20 contract For proxy contract delegating erc20 contract, verify its contract code hash

func (*Bridge) VerifyMbtcContractAddress

func (b *Bridge) VerifyMbtcContractAddress(contract string) (err error)

VerifyMbtcContractAddress verify mbtc contract

func (*Bridge) VerifyMsgHash

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

VerifyMsgHash verify msg hash

func (*Bridge) VerifyTokenConfig added in v0.3.0

func (b *Bridge) VerifyTokenConfig(tokenCfg *tokens.TokenConfig) (err error)

VerifyTokenConfig verify token config

func (*Bridge) VerifyTransaction

func (b *Bridge) VerifyTransaction(pairID, txHash string, allowUnstable bool) (*tokens.TxSwapInfo, error)

VerifyTransaction impl

type NonceSetterBase

type NonceSetterBase struct {
	SwapinNonce  map[string]uint64
	SwapoutNonce map[string]uint64
}

NonceSetterBase base nonce setter

func NewNonceSetterBase

func NewNonceSetterBase() *NonceSetterBase

NewNonceSetterBase new base nonce setter

Jump to

Keyboard shortcuts

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