zeroex

package
v0.0.0-...-0b85bb3 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ESInvalid is an event that is never emitted. It is here to discern between a declared but uninitialized OrderEventEndState
	ESInvalid = OrderEventEndState("INVALID")
	// ESOrderAdded means an order was successfully added to the Mesh node
	ESOrderAdded = OrderEventEndState("ADDED")
	// ESOrderFilled means an order was filled for a partial amount
	ESOrderFilled = OrderEventEndState("FILLED")
	// ESOrderFullyFilled means an order was fully filled such that it's remaining fillableTakerAssetAmount is 0
	ESOrderFullyFilled = OrderEventEndState("FULLY_FILLED")
	// ESOrderCancelled means an order was cancelled on-chain
	ESOrderCancelled = OrderEventEndState("CANCELLED")
	// ESOrderExpired means an order expired according to the latest block timestamp
	ESOrderExpired = OrderEventEndState("EXPIRED")
	// ESOrderUnexpired means an order is no longer expired. This can happen if a block re-org causes the latest
	// block timestamp to decline below the order's expirationTimestamp (rare and usually short-lived)
	ESOrderUnexpired = OrderEventEndState("UNEXPIRED")
	// ESOrderBecameUnfunded means an order has become unfunded. This happens if the maker transfers the balance /
	// changes their allowance backing an order
	ESOrderBecameUnfunded = OrderEventEndState("UNFUNDED")
	// ESOrderFillabilityIncreased means the fillability of an order has increased. Fillability for an order can
	// increase if a previously processed fill event gets reverted, or if a maker tops up their balance/allowance
	// backing an order
	ESOrderFillabilityIncreased = OrderEventEndState("FILLABILITY_INCREASED")
	// ESStoppedWatching means an order is potentially still valid but was removed for a different reason (e.g.
	// the database is full or the peer that sent the order was misbehaving). The order will no longer be watched
	// and no further events for this order will be emitted. In some cases, the order may be re-added in the
	// future.
	ESStoppedWatching = OrderEventEndState("STOPPED_WATCHING")
)

OrderEventEndState values

View Source
const ERC1155AssetDataID = "a7cb5fb7"

ERC1155AssetDataID is the assetDataId for ERC721 tokens

View Source
const ERC20AssetDataID = "f47261b0"

ERC20AssetDataID is the assetDataId for ERC20 tokens

View Source
const ERC20BridgeAssetDataID = "dc1600f3"

ERC20BridgeAssetDataID is the assetDataId for ERC20Bridge assets

View Source
const ERC721AssetDataID = "02571792"

ERC721AssetDataID is the assetDataId for ERC721 tokens

View Source
const MultiAssetDataID = "94cfcdd7"

MultiAssetDataID is the assetDataId for multiAsset tokens

Variables

This section is empty.

Functions

This section is empty.

Types

type AssetDataDecoder

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

AssetDataDecoder decodes 0x order asset data

func NewAssetDataDecoder

func NewAssetDataDecoder() *AssetDataDecoder

NewAssetDataDecoder instantiates a new asset data decoder

func (*AssetDataDecoder) Decode

func (a *AssetDataDecoder) Decode(assetData []byte, decodedAssetData interface{}) error

Decode decodes an encoded asset data into it's sub-components

func (*AssetDataDecoder) GetName

func (a *AssetDataDecoder) GetName(assetData []byte) (string, error)

GetName returns the name of the assetData type

type ContractEvent

type ContractEvent struct {
	BlockHash  common.Hash
	TxHash     common.Hash
	TxIndex    uint
	LogIndex   uint
	IsRemoved  bool
	Address    common.Address
	Kind       string
	Parameters interface{}
}

ContractEvent is an event emitted by a smart contract

func (ContractEvent) MarshalJSON

func (c ContractEvent) MarshalJSON() ([]byte, error)

MarshalJSON implements a custom JSON marshaller for the ContractEvent type

type ERC1155AssetData

type ERC1155AssetData struct {
	Address      common.Address
	Ids          []*big.Int
	Values       []*big.Int
	CallbackData []byte
}

ERC1155AssetData represents an ERC1155 assetData

type ERC20AssetData

type ERC20AssetData struct {
	Address common.Address
}

ERC20AssetData represents an ERC20 assetData

type ERC721AssetData

type ERC721AssetData struct {
	Address common.Address
	TokenId *big.Int
}

ERC721AssetData represents an ERC721 assetData

type MultiAssetData

type MultiAssetData struct {
	Amounts         []*big.Int
	NestedAssetData [][]byte
}

MultiAssetData represents an MultiAssetData

type Order

type Order struct {
	ChainID               *big.Int       `json:"chainId"`
	ExchangeAddress       common.Address `json:"exchangeAddress"`
	MakerAddress          common.Address `json:"makerAddress"`
	MakerAssetData        []byte         `json:"makerAssetData"`
	MakerFeeAssetData     []byte         `json:"makerFeeAssetData"`
	MakerAssetAmount      *big.Int       `json:"makerAssetAmount"`
	MakerFee              *big.Int       `json:"makerFee"`
	TakerAddress          common.Address `json:"takerAddress"`
	TakerAssetData        []byte         `json:"takerAssetData"`
	TakerFeeAssetData     []byte         `json:"takerFeeAssetData"`
	TakerAssetAmount      *big.Int       `json:"takerAssetAmount"`
	TakerFee              *big.Int       `json:"takerFee"`
	SenderAddress         common.Address `json:"senderAddress"`
	FeeRecipientAddress   common.Address `json:"feeRecipientAddress"`
	ExpirationTimeSeconds *big.Int       `json:"expirationTimeSeconds"`
	Salt                  *big.Int       `json:"salt"`
	// contains filtered or unexported fields
}

