Documentation ¶
Index ¶
Constants ¶
const ( ZeroExValidation = RejectedOrderKind("ZEROEX_VALIDATION") MeshError = RejectedOrderKind("MESH_ERROR") MeshValidation = RejectedOrderKind("MESH_VALIDATION") CoordinatorError = RejectedOrderKind("COORDINATOR_ERROR") )
RejectedOrderKind values
const ROInvalidSchemaCode = "InvalidSchema"
ROInvalidSchemaCode is the RejectedOrderStatus emitted if an order doesn't conform to the order schema
Variables ¶
var ( ROEthRPCRequestFailed = RejectedOrderStatus{ Code: "EthRPCRequestFailed", Message: "network request to Ethereum RPC endpoint failed", } ROCoordinatorRequestFailed = RejectedOrderStatus{ Code: "CoordinatorRequestFailed", Message: "network request to coordinator server endpoint failed", } ROCoordinatorSoftCancelled = RejectedOrderStatus{ Code: "CoordinatorSoftCancelled", Message: "order was soft-cancelled via the coordinator server", } ROCoordinatorEndpointNotFound = RejectedOrderStatus{ Code: "CoordinatorEndpointNotFound", Message: "corresponding coordinator endpoint not found in CoordinatorRegistry contract", } ROInvalidMakerAssetAmount = RejectedOrderStatus{ Code: "OrderHasInvalidMakerAssetAmount", Message: "order makerAssetAmount cannot be 0", } ROInvalidTakerAssetAmount = RejectedOrderStatus{ Code: "OrderHasInvalidTakerAssetAmount", Message: "order takerAssetAmount cannot be 0", } ROExpired = RejectedOrderStatus{ Code: "OrderExpired", Message: "order expired according to latest block timestamp", } ROFullyFilled = RejectedOrderStatus{ Code: "OrderFullyFilled", Message: "order already fully filled", } ROCancelled = RejectedOrderStatus{ Code: "OrderCancelled", Message: "order cancelled", } ROUnfunded = RejectedOrderStatus{ Code: "OrderUnfunded", Message: "maker has insufficient balance or allowance for this order to be filled", } ROInvalidMakerAssetData = RejectedOrderStatus{ Code: "OrderHasInvalidMakerAssetData", Message: "order makerAssetData must encode a supported assetData type", } ROInvalidTakerAssetData = RejectedOrderStatus{ Code: "OrderHasInvalidTakerAssetData", Message: "order takerAssetData must encode a supported assetData type", } ROInvalidSignature = RejectedOrderStatus{ Code: "OrderHasInvalidSignature", Message: "order signature must be valid", } ROMaxExpirationExceeded = RejectedOrderStatus{ Code: "OrderMaxExpirationExceeded", Message: "order expiration too far in the future", } ROInternalError = RejectedOrderStatus{ Code: "InternalError", Message: "an unexpected internal error has occurred", } ROMaxOrderSizeExceeded = RejectedOrderStatus{ Code: "MaxOrderSizeExceeded", Message: fmt.Sprintf("order exceeds the maximum encoded size of %d bytes", constants.MaxOrderSizeInBytes), } ROOrderAlreadyStoredAndUnfillable = RejectedOrderStatus{ Code: "OrderAlreadyStoredAndUnfillable", Message: "order is already stored and is unfillable. Mesh keeps unfillable orders in storage for a little while incase a block re-org makes them fillable again", } ROIncorrectChain = RejectedOrderStatus{ Code: "OrderForIncorrectChain", Message: "order was created for a different chain than the one this Mesh node is configured to support", } ROSenderAddressNotAllowed = RejectedOrderStatus{ Code: "SenderAddressNotAllowed", Message: "orders with a senderAddress are not currently supported", } RODatabaseFullOfOrders = RejectedOrderStatus{ Code: "DatabaseFullOfOrders", Message: "database is full of pinned orders and no orders can be deleted to make space (consider increasing MAX_ORDERS_IN_STORAGE)", } )
RejectedOrderStatus values
Functions ¶
func ConvertRejectOrderCodeToOrderEventEndState ¶
func ConvertRejectOrderCodeToOrderEventEndState(rejectedOrderStatus RejectedOrderStatus) (zeroex.OrderEventEndState, bool)
ConvertRejectOrderCodeToOrderEventEndState converts an RejectOrderCode to an OrderEventEndState type
Types ¶
type AcceptedOrderInfo ¶
type AcceptedOrderInfo struct { OrderHash common.Hash `json:"orderHash"` SignedOrder *zeroex.SignedOrder `json:"signedOrder"` FillableTakerAssetAmount *big.Int `json:"fillableTakerAssetAmount"` IsNew bool `json:"isNew"` }
AcceptedOrderInfo represents an fillable order and how much it could be filled for
func (AcceptedOrderInfo) MarshalJSON ¶
func (a AcceptedOrderInfo) MarshalJSON() ([]byte, error)
MarshalJSON is a custom Marshaler for AcceptedOrderInfo
func (*AcceptedOrderInfo) UnmarshalJSON ¶
func (a *AcceptedOrderInfo) UnmarshalJSON(data []byte) error
UnmarshalJSON implements a custom JSON unmarshaller for the OrderEvent type
type OrderValidator ¶
type OrderValidator struct {
// contains filtered or unexported fields
}
OrderValidator validates 0x orders
func New ¶
func New(contractCaller bind.ContractCaller, chainID int, maxRequestContentLength int) (*OrderValidator, error)
New instantiates a new order validator
func (*OrderValidator) BatchOffchainValidation ¶
func (o *OrderValidator) BatchOffchainValidation(signedOrders []*zeroex.SignedOrder) ([]*zeroex.SignedOrder, []*RejectedOrderInfo)
BatchOffchainValidation performs all off-chain validation checks on a batch of 0x orders. These checks include: - `MakerAssetAmount` and `TakerAssetAmount` cannot be 0 - `AssetData` fields contain properly encoded, and currently supported assetData (ERC20 & ERC721 for now) - `Signature` contains a properly encoded 0x signature - Validate that order isn't expired Returns the signedOrders that are off-chain valid along with an array of orderInfo for the rejected orders
func (*OrderValidator) BatchValidate ¶
func (o *OrderValidator) BatchValidate(ctx context.Context, rawSignedOrders []*zeroex.SignedOrder, areNewOrders bool, blockNumber *big.Int) *ValidationResults
BatchValidate retrieves all the information needed to validate the supplied orders. It splits the orders into chunks of `chunkSize`, and makes no more then `concurrencyLimit` requests concurrently. If a request fails, re-attempt it up to four times before giving up. If some requests fail, this method still returns whatever order information it was able to retrieve up until the failure. The `blockNumber` parameter lets the caller specify a specific block height at which to validate the orders. This can be set to the `latest` block or any other historical block number.
type RejectedOrderInfo ¶
type RejectedOrderInfo struct { OrderHash common.Hash `json:"orderHash"` SignedOrder *zeroex.SignedOrder `json:"signedOrder"` Kind RejectedOrderKind `json:"kind"` Status RejectedOrderStatus `json:"status"` }
RejectedOrderInfo encapsulates all the needed information to understand _why_ a 0x order was rejected (i.e. did not pass) order validation. Since there are many potential reasons, some Mesh-specific, others 0x-specific and others due to external factors (i.e., network disruptions, etc...), we categorize them into `Kind`s and uniquely identify the reasons for machines with a `Code`
type RejectedOrderKind ¶
type RejectedOrderKind string
RejectedOrderKind enumerates all kinds of reasons an order could be rejected by Mesh
type RejectedOrderStatus ¶
RejectedOrderStatus enumerates all the unique reasons for an orders rejection
type ValidationResults ¶
type ValidationResults struct { Accepted []*AcceptedOrderInfo `json:"accepted"` Rejected []*RejectedOrderInfo `json:"rejected"` }
ValidationResults defines the validation results returned from BatchValidate Within this context, an order is `Accepted` if it passes all the 0x schema tests and is fillable for a non-zero amount. An order is `Rejected` if it does not satisfy these conditions OR if we were unable to complete the validation process for whatever reason