ethereum

package
v0.0.0-...-8799a46 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2020 License: LGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DepositAsset           = "DepositAsset"
	NftTransfer            = "NftTransfer"
	ErcTransfer            = "ErcTransfer"
	DepositProposalCreated = "DepositProposalCreated"
	DepositedErc20         = "DepositedErc20"

	DepositedErc20Signature         = "ERC20Deposited(uint256,uint256)"
	DepositAssetSignature           = "DepositAsset(address,bytes32)"
	NftTransferSignature            = "NFTTransfer(uint256,uint256,address,address,uint256,bytes)"
	ErcTransferSignature            = "ERCTransfer(uint256,uint256,address,uint256,address)"
	DepositProposalCreatedSignature = "DepositProposalCreated(uint256,uint256,bytes32)"
)
View Source
const CreateDepositProposalMethod = "createDepositProposal"
View Source
const DefaultGasLimit = 6721975
View Source
const DefaultGasPrice = 20000000000
View Source
const ExecuteDepositMethod = "executeDepositProposal"
View Source
const StoreMethod = "store"
View Source
const VoteDepositProposalMethod = "voteDepositProposal"

Variables

View Source
var (
	RELAYER_ADDRESS = []string{
		keystore.TestKeyRing.EthereumKeys[keystore.AliceKey].Address(),
		keystore.TestKeyRing.EthereumKeys[keystore.BobKey].Address(),
		keystore.TestKeyRing.EthereumKeys[keystore.CharlieKey].Address(),
		keystore.TestKeyRing.EthereumKeys[keystore.DaveKey].Address(),
		keystore.TestKeyRing.EthereumKeys[keystore.EveKey].Address(),
	}

	ZERO_ADDRESS = common.HexToAddress("0x0000000000000000000000000000000000000000")
)

Functions

func UnpackDepositProposal

func UnpackDepositProposal(args ...interface{}) (depositProposal, error)

func UnpackErc20DepositRecord

func UnpackErc20DepositRecord(args ...interface{}) (erc20DepositRecord, error)

func UnpackGenericDepositRecord

func UnpackGenericDepositRecord(args ...interface{}) (genericDepositRecord, error)

Types

type ActiveSubscription

type ActiveSubscription struct {
	// contains filtered or unexported fields
}

type BridgeCaller

type BridgeCaller interface {
	GetGenericDepositRecord(opts *bind.CallOpts, originChainID *big.Int, depositNonce *big.Int) (common.Address, common.Address, *big.Int, common.Address, common.Address, []byte, error)
	GetERC20DepositRecord(opts *bind.CallOpts, originChainID *big.Int, depositNonce *big.Int) (common.Address, common.Address, *big.Int, common.Address, common.Address, *big.Int, error)
	GetDepositProposal(opts *bind.CallOpts, destinationChainID *big.Int, depositNonce *big.Int) (*big.Int, *big.Int, [32]byte, []common.Address, []common.Address, string, error)
}

type BridgeContract

type BridgeContract struct {
	BridgeFilterer
	BridgeCaller
	BridgeRaw
}

type BridgeFilterer

type BridgeFilterer interface {
}

type BridgeRaw

type BridgeRaw interface {
	Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error
	Transfer(opts *bind.TransactOpts) (*types.Transaction, error)
	Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error)
}

type Chain

type Chain struct {
	// contains filtered or unexported fields
}

func InitializeChain

func InitializeChain(chainCfg *core.ChainConfig) (*Chain, error)

func (*Chain) GetWriter

func (c *Chain) GetWriter() chains.Writer

func (*Chain) Id

func (c *Chain) Id() msg.ChainId

func (*Chain) SetRouter

func (c *Chain) SetRouter(r *router.Router)

func (*Chain) Start

func (c *Chain) Start() error

func (*Chain) Stop

func (c *Chain) Stop() error

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config encapsulates all necessary parameters in ethereum compatible forms

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

func NewConnection

func NewConnection(cfg *Config, kp *secp256k1.Keypair) *Connection

func (*Connection) Close

func (c *Connection) Close()

Close stops the WS connection

func (*Connection) Connect

func (c *Connection) Connect() error

Connect starts the ethereum WS connection

func (*Connection) LatestBlock

func (c *Connection) LatestBlock() (*ethtypes.Block, error)

LatestBlock returns the latest block from the current chain

func (*Connection) NetworkId

func (c *Connection) NetworkId() (*big.Int, error)

func (*Connection) NonceAt

func (c *Connection) NonceAt(account [20]byte, blockNum *big.Int) (uint64, error)

NonceAt returns the nonce of the given account and the given block

func (*Connection) PendingNonceAt

func (c *Connection) PendingNonceAt(account [20]byte) (*Nonce, error)

PendingNonceAt returns the pending nonce of the given account and the given block

func (*Connection) SubmitTx

func (c *Connection) SubmitTx(data []byte) error

SubmitTx submits a transaction to the chain It assumes the input data is an ethtypes.Transaction, marshalled as JSON

type DeployedContracts

type DeployedContracts struct {
	BridgeAddress            common.Address
	RelayerAddress           common.Address
	ERC20HandlerAddress      common.Address
	ERC721HandlerAddress     common.Address
	CentrifugeHandlerAddress common.Address
}

func DeployContracts

func DeployContracts(deployPK string, url string, relayers int, initialRelayerThreshold *big.Int, minCount uint8) (*DeployedContracts, error)

type EventSig

type EventSig string

func (*EventSig) GetTopic

func (en *EventSig) GetTopic() common.Hash

type Listener

type Listener struct {
	// contains filtered or unexported fields
}

func NewListener

func NewListener(conn *Connection, cfg *Config) *Listener

func (*Listener) GetSubscriptions

func (l *Listener) GetSubscriptions() []*Subscription

func (*Listener) RegisterEventHandler

func (l *Listener) RegisterEventHandler(subscription string, handler evtHandlerFn) error

RegisterEventHandler creates a subscription for the provided event on the bridge contract. Handler will be called for every instance of event.

func (*Listener) SetBridgeContract

func (l *Listener) SetBridgeContract(contract BridgeContract)

func (*Listener) SetRouter

func (l *Listener) SetRouter(r chains.Router)

func (*Listener) Start

func (l *Listener) Start() error

Start registers all subscriptions provided by the config

func (*Listener) Stop

func (l *Listener) Stop() error

Stop cancels all subscriptions. Must be called before Connection.Stop().

func (*Listener) Unsubscribe

func (l *Listener) Unsubscribe(sig EventSig)

Unsubscribe cancels a subscription for the given event

type Nonce

type Nonce struct {
	// contains filtered or unexported fields
}

Nonce is a struct that wraps the Nonce with a mutex lock this struct was implemented to prevent race conditions where two transactions try to transact at the same time and recieve the same nonce, causing one to be rejected.

type Subscription

type Subscription struct {
	// contains filtered or unexported fields
}

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

func NewWriter

func NewWriter(conn *Connection, cfg *Config) *Writer

func (*Writer) ResolveMessage

func (w *Writer) ResolveMessage(m msg.Message) bool

ResolveMessage handles any given message based on type A bool is returned to indicate failure/success, this should be ignored except for within tests.

func (*Writer) SetBridgeContract

func (w *Writer) SetBridgeContract(bridge BridgeContract)

func (*Writer) Start

func (w *Writer) Start() error

func (*Writer) Stop

func (w *Writer) Stop() error

Jump to

Keyboard shortcuts

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