Merge pull request #2219 from 0xProject/feature/sra-v3

Upgrade @0x/json-schemas, @0x/types, @0x/connect, @sra-spec to SRA V3
This commit is contained in:
Francesco Agosti 2019-09-30 18:00:29 -07:00 committed by GitHub
commit d6d506d1c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 183 additions and 100 deletions

View File

@ -19,7 +19,7 @@ import { fetchAsync } from '@0x/utils';
import * as _ from 'lodash';
import * as queryString from 'query-string';
import { Client, HttpRequestOptions, HttpRequestType } from './types';
import { HttpRequestOptions, HttpRequestType } from './types';
import { relayerResponseJsonParsers } from './utils/relayer_response_json_parsers';
const TRAILING_SLASHES_REGEX = /\/+$/;
@ -28,7 +28,7 @@ const TRAILING_SLASHES_REGEX = /\/+$/;
* This class includes all the functionality related to interacting with a set of HTTP endpoints
* that implement the standard relayer API v2
*/
export class HttpClient implements Client {
export class HttpClient {
private readonly _apiEndpointUrl: string;
/**
* Format parameters to be appended to http requests into query string form

View File

@ -1,6 +1,6 @@
export { HttpClient } from './http_client';
export { ordersChannelFactory } from './orders_channel_factory';
export { Client, OrdersChannel, OrdersChannelHandler } from './types';
export { OrdersChannel, OrdersChannelHandler } from './types';
export {
APIOrder,
AssetPairsRequestOpts,

View File

@ -1,30 +1,4 @@
import {
APIOrder,
AssetPairsItem,
AssetPairsRequestOpts,
FeeRecipientsResponse,
OrderbookRequest,
OrderbookResponse,
OrderConfigRequest,
OrderConfigResponse,
OrdersChannelSubscriptionOpts,
OrdersRequestOpts,
PagedRequestOpts,
PaginatedCollection,
SignedOrder,
} from '@0x/types';
export interface Client {
getAssetPairsAsync: (
requestOpts?: AssetPairsRequestOpts & PagedRequestOpts,
) => Promise<PaginatedCollection<AssetPairsItem>>;
getOrdersAsync: (requestOpts?: OrdersRequestOpts & PagedRequestOpts) => Promise<PaginatedCollection<APIOrder>>;
getOrderAsync: (orderHash: string) => Promise<APIOrder>;
getOrderbookAsync: (request: OrderbookRequest, requestOpts?: PagedRequestOpts) => Promise<OrderbookResponse>;
getOrderConfigAsync: (request: OrderConfigRequest) => Promise<OrderConfigResponse>;
getFeeRecipientsAsync: (requestOpts?: PagedRequestOpts) => Promise<FeeRecipientsResponse>;
submitOrderAsync: (signedOrder: SignedOrder) => Promise<void>;
}
import { APIOrder, OrdersChannelSubscriptionOpts } from '@0x/types';
export interface OrdersChannel {
subscribe: (subscriptionOpts: OrdersChannelSubscriptionOpts) => void;

View File

@ -2,5 +2,7 @@
"senderAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
"feeRecipientAddress": "0xb046140686d052fff581f63f8136cce132e857da",
"makerFee": "100000000000000",
"takerFee": "200000000000000"
"takerFee": "200000000000000",
"makerFeeAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
"takerFeeAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d"
}

View File

@ -7,4 +7,6 @@ export const orderConfigResponse: OrderConfigResponse = {
feeRecipientAddress: '0xb046140686d052fff581f63f8136cce132e857da',
makerFee: new BigNumber('100000000000000'),
takerFee: new BigNumber('200000000000000'),
makerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
takerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
};

View File

@ -1,10 +1,18 @@
{
"id": "/eip712DomainSchema",
"properties": {
"name": { "type": "string" },
"version": { "type": "version" },
"chainId": { "type": "number" },
"verifyingContractAddress": { "$ref": "/addressSchema" }
"name": {
"type": "string"
},
"version": {
"type": "version"
},
"chainId": {
"type": "number"
},
"verifyingContract": {
"$ref": "/addressSchema"
}
},
"required": [
"chainId",

View File

@ -2,18 +2,50 @@
"id": "/OrdersRequestOptsSchema",
"type": "object",
"properties": {
"makerAssetProxyId": { "$ref": "/hexSchema" },
"takerAssetProxyId": { "$ref": "/hexSchema" },
"makerAssetAddress": { "$ref": "/addressSchema" },
"takerAssetAddress": { "$ref": "/addressSchema" },
"exchangeAddress": { "$ref": "/addressSchema" },
"senderAddress": { "$ref": "/addressSchema" },
"makerAssetData": { "$ref": "/hexSchema" },
"takerAssetData": { "$ref": "/hexSchema" },
"traderAssetData": { "$ref": "/hexSchema" },
"makerAddress": { "$ref": "/addressSchema" },
"takerAddress": { "$ref": "/addressSchema" },
"traderAddress": { "$ref": "/addressSchema" },
"feeRecipientAddress": { "$ref": "/addressSchema" }
"makerAssetProxyId": {
"$ref": "/hexSchema"
},
"takerAssetProxyId": {
"$ref": "/hexSchema"
},
"makerAssetAddress": {
"$ref": "/addressSchema"
},
"takerAssetAddress": {
"$ref": "/addressSchema"
},
"exchangeAddress": {
"$ref": "/addressSchema"
},
"senderAddress": {
"$ref": "/addressSchema"
},
"makerAssetData": {
"$ref": "/hexSchema"
},
"takerAssetData": {
"$ref": "/hexSchema"
},
"traderAssetData": {
"$ref": "/hexSchema"
},
"makerFeeAssetData": {
"$ref": "/hexSchema"
},
"takerFeeAssetData": {
"$ref": "/hexSchema"
},
"makerAddress": {
"$ref": "/addressSchema"
},
"takerAddress": {
"$ref": "/addressSchema"
},
"traderAddress": {
"$ref": "/addressSchema"
},
"feeRecipientAddress": {
"$ref": "/addressSchema"
}
}
}

View File

@ -2,10 +2,31 @@
"id": "/relayerApiOrderConfigResponseSchema",
"type": "object",
"properties": {
"makerFee": { "$ref": "/wholeNumberSchema" },
"takerFee": { "$ref": "/wholeNumberSchema" },
"feeRecipientAddress": { "$ref": "/addressSchema" },
"senderAddress": { "$ref": "/addressSchema" }
"makerFee": {
"$ref": "/wholeNumberSchema"
},
"required": ["makerFee", "takerFee", "feeRecipientAddress", "senderAddress"]
"takerFee": {
"$ref": "/wholeNumberSchema"
},
"feeRecipientAddress": {
"$ref": "/addressSchema"
},
"senderAddress": {
"$ref": "/addressSchema"
},
"makerFeeAssetData": {
"$ref": "/hexSchema"
},
"takerFeeAssetData": {
"$ref": "/hexSchema"
}
},
"required": [
"makerFee",
"takerFee",
"feeRecipientAddress",
"senderAddress",
"makerFeeAssetData",
"takerFeeAssetData"
]
}

View File

@ -1,5 +1,7 @@
{
"id": "/relayerApiOrdersSchema",
"type": "array",
"items": { "$ref": "/relayerApiOrderSchema" }
"items": {
"$ref": "/relayerApiOrderSchema"
}
}

View File

@ -478,6 +478,8 @@ describe('Schema', () => {
takerFee: '30000000000000000',
feeRecipientAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
senderAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
makerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
takerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
},
];
validateAgainstSchema(testCases, relayerApiOrderConfigResponseSchema);

View File

@ -1,6 +1,6 @@
{
"domain": "sra-spec",
"build_command": "yarn build-json",
"domain": "sra3-spec",
"build_command": "yarn build",
"upload_directory": "public",
"index_key": "index.html",
"error_key": "index.html",

View File

@ -1,5 +1,6 @@
<!DOCTYPE html>
<html>
<head>
<title>0x Standard Relayer API</title>
<!-- needed for adaptive design -->
@ -17,8 +18,10 @@
}
</style>
</head>
<body>
<redoc spec-url='http://sra-spec.s3-website-us-east-1.amazonaws.com/api.json'></redoc>
<redoc spec-url='http://sra3-spec.s3-website-us-east-1.amazonaws.com/api.json'></redoc>
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"> </script>
</body>
</html>

View File

@ -9,7 +9,7 @@ import { generateResponses } from './responses';
export const api: OpenApiSpec = {
openapi: '3.0.0',
info: {
version: '2.0.0',
version: '3.0.0',
title: 'Standard Relayer REST API',
description: md.introduction,
license: {
@ -18,7 +18,7 @@ export const api: OpenApiSpec = {
},
},
paths: {
'/v2/asset_pairs': {
'/v3/asset_pairs': {
get: {
description:
'Retrieves a list of available asset pairs and the information required to trade them (in any order). Setting only `assetDataA` or `assetDataB` returns pairs filtered by that asset only.',
@ -53,7 +53,7 @@ export const api: OpenApiSpec = {
),
},
},
'/v2/orders': {
'/v3/orders': {
get: {
description:
'Retrieves a list of orders given query parameters. This endpoint should be [paginated](#section/Pagination). For querying an entire orderbook snapshot, the [orderbook endpoint](#operation/getOrderbook) is recommended. If both makerAssetData and takerAssetData are specified, returned orders will be sorted by price determined by (takerTokenAmount/makerTokenAmount) in ascending order. By default, orders returned by this endpoint are unsorted.',
@ -99,7 +99,7 @@ export const api: OpenApiSpec = {
{
name: 'exchangeAddress',
in: 'query',
description: `Same as exchangeAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)`,
description: `Same as exchangeAddress in the [0x Protocol v3 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#order-message-format)`,
example: '0xe41d2489571d322189246dafa5ebde1f4699f498',
schema: {
$ref: '#/components/schemas/addressSchema',
@ -108,7 +108,7 @@ export const api: OpenApiSpec = {
{
name: 'senderAddress',
in: 'query',
description: `Same as senderAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)`,
description: `Same as senderAddress in the [0x Protocol v3 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#order-message-format)`,
example: '0xe41d2489571d322189246dafa5ebde1f4699f498',
schema: {
$ref: '#/components/schemas/addressSchema',
@ -117,7 +117,7 @@ export const api: OpenApiSpec = {
{
name: 'makerAssetData',
in: 'query',
description: `Same as makerAssetData in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)`,
description: `Same as makerAssetData in the [0x Protocol v3 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#order-message-format)`,
example: '0xe41d2489571d322189246dafa5ebde1f4699f498',
schema: {
$ref: '#/components/schemas/hexSchema',
@ -126,7 +126,7 @@ export const api: OpenApiSpec = {
{
name: 'takerAssetData',
in: 'query',
description: `Same as takerAssetData in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)`,
description: `Same as takerAssetData in the [0x Protocol v3 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#order-message-format)`,
example: '0xe41d2489571d322189246dafa5ebde1f4699f498',
schema: {
$ref: '#/components/schemas/hexSchema',
@ -135,7 +135,7 @@ export const api: OpenApiSpec = {
{
name: 'traderAssetData',
in: 'query',
description: `Same as traderAssetData in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)`,
description: `Same as traderAssetData in the [0x Protocol v3 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#order-message-format)`,
example: '0xe41d2489571d322189246dafa5ebde1f4699f498',
schema: {
$ref: '#/components/schemas/hexSchema',
@ -144,7 +144,7 @@ export const api: OpenApiSpec = {
{
name: 'makerAddress',
in: 'query',
description: `Same as makerAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)`,
description: `Same as makerAddress in the [0x Protocol v3 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#order-message-format)`,
example: '0xe41d2489571d322189246dafa5ebde1f4699f498',
schema: {
$ref: '#/components/schemas/addressSchema',
@ -153,7 +153,7 @@ export const api: OpenApiSpec = {
{
name: 'takerAddress',
in: 'query',
description: `Same as takerAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)`,
description: `Same as takerAddress in the [0x Protocol v3 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#order-message-format)`,
example: '0xe41d2489571d322189246dafa5ebde1f4699f498',
schema: {
$ref: '#/components/schemas/addressSchema',
@ -162,7 +162,7 @@ export const api: OpenApiSpec = {
{
name: 'traderAddress',
in: 'query',
description: `Same as traderAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)`,
description: `Same as traderAddress in the [0x Protocol v3 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#order-message-format)`,
example: '0xe41d2489571d322189246dafa5ebde1f4699f498',
schema: {
$ref: '#/components/schemas/addressSchema',
@ -171,12 +171,30 @@ export const api: OpenApiSpec = {
{
name: 'feeRecipientAddress',
in: 'query',
description: `Same as feeRecipientAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)`,
description: `Same as feeRecipientAddress in the [0x Protocol v3 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#order-message-format)`,
example: '0xe41d2489571d322189246dafa5ebde1f4699f498',
schema: {
$ref: '#/components/schemas/addressSchema',
},
},
{
name: 'makerFeeAssetData',
in: 'query',
description: `Same as makerFeeAssetData in the [0x Protocol v3 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#order-message-format)`,
example: '0xe41d2489571d322189246dafa5ebde1f4699f498',
schema: {
$ref: '#/components/schemas/hexSchema',
},
},
{
name: 'takerFeeAssetData',
in: 'query',
description: `Same as takerFeeAssetData in the [0x Protocol v3 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#order-message-format)`,
example: '0xe41d2489571d322189246dafa5ebde1f4699f498',
schema: {
$ref: '#/components/schemas/hexSchema',
},
},
],
true,
),
@ -187,7 +205,7 @@ export const api: OpenApiSpec = {
),
},
},
'/v2/order/{orderHash}': {
'/v3/order/{orderHash}': {
get: {
description: 'Retrieves the 0x order with meta info that is associated with the hash.',
operationId: 'getOrder',
@ -212,7 +230,7 @@ export const api: OpenApiSpec = {
),
},
},
'/v2/orderbook': {
'/v3/orderbook': {
get: {
description: `Retrieves the orderbook for a given asset pair. This endpoint should be [paginated](#section/Pagination). Bids will be sorted in descending order by price, and asks will be sorted in ascending order by price. Within the price sorted orders, the orders are further sorted by _taker fee price_ which is defined as the **takerFee** divided by **takerTokenAmount**. After _taker fee price_, orders are to be sorted by expiration in ascending order. The way pagination works for this endpoint is that the **page** and **perPage** query params apply to both \`bids\` and \`asks\` collections, and if \`page\` * \`perPage\` > \`total\` for a certain collection, the \`records\` for that collection should just be empty. `,
operationId: 'getOrderbook',
@ -248,9 +266,9 @@ export const api: OpenApiSpec = {
),
},
},
'/v2/order_config': {
'/v3/order_config': {
post: {
description: `Relayers have full discretion over the orders that they are willing to host on their orderbooks (e.g what fees they charge, etc...). In order for traders to discover their requirements programmatically, they can send an incomplete order to this endpoint and receive the missing fields, specifc to that order. This gives relayers a large amount of flexibility to tailor fees to unique traders, trading pairs and volume amounts. Submit a partial order and receive information required to complete the order: \`senderAddress\`, \`feeRecipientAddress\`, \`makerFee\`, \`takerFee\`. `,
description: `Relayers have full discretion over the orders that they are willing to host on their orderbooks (e.g what fees they charge, etc...). In order for traders to discover their requirements programmatically, they can send an incomplete order to this endpoint and receive the missing fields, specifc to that order. This gives relayers a large amount of flexibility to tailor fees to unique traders, trading pairs and volume amounts. Submit a partial order and receive information required to complete the order: \`senderAddress\`, \`feeRecipientAddress\`, \`makerFee\`, \`takerFee\`, \`makerFeeAssetData\`, \`takerFeeAssetData\`. `,
operationId: 'getOrderConfig',
parameters: generateParameters([], false),
requestBody: {
@ -272,7 +290,7 @@ export const api: OpenApiSpec = {
),
},
},
'/v2/fee_recipients': {
'/v3/fee_recipients': {
get: {
description: `Retrieves a collection of all fee recipient addresses for a relayer. This endpoint should be [paginated](#section/Pagination).`,
operationId: 'getFeeRecipients',
@ -284,7 +302,7 @@ export const api: OpenApiSpec = {
),
},
},
'/v2/order': {
'/v3/order': {
post: {
description: `Submit a signed order to the relayer.`,
operationId: 'postOrder',

View File

@ -13,8 +13,11 @@ export const relayerApiOrder = {
makerAssetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498',
takerAssetData:
'0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063',
makerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
takerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
chainId: 1,
},
metaData: {},
};

View File

@ -3,4 +3,6 @@ export const relayerApiOrderConfigResponse = {
feeRecipientAddress: '0xb046140686d052fff581f63f8136cce132e857da',
makerFee: '100000000000000',
takerFee: '200000000000000',
makerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
takerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
};

View File

@ -19,8 +19,11 @@ export const relayerApiOrderbookResponse = {
makerAssetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498',
takerAssetData:
'0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063',
makerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
takerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
chainId: 1,
},
metaData: {},
},
@ -48,6 +51,7 @@ export const relayerApiOrderbookResponse = {
takerAssetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498',
exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
signature: '0x013842a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b3518891',
chainId: 1,
},
metaData: {},
},

View File

@ -18,8 +18,11 @@ export const relayerApiOrdersResponse = {
makerAssetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498',
takerAssetData:
'0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063',
makerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
takerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
chainId: 1,
},
metaData: {},
},

View File

@ -12,6 +12,9 @@ export const signedOrder = {
makerAssetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498',
takerAssetData:
'0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063',
makerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
takerFeeAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
chainId: 1,
};

View File

@ -25,21 +25,21 @@ const validatorResult: ValidatorResult = validator.validate(tokenPairsResponse,
Requests that return potentially large collections should respond to the **?page** and **?perPage** parameters. For example:
```bash
$ curl https://api.example-relayer.com/v2/asset_pairs?page=3&perPage=20
$ curl https://api.example-relayer.com/v3/asset_pairs?page=3&perPage=20
```
Page numbering should be 1-indexed, not 0-indexed. If a query provides an unreasonable (ie. too high) `perPage` value, the response can return a validation error as specified in the [errors section](#section/Errors). If the query specifies a `page` that does not exist (ie. there are not enough `records`), the response should just return an empty `records` array.
All endpoints that are paginated should return a `total`, `page`, `perPage` and a `records` value in the top level of the collection. The value of `total` should be the total number of records for a given query, whereas `records` should be an array representing the response to the query for that page. `page` and `perPage`, are the same values that were specified in the request. See the note in [miscellaneous](#section/Misc.) about formatting `snake_case` vs. `lowerCamelCase`.
These requests include the [`/v2/asset_pairs`](#operation/getAssetPairs), [`/v2/orders`](#operation/getOrders), [`/v2/fee_recipients`](#operation/getFeeRecipients) and [`/v2/orderbook`](#operation/getOrderbook) endpoints.
These requests include the [`/v3/asset_pairs`](#operation/getAssetPairs), [`/v3/orders`](#operation/getOrders), [`/v3/fee_recipients`](#operation/getFeeRecipients) and [`/v3/orderbook`](#operation/getOrderbook) endpoints.
# Network Id
All requests should be able to specify a **?networkId** query param for all supported networks. For example:
```bash
$ curl https://api.example-relayer.com/v2/asset_pairs?networkId=1
$ curl https://api.example-relayer.com/v3/asset_pairs?networkId=1
```
If the query param is not provided, it should default to **1** (mainnet).
@ -75,7 +75,7 @@ A [Link Header](https://tools.ietf.org/html/rfc5988) can be included in a respon
For example:
```bash
Link: <https://api.example-relayer.com/v2/asset_pairs?page=3&perPage=20>; rel="next",
Link: <https://api.example-relayer.com/v3/asset_pairs?page=3&perPage=20>; rel="next",
<https://api.github.com/user/repos?page=10&perPage=20>; rel="last"
```
@ -103,7 +103,7 @@ Rate limit guidance for clients can be optionally returned in the response heade
For example:
```bash
$ curl -i https://api.example-relayer.com/v2/asset_pairs
$ curl -i https://api.example-relayer.com/v3/asset_pairs
HTTP/1.1 200 OK
Date: Mon, 20 Oct 2017 12:30:06 GMT
Status: 200 OK
@ -169,7 +169,7 @@ Validation error codes:
# Asset Data Encoding
As we now support multiple [token transfer proxies](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#assetproxy), the identifier of which proxy to use for the token transfer must be encoded, along with the token information. Each proxy in 0x v2 has a unique identifier. If you're using 0x.js there will be helper methods for this encoding and decoding.
As we now support multiple [token transfer proxies](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#assetproxy), the identifier of which proxy to use for the token transfer must be encoded, along with the token information. Each proxy in 0x v3 has a unique identifier. If you're using 0x.js there will be helper methods for this encoding and decoding.
The identifier for the Proxy uses a similar scheme to [ABI function selectors](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI#function-selector).
@ -194,11 +194,11 @@ Encoding the ERC721 token contract (address: `0x371b13d97f4bf77d724e78c16b7dc740
0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063
```
For more information see [the Asset Proxy](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#erc20proxy) section of the v2 spec and the [Ethereum ABI Spec](https://solidity.readthedocs.io/en/develop/abi-spec.html).
For more information see [the Asset Proxy](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#erc20proxy) section of the v3 spec and the [Ethereum ABI Spec](https://solidity.readthedocs.io/en/develop/abi-spec.html).
# Meta Data in Order Responses
In v2 of the standard relayer API we added the `metaData` field. It is meant to provide a standard place for relayers to put optional, custom or non-standard fields that may of interest to the consumer of the API.
In v3 of the standard relayer API we added the `metaData` field. It is meant to provide a standard place for relayers to put optional, custom or non-standard fields that may of interest to the consumer of the API.
A good example of such a field is `remainingTakerAssetAmount`, which is a convenience field that communicates how much of a 0x order is potentially left to be filled. Unlike the other fields in a 0x order, it is not guaranteed to be correct as it is derived from whatever mechanism the implementer (ie. the relayer) is using. While convenient for prototyping and low stakes situations, we recommend validating the value of the field by checking the state of the blockchain yourself.

View File

@ -429,6 +429,8 @@ export interface OrdersRequestOpts {
senderAddress?: string;
makerAssetData?: string;
takerAssetData?: string;
makerFeeAssetData?: string;
takerFeeAssetData?: string;
makerAddress?: string;
takerAddress?: string;
traderAddress?: string;
@ -468,6 +470,8 @@ export interface OrderConfigResponse {
takerFee: BigNumber;
feeRecipientAddress: string;
senderAddress: string;
makerFeeAssetData: string;
takerFeeAssetData: string;
}
export type FeeRecipientsResponse = PaginatedCollection<string>;