Documentation ¶
Index ¶
- Constants
- Variables
- func Denominate(gwei *big.Int) string
- func IsNoPeerErr(err error) bool
- type Bridge
- func (bridge *Bridge) Close() error
- func (bridge *Bridge) GetBridgeContract() *BridgeContract
- func (bridge *Bridge) GetClient() *LightClient
- func (bridge *Bridge) ProcessConsensusChange(css modules.ConsensusChange)
- func (bridge *Bridge) Start(cs modules.ConsensusSet, erc20Registry erc20types.ERC20Registry, ...) error
- type BridgeContract
- func (bridge *BridgeContract) ABI() abi.ABI
- func (bridge *BridgeContract) AccountAddress() (common.Address, error)
- func (bridge *BridgeContract) Close() error
- func (bridge *BridgeContract) EthBalance() (*big.Int, error)
- func (bridge *BridgeContract) GetContractAdress() common.Address
- func (bridge *BridgeContract) GetPastWithdraws(startHeight uint64, endHeight *uint64) ([]WithdrawEvent, error)
- func (bridge *BridgeContract) IsMintTxID(txID string) (bool, error)
- func (bridge *BridgeContract) IsWithdrawalAddress(address erc20types.ERC20Address) (bool, error)
- func (bridge *BridgeContract) LightClient() *LightClient
- func (bridge *BridgeContract) Loop(ch chan<- *types.Header)
- func (bridge *BridgeContract) Mint(receiver erc20types.ERC20Address, amount *big.Int, txID string) error
- func (bridge *BridgeContract) Refresh(head *types.Header) error
- func (bridge *BridgeContract) RegisterWithdrawalAddress(address erc20types.ERC20Address) error
- func (bridge *BridgeContract) SubscribeMint() error
- func (bridge *BridgeContract) SubscribeRegisterWithdrawAddress() error
- func (bridge *BridgeContract) SubscribeTransfers() error
- func (bridge *BridgeContract) SubscribeWithdraw(wc chan<- WithdrawEvent, startHeight uint64) error
- func (bridge *BridgeContract) TokenBalance(address common.Address) (*big.Int, error)
- func (bridge *BridgeContract) TransferFunds(recipient common.Address, amount *big.Int) error
- func (bridge *BridgeContract) WatchWithdraw(opts *bind.WatchOpts, sink chan<- *contract.TTFT20Withdraw, ...) (event.Subscription, error)
- type LightClient
- func (lc *LightClient) AccountAddress() (common.Address, error)
- func (lc *LightClient) AccountBalanceAt(ctx context.Context, blockNumber *big.Int) (*big.Int, error)
- func (lc *LightClient) Close() error
- func (lc *LightClient) FetchTransaction(ctx context.Context, blockHash common.Hash, txHash common.Hash) (*types.Transaction, uint64, error)
- func (lc *LightClient) GetBalanceInfo() (*erc20types.ERC20BalanceInfo, error)
- func (lc *LightClient) GetStatus() (*erc20types.ERC20SyncStatus, error)
- func (lc *LightClient) LoadAccount(accountJSON, accountPass string) error
- func (lc *LightClient) SignTx(tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)
- func (lc *LightClient) Synchronising() bool
- func (lc *LightClient) Wait(ctx context.Context) error
- type LightClientConfig
- type WithdrawEvent
Constants ¶
const ( // TFTBlockDelay is the amount of blocks to wait before // pushing tft transactions to the ethereum contract TFTBlockDelay = 6 // EthBlockDelay is the amount of blocks to wait before // pushing eth transaction to the tfchain network EthBlockDelay = 30 )
Variables ¶
var ( // ErrNoAccountLoaded is an error returned for all Light Client methods // that require an account and for which no account is loaded. ErrNoAccountLoaded = errors.New("no account was loaded into the light client") )
Functions ¶
func Denominate ¶
Denominate converts gwei units into ether units
func IsNoPeerErr ¶
IsNoPeerErr checks if an error is means an ethereum client could not execute a call because it has no valid peers
Types ¶
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
Bridge is a high lvl structure which listens on contract events and bridge-related tfchain transactions, and handles them
func NewBridge ¶
func NewBridge(cs modules.ConsensusSet, tp modules.TransactionPool, ethPort uint16, accountJSON, accountPass string, ethNetworkName string, bootnodes []string, contractAddress string, datadir string, bcInfo types.BlockchainInfo, chainCts types.ChainConstants, txVersions erc20types.TransactionVersions, cancel <-chan struct{}) (*Bridge, error)
NewBridge creates a new Bridge.
func (*Bridge) GetBridgeContract ¶
func (bridge *Bridge) GetBridgeContract() *BridgeContract
GetBridgeContract returns this bridge's contract.
func (*Bridge) GetClient ¶
func (bridge *Bridge) GetClient() *LightClient
GetClient returns bridgecontract lightclient
func (*Bridge) ProcessConsensusChange ¶
func (bridge *Bridge) ProcessConsensusChange(css modules.ConsensusChange)
ProcessConsensusChange implements modules.ConsensusSetSubscriber, used to apply/revert blocks.
func (*Bridge) Start ¶
func (bridge *Bridge) Start(cs modules.ConsensusSet, erc20Registry erc20types.ERC20Registry, cancel <-chan struct{}) error
Start the main processing loop of the bridge
type BridgeContract ¶
type BridgeContract struct {
// contains filtered or unexported fields
}
BridgeContract exposes a higher lvl api for specific contract bindings. In case of proxy contracts, the bridge needs to use the bindings of the implementation contract, but the address of the proxy.
func NewBridgeContract ¶
func NewBridgeContract(networkName string, bootnodes []string, contractAddress string, port int, accountJSON, accountPass string, datadir string, cancel <-chan struct{}) (*BridgeContract, error)
NewBridgeContract creates a new wrapper for an allready deployed contract
func (*BridgeContract) ABI ¶
func (bridge *BridgeContract) ABI() abi.ABI
ABI returns the parsed and bound ABI driving this bridge contract
func (*BridgeContract) AccountAddress ¶
func (bridge *BridgeContract) AccountAddress() (common.Address, error)
AccountAddress returns the account address of the bridge contract
func (*BridgeContract) Close ¶
func (bridge *BridgeContract) Close() error
Close terminates the Ethereum connection and tears down the stack.
func (*BridgeContract) EthBalance ¶
func (bridge *BridgeContract) EthBalance() (*big.Int, error)
func (*BridgeContract) GetContractAdress ¶
func (bridge *BridgeContract) GetContractAdress() common.Address
GetContractAdress returns the address of this contract
func (*BridgeContract) GetPastWithdraws ¶
func (bridge *BridgeContract) GetPastWithdraws(startHeight uint64, endHeight *uint64) ([]WithdrawEvent, error)
GetPastWithdraws gets a list of past withdraw events between two block numbers
func (*BridgeContract) IsMintTxID ¶
func (bridge *BridgeContract) IsMintTxID(txID string) (bool, error)
func (*BridgeContract) IsWithdrawalAddress ¶
func (bridge *BridgeContract) IsWithdrawalAddress(address erc20types.ERC20Address) (bool, error)
func (*BridgeContract) LightClient ¶
func (bridge *BridgeContract) LightClient() *LightClient
LightClient returns the LightClient driving this bridge contract
func (*BridgeContract) Loop ¶
func (bridge *BridgeContract) Loop(ch chan<- *types.Header)
Loop subscribes to new eth heads. If a new head is received, it is passed on the given channel, after which the internal stats are updated if no update is already in progress
func (*BridgeContract) Mint ¶
func (bridge *BridgeContract) Mint(receiver erc20types.ERC20Address, amount *big.Int, txID string) error
func (*BridgeContract) Refresh ¶
func (bridge *BridgeContract) Refresh(head *types.Header) error
Refresh attempts to retrieve the latest header from the chain and extract the associated bridge balance and nonce for connectivity caching.
func (*BridgeContract) RegisterWithdrawalAddress ¶
func (bridge *BridgeContract) RegisterWithdrawalAddress(address erc20types.ERC20Address) error
func (*BridgeContract) SubscribeMint ¶
func (bridge *BridgeContract) SubscribeMint() error
SubscribeMint subscribes to new Mint events on the given contract. This call blocks and prints out info about any mint as it happened
func (*BridgeContract) SubscribeRegisterWithdrawAddress ¶
func (bridge *BridgeContract) SubscribeRegisterWithdrawAddress() error
SubscribeRegisterWithdrawAddress subscribes to new RegisterWithdrawalAddress events on the given contract. This call blocks and prints out info about any RegisterWithdrawalAddress event as it happened
func (*BridgeContract) SubscribeTransfers ¶
func (bridge *BridgeContract) SubscribeTransfers() error
SubscribeTransfers subscribes to new Transfer events on the given contract. This call blocks and prints out info about any transfer as it happened
func (*BridgeContract) SubscribeWithdraw ¶
func (bridge *BridgeContract) SubscribeWithdraw(wc chan<- WithdrawEvent, startHeight uint64) error
SubscribeWithdraw subscribes to new Withdraw events on the given contract. This call blocks and prints out info about any withdraw as it happened
func (*BridgeContract) TokenBalance ¶
func (*BridgeContract) TransferFunds ¶
TransferFunds transfers funds from one address to another
func (*BridgeContract) WatchWithdraw ¶
func (bridge *BridgeContract) WatchWithdraw(opts *bind.WatchOpts, sink chan<- *contract.TTFT20Withdraw, receiver []common.Address) (event.Subscription, error)
WatchWithdraw is a free log subscription operation binding the contract event 0x884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a9424364.
Solidity: e Withdraw(receiver indexed address, tokens uint256)
This method is copied from the generated bindings and slightly modified, so we can add logic to stay backwards compatible with the old withdraw event signature
type LightClient ¶
type LightClient struct { *ethclient.Client // Client connection to the Ethereum chain // contains filtered or unexported fields }
LightClient creates a light client that can be used to interact with the Ethereum network, for ERC20 purposes. By default it is read-only, in order to also write to the network, you'll need load an account using the LoadAccount method.
func NewLightClient ¶
func NewLightClient(lccfg LightClientConfig) (*LightClient, error)
NewLightClient creates a new light client that can be used to interact with the ETH network. See `LightClient` for more information.
func (*LightClient) AccountAddress ¶
func (lc *LightClient) AccountAddress() (common.Address, error)
AccountAddress returns the address of the loaded account, returning an error only if no account was loaded.
func (*LightClient) AccountBalanceAt ¶
func (lc *LightClient) AccountBalanceAt(ctx context.Context, blockNumber *big.Int) (*big.Int, error)
AccountBalanceAt returns the balance for the account at the given block height.
func (*LightClient) Close ¶
func (lc *LightClient) Close() error
Close terminates the Ethereum connection and tears down the stack.
func (*LightClient) FetchTransaction ¶
func (lc *LightClient) FetchTransaction(ctx context.Context, blockHash common.Hash, txHash common.Hash) (*types.Transaction, uint64, error)
FetchTransaction fetches a transaction from a remote peer using its block hash and tx index (within that block). Together with a found transactions it also returns the confirmations available for that Tx.
func (*LightClient) GetBalanceInfo ¶
func (lc *LightClient) GetBalanceInfo() (*erc20types.ERC20BalanceInfo, error)
GetBalanceInfo returns bridge ethereum address and balance
func (*LightClient) GetStatus ¶
func (lc *LightClient) GetStatus() (*erc20types.ERC20SyncStatus, error)
GetStatus implements ERC20TransactionValidator.GetStatus
func (*LightClient) LoadAccount ¶
func (lc *LightClient) LoadAccount(accountJSON, accountPass string) error
LoadAccount loads an account into this light client, allowing writeable operations using the loaded account. An error is returned in case no account could be loaded.
func (*LightClient) SignTx ¶
func (lc *LightClient) SignTx(tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)
SignTx signs a given traction with the loaded account, returning the signed transaction and no error on success.
func (*LightClient) Synchronising ¶
func (lc *LightClient) Synchronising() bool
Synchronising returns a boolean if the ethereum client is syncing or not
type LightClientConfig ¶
type LightClientConfig struct { Port int DataDir string BootstrapNodes []*enode.Node NetworkName string NetworkID uint64 GenesisBlock *core.Genesis }
LightClientConfig combines all configuration required for creating and configuring a LightClient.
type WithdrawEvent ¶
type WithdrawEvent struct {
// contains filtered or unexported fields
}
WithdrawEvent holds relevant information about a withdraw event
func (WithdrawEvent) BlockHash ¶
func (w WithdrawEvent) BlockHash() common.Hash
BlockHash of the containing block
func (WithdrawEvent) BlockHeight ¶
func (w WithdrawEvent) BlockHeight() uint64
BlockHeight of the containing block
func (WithdrawEvent) Receiver ¶
func (w WithdrawEvent) Receiver() common.Address
Receiver of the withdraw
func (WithdrawEvent) TxHash ¶
func (w WithdrawEvent) TxHash() common.Hash
TxHash hash of the transaction