ethtxs

package
Version: v1.65.3 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: BSD-3-Clause Imports: 28 Imported by: 0

Documentation

Index

Constants

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

const

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

const ...

View Source
const (
	X2Eth      = "x2ethereum"
	BurnAction = "Chain33ToEthBurn"
	LockAction = "Chain33ToEthLock"
)

const ...

View Source
const (
	PendingDuration4TxExeuction = 300
	EthTxPending                = EthTxStatus(2)
)

const

Variables

This section is empty.

Functions

func AddToken2LockList

func AddToken2LockList(symbol, token string, client ethinterface.EthClientSpec, para *OperatorInfo, x2EthContracts *X2EthContracts) (string, error)

func ApproveAllowance

func ApproveAllowance(ownerPrivateKeyStr, tokenAddr string, bridgeBank common.Address, amount *big.Int, client ethinterface.EthClientSpec) (string, error)

ApproveAllowance ...

func Burn

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

Burn ...

func BurnAsync

func BurnAsync(ownerPrivateKeyStr, tokenAddrstr, chain33Receiver string, amount *big.Int, bridgeBankIns *generated.BridgeBank, client ethinterface.EthClientSpec) (string, error)

BurnAsync ...

func ConfigLockedTokenOfflineSave

func ConfigLockedTokenOfflineSave(addr, symbol string, threshold *big.Int, percents uint8, client ethinterface.EthClientSpec, para *OperatorInfo, x2EthContracts *X2EthContracts) (string, error)

func ConfigOfflineSaveAccount

func ConfigOfflineSaveAccount(addr string, client ethinterface.EthClientSpec, para *OperatorInfo, x2EthContracts *X2EthContracts) (string, error)

func CreateBridgeToken

func CreateBridgeToken(symbol string, client ethinterface.EthClientSpec, para *OperatorInfo, x2EthDeployInfo *X2EthDeployInfo, x2EthContracts *X2EthContracts) (string, error)

CreateBridgeToken ...

func DeployAndInit

func DeployAndInit(client ethinterface.EthClientSpec, para *DeployPara) (*X2EthContracts, *X2EthDeployInfo, error)

DeployAndInit ...

func DeployERC20

func DeployERC20(ownerAddr, name, symbol string, amount *big.Int, client ethinterface.EthClientSpec, para *OperatorInfo) (string, error)

func DeployMulSign2Eth

func DeployMulSign2Eth(client ethinterface.EthClientSpec, para *OperatorInfo) (string, error)

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 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) (string, error)

LockEthErc20Asset ...

func LockEthErc20AssetAsync

func LockEthErc20AssetAsync(ownerPrivateKeyStr, tokenAddrStr, chain33Receiver string, amount *big.Int, client ethinterface.EthClientSpec, bridgeBank *generated.BridgeBank) (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 PrepareAuth

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

PrepareAuth ...

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(oracleInstance *generated.Oracle, client ethinterface.EthClientSpec, sender, tokenOnEth common.Address, claim ProphecyClaim, privateKey *ecdsa.PrivateKey) (txhash string, err 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) (string, error)

func SetupMultiSign

func SetupMultiSign(ownerPrivateKeyStr, multiSignAddrstr string, owners []string, client ethinterface.EthClientSpec) (string, error)

func SetupWebsocketEthClient

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

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

func TransferEth

func TransferEth(fromPrivateKeyStr, toAddr string, amount *big.Int, client ethinterface.EthClientSpec) (string, error)

func TransferToken

func TransferToken(tokenAddr, fromPrivateKeyStr, toAddr string, amount *big.Int, client ethinterface.EthClientSpec) (string, error)

TransferToken ...

Types

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 ...

func DeployBridgeBank

func DeployBridgeBank(client ethinterface.EthClientSpec, privateKey *ecdsa.PrivateKey, deployer, operator, oracle, chain33Bridge common.Address) (*generated.BridgeBank, *DeployResult, error)

DeployBridgeBank : 部署BridgeBank

func DeployBridgeRegistry

func DeployBridgeRegistry(client ethinterface.EthClientSpec, privateKey *ecdsa.PrivateKey, deployer, chain33BridgeAddr, bridgeBankAddr, oracleAddr, valsetAddr common.Address) (*generated.BridgeRegistry, *DeployResult, error)

DeployBridgeRegistry : 部署BridgeRegistry

func DeployChain33Bridge

func DeployChain33Bridge(client ethinterface.EthClientSpec, privateKey *ecdsa.PrivateKey, deployer common.Address, operator, valset common.Address) (*generated.Chain33Bridge, *DeployResult, error)

DeployChain33Bridge : 部署Chain33Bridge

func DeployOracle

func DeployOracle(client ethinterface.EthClientSpec, privateKey *ecdsa.PrivateKey, deployer, operator, valset, chain33Bridge common.Address) (*generated.Oracle, *DeployResult, error)

DeployOracle : 部署Oracle

func DeployValset

func DeployValset(client ethinterface.EthClientSpec, privateKey *ecdsa.PrivateKey, deployer common.Address, operator common.Address, initValidators []common.Address, initPowers []*big.Int) (*generated.Valset, *DeployResult, error)

DeployValset : 部署Valset

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 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
	// contains filtered or unexported fields
}

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 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