Documentation ¶
Overview ¶
Package eth test eth router by implementing `tokens.IBridge` interface. this testing implementation is using the product `token/eth` impl. this way implementation is just an example, in reality we need impl the `tokens.IBridge` interface from scratch, and take it into the product implementation after this testing is passed.
Index ¶
- type Bridge
- func (b *Bridge) BuildRawTransaction(args *tokens.BuildTxArgs) (rawTx interface{}, err error)
- func (b *Bridge) GetLatestBlockNumber() (uint64, error)
- func (b *Bridge) GetLatestBlockNumberOf(url string) (uint64, error)
- func (b *Bridge) GetTransaction(txHash string) (interface{}, error)
- func (b *Bridge) GetTransactionStatus(txHash string) (*tokens.TxStatus, error)
- func (b *Bridge) InitAfterConfig()
- func (b *Bridge) IsValidAddress(address string) bool
- func (b *Bridge) MPCSignTransaction(rawTx interface{}, args *tokens.BuildTxArgs) (signedTx interface{}, txHash string, err error)
- func (b *Bridge) RegisterSwap(txHash string, args *tokens.RegisterArgs) ([]*tokens.SwapTxInfo, []error)
- func (b *Bridge) SendTransaction(signedTx interface{}) (txHash string, err error)
- func (b *Bridge) VerifyMsgHash(rawTx interface{}, msgHash []string) error
- func (b *Bridge) VerifyTransaction(txHash string, ars *tokens.VerifyArgs) (*tokens.SwapTxInfo, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bridge ¶
Bridge bridge impl struct
func NewCrossChainBridge ¶
func NewCrossChainBridge() *Bridge
NewCrossChainBridge new bridge instance
func (*Bridge) BuildRawTransaction ¶
func (b *Bridge) BuildRawTransaction(args *tokens.BuildTxArgs) (rawTx interface{}, err error)
BuildRawTransaction build tx with specified args.
func (*Bridge) GetLatestBlockNumber ¶
GetLatestBlockNumber get latest block number through gateway urls. used in `GetRouterSwap` server rpc.
func (*Bridge) GetLatestBlockNumberOf ¶
GetLatestBlockNumberOf get latest block number of specified url. used in `AdjustGatewayOrder` function.
func (*Bridge) GetTransaction ¶
GetTransaction get tx by hash.
func (*Bridge) GetTransactionStatus ¶
GetTransactionStatus get tx status by hash. get tx related infos like block height, confirmations, receipts etc. These infos is used to verify tx is acceptable. you can extend `TxStatus` if fields in it is not enough to do the checking.
func (*Bridge) InitAfterConfig ¶
func (b *Bridge) InitAfterConfig()
InitAfterConfig init variables (ie. extra members) after loading config
func (*Bridge) IsValidAddress ¶
IsValidAddress check if given `address` is valid on this chain. prevent swap to an invalid `bind` address which will make assets loss.
func (*Bridge) MPCSignTransaction ¶
func (b *Bridge) MPCSignTransaction(rawTx interface{}, args *tokens.BuildTxArgs) (signedTx interface{}, txHash string, err error)
MPCSignTransaction mpc sign tx.
func (*Bridge) RegisterSwap ¶
func (b *Bridge) RegisterSwap(txHash string, args *tokens.RegisterArgs) ([]*tokens.SwapTxInfo, []error)
RegisterSwap register swap. used in `RegisterRouterSwap` server rpc.
func (*Bridge) SendTransaction ¶
SendTransaction send signed raw tx.
func (*Bridge) VerifyMsgHash ¶
VerifyMsgHash verify message hash is same. 'message hash' here is the real content (usually a hash) which will be signed. used in `accept` work for oracles to replay the same tx on destination chain. oracle will only accept a sign info if and only if the oracle can verify the tx and rebuild a tx and ensure the message hash is same.
func (*Bridge) VerifyTransaction ¶
func (b *Bridge) VerifyTransaction(txHash string, ars *tokens.VerifyArgs) (*tokens.SwapTxInfo, error)
VerifyTransaction verify swap tx is valid and success on chain with needed confirmations.