ethtxs

package
v1.68.4 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: BSD-3-Clause Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BridgeBankABI    = "BridgeBankABI"
	Chain33BankABI   = "Chain33BankABI"
	Chain33BridgeABI = "Chain33BridgeABI"
	EthereumBankABI  = "EthereumBankABI"
	OracleABI        = "OracleABI"
)

const

View Source
const (
	// GasLimit : the gas limit in Gwei used for transactions sent with TransactOpts
	GasLimit         = uint64(100 * 10000)
	GasLimit4RelayTx = uint64(40 * 10000)
	GasLimit4Deploy  = uint64(0) //此处需要设置为0,让交易自行估计,否则将会导致部署失败,TODO:其他解决途径后续调研解决
)

const ...

View Source
const (
	WDError      = WithdrawStatus(1)
	WDPending    = WithdrawStatus(2)
	WDFailed     = WithdrawStatus(3)
	WDSuccess    = WithdrawStatus(4)
	BinanceChain = "Binance"
)
View Source
const (
	PendingDuration4TxExeuction = 300
	EthTxPending                = EthTxStatus(2)
)

const

View Source
const (
	EthNullAddr = "0x0000000000000000000000000000000000000000"
)

const ...

Variables

View Source
var (
	ErrGetSuggestGasPrice = errors.New("ErrGetSuggestGasPrice")
	ErrNodeNetwork        = errors.New("ErrNodeNetwork")
)

Functions

func Burn

func Burn(ownerPrivateKeyStr, tokenAddrstr, chain33Receiver string, bridgeBank common.Address, amount *big.Int,
	bridgeBankIns *generated.BridgeBank, client ethinterface.EthClientSpec, addr2TxNonce map[common.Address]*NonceMutex, providerHttp string) (string, error)

Burn ...

func BurnAsync

func BurnAsync(ownerPrivateKeyStr, tokenAddrstr, chain33Receiver string, amount *big.Int, bridgeBankIns *generated.BridgeBank,
	client ethinterface.EthClientSpec, addr2TxNonce map[common.Address]*NonceMutex) (string, error)

BurnAsync ...

func Dial2MakeEthClient added in v1.66.3

func Dial2MakeEthClient(ethURL string) (*ethclient.Client, error)

Dial2MakeEthClient : returns boolean indicating if a URL is valid websocket ethclient

func GetAddressFromBridgeRegistry

func GetAddressFromBridgeRegistry(client ethinterface.EthClientSpec, sender, registry common.Address, target ContractRegistry) (address *common.Address, err error)

GetAddressFromBridgeRegistry : utility method which queries the requested contract address from the BridgeRegistry

func GetBalance

func GetBalance(client ethinterface.EthClientSpec, tokenAddr, owner string) (string, error)

GetBalance ...

func GetDeployHeight

func GetDeployHeight(client ethinterface.EthClientSpec, sender, registry common.Address) (height int64, err error)

GetDeployHeight : 获取合约部署高度

func GetDepositFunds

func GetDepositFunds(client bind.ContractBackend, tokenAddrStr string) (string, error)

GetDepositFunds ...

func GetEthTxStatus

func GetEthTxStatus(client ethinterface.EthClientSpec, txhash common.Hash) string

GetEthTxStatus ...

func GetLockedFunds

func GetLockedFunds(bridgeBank *generated.BridgeBank, tokenAddrStr string) (string, error)

GetLockedFunds ...

func GetLockedTokenAddress

func GetLockedTokenAddress(bridgeBank *generated.BridgeBank, tokenSymbol string) (string, error)

GetLockedTokenAddress ...

func GetOperator

func GetOperator(client ethinterface.EthClientSpec, sender, bridgeBank common.Address) (common.Address, error)

GetOperator ...

func GetOracleInstance added in v1.67.4

func GetOracleInstance(client ethinterface.EthClientSpec, registry common.Address) (*generated.Oracle, error)

func GetToken2address

func GetToken2address(bridgeBank *generated.BridgeBank, tokenSymbol string) (string, error)

GetToken2address ...

func IsActiveValidator

func IsActiveValidator(validator common.Address, valset *generated.Valset) (bool, error)

IsActiveValidator ...

func IsProphecyPending

func IsProphecyPending(claimID [32]byte, validator common.Address, chain33Bridge *generated.Chain33Bridge) (bool, error)

IsProphecyPending ...

func LoadABI