Order represents an unsigned 0x order

func (*Order) ComputeOrderHash

func (o *Order) ComputeOrderHash() (common.Hash, error)

ComputeOrderHash computes a 0x order hash

func (*Order) ResetHash

func (o *Order) ResetHash()

ResetHash resets the cached order hash. Usually only required for testing.

type OrderEvent

type OrderEvent struct {
	// Timestamp is an order event timestamp that can be used for bookkeeping purposes.
	// If the OrderEvent represents a Mesh-specific event (e.g., ADDED, STOPPED_WATCHING),
	// the timestamp is when the event was generated. If the event was generated after
	// re-validating an order at the latest block height (e.g., FILLED, UNFUNDED, CANCELED),
	// then it is set to the latest block timestamp at which the order was re-validated.
	Timestamp time.Time `json:"timestamp"`
	// OrderHash is the EIP712 hash of the 0x order
	OrderHash common.Hash `json:"orderHash"`
	// SignedOrder is the signed 0x order struct
	SignedOrder *SignedOrder `json:"signedOrder"`
	// EndState is the end state of this order at the time this event was generated
	EndState OrderEventEndState `json:"endState"`
	// FillableTakerAssetAmount is the amount for which this order is still fillable
	FillableTakerAssetAmount *big.Int `json:"fillableTakerAssetAmount"`
	// ContractEvents contains all the contract events that triggered this orders re-evaluation.
	// They did not all necessarily cause the orders state change itself, only it's re-evaluation.
	// Since it's state _did_ change, at least one of them did cause the actual state change.
	ContractEvents []*ContractEvent `json:"contractEvents"`
}

OrderEvent is the order event emitted by Mesh nodes on the "orders" topic when calling JSON-RPC method `mesh_subscribe`

func (OrderEvent) MarshalJSON

func (o OrderEvent) MarshalJSON() ([]byte, error)

MarshalJSON implements a custom JSON marshaller for the OrderEvent type

func (*OrderEvent) UnmarshalJSON

func (o *OrderEvent) UnmarshalJSON(data []byte) error

UnmarshalJSON implements a custom JSON unmarshaller for the OrderEvent type

type OrderEventEndState

type OrderEventEndState string

OrderEventEndState enumerates all the possible order event types. An OrderEventEndState describes the end state of a 0x order after revalidation

type OrderStatus

type OrderStatus uint8

OrderStatus represents the status of an order as returned from the 0x smart contracts as part of OrderInfo

const (
	OSInvalid OrderStatus = iota
	OSInvalidMakerAssetAmount
	OSInvalidTakerAssetAmount
	OSFillable
	OSExpired
	OSFullyFilled
	OSCancelled
	OSSignatureInvalid
	OSInvalidMakerAssetData
	OSInvalidTakerAssetData
)

OrderStatus values

type SignatureType

type SignatureType uint8

SignatureType represents the type of 0x signature encountered

const (
	IllegalSignature SignatureType = iota
	InvalidSignature
	EIP712Signature
	KlaySignSignature
	WalletSignature
	ValidatorSignature
	PreSignedSignature
	EIP1271WalletSignature
	NSignatureTypesSignature
)

SignatureType values

type SignedOrder

type SignedOrder struct {
	Order
	Signature []byte `json:"signature"`
}

SignedOrder represents a signed 0x order

func SignOrder

func SignOrder(signer signer.Signer, order *Order) (*SignedOrder, error)

SignOrder signs the 0x order with the supplied Signer

func (SignedOrder) MarshalJSON

func (s SignedOrder) MarshalJSON() ([]byte, error)

MarshalJSON implements a custom JSON marshaller for the SignedOrder type

func (*SignedOrder) Trim

func (s *SignedOrder) Trim() wrappers.TrimmedOrder

Trim converts the order to a TrimmedOrder, which is the format expected by our smart contracts. It removes the ChainID and ExchangeAddress fields.

func (*SignedOrder) UnmarshalJSON

func (s *SignedOrder) UnmarshalJSON(data []byte) error

UnmarshalJSON implements a custom JSON unmarshaller for the SignedOrder type

type SignedOrderJSON

type SignedOrderJSON struct {
	ChainID               int64  `json:"chainId"`
	ExchangeAddress       string `json:"exchangeAddress"`
	MakerAddress          string `json:"makerAddress"`
	MakerAssetData        string `json:"makerAssetData"`
	MakerFeeAssetData     string `json:"makerFeeAssetData"`
	MakerAssetAmount      string `json:"makerAssetAmount"`
	MakerFee              string `json:"makerFee"`
	TakerAddress          string `json:"takerAddress"`
	TakerAssetData        string `json:"takerAssetData"`
	TakerFeeAssetData     string `json:"takerFeeAssetData"`
	TakerAssetAmount      string `json:"takerAssetAmount"`
	TakerFee              string `json:"takerFee"`
	SenderAddress         string `json:"senderAddress"`
	FeeRecipientAddress   string `json:"feeRecipientAddress"`
	ExpirationTimeSeconds string `json:"expirationTimeSeconds"`
	Salt                  string `json:"salt"`
	Signature             string `json:"signature"`
}

SignedOrderJSON is an unmodified JSON representation of a SignedOrder

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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