aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/sra-api/src/api.ts22
-rw-r--r--packages/sra-api/src/examples/index.ts2
-rw-r--r--packages/sra-api/src/examples/signedOrder.ts16
-rw-r--r--packages/sra-api/src/parameters.ts4
-rw-r--r--packages/sra-api/src/responses.ts24
5 files changed, 56 insertions, 12 deletions
diff --git a/packages/sra-api/src/api.ts b/packages/sra-api/src/api.ts
index 50e656599..5973e11cd 100644
--- a/packages/sra-api/src/api.ts
+++ b/packages/sra-api/src/api.ts
@@ -196,7 +196,7 @@ export const api: OpenApiSpec = {
},
},
],
- true,
+ false,
),
responses: generateResponses(
'relayerApiOrderSchema',
@@ -245,6 +245,7 @@ export const api: OpenApiSpec = {
get: {
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\`. `,
operationId: 'getOrderConfig',
+ parameters: generateParameters([], false),
requestBody: {
description:
'The fields of a 0x order the relayer may want to decide what configuration to send back.',
@@ -276,6 +277,25 @@ export const api: OpenApiSpec = {
),
},
},
+ '/v2/order': {
+ post: {
+ description: `Submit a signed order to the relayer.`,
+ operationId: 'postOrder',
+ parameters: generateParameters([], false),
+ requestBody: {
+ description: 'A valid signed 0x order based on the schema.',
+ content: {
+ 'application/json': {
+ schema: {
+ $ref: '#/components/schemas/signedOrderSchema',
+ },
+ example: examples.signedOrder,
+ },
+ },
+ },
+ responses: generateResponses(),
+ },
+ },
},
components: {
schemas: openApiSchemas,
diff --git a/packages/sra-api/src/examples/index.ts b/packages/sra-api/src/examples/index.ts
index 06560f8ad..cdc4fac53 100644
--- a/packages/sra-api/src/examples/index.ts
+++ b/packages/sra-api/src/examples/index.ts
@@ -6,6 +6,7 @@ import { relayerApiOrderBookResponse } from './relayerApiOrderBookResponse';
import { relayerApiOrderConfigPayload } from './relayerApiOrderConfigPayload';
import { relayerApiOrderConfigResponse } from './relayerApiOrderConfigResponse';
import { relayerApiOrdersResponse } from './relayerApiOrdersResponse';
+import { signedOrder } from './signedOrder';
export const examples = {
validationError,
@@ -16,4 +17,5 @@ export const examples = {
relayerApiOrderConfigPayload,
relayerApiOrderConfigResponse,
relayerApiOrdersResponse,
+ signedOrder,
};
diff --git a/packages/sra-api/src/examples/signedOrder.ts b/packages/sra-api/src/examples/signedOrder.ts
new file mode 100644
index 000000000..440566027
--- /dev/null
+++ b/packages/sra-api/src/examples/signedOrder.ts
@@ -0,0 +1,16 @@
+export const signedOrder = {
+ makerAddress: '0x9e56625509c2f60af937f23b7b532600390e8c8b',
+ takerAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
+ feeRecipientAddress: '0xb046140686d052fff581f63f8136cce132e857da',
+ senderAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
+ makerAssetAmount: '10000000000000000',
+ takerAssetAmount: '20000000000000000',
+ makerFee: '100000000000000',
+ takerFee: '200000000000000',
+ expirationTimeSeconds: '1532560590',
+ salt: '1532559225',
+ makerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
+ takerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
+ exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
+ signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
+};
diff --git a/packages/sra-api/src/parameters.ts b/packages/sra-api/src/parameters.ts
index dac898931..bfa261df0 100644
--- a/packages/sra-api/src/parameters.ts
+++ b/packages/sra-api/src/parameters.ts
@@ -20,7 +20,7 @@ export const paginationParameters: ParameterObject[] = [
},
];
-export const networkdIdParameter = {
+export const networkdIdParameter: ParameterObject = {
name: 'network_id',
in: 'query',
description: 'The id of the Ethereum network',
@@ -33,5 +33,5 @@ export const networkdIdParameter = {
export const generateParameters = (parameters: ParameterObject[], isPaginated: boolean = false): ParameterObject[] => {
const optionalParameters = isPaginated ? paginationParameters : [];
- return [...optionalParameters, ...parameters];
+ return [networkdIdParameter, ...optionalParameters, ...parameters];
};
diff --git a/packages/sra-api/src/responses.ts b/packages/sra-api/src/responses.ts
index 03a0cced8..cd7352058 100644
--- a/packages/sra-api/src/responses.ts
+++ b/packages/sra-api/src/responses.ts
@@ -3,16 +3,22 @@ import { ResponsesObject } from '@loopback/openapi-v3-types';
import { errorResponses } from './errors';
import { headers } from './headers';
-export const generateResponses = (schemaName: string, example: any, description: string = 'OK'): ResponsesObject => ({
- '200': {
- headers,
- description,
- content: {
+export const generateResponses = (schemaName?: string, example?: any, description: string = 'OK'): ResponsesObject => {
+ const responses = {
+ '200': {
+ headers,
+ description,
+ content: {},
+ },
+ ...errorResponses,
+ };
+ if (schemaName) {
+ responses['200'].content = {
'application/json': {
schema: { $ref: `#/components/schemas/${schemaName}` },
example,
},
- },
- },
- ...errorResponses,
-});
+ };
+ }
+ return responses;
+};