ethtxs

package
v1.66.2 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2022 License: BSD-3-Clause Imports: 32 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 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 CreateBridgeToken

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

CreateBridgeToken ...

func CreateERC20Token

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

CreateERC20Token ...

func DeployAndInit

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

DeployAndInit ...

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 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 string, decimal int64) (*ebrelayerTypes.EthBridgeClaim, error)

LogBurnToEthBridgeClaim ...

func LogLockToEthBridgeClaim

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

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

func MintERC20Token

func MintERC20Token(tokenAddr, ownerAddr string, amount *big.Int, client ethinterface.EthClientSpec, para *OperatorInfo) (string, error)

MintERC20Token ...

func ParseBurnLockTxReceipt

func ParseBurnLockTxReceipt(claimType events.Event, receipt *chain33Types.ReceiptData) *events.Chain33Msg

ParseBurnLockTxReceipt : parses data from a Burn/Lock event witnessed on chain33 into a Chain33Msg struct

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 RelayBurnToChain33

func RelayBurnToChain33(privateKey chain33Crypto.PrivKey, claim *ebrelayerTypes.EthBridgeClaim, rpcURL string) (string, error)

RelayBurnToChain33 ...

func RelayLockToChain33

func RelayLockToChain33(privateKey chain33Crypto.PrivKey, claim *ebrelayerTypes.EthBridgeClaim, rpcURL string) (string, error)

RelayLockToChain33 : RelayLockToChain33 applies validator's signature to an EthBridgeClaim message

containing information about an event on the Ethereum blockchain before relaying to the Bridge

func RelayOracleClaimToEthereum

func RelayOracleClaimToEthereum(oracleInstance *generated.Oracle, client ethinterface.EthClientSpec, sender common.Address, event events.Event, claim ProphecyClaim, privateKey *ecdsa.PrivateKey, chain33TxHash []byte) (txhash string, err error)

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

func SetupWebsocketEthClient

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

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

func SignClaim4Eth

func SignClaim4Eth(hash common.Hash, privateKey *ecdsa.PrivateKey) ([]byte, error)

SignClaim4Eth ...

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.Event
	Chain33Sender        []byte
	EthereumReceiver     common.Address
	TokenContractAddress common.Address
	Symbol               string
	Amount               *big.Int
}

ProphecyClaim : contains data required to make an ProphecyClaim

func Chain33MsgToProphecyClaim

func Chain33MsgToProphecyClaim(event 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
}

X2EthDeployInfo ...

Jump to

Keyboard shortcuts

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