func LoadABI(contractName string) abi.ABI

LoadABI ...

func LockEthErc20Asset

func LockEthErc20Asset(ownerPrivateKeyStr, tokenAddrStr, chain33Receiver string, amount *big.Int, client ethinterface.EthClientSpec, bridgeBank *generated.BridgeBank, bridgeBankAddr common.Address, addr2TxNonce map[common.Address]*NonceMutex, providerHttp string) (string, error)

LockEthErc20Asset ...

func LockEthErc20AssetAsync

func LockEthErc20AssetAsync(ownerPrivateKeyStr, tokenAddrStr, chain33Receiver string, amount *big.Int, client ethinterface.EthClientSpec, bridgeBank *generated.BridgeBank, addr2TxNonce map[common.Address]*NonceMutex) (string, error)

LockEthErc20AssetAsync ...

func LogBurnToEthBridgeClaim

func LogBurnToEthBridgeClaim(event *events.BurnEvent, ethereumChainID int64, bridgeBrankAddr, ethTxHash string, decimal int64) (*ebrelayerTypes.EthBridgeClaim, error)

LogBurnToEthBridgeClaim ...

func LogLockToEthBridgeClaim

func LogLockToEthBridgeClaim(event *events.LockEvent, ethereumChainID int64, bridgeBrankAddr, ethTxHash string, decimal int64) (*ebrelayerTypes.EthBridgeClaim, error)

LogLockToEthBridgeClaim : parses and packages a LockEvent struct with a validator address in an EthBridgeClaim msg

func NewTransferTx added in v1.66.0

func NewTransferTx(clientSpec ethinterface.EthClientSpec, from, to common.Address, input []byte, value *big.Int, addr2TxNonce map[common.Address]*NonceMutex, fromChain bool) (*types.Transaction, error)

func PrepareAuth

func PrepareAuth(client ethinterface.EthClientSpec, privateKey *ecdsa.PrivateKey, transactor common.Address) (*bind.TransactOpts, error)

PrepareAuth ...

func PrepareAuth4MultiEthereum added in v1.66.2

func PrepareAuth4MultiEthereum(client ethinterface.EthClientSpec, privateKey *ecdsa.PrivateKey, transactor common.Address, addr2TxNonce map[common.Address]*NonceMutex) (*bind.TransactOpts, error)

func PrepareAuth4MultiEthereumOpt added in v1.66.3

func PrepareAuth4MultiEthereumOpt(client ethinterface.EthClientSpec, privateKey *ecdsa.PrivateKey, transactor common.Address, addr2TxNonce map[common.Address]*NonceMutex, chainID *big.Int) (*bind.TransactOpts, error)

func RecoverContractHandler

func RecoverContractHandler(client ethinterface.EthClientSpec, sender, registry common.Address) (*X2EthContracts, *X2EthDeployInfo, error)

RecoverContractHandler ...

func RecoverOracleInstance

func RecoverOracleInstance(client ethinterface.EthClientSpec, sender, registry common.Address) (*generated.Oracle, error)

RecoverOracleInstance ...

func RelayOracleClaimToEthereum

func RelayOracleClaimToEthereum(burnOrLockParameter *BurnOrLockParameter) (string, error)

RelayOracleClaimToEthereum : relays the provided burn or lock to Chain33Bridge contract on the Ethereum network

func SafeTransfer

func SafeTransfer(ownerPrivateKeyStr, multiSignAddrstr, receiver, token string, privateKeys []string, amount float64, client ethinterface.EthClientSpec, addr2TxNonce map[common.Address]*NonceMutex, providerHttp string) (string, error)

func SelectAndRoundEthURL added in v1.66.3

func SelectAndRoundEthURL(ethURL *[]string) (string, error)

SelectAndRoundEthURL: 获取配置列表中的第一个配置项,同时将其调整配置配置项

func SetupEthClient added in v1.66.3

func SetupEthClient(ethURL *[]string) (*ethclient.Client, string, error)

func TransferEth

func TransferEth(fromPrivateKeyStr, toAddr string, amount *big.Int, client ethinterface.EthClientSpec, addr2TxNonce map[common.Address]*NonceMutex, providerHttp string) (string, error)

func TransferToken

func TransferToken(tokenAddr, fromPrivateKeyStr, toAddr string, amount *big.Int, client ethinterface.EthClientSpec, addr2TxNonce map[common.Address]*NonceMutex, providerHttp string) (string, error)

