Socket
Socket
Sign inDemoInstall

@0xproject/connect

Package Overview
Dependencies
113
Maintainers
6
Versions
49
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.5 to 2.0.0-rc.1

lib/src/orders_channel_factory.d.ts

14

CHANGELOG.json
[
{
"version": "2.0.0-rc.1",
"changes": [
{
"note": "Updated for SRA v2",
"pr": 974
},
{
"note": "Stopped exporting `Order` type",
"pr": 924
}
],
"timestamp": 1535133899
},
{
"timestamp": 1534210131,

@@ -4,0 +18,0 @@ "version": "1.0.5",

11

CHANGELOG.md

@@ -8,4 +8,9 @@ <!--

## v1.0.5 - _August 13, 2018_
## v2.0.0-rc.1 - _August 24, 2018_
* Updated for SRA v2 (#974)
* Stopped exporting `Order` type (#924)
## v1.0.5 - _August 14, 2018_
* Dependencies updated

@@ -29,3 +34,3 @@

## v1.0.0 - _July 19, 2018_
## v1.0.0 - _July 20, 2018_

@@ -54,3 +59,3 @@ * Remove `WebSocketOrderbookChannel` from the public interface and replace with `orderbookChannelFactory`

## v0.6.12 - _May 4, 2018_
## v0.6.12 - _May 5, 2018_

@@ -57,0 +62,0 @@ * Dependencies updated

import { SignedOrder } from '@0xproject/types';
import { Client, FeesRequest, FeesResponse, OrderbookRequest, OrderbookResponse, OrdersRequestOpts, PagedRequestOpts, TokenPairsItem, TokenPairsRequestOpts } from './types';
import { APIOrder, AssetPairsRequestOpts, AssetPairsResponse, Client, FeeRecipientsResponse, OrderbookRequest, OrderbookResponse, OrderConfigRequest, OrderConfigResponse, OrdersRequestOpts, OrdersResponse, PagedRequestOpts, RequestOpts } from './types';
/**

@@ -20,38 +20,46 @@ * This class includes all the functionality related to interacting with a set of HTTP endpoints

/**
* Retrieve token pair info from the API
* @param requestOpts Options specifying token information to retrieve and page information, defaults to { page: 1, perPage: 100 }
* @return The resulting TokenPairsItems that match the request
* Retrieve assetData pair info from the API
* @param requestOpts Options specifying assetData information to retrieve, page information, and network id.
* @return The resulting AssetPairsResponse that match the request
*/
getTokenPairsAsync(requestOpts?: TokenPairsRequestOpts & PagedRequestOpts): Promise<TokenPairsItem[]>;
getAssetPairsAsync(requestOpts?: RequestOpts & AssetPairsRequestOpts & PagedRequestOpts): Promise<AssetPairsResponse>;
/**
* Retrieve orders from the API
* @param requestOpts Options specifying orders to retrieve and page information, defaults to { page: 1, perPage: 100 }
* @return The resulting SignedOrders that match the request
* @param requestOpts Options specifying orders to retrieve and page information, page information, and network id.
* @return The resulting OrdersResponse that match the request
*/
getOrdersAsync(requestOpts?: OrdersRequestOpts & PagedRequestOpts): Promise<SignedOrder[]>;
getOrdersAsync(requestOpts?: RequestOpts & OrdersRequestOpts & PagedRequestOpts): Promise<OrdersResponse>;
/**
* Retrieve a specific order from the API
* @param orderHash An orderHash generated from the desired order
* @return The SignedOrder that matches the supplied orderHash
* @return The APIOrder that matches the supplied orderHash
*/
getOrderAsync(orderHash: string): Promise<SignedOrder>;
getOrderAsync(orderHash: string, requestOpts?: RequestOpts): Promise<APIOrder>;
/**
* Retrieve an orderbook from the API
* @param request An OrderbookRequest instance describing the specific orderbook to retrieve
* @param requestOpts Options specifying page information, defaults to { page: 1, perPage: 100 }
* @param requestOpts Options specifying page information, and network id.
* @return The resulting OrderbookResponse that matches the request
*/
getOrderbookAsync(request: OrderbookRequest, requestOpts?: PagedRequestOpts): Promise<OrderbookResponse>;
getOrderbookAsync(request: OrderbookRequest, requestOpts?: RequestOpts & PagedRequestOpts): Promise<OrderbookResponse>;
/**
* Retrieve fee information from the API
* @param request A FeesRequest instance describing the specific fees to retrieve
* @return The resulting FeesResponse that matches the request
* @param request A OrderConfigRequest instance describing the specific fees to retrieve
* @param requestOpts Options specifying network id.
* @return The resulting OrderConfigResponse that matches the request
*/
getFeesAsync(request: FeesRequest): Promise<FeesResponse>;
getOrderConfigAsync(request: OrderConfigRequest, requestOpts?: RequestOpts): Promise<OrderConfigResponse>;
/**
* Retrieve the list of fee recipient addresses used by the relayer.
* @param requestOpts Options specifying page information, and network id.
* @return The resulting FeeRecipientsResponse
*/
getFeeRecipientsAsync(requestOpts?: RequestOpts & PagedRequestOpts): Promise<FeeRecipientsResponse>;
/**
* Submit a signed order to the API
* @param signedOrder A SignedOrder instance to submit
* @param requestOpts Options specifying network id.
*/
submitOrderAsync(signedOrder: SignedOrder): Promise<void>;
submitOrderAsync(signedOrder: SignedOrder, requestOpts?: RequestOpts): Promise<void>;
private _requestAsync;
}

@@ -47,13 +47,3 @@ "use strict";

var TRAILING_SLASHES_REGEX = /\/+$/;
var DEFAULT_PAGED_REQUEST_OPTS = {
page: 1,
perPage: 100,
};
/**
* This mapping defines how an option property name gets converted into an HTTP request query field
*/
var OPTS_TO_QUERY_FIELD_MAP = {
perPage: 'per_page',
};
/**
* This class includes all the functionality related to interacting with a set of HTTP endpoints

@@ -80,18 +70,14 @@ * that implement the standard relayer API v0

}
// format params into a form the api expects
var formattedParams = _.mapKeys(params, function (_value, key) {
return _.get(OPTS_TO_QUERY_FIELD_MAP, key, key);
});
// stringify the formatted object
var stringifiedParams = queryString.stringify(formattedParams);
var stringifiedParams = queryString.stringify(params);
return "?" + stringifiedParams;
};
/**
* Retrieve token pair info from the API
* @param requestOpts Options specifying token information to retrieve and page information, defaults to { page: 1, perPage: 100 }
* @return The resulting TokenPairsItems that match the request
* Retrieve assetData pair info from the API
* @param requestOpts Options specifying assetData information to retrieve, page information, and network id.
* @return The resulting AssetPairsResponse that match the request
*/
HttpClient.prototype.getTokenPairsAsync = function (requestOpts) {
HttpClient.prototype.getAssetPairsAsync = function (requestOpts) {
return __awaiter(this, void 0, void 0, function () {
var httpRequestOpts, responseJson, tokenPairs;
var httpRequestOpts, responseJson, assetDataPairs;
return __generator(this, function (_a) {

@@ -101,13 +87,14 @@ switch (_a.label) {

if (!_.isUndefined(requestOpts)) {
assert_1.assert.doesConformToSchema('requestOpts', requestOpts, schemas_1.schemas.tokenPairsRequestOptsSchema);
assert_1.assert.doesConformToSchema('requestOpts', requestOpts, schemas_1.schemas.assetPairsRequestOptsSchema);
assert_1.assert.doesConformToSchema('requestOpts', requestOpts, schemas_1.schemas.pagedRequestOptsSchema);
assert_1.assert.doesConformToSchema('requestOpts', requestOpts, schemas_1.schemas.requestOptsSchema);
}
httpRequestOpts = {
params: _.defaults({}, requestOpts, DEFAULT_PAGED_REQUEST_OPTS),
params: requestOpts,
};
return [4 /*yield*/, this._requestAsync('/token_pairs', types_1.HttpRequestType.Get, httpRequestOpts)];
return [4 /*yield*/, this._requestAsync('/asset_pairs', types_1.HttpRequestType.Get, httpRequestOpts)];
case 1:
responseJson = _a.sent();
tokenPairs = relayer_response_json_parsers_1.relayerResponseJsonParsers.parseTokenPairsJson(responseJson);
return [2 /*return*/, tokenPairs];
assetDataPairs = relayer_response_json_parsers_1.relayerResponseJsonParsers.parseAssetDataPairsJson(responseJson);
return [2 /*return*/, assetDataPairs];
}

@@ -119,4 +106,4 @@ });

* Retrieve orders from the API
* @param requestOpts Options specifying orders to retrieve and page information, defaults to { page: 1, perPage: 100 }
* @return The resulting SignedOrders that match the request
* @param requestOpts Options specifying orders to retrieve and page information, page information, and network id.
* @return The resulting OrdersResponse that match the request
*/

@@ -132,5 +119,6 @@ HttpClient.prototype.getOrdersAsync = function (requestOpts) {

assert_1.assert.doesConformToSchema('requestOpts', requestOpts, schemas_1.schemas.pagedRequestOptsSchema);
assert_1.assert.doesConformToSchema('requestOpts', requestOpts, schemas_1.schemas.requestOptsSchema);
}
httpRequestOpts = {
params: _.defaults({}, requestOpts, DEFAULT_PAGED_REQUEST_OPTS),
params: requestOpts,
};

@@ -149,15 +137,21 @@ return [4 /*yield*/, this._requestAsync("/orders", types_1.HttpRequestType.Get, httpRequestOpts)];

* @param orderHash An orderHash generated from the desired order
* @return The SignedOrder that matches the supplied orderHash
* @return The APIOrder that matches the supplied orderHash
*/
HttpClient.prototype.getOrderAsync = function (orderHash) {
HttpClient.prototype.getOrderAsync = function (orderHash, requestOpts) {
return __awaiter(this, void 0, void 0, function () {
var responseJson, order;
var httpRequestOpts, responseJson, order;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!_.isUndefined(requestOpts)) {
assert_1.assert.doesConformToSchema('requestOpts', requestOpts, schemas_1.schemas.requestOptsSchema);
}
assert_1.assert.doesConformToSchema('orderHash', orderHash, json_schemas_1.schemas.orderHashSchema);
return [4 /*yield*/, this._requestAsync("/order/" + orderHash, types_1.HttpRequestType.Get)];
httpRequestOpts = {
params: requestOpts,
};
return [4 /*yield*/, this._requestAsync("/order/" + orderHash, types_1.HttpRequestType.Get, httpRequestOpts)];
case 1:
responseJson = _a.sent();
order = relayer_response_json_parsers_1.relayerResponseJsonParsers.parseOrderJson(responseJson);
order = relayer_response_json_parsers_1.relayerResponseJsonParsers.parseAPIOrderJson(responseJson);
return [2 /*return*/, order];

@@ -171,3 +165,3 @@ }

* @param request An OrderbookRequest instance describing the specific orderbook to retrieve
* @param requestOpts Options specifying page information, defaults to { page: 1, perPage: 100 }
* @param requestOpts Options specifying page information, and network id.
* @return The resulting OrderbookResponse that matches the request

@@ -184,5 +178,6 @@ */

assert_1.assert.doesConformToSchema('requestOpts', requestOpts, schemas_1.schemas.pagedRequestOptsSchema);
assert_1.assert.doesConformToSchema('requestOpts', requestOpts, schemas_1.schemas.requestOptsSchema);
}
httpRequestOpts = {
params: _.defaults({}, request, requestOpts, DEFAULT_PAGED_REQUEST_OPTS),
params: _.defaults({}, request, requestOpts),
};

@@ -200,6 +195,7 @@ return [4 /*yield*/, this._requestAsync('/orderbook', types_1.HttpRequestType.Get, httpRequestOpts)];

* Retrieve fee information from the API
* @param request A FeesRequest instance describing the specific fees to retrieve
* @return The resulting FeesResponse that matches the request
* @param request A OrderConfigRequest instance describing the specific fees to retrieve
* @param requestOpts Options specifying network id.
* @return The resulting OrderConfigResponse that matches the request
*/
HttpClient.prototype.getFeesAsync = function (request) {
HttpClient.prototype.getOrderConfigAsync = function (request, requestOpts) {
return __awaiter(this, void 0, void 0, function () {

@@ -210,10 +206,14 @@ var httpRequestOpts, responseJson, fees;

case 0:
assert_1.assert.doesConformToSchema('request', request, schemas_1.schemas.feesRequestSchema);
if (!_.isUndefined(requestOpts)) {
assert_1.assert.doesConformToSchema('requestOpts', requestOpts, schemas_1.schemas.requestOptsSchema);
}
assert_1.assert.doesConformToSchema('request', request, schemas_1.schemas.orderConfigRequestSchema);
httpRequestOpts = {
params: requestOpts,
payload: request,
};
return [4 /*yield*/, this._requestAsync('/fees', types_1.HttpRequestType.Post, httpRequestOpts)];
return [4 /*yield*/, this._requestAsync('/order_config', types_1.HttpRequestType.Post, httpRequestOpts)];
case 1:
responseJson = _a.sent();
fees = relayer_response_json_parsers_1.relayerResponseJsonParsers.parseFeesResponseJson(responseJson);
fees = relayer_response_json_parsers_1.relayerResponseJsonParsers.parseOrderConfigResponseJson(responseJson);
return [2 /*return*/, fees];

@@ -225,8 +225,36 @@ }

/**
* Retrieve the list of fee recipient addresses used by the relayer.
* @param requestOpts Options specifying page information, and network id.
* @return The resulting FeeRecipientsResponse
*/
HttpClient.prototype.getFeeRecipientsAsync = function (requestOpts) {
return __awaiter(this, void 0, void 0, function () {
var httpRequestOpts, feeRecipients;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!_.isUndefined(requestOpts)) {
assert_1.assert.doesConformToSchema('requestOpts', requestOpts, schemas_1.schemas.pagedRequestOptsSchema);
assert_1.assert.doesConformToSchema('requestOpts', requestOpts, schemas_1.schemas.requestOptsSchema);
}
httpRequestOpts = {
params: requestOpts,
};
return [4 /*yield*/, this._requestAsync('/fee_recipients', types_1.HttpRequestType.Get, httpRequestOpts)];
case 1:
feeRecipients = _a.sent();
assert_1.assert.doesConformToSchema('feeRecipients', feeRecipients, json_schemas_1.schemas.relayerApiFeeRecipientsResponseSchema);
return [2 /*return*/, feeRecipients];
}
});
});
};
/**
* Submit a signed order to the API
* @param signedOrder A SignedOrder instance to submit
* @param requestOpts Options specifying network id.
*/
HttpClient.prototype.submitOrderAsync = function (signedOrder) {
HttpClient.prototype.submitOrderAsync = function (signedOrder, requestOpts) {
return __awaiter(this, void 0, void 0, function () {
var requestOpts;
var httpRequestOpts;
return __generator(this, function (_a) {

@@ -236,6 +264,7 @@ switch (_a.label) {

assert_1.assert.doesConformToSchema('signedOrder', signedOrder, json_schemas_1.schemas.signedOrderSchema);
requestOpts = {
httpRequestOpts = {
params: requestOpts,
payload: signedOrder,
};
return [4 /*yield*/, this._requestAsync('/order', types_1.HttpRequestType.Post, requestOpts)];
return [4 /*yield*/, this._requestAsync('/order', types_1.HttpRequestType.Post, httpRequestOpts)];
case 1:

@@ -242,0 +271,0 @@ _a.sent();

export { HttpClient } from './http_client';
export { orderbookChannelFactory } from './orderbook_channel_factory';
export { Client, FeesRequest, FeesResponse, OrderbookChannel, OrderbookChannelHandler, OrderbookChannelSubscriptionOpts, OrderbookRequest, OrderbookResponse, OrdersRequestOpts, PagedRequestOpts, TokenPairsItem, TokenPairsRequestOpts, TokenTradeInfo, } from './types';
export { Order, SignedOrder } from '@0xproject/types';
export { ordersChannelFactory } from './orders_channel_factory';
export { Client, OrderConfigRequest, OrderConfigResponse, OrdersChannel, OrdersChannelHandler, OrdersChannelSubscriptionOpts, OrderbookRequest, OrderbookResponse, OrdersRequestOpts, PagedRequestOpts, AssetPairsRequestOpts, RequestOpts, AssetPairsResponse, FeeRecipientsResponse, APIOrder, OrdersResponse, PaginatedCollection, } from './types';
export { SignedOrder } from '@0xproject/types';

@@ -5,4 +5,4 @@ "use strict";

exports.HttpClient = http_client_1.HttpClient;
var orderbook_channel_factory_1 = require("./orderbook_channel_factory");
exports.orderbookChannelFactory = orderbook_channel_factory_1.orderbookChannelFactory;
var orders_channel_factory_1 = require("./orders_channel_factory");
exports.ordersChannelFactory = orders_channel_factory_1.ordersChannelFactory;
//# sourceMappingURL=index.js.map

@@ -5,6 +5,6 @@ export declare const orderBookRequestSchema: {

properties: {
baseTokenAddress: {
baseAssetData: {
$ref: string;
};
quoteTokenAddress: {
quoteAssetData: {
$ref: string;

@@ -11,0 +11,0 @@ };

@@ -7,7 +7,7 @@ "use strict";

properties: {
baseTokenAddress: { $ref: '/Address' },
quoteTokenAddress: { $ref: '/Address' },
baseAssetData: { $ref: '/hexSchema' },
quoteAssetData: { $ref: '/hexSchema' },
},
required: ['baseTokenAddress', 'quoteTokenAddress'],
required: ['baseAssetData', 'quoteAssetData'],
};
//# sourceMappingURL=orderbook_request_schema.js.map

@@ -5,33 +5,42 @@ export declare const ordersRequestOptsSchema: {

properties: {
exchangeContractAddress: {
makerAssetProxyId: {
$ref: string;
};
tokenAddress: {
takerAssetProxyId: {
$ref: string;
};
makerTokenAddress: {
makerAssetAddress: {
$ref: string;
};
takerTokenAddress: {
takerAssetAddress: {
$ref: string;
};
tokenA: {
exchangeAddress: {
$ref: string;
};
tokenB: {
senderAddress: {
$ref: string;
};
maker: {
makerAssetData: {
$ref: string;
};
taker: {
takerAssetData: {
$ref: string;
};
trader: {
traderAssetData: {
$ref: string;
};
feeRecipient: {
makerAddress: {
$ref: string;
};
takerAddress: {
$ref: string;
};
traderAddress: {
$ref: string;
};
feeRecipientAddress: {
$ref: string;
};
};
};

@@ -7,14 +7,17 @@ "use strict";

properties: {
exchangeContractAddress: { $ref: '/Address' },
tokenAddress: { $ref: '/Address' },
makerTokenAddress: { $ref: '/Address' },
takerTokenAddress: { $ref: '/Address' },
tokenA: { $ref: '/Address' },
tokenB: { $ref: '/Address' },
maker: { $ref: '/Address' },
taker: { $ref: '/Address' },
trader: { $ref: '/Address' },
feeRecipient: { $ref: '/Address' },
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' },
},
};
//# sourceMappingURL=orders_request_opts_schema.js.map
export declare const schemas: {
feesRequestSchema: {
orderConfigRequestSchema: {
id: string;
type: string;
properties: {
exchangeContractAddress: {
makerAddress: {
$ref: string;
};
maker: {
takerAddress: {
$ref: string;
};
taker: {
makerAssetAmount: {
$ref: string;
};
makerTokenAddress: {
takerAssetAmount: {
$ref: string;
};
takerTokenAddress: {
makerAssetData: {
$ref: string;
};
makerTokenAmount: {
takerAssetData: {
$ref: string;
};
takerTokenAmount: {
exchangeAddress: {
$ref: string;
};
expirationUnixTimestampSec: {
expirationTimeSeconds: {
$ref: string;
};
salt: {
$ref: string;
};
};

@@ -40,6 +37,6 @@ required: string[];

properties: {
baseTokenAddress: {
baseAssetData: {
$ref: string;
};
quoteTokenAddress: {
quoteAssetData: {
$ref: string;

@@ -54,32 +51,41 @@ };

properties: {
exchangeContractAddress: {
makerAssetProxyId: {
$ref: string;
};
tokenAddress: {
takerAssetProxyId: {
$ref: string;
};
makerTokenAddress: {
makerAssetAddress: {
$ref: string;
};
takerTokenAddress: {
takerAssetAddress: {
$ref: string;
};
tokenA: {
exchangeAddress: {
$ref: string;
};
tokenB: {
senderAddress: {
$ref: string;
};
maker: {
makerAssetData: {
$ref: string;
};
taker: {
takerAssetData: {
$ref: string;
};
trader: {
traderAssetData: {
$ref: string;
};
feeRecipient: {
makerAddress: {
$ref: string;
};
takerAddress: {
$ref: string;
};
traderAddress: {
$ref: string;
};
feeRecipientAddress: {
$ref: string;
};
};

@@ -99,10 +105,19 @@ };

};
tokenPairsRequestOptsSchema: {
requestOptsSchema: {
id: string;
type: string;
properties: {
tokenA: {
networkId: {
type: string;
};
};
};
assetPairsRequestOptsSchema: {
id: string;
type: string;
properties: {
assetDataA: {
$ref: string;
};
tokenB: {
assetDataB: {
$ref: string;

@@ -109,0 +124,0 @@ };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var fees_request_schema_1 = require("./fees_request_schema");
var asset_pairs_request_opts_schema_1 = require("./asset_pairs_request_opts_schema");
var order_config_request_schema_1 = require("./order_config_request_schema");
var orderbook_request_schema_1 = require("./orderbook_request_schema");
var orders_request_opts_schema_1 = require("./orders_request_opts_schema");
var paged_request_opts_schema_1 = require("./paged_request_opts_schema");
var token_pairs_request_opts_schema_1 = require("./token_pairs_request_opts_schema");
var request_opts_schema_1 = require("./request_opts_schema");
exports.schemas = {
feesRequestSchema: fees_request_schema_1.feesRequestSchema,
orderConfigRequestSchema: order_config_request_schema_1.orderConfigRequestSchema,
orderBookRequestSchema: orderbook_request_schema_1.orderBookRequestSchema,
ordersRequestOptsSchema: orders_request_opts_schema_1.ordersRequestOptsSchema,
pagedRequestOptsSchema: paged_request_opts_schema_1.pagedRequestOptsSchema,
tokenPairsRequestOptsSchema: token_pairs_request_opts_schema_1.tokenPairsRequestOptsSchema,
requestOptsSchema: request_opts_schema_1.requestOptsSchema,
assetPairsRequestOptsSchema: asset_pairs_request_opts_schema_1.assetPairsRequestOptsSchema,
};
//# sourceMappingURL=schemas.js.map
import { SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
export interface Client {
getTokenPairsAsync: (requestOpts?: TokenPairsRequestOpts & PagedRequestOpts) => Promise<TokenPairsItem[]>;
getOrdersAsync: (requestOpts?: OrdersRequestOpts & PagedRequestOpts) => Promise<SignedOrder[]>;
getOrderAsync: (orderHash: string) => Promise<SignedOrder>;
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>;
getFeesAsync: (request: FeesRequest) => Promise<FeesResponse>;
getOrderConfigAsync: (request: OrderConfigRequest) => Promise<OrderConfigResponse>;
getFeeRecipientsAsync: (requestOpts?: PagedRequestOpts) => Promise<FeeRecipientsResponse>;
submitOrderAsync: (signedOrder: SignedOrder) => Promise<void>;
}
export interface OrderbookChannel {
subscribe: (subscriptionOpts: OrderbookChannelSubscriptionOpts) => void;
export interface OrdersChannel {
subscribe: (subscriptionOpts: OrdersChannelSubscriptionOpts) => void;
close: () => void;
}
/**
* baseTokenAddress: The address of token designated as the baseToken in the currency pair calculation of price
* quoteTokenAddress: The address of token designated as the quoteToken in the currency pair calculation of price
* snapshot: If true, a snapshot of the orderbook will be sent before the updates to the orderbook
* baseAssetData: The address of assetData designated as the baseToken in the currency pair calculation of price
* quoteAssetData: The address of assetData designated as the quoteToken in the currency pair calculation of price
* limit: Maximum number of bids and asks in orderbook snapshot
*/
export interface OrderbookChannelSubscriptionOpts {
baseTokenAddress: string;
quoteTokenAddress: string;
snapshot: boolean;
export interface OrdersChannelSubscriptionOpts {
baseAssetData: string;
quoteAssetData: string;
limit: number;
}
export interface OrderbookChannelHandler {
onSnapshot: (channel: OrderbookChannel, subscriptionOpts: OrderbookChannelSubscriptionOpts, snapshot: OrderbookResponse) => void;
onUpdate: (channel: OrderbookChannel, subscriptionOpts: OrderbookChannelSubscriptionOpts, order: SignedOrder) => void;
onError: (channel: OrderbookChannel, err: Error, subscriptionOpts?: OrderbookChannelSubscriptionOpts) => void;
onClose: (channel: OrderbookChannel) => void;
export interface OrdersChannelHandler {
onUpdate: (channel: OrdersChannel, subscriptionOpts: OrdersChannelSubscriptionOpts, orders: APIOrder[]) => void;
onError: (channel: OrdersChannel, err: Error, subscriptionOpts?: OrdersChannelSubscriptionOpts) => void;
onClose: (channel: OrdersChannel) => void;
}
export declare type OrderbookChannelMessage = SnapshotOrderbookChannelMessage | UpdateOrderbookChannelMessage | UnknownOrderbookChannelMessage;
export declare enum OrderbookChannelMessageTypes {
Snapshot = "snapshot",
export declare type OrdersChannelMessage = UpdateOrdersChannelMessage | UnknownOrdersChannelMessage;
export declare enum OrdersChannelMessageTypes {
Update = "update",
Unknown = "unknown"
}
export interface SnapshotOrderbookChannelMessage {
type: OrderbookChannelMessageTypes.Snapshot;
requestId: number;
payload: OrderbookResponse;
export interface UpdateOrdersChannelMessage {
type: OrdersChannelMessageTypes.Update;
requestId: string;
payload: APIOrder[];
}
export interface UpdateOrderbookChannelMessage {
type: OrderbookChannelMessageTypes.Update;
requestId: number;
payload: SignedOrder;
}
export interface UnknownOrderbookChannelMessage {
type: OrderbookChannelMessageTypes.Unknown;
requestId: number;
export interface UnknownOrdersChannelMessage {
type: OrdersChannelMessageTypes.Unknown;
requestId: string;
payload: undefined;

@@ -63,12 +55,18 @@ }

}
export interface TokenPairsRequestOpts {
tokenA?: string;
tokenB?: string;
export declare type OrdersResponse = PaginatedCollection<APIOrder>;
export interface APIOrder {
order: SignedOrder;
metaData: object;
}
export interface TokenPairsItem {
tokenA: TokenTradeInfo;
tokenB: TokenTradeInfo;
export interface AssetPairsRequestOpts {
assetDataA?: string;
assetDataB?: string;
}
export interface TokenTradeInfo {
address: string;
export declare type AssetPairsResponse = PaginatedCollection<AssetPairsItem>;
export interface AssetPairsItem {
assetDataA: Asset;
assetDataB: Asset;
}
export interface Asset {
assetData: string;
minAmount: BigNumber;

@@ -79,35 +77,49 @@ maxAmount: BigNumber;

export interface OrdersRequestOpts {
exchangeContractAddress?: string;
tokenAddress?: string;
makerTokenAddress?: string;
takerTokenAddress?: string;
maker?: string;
taker?: string;
trader?: string;
feeRecipient?: string;
makerAssetProxyId?: string;
takerAssetProxyId?: string;
makerAssetAddress?: string;
takerAssetAddress?: string;
exchangeAddress?: string;
senderAddress?: string;
makerAssetData?: string;
takerAssetData?: string;
makerAddress?: string;
takerAddress?: string;
traderAddress?: string;
feeRecipientAddress?: string;
}
export interface OrderbookRequest {
baseTokenAddress: string;
quoteTokenAddress: string;
baseAssetData: string;
quoteAssetData: string;
}
export interface OrderbookResponse {
bids: SignedOrder[];
asks: SignedOrder[];
bids: PaginatedCollection<APIOrder>;
asks: PaginatedCollection<APIOrder>;
}
export interface FeesRequest {
exchangeContractAddress: string;
maker: string;
taker: string;
makerTokenAddress: string;
takerTokenAddress: string;
makerTokenAmount: BigNumber;
takerTokenAmount: BigNumber;
expirationUnixTimestampSec: BigNumber;
salt: BigNumber;
export interface PaginatedCollection<T> {
total: number;
page: number;
perPage: number;
records: T[];
}
export interface FeesResponse {
feeRecipient: string;
export interface OrderConfigRequest {
makerAddress: string;
takerAddress: string;
makerAssetAmount: string;
takerAssetAmount: string;
makerAssetData: string;
takerAssetData: string;
exchangeAddress: string;
expirationTimeSeconds: string;
}
export interface OrderConfigResponse {
makerFee: BigNumber;
takerFee: BigNumber;
feeRecipientAddress: string;
senderAddress: string;
}
export declare type FeeRecipientsResponse = PaginatedCollection<string>;
export interface RequestOpts {
networkId?: number;
}
export interface PagedRequestOpts {

@@ -114,0 +126,0 @@ page?: number;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var OrderbookChannelMessageTypes;
(function (OrderbookChannelMessageTypes) {
OrderbookChannelMessageTypes["Snapshot"] = "snapshot";
OrderbookChannelMessageTypes["Update"] = "update";
OrderbookChannelMessageTypes["Unknown"] = "unknown";
})(OrderbookChannelMessageTypes = exports.OrderbookChannelMessageTypes || (exports.OrderbookChannelMessageTypes = {}));
var OrdersChannelMessageTypes;
(function (OrdersChannelMessageTypes) {
OrdersChannelMessageTypes["Update"] = "update";
OrdersChannelMessageTypes["Unknown"] = "unknown";
})(OrdersChannelMessageTypes = exports.OrdersChannelMessageTypes || (exports.OrdersChannelMessageTypes = {}));
var WebsocketConnectionEventType;

@@ -10,0 +9,0 @@ (function (WebsocketConnectionEventType) {

import { Schema } from '@0xproject/json-schemas';
import { BigNumber } from '@0xproject/utils';
export declare const assert: {
isOrderbookChannelSubscriptionOpts(variableName: string, subscriptionOpts: any): void;
isOrderbookChannelHandler(variableName: string, handler: any): void;
isOrdersChannelSubscriptionOpts(variableName: string, subscriptionOpts: any): void;
isOrdersChannelHandler(variableName: string, handler: any): void;
isBigNumber(variableName: string, value: BigNumber): void;

@@ -7,0 +7,0 @@ isValidBaseUnitAmount(variableName: string, value: BigNumber): void;

"use strict";
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};

@@ -16,7 +19,6 @@ Object.defineProperty(exports, "__esModule", { value: true });

var _ = require("lodash");
exports.assert = __assign({}, assert_1.assert, { isOrderbookChannelSubscriptionOpts: function (variableName, subscriptionOpts) {
assert_1.assert.doesConformToSchema(variableName, subscriptionOpts, json_schemas_1.schemas.relayerApiOrderbookChannelSubscribePayload);
exports.assert = __assign({}, assert_1.assert, { isOrdersChannelSubscriptionOpts: function (variableName, subscriptionOpts) {
assert_1.assert.doesConformToSchema(variableName, subscriptionOpts, json_schemas_1.schemas.relayerApiOrdersChannelSubscribePayload);
},
isOrderbookChannelHandler: function (variableName, handler) {
assert_1.assert.isFunction(variableName + ".onSnapshot", _.get(handler, 'onSnapshot'));
isOrdersChannelHandler: function (variableName, handler) {
assert_1.assert.isFunction(variableName + ".onUpdate", _.get(handler, 'onUpdate'));

@@ -23,0 +25,0 @@ assert_1.assert.isFunction(variableName + ".onError", _.get(handler, 'onError'));

@@ -1,9 +0,10 @@

import { SignedOrder } from '@0xproject/types';
import { FeesResponse, OrderbookResponse, TokenPairsItem } from '../types';
import { APIOrder, AssetPairsItem, OrderbookResponse, OrderConfigResponse } from '../types';
export declare const relayerResponseJsonParsers: {
parseTokenPairsJson(json: any): TokenPairsItem[];
parseOrdersJson(json: any): SignedOrder[];
parseOrderJson(json: any): SignedOrder;
parseAssetDataPairsJson(json: any): import("@0xproject/connect/src/types").PaginatedCollection<AssetPairsItem>;
parseAssetPairsItemsJson(json: any): AssetPairsItem[];
parseOrdersJson(json: any): import("@0xproject/connect/src/types").PaginatedCollection<APIOrder>;
parseAPIOrdersJson(json: any): APIOrder[];
parseAPIOrderJson(json: any): APIOrder;
parseOrderbookResponseJson(json: any): OrderbookResponse;
parseFeesResponseJson(json: any): FeesResponse;
parseOrderConfigResponseJson(json: any): OrderConfigResponse;
};
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -7,10 +18,13 @@ var assert_1 = require("@0xproject/assert");

exports.relayerResponseJsonParsers = {
parseTokenPairsJson: function (json) {
assert_1.assert.doesConformToSchema('tokenPairs', json, json_schemas_1.schemas.relayerApiTokenPairsResponseSchema);
return json.map(function (tokenPair) {
return type_converters_1.typeConverters.convertStringsFieldsToBigNumbers(tokenPair, [
'tokenA.minAmount',
'tokenA.maxAmount',
'tokenB.minAmount',
'tokenB.maxAmount',
parseAssetDataPairsJson: function (json) {
assert_1.assert.doesConformToSchema('assetDataPairsResponse', json, json_schemas_1.schemas.relayerApiAssetDataPairsResponseSchema);
return __assign({}, json, { records: exports.relayerResponseJsonParsers.parseAssetPairsItemsJson(json.records) });
},
parseAssetPairsItemsJson: function (json) {
return json.map(function (assetDataPair) {
return type_converters_1.typeConverters.convertStringsFieldsToBigNumbers(assetDataPair, [
'assetDataA.minAmount',
'assetDataA.maxAmount',
'assetDataB.minAmount',
'assetDataB.maxAmount',
]);

@@ -20,15 +34,18 @@ });

parseOrdersJson: function (json) {
assert_1.assert.doesConformToSchema('orders', json, json_schemas_1.schemas.signedOrdersSchema);
return json.map(function (order) { return type_converters_1.typeConverters.convertOrderStringFieldsToBigNumber(order); });
assert_1.assert.doesConformToSchema('relayerApiOrdersResponse', json, json_schemas_1.schemas.relayerApiOrdersResponseSchema);
return __assign({}, json, { records: exports.relayerResponseJsonParsers.parseAPIOrdersJson(json.records) });
},
parseOrderJson: function (json) {
assert_1.assert.doesConformToSchema('order', json, json_schemas_1.schemas.signedOrderSchema);
return type_converters_1.typeConverters.convertOrderStringFieldsToBigNumber(json);
parseAPIOrdersJson: function (json) {
return json.map(exports.relayerResponseJsonParsers.parseAPIOrderJson.bind(exports.relayerResponseJsonParsers));
},
parseAPIOrderJson: function (json) {
assert_1.assert.doesConformToSchema('relayerApiOrder', json, json_schemas_1.schemas.relayerApiOrderSchema);
return type_converters_1.typeConverters.convertAPIOrderStringFieldsToBigNumber(json);
},
parseOrderbookResponseJson: function (json) {
assert_1.assert.doesConformToSchema('orderBook', json, json_schemas_1.schemas.relayerApiOrderBookResponseSchema);
assert_1.assert.doesConformToSchema('orderBookResponse', json, json_schemas_1.schemas.relayerApiOrderbookResponseSchema);
return type_converters_1.typeConverters.convertOrderbookStringFieldsToBigNumber(json);
},
parseFeesResponseJson: function (json) {
assert_1.assert.doesConformToSchema('fees', json, json_schemas_1.schemas.relayerApiFeesResponseSchema);
parseOrderConfigResponseJson: function (json) {
assert_1.assert.doesConformToSchema('orderConfigResponse', json, json_schemas_1.schemas.relayerApiOrderConfigResponseSchema);
return type_converters_1.typeConverters.convertStringsFieldsToBigNumbers(json, ['makerFee', 'takerFee']);

@@ -35,0 +52,0 @@ },

@@ -0,5 +1,7 @@

import { APIOrder } from '../types';
export declare const typeConverters: {
convertOrderbookStringFieldsToBigNumber(orderbook: any): any;
convertAPIOrderStringFieldsToBigNumber(apiOrder: any): APIOrder;
convertOrderStringFieldsToBigNumber(order: any): any;
convertStringsFieldsToBigNumbers(obj: any, fields: string[]): any;
};
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -9,14 +20,19 @@ var utils_1 = require("@0xproject/utils");

var asks = _.get(orderbook, 'asks', []);
var convertedBids = __assign({}, bids, { records: bids.records.map(function (order) { return exports.typeConverters.convertAPIOrderStringFieldsToBigNumber(order); }) });
var convertedAsks = __assign({}, asks, { records: asks.records.map(function (order) { return exports.typeConverters.convertAPIOrderStringFieldsToBigNumber(order); }) });
return {
bids: bids.map(function (order) { return exports.typeConverters.convertOrderStringFieldsToBigNumber(order); }),
asks: asks.map(function (order) { return exports.typeConverters.convertOrderStringFieldsToBigNumber(order); }),
bids: convertedBids,
asks: convertedAsks,
};
},
convertAPIOrderStringFieldsToBigNumber: function (apiOrder) {
return __assign({}, apiOrder, { order: exports.typeConverters.convertOrderStringFieldsToBigNumber(apiOrder.order) });
},
convertOrderStringFieldsToBigNumber: function (order) {
return exports.typeConverters.convertStringsFieldsToBigNumbers(order, [
'makerTokenAmount',
'takerTokenAmount',
'makerAssetAmount',
'takerAssetAmount',
'makerFee',
'takerFee',
'expirationUnixTimestampSec',
'expirationTimeSeconds',
'salt',

@@ -28,3 +44,8 @@ ]);

_.each(fields, function (field) {
_.update(result, field, function (value) { return new utils_1.BigNumber(value); });
_.update(result, field, function (value) {
if (_.isUndefined(value)) {
throw new Error("Could not find field '" + field + "' while converting string fields to BigNumber.");
}
return new utils_1.BigNumber(value);
});
});

@@ -31,0 +52,0 @@ return result;

{
"name": "@0xproject/connect",
"version": "1.0.5",
"version": "2.0.0-rc.1",
"engines": {

@@ -19,4 +19,4 @@ "node": ">=6.12"

"watch_without_deps": "tsc -w",
"build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
"clean": "shx rm -rf lib test_temp scripts",
"build": "tsc",
"clean": "shx rm -rf lib test_temp generated_docs",
"copy_test_fixtures": "copyfiles -u 2 './test/fixtures/**/*.json' ./lib/test/fixtures",

@@ -30,14 +30,7 @@ "lint": "tslint --project .",

"test:circleci": "yarn test:coverage",
"manual:postpublish": "yarn build; node ./scripts/postpublish.js",
"docs:stage": "node scripts/stage_docs.js",
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES",
"upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json"
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES"
},
"config": {
"postpublish": {
"assets": [],
"docPublishConfigs": {
"s3BucketPath": "s3://doc-jsons/connect/",
"s3StagingBucketPath": "s3://staging-doc-jsons/connect/"
}
"assets": []
}

@@ -56,16 +49,16 @@ },

"dependencies": {
"@0xproject/assert": "^0.2.14",
"@0xproject/json-schemas": "^0.8.3",
"@0xproject/types": "^0.8.2",
"@0xproject/typescript-typings": "^1.0.4",
"@0xproject/utils": "^1.0.5",
"@0xproject/assert": "^1.0.6",
"@0xproject/json-schemas": "^1.0.1-rc.5",
"@0xproject/types": "^1.0.1-rc.5",
"@0xproject/typescript-typings": "^1.0.5",
"@0xproject/utils": "^1.0.6",
"lodash": "^4.17.5",
"query-string": "^5.0.1",
"sinon": "^4.0.0",
"uuid": "^3.3.2",
"websocket": "^1.0.25"
},
"devDependencies": {
"@0xproject/monorepo-scripts": "^1.0.5",
"@0xproject/tslint-config": "^1.0.5",
"@types/fetch-mock": "^5.12.2",
"@0xproject/tslint-config": "^1.0.6",
"@types/fetch-mock": "^6.0.3",
"@types/lodash": "4.14.104",

@@ -75,2 +68,3 @@ "@types/mocha": "^2.2.42",

"@types/sinon": "^2.2.2",
"@types/uuid": "^3.4.3",
"@types/websocket": "^0.0.39",

@@ -80,3 +74,3 @@ "async-child-process": "^1.1.1",

"chai-as-promised": "^7.1.0",
"copyfiles": "^1.2.0",
"copyfiles": "^2.0.0",
"dirty-chai": "^2.0.1",

@@ -90,4 +84,4 @@ "fetch-mock": "^5.13.1",

"tslint": "5.11.0",
"typedoc": "~0.8.0",
"typescript": "2.9.2"
"typedoc": "0.12.0",
"typescript": "3.0.1"
},

@@ -97,3 +91,3 @@ "publishConfig": {

},
"gitHead": "fadd292ecf367e42154856509d0ea0c20b23f2f1"
"gitHead": "7f585a15f526e0a61fd822cdefb7087fc6bb8934"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc