Run prettier

This commit is contained in:
fragosti 2018-08-20 11:53:49 -07:00
parent 1ae11ed8ae
commit 44cc5e45cc
12 changed files with 33 additions and 35 deletions

View File

@ -59,7 +59,9 @@ export class HttpClient implements Client {
* @param requestOpts Options specifying assetData information to retrieve and page information, defaults to { page: 1, perPage: 100 } * @param requestOpts Options specifying assetData information to retrieve and page information, defaults to { page: 1, perPage: 100 }
* @return The resulting AssetPairsItems that match the request * @return The resulting AssetPairsItems that match the request
*/ */
public async getAssetPairsAsync(requestOpts?: RequestOpts & AssetPairsRequestOpts & PagedRequestOpts): Promise<AssetPairsResponse> { public async getAssetPairsAsync(
requestOpts?: RequestOpts & AssetPairsRequestOpts & PagedRequestOpts,
): Promise<AssetPairsResponse> {
if (!_.isUndefined(requestOpts)) { if (!_.isUndefined(requestOpts)) {
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.assetPairsRequestOptsSchema); assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.assetPairsRequestOptsSchema);
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema); assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema);
@ -77,7 +79,9 @@ export class HttpClient implements Client {
* @param requestOpts Options specifying orders to retrieve and page information, defaults to { page: 1, perPage: 100 } * @param requestOpts Options specifying orders to retrieve and page information, defaults to { page: 1, perPage: 100 }
* @return The resulting SignedOrders that match the request * @return The resulting SignedOrders that match the request
*/ */
public async getOrdersAsync(requestOpts?: RequestOpts & OrdersRequestOpts & PagedRequestOpts): Promise<OrdersResponse> { public async getOrdersAsync(
requestOpts?: RequestOpts & OrdersRequestOpts & PagedRequestOpts,
): Promise<OrdersResponse> {
if (!_.isUndefined(requestOpts)) { if (!_.isUndefined(requestOpts)) {
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.ordersRequestOptsSchema); assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.ordersRequestOptsSchema);
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema); assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema);
@ -134,7 +138,10 @@ export class HttpClient implements Client {
* @param request A OrderConfigRequest instance describing the specific fees to retrieve * @param request A OrderConfigRequest instance describing the specific fees to retrieve
* @return The resulting OrderConfigResponse that matches the request * @return The resulting OrderConfigResponse that matches the request
*/ */
public async getOrderConfigAsync(request: OrderConfigRequest, requestOpts?: RequestOpts): Promise<OrderConfigResponse> { public async getOrderConfigAsync(
request: OrderConfigRequest,
requestOpts?: RequestOpts,
): Promise<OrderConfigResponse> {
if (!_.isUndefined(requestOpts)) { if (!_.isUndefined(requestOpts)) {
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.requestOptsSchema); assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.requestOptsSchema);
} }

View File

@ -12,10 +12,7 @@ export const ordersChannelFactory = {
* channel updates * channel updates
* @return An OrdersChannel Promise * @return An OrdersChannel Promise
*/ */
async createWebSocketOrdersChannelAsync( async createWebSocketOrdersChannelAsync(url: string, handler: OrdersChannelHandler): Promise<OrdersChannel> {
url: string,
handler: OrdersChannelHandler,
): Promise<OrdersChannel> {
assert.isUri('url', url); assert.isUri('url', url);
assert.isOrdersChannelHandler('handler', handler); assert.isOrdersChannelHandler('handler', handler);
return new Promise<OrdersChannel>((resolve, reject) => { return new Promise<OrdersChannel>((resolve, reject) => {

View File

@ -6,7 +6,7 @@ export const orderConfigRequestSchema = {
takerAddress: { $ref: '/addressSchema' }, takerAddress: { $ref: '/addressSchema' },
makerAssetAmount: { $ref: '/numberSchema' }, makerAssetAmount: { $ref: '/numberSchema' },
takerAssetAmount: { $ref: '/numberSchema' }, takerAssetAmount: { $ref: '/numberSchema' },
makerAssetData: { $ref: '/hexSchema'}, makerAssetData: { $ref: '/hexSchema' },
takerAssetData: { $ref: '/hexSchema' }, takerAssetData: { $ref: '/hexSchema' },
exchangeAddress: { $ref: '/addressSchema' }, exchangeAddress: { $ref: '/addressSchema' },
expirationTimeSeconds: { $ref: '/numberSchema' }, expirationTimeSeconds: { $ref: '/numberSchema' },

View File

@ -2,7 +2,9 @@ import { SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils'; import { BigNumber } from '@0xproject/utils';
export interface Client { export interface Client {
getAssetPairsAsync: (requestOpts?: AssetPairsRequestOpts & PagedRequestOpts) => Promise<PaginatedCollection<AssetPairsItem>>; getAssetPairsAsync: (
requestOpts?: AssetPairsRequestOpts & PagedRequestOpts,
) => Promise<PaginatedCollection<AssetPairsItem>>;
getOrdersAsync: (requestOpts?: OrdersRequestOpts & PagedRequestOpts) => Promise<PaginatedCollection<APIOrder>>; getOrdersAsync: (requestOpts?: OrdersRequestOpts & PagedRequestOpts) => Promise<PaginatedCollection<APIOrder>>;
getOrderAsync: (orderHash: string) => Promise<APIOrder>; getOrderAsync: (orderHash: string) => Promise<APIOrder>;
getOrderbookAsync: (request: OrderbookRequest, requestOpts?: PagedRequestOpts) => Promise<OrderbookResponse>; getOrderbookAsync: (request: OrderbookRequest, requestOpts?: PagedRequestOpts) => Promise<OrderbookResponse>;
@ -28,18 +30,12 @@ export interface OrdersChannelSubscriptionOpts {
} }
export interface OrdersChannelHandler { export interface OrdersChannelHandler {
onUpdate: ( onUpdate: (channel: OrdersChannel, subscriptionOpts: OrdersChannelSubscriptionOpts, orders: APIOrder[]) => void;
channel: OrdersChannel,
subscriptionOpts: OrdersChannelSubscriptionOpts,
orders: APIOrder[],
) => void;
onError: (channel: OrdersChannel, err: Error, subscriptionOpts?: OrdersChannelSubscriptionOpts) => void; onError: (channel: OrdersChannel, err: Error, subscriptionOpts?: OrdersChannelSubscriptionOpts) => void;
onClose: (channel: OrdersChannel) => void; onClose: (channel: OrdersChannel) => void;
} }
export type OrdersChannelMessage = export type OrdersChannelMessage = UpdateOrdersChannelMessage | UnknownOrdersChannelMessage;
| UpdateOrdersChannelMessage
| UnknownOrdersChannelMessage;
export enum OrdersChannelMessageTypes { export enum OrdersChannelMessageTypes {
Update = 'update', Update = 'update',

View File

@ -1,7 +1,14 @@
import { assert } from '@0xproject/assert'; import { assert } from '@0xproject/assert';
import { schemas } from '@0xproject/json-schemas'; import { schemas } from '@0xproject/json-schemas';
import { APIOrder, AssetPairsItem, AssetPairsResponse, OrderbookResponse, OrderConfigResponse, OrdersResponse } from '../types'; import {
APIOrder,
AssetPairsItem,
AssetPairsResponse,
OrderbookResponse,
OrderConfigResponse,
OrdersResponse,
} from '../types';
import { typeConverters } from './type_converters'; import { typeConverters } from './type_converters';

View File

@ -2,12 +2,7 @@ import * as _ from 'lodash';
import { v4 as uuid } from 'uuid'; import { v4 as uuid } from 'uuid';
import * as WebSocket from 'websocket'; import * as WebSocket from 'websocket';
import { import { OrdersChannel, OrdersChannelHandler, OrdersChannelMessageTypes, OrdersChannelSubscriptionOpts } from './types';
OrdersChannel,
OrdersChannelHandler,
OrdersChannelMessageTypes,
OrdersChannelSubscriptionOpts,
} from './types';
import { assert } from './utils/assert'; import { assert } from './utils/assert';
import { ordersChannelMessageParser } from './utils/orders_channel_message_parser'; import { ordersChannelMessageParser } from './utils/orders_channel_message_parser';

View File

@ -24,4 +24,3 @@
} }
] ]
} }

View File

@ -109,9 +109,9 @@ describe('HttpClient', () => {
}; };
const url = `${relayUrl}/orderbook`; const url = `${relayUrl}/orderbook`;
it('gets orderbook with default page options when none are provided', async () => { it('gets orderbook with default page options when none are provided', async () => {
const urlWithQuery = `${url}?baseAssetData=${ const urlWithQuery = `${url}?baseAssetData=${request.baseAssetData}&quoteAssetData=${
request.baseAssetData request.quoteAssetData
}&quoteAssetData=${request.quoteAssetData}`; }`;
fetchMock.get(urlWithQuery, orderbookJSON); fetchMock.get(urlWithQuery, orderbookJSON);
const orderbook = await relayerClient.getOrderbookAsync(request); const orderbook = await relayerClient.getOrderbookAsync(request);
expect(orderbook).to.be.deep.equal(orderbookResponse); expect(orderbook).to.be.deep.equal(orderbookResponse);

View File

@ -20,10 +20,7 @@ describe('ordersChannelFactory', () => {
it('throws when input is not a url', () => { it('throws when input is not a url', () => {
const badUrlInput = 54; const badUrlInput = 54;
expect( expect(
ordersChannelFactory.createWebSocketOrdersChannelAsync( ordersChannelFactory.createWebSocketOrdersChannelAsync(badUrlInput as any, emptyOrdersChannelHandler),
badUrlInput as any,
emptyOrdersChannelHandler,
),
).to.be.rejected(); ).to.be.rejected();
}); });
it('throws when handler has the incorrect members', () => { it('throws when handler has the incorrect members', () => {