TransferToken ...

Types

type BurnOrLockParameter added in v1.66.3

type BurnOrLockParameter struct {
	ClientSpec              *EthClientWithUrl
	Clients                 []*EthClientWithUrl
	ClientBSCRecommendSpecs []*EthClientWithUrl
	Sender                  common.Address
	TokenOnEth              common.Address
	Claim                   ProphecyClaim
	PrivateKey              *ecdsa.PrivateKey
	Addr2TxNonce            map[common.Address]*NonceMutex
	ChainId                 *big.Int
	ChainName               string
}

type ContractRegistry

type ContractRegistry byte

ContractRegistry :

const (
	// Valset : valset contract
	Valset ContractRegistry = iota + 1
	// Oracle : oracle contract
	Oracle
	// BridgeBank : bridgeBank contract
	BridgeBank
	// Chain33Bridge : chain33Bridge contract
	Chain33Bridge
)

func (ContractRegistry) String

func (d ContractRegistry) String() string

String : returns the event type as a string

type DeployPara

type DeployPara struct {
	DeployPrivateKey *ecdsa.PrivateKey
	Deployer         common.Address
	Operator         common.Address
	InitValidators   []common.Address
	ValidatorPriKey  []*ecdsa.PrivateKey
	InitPowers       []*big.Int
}

DeployPara ...

type DeployResult

type DeployResult struct {
	Address common.Address
	TxHash  string
}

DeployResult ...

type EthClientWithUrl added in v1.67.4

type EthClientWithUrl struct {
	ClientUrl      string
	Client         ethinterface.EthClientSpec
	OracleInstance *generated.Oracle
}

func SetupEthClients added in v1.67.1

func SetupEthClients(ethURL *[]string, registry common.Address) ([]*EthClientWithUrl, *big.Int, error)

func SetupRecommendClients added in v1.67.1

func SetupRecommendClients(ethURL *[]string, registry common.Address) ([]*EthClientWithUrl, error)

type EthTxStatus

type EthTxStatus int32

EthTxStatus ...

func (EthTxStatus) String

func (ethTxStatus EthTxStatus) String() string

String ...

type NewProphecyClaimPara

type NewProphecyClaimPara struct {
	ClaimType     uint8
	Chain33Sender []byte
	TokenAddr     common.Address
	EthReceiver   common.Address
	Symbol        string
	Amount        *big.Int
	Txhash        []byte
}

NewProphecyClaimPara ...

type NonceMutex added in v1.66.2

type NonceMutex struct {
	Nonce  int64
	RWLock *sync.RWMutex
}

type OperatorInfo

type OperatorInfo struct {
	PrivateKey *ecdsa.PrivateKey
	Address    common.Address
}

OperatorInfo ...

type OracleClaim

type OracleClaim struct {
	ProphecyID *big.Int
	Message    [32]byte
	Signature  []byte
}

OracleClaim : contains data required to make an OracleClaim

type ProphecyClaim

type ProphecyClaim struct {
	ClaimType            events.ClaimType
	Chain33Sender        []byte
	EthereumReceiver     common.Address
	TokenContractAddress common.Address
	Symbol               string
	Amount               *big.Int
	Chain33TxHash        []byte
}

ProphecyClaim : contains data required to make an ProphecyClaim

func Chain33MsgToProphecyClaim

func Chain33MsgToProphecyClaim(msg events.Chain33Msg) ProphecyClaim

Chain33MsgToProphecyClaim : parses event data from a Chain33Msg, packaging it as a ProphecyClaim

type WithdrawStatus added in v1.66.0

type WithdrawStatus int32

func (WithdrawStatus) String added in v1.66.0

func (d WithdrawStatus) String() string

此处的名字命令不能随意改动,需要与合约event中的命名完全一致

type X2EthContracts

type X2EthContracts struct {
	BridgeRegistry *generated.BridgeRegistry
	BridgeBank     *generated.BridgeBank
	Chain33Bridge  *generated.Chain33Bridge
	Valset         *generated.Valset
	Oracle         *generated.Oracle
}

X2EthContracts ...

type X2EthDeployInfo

type X2EthDeployInfo struct {
	BridgeRegistry *DeployResult
	BridgeBank     *DeployResult
	Chain33Bridge  *DeployResult
	Valset         *DeployResult
	Oracle         *DeployResult
}

X2EthDeployResult ...

Jump to

Keyboard shortcuts

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