orderwatch

package
v1.0.6-beta Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2019 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EVENT_SIGNATURES = [...]string{
	"Transfer(address,address,uint256)",
	"Approval(address,address,uint256)",
	"ApprovalForAll(address,address,bool)",
	"Deposit(address,uint256)",
	"Withdrawal(address,uint256)",
	"Fill(address,address,address,address,uint256,uint256,uint256,uint256,bytes32,bytes,bytes)",
	"Cancel(address,address,address,bytes32,bytes,bytes)",
	"CancelUpTo(address,address,uint256)",
}

Functions

func GetRelevantTopics

func GetRelevantTopics() []common.Hash

GetRelevantTopics returns the OrderWatcher-relevant topics that should be used when filtering the logs retrieved for Ethereum blocks

Types

type Decoder

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

Decoder decodes events relevant to the fillability of 0x orders. Since ERC20 & ERC721 events have the same signatures, but different meanings, all ERC20 & ERC721 contract addresses must be added to the decoder ahead of time.

func NewDecoder

func NewDecoder() (*Decoder, error)

NewDecoder instantiates a new 0x order-relevant events decoder

func (*Decoder) AddKnownERC20

func (d *Decoder) AddKnownERC20(address common.Address)

AddKnownERC20 registers the supplied contract address as an ERC20 contract. If an event is found from this contract address, the decoder will properly decode the `Transfer` and `Approve` events including the correct event parameter names.

func (*Decoder) AddKnownERC721

func (d *Decoder) AddKnownERC721(address common.Address)

AddKnownERC721 registers the supplied contract address as an ERC721 contract. If an event is found from this contract address, the decoder will properly decode the `Transfer` and `Approve` events including the correct event parameter names.

func (*Decoder) AddKnownExchange

func (d *Decoder) AddKnownExchange(address common.Address)

AddKnownExchange registers the supplied contract address as a 0x Exchange contract. If an event is found from this contract address, the decoder will properly decode it's events including the correct event parameter names.

func (*Decoder) Decode

func (d *Decoder) Decode(log types.Log, decodedLog interface{}) error

Decode attempts to decode the supplied log given the event types relevant to 0x orders. The decoded result is stored in the value pointed to by supplied `decodedLog` struct.

func (*Decoder) FindEventType

func (d *Decoder) FindEventType(log types.Log) (string, error)

FindEventType returns to event type contained in the supplied log. It looks both at the registered contract addresses and the log topic.

func (*Decoder) RemoveKnownERC20

func (d *Decoder) RemoveKnownERC20(address common.Address)

RemoveKnownERC20 removes an ERC20 address from the list of known addresses. We will no longer decode events for this token.

func (*Decoder) RemoveKnownERC721

func (d *Decoder) RemoveKnownERC721(address common.Address)

RemoveKnownERC721 removes an ERC721 address from the list of known addresses. We will no longer decode events for this token.

func (*Decoder) RemoveKnownExchange

func (d *Decoder) RemoveKnownExchange(address common.Address)

RemoveKnownExchange removes an Exchange address from the list of known addresses. We will no longer decode events for this contract.

type ERC20ApprovalEvent

type ERC20ApprovalEvent struct {
	Owner   common.Address
	Spender common.Address
	Value   *big.Int
}

ERC20ApprovalEvent represents an ERC20 Approval event

type ERC20TransferEvent

type ERC20TransferEvent struct {
	From  common.Address
	To    common.Address
	Value *big.Int
}

ERC20TransferEvent represents an ERC20 Transfer event

type ERC721ApprovalEvent

type ERC721ApprovalEvent struct {
	Owner    common.Address
	Approved common.Address
	TokenId  *big.Int
}

ERC721ApprovalEvent represents an ERC721 Approval event

type ERC721ApprovalForAllEvent

type ERC721ApprovalForAllEvent struct {
	Owner    common.Address
	Operator common.Address
	Approved bool
}

ERC721ApprovalForAllEvent represents an ERC721 ApprovalForAll event

type ERC721TransferEvent

type ERC721TransferEvent struct {
	From    common.Address
	To      common.Address
	TokenId *big.Int
}

ERC721TransferEvent represents an ERC721 Transfer event

type ExchangeCancelEvent

type ExchangeCancelEvent struct {
	MakerAddress        common.Address
	FeeRecipientAddress common.Address
	SenderAddress       common.Address
	OrderHash           common.Hash
	MakerAssetData      []byte
	TakerAssetData      []byte
}

ExchangeCancelEvent represents a 0x Exchange Cancel event

type ExchangeCancelUpToEvent

type ExchangeCancelUpToEvent struct {
	MakerAddress  common.Address
	SenderAddress common.Address
	OrderEpoch    *big.Int
}

ExchangeCancelUpToEvent represents a 0x Exchange CancelUpTo event

type ExchangeFillEvent

type ExchangeFillEvent struct {
	MakerAddress           common.Address
	TakerAddress           common.Address
	SenderAddress          common.Address
	FeeRecipientAddress    common.Address
	MakerAssetFilledAmount *big.Int
	TakerAssetFilledAmount *big.Int
	MakerFeePaid           *big.Int
	TakerFeePaid           *big.Int
	OrderHash              common.Hash
	MakerAssetData         []byte
	TakerAssetData         []byte
}

ExchangeFillEvent represents a 0x Exchange Fill event

type OrderWithTxHashes

type OrderWithTxHashes struct {
	Order    *meshdb.Order
	TxHashes map[common.Hash]interface{}
}

type UnsupportedEventError

type UnsupportedEventError struct {
	Topics          []common.Hash
	ContractAddress common.Address
}

UnsupportedEventError is thrown when an unsupported topic is encountered

func (UnsupportedEventError) Error

func (e UnsupportedEventError) Error() string

Error returns the error string

type UntrackedTokenError

type UntrackedTokenError struct {
	Topic        common.Hash
	TokenAddress common.Address
}

func (UntrackedTokenError) Error

func (e UntrackedTokenError) Error() string

Error returns the error string

type Watcher

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

Watcher watches all order-relevant state and handles the state transitions

func New

func New(meshDB *meshdb.MeshDB, blockWatcher *blockwatch.Watcher, orderValidator *zeroex.OrderValidator, networkID int, expirationBuffer time.Duration) (*Watcher, error)

New instantiates a new order watcher

func (*Watcher) Start

func (w *Watcher) Start() error

Start sets up the event & expiration watchers as well as the cleanup worker. Event watching will require the blockwatch.Watcher to be started however.

func (*Watcher) Stop

func (w *Watcher) Stop() error

Stop closes the block subscription, stops the event, expiration watcher and the cleanup worker.

func (*Watcher) Subscribe

func (w *Watcher) Subscribe(sink chan<- []*zeroex.OrderEvent) event.Subscription

Subscribe allows one to subscribe to the order events emitted by the OrderWatcher. To unsubscribe, simply call `Unsubscribe` on the returned subscription. The sink channel should have ample buffer space to avoid blocking other subscribers. Slow subscribers are not dropped.

func (*Watcher) Watch

func (w *Watcher) Watch(orderInfo *zeroex.AcceptedOrderInfo) error

Watch adds a 0x order to the DB and watches it for changes in fillability.

type WethDepositEvent

type WethDepositEvent struct {
	Owner common.Address
	Value *big.Int
}

WethDepositEvent represents a wrapped Ether Deposit event

type WethWithdrawalEvent

type WethWithdrawalEvent struct {
	Owner common.Address
	Value *big.Int
}

WethWithdrawalEvent represents a wrapped Ether Withdraw event

Jump to

Keyboard shortcuts